-1

I have a Mac Mini (running OS X Version 10.11.6 on it), and I have been trying to compile a binary that I want to run on the Travis-CI OS X servers.

I have succeeded at doing this before (with the same device). But this time around, I'm getting the Illegal Instruction 4 error you can see on this line. This error does not occur on my Mac Mini. The program runs fine. It only occurs on Travis-CI.

A quick stack overflow search of this error gives me this question, which shows that the error can be fixed by compiling the binaries with the -mmacosx-version-min=10.x flag. Well, I have tried that to no avail. To be more specific, I compiled by binary with the -mmacosx-version-min=10.9 flag, which I think should be fine considering that the Travis-CI OS X version is 10.11 (which makes me wonder why I was getting that error in the first place since I built the binary on OS X 10.11).

The binary I am trying to run can be found here, and if I run otool -l on it, I see this section:

Load command 9
cmd LC_VERSION_MIN_MACOSX
cmdsize 16
version 10.9
sdk 10.11

which looks fine. I compiled it and linked it in compatibility mode for OS X 10.9, and I compiled it on an OS X 10.11 machine. The dynamic dependencies appear to be alright as well:

Mac-mini:~ patrick$ otool -L ./osx64-genXrdPattern 
./osx64-genXrdPattern:
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)

And here is the g++ version that I built the binary with:

Mac-mini:~ patrick$ g++ --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

So I've just been spending a lot of time trying to figure out: why will my binary not run on Travis-CI? And why do I keep getting an Illegal Instruction: 4? The binary seems to run fine on my Mac Mini. If anyone knows what the problem is or has any advice on fixing the problem, it would be greatly appreciated. Thank you!

Edit: by the way, the code for this binary can be found here, and I link it to the objcryst libraries.

Edit2: I tried turning off compiler optimization flags to see if something strange has been going on with the optimizations. I still get the same result, though, even with compiler optimization flags off...

Community
  • 1
  • 1

1 Answers1

0

I emailed the Travis-CI staff, and I received this reply, which I think explains the problem:

I had a look and I believe this can happen because we are using a mix of old Apple Xserves (from 2004) and new Mac Pros. We've had other customers writing in for the same reason and often, the call they were making required newer hardware to succeed. Hence, my hunch here is that you get this error when your build runs on an Xserve machine.

Even though Travis-CI is running OS X 10.11, I'm guessing the old Apple Xserve hardware cannot execute all of the instructions that a newer AppleClang can produce.

My fix for this problem was to actually compile and link the program on the Travis-CI Xserve machines themselves. I think this helped ensure that an illegal instruction would not be produced. The program now successfully runs on Travis-CI.