I have a couple of plain C-programs (actually plugins that are dlopen()
ed by some host) to compile, and I would like to support as many OSX/macOS versions as possible.
The actual number supported versions of OSX/macOS are not so important, but i strive for a maximum coverage ("whatever is possible").
The C-programs virtually don't use any libraries apart from libc, and are cross-platform (linux/windows/macOS).
To achieve maximum compatibility, I use the -mmacosx-version-min
flag when compiling on macOS.
In the past, I've build my binaries on macOS Sierra using -mmacosx-version-min=10.5
, which used to work nicely. This flag is now hardcoded in my Makefile
.
However, since I've upgraded my build machine to macOS Mojave the builds fail with:
ld: library not found for -lgcc_s.10.5
So it seems that recent versions of XCode have a minimum deployment target of OSX-10.6.
Obviously I could just go and update all my Makefile's to use -mmacosx-version-min=10.6
, but I guess I will have the same problem soon enough when Apple decides to ditch 10.6 support.
So my question is: is there any way to determine programmatically the minimum supported value for -mmacosx-version-min
on my build host?
My build system is a very simple pure GNU make
(no autotools, CMake and the like), and I'd like to keep it that way.
So any check should be simple enough to be done at the beginning of the make
invocation.
Ideally something like:
CFLAGS+=-mmacosx-version-min=$(shell xcodebuild --minimum-supported-version)
Ideas?
NOTE: my target build hosts are headless CI-machines, that usually will only have the "cmdline" version of the build-tools installed. Any proposed solution should run on a system that doesn't have the full XCode suite installed.
on older systems
Funnily enough, specifying a very low deployment target on Sierra was handled much more gracefully:
E.g. adding -mmacosx-version-min=10.1
would compile without a problem, creating a x86_64 binary (which iirc was only supported starting with OSX-10.4), and which - according to otool -l
is only compatible with OSX-10.4.
Given that older versions of clang/Xcode/... handled out-of-bound values for -mmacosx-version-min
gracefully, I wonder whether this is an actual regression bug on Apple's side.
further information
This is what the compiler on Mojave tells me about it's own version:
$ cc --version
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
On Sierra (where everything works), I get:
$ cc --version
Apple LLVM version 9.0.0 (clang-900.0.38)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin