-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Description
(Somewhat related to #57438)
In trying to turn on cross-language LTO in Firefox for all of our supported targets, we discovered that clang --target=X doesn't necessarily tag the generated bitcode files as belonging to target X on OS X. The Darwin driver for clang will compute an OS-specific (ios, macosx, etc.) and version-specific (macosx10.9.0, etc.) triple based on things like MACOSX_DEPLOYMENT_TARGET and the particular SDK in use. See for example:
https://github.com/llvm-mirror/clang/blob/cda3d286934fcc7de3687bb8a178947a8266d1f8/lib/Driver/ToolChains/Darwin.cpp#L1598-L1761
https://github.com/llvm-mirror/clang/blob/cda3d286934fcc7de3687bb8a178947a8266d1f8/lib/Driver/ToolChains/Darwin.cpp#L828-L850
So if you are using clang --target=x86_64-apple-darwin and rustc --target=x86_64-apple-darwin in your build system, you'll still get bitcode files that ThinLTO will refuse to link together. This is not a great experience by default. I assume the same would be true when compiling for iOS.
It can be worked around on the C/C++ side of things (clang --target=X ... -Xclang -triple -Xclang x86_64-apple-darwin, where the -Xclang options override the driver magic above), but it would be nice if rustc somehow did the right thing by default. At minimum, I think supporting MACOSX_DEPLOYMENT_TARGET (and others?) and something to determine a more specific OS for the triple than darwin would be good; I'm less certain that groveling around in the SDK is a good thing, especially since rustc doesn't need the SDK in the same way clang does.