Availability of "-export_dynamic" when compiling with support for older OS X releases

Looking at tools/clang/lib/Driver/Tools.cpp , there's this fragment of code:

if (Args.hasArg(options::OPT_rdynamic) && Version[0] >= 137)

I built LLVM 3.4.2 from a OS X 10.11 "El Capitan" but specifying a fat
build (386+x86_64) and requesting support back up to 10.6. It went
fine, and the build passes all tests when run on a 10.6.8 machine.

But now, trying to compile LLVM 3.8.0, on 10.6.8, with that LLVM 3.4.2
build, everything goes fine until trying to link bugpoint. Then the
linker reports the -export_dynamic option as an error.

My guess is that when I built 3.4.2 in El Capitan, it found that the
toolchain being used did support "-export_dynamic", but, however I
wasn't interested in that toolchain, but in the system standard linker
in 10.6.8.

Is there any way I can build LLVM 3.4.2 in El Capitan, specifying that
the linker will be the one from 10.6.8?



Is there any way I can build LLVM 3.4.2 in El Capitan, specifying that
the linker will be the one from 10.6.8?

In case anybody else faces this problem, if you build LLVM on a recent
OS X release but specifying the deployment target to an older OS X
version, when you run such build on the older OS X version, you need
to specify -mlinker-version=97.17 as an option to clang/clang++ if the
-rdynamic flag is also used. Otherwise, it will call the linker
supposing it's a newer one, and it will fail because of unsupported

It's somewhat uncomfortable to specify -mlinker-version=97.17 on each
clang/clang++ invocation, but at least it fixes this problem and it


Thanks for your progress messages. I still have 10.6.8 machines that I might one day want a modern LLVM on, ranging from a Core Solo Mac Mini, to an alternative boot partition on my main quad core i7 17" MBP (take it from my cold dead hands etc etc).

Do you now have LLVM 3.8 working?

Not yet. I've been trying for almost a week now. It's quite hard to
get it working on any system more than 3 years old (and I'm precisely
taking this effort because I want to substitute gcc with clang on all
my Macs, but, the weird thing is that it's only easy to do so for
systems for which Xcode already ships clang).

Anyway, today I arrived up to a 98% of the build, and seemed to be
successful, but, at that point, it entered the test-suite, and
reported that cmake 3.2 was a requisite (well... that would have been
nice to be reported when generating the Makefiles at the start of the
build rather than at the end). I updated my cmake to 3.5.1, but now...
I type make and... ooops... start again at 0% of the build...

I don't surrender, because I really want to have clang on all my Macs,
but a degree of patience is really mandatory.