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...