rustc LTO bitcode incompatible with clang LTO bitcode files by default on OS X #60235
Labels
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
C-bug
Category: This is a bug.
E-help-wanted
Call for participation: Help is requested to fix this issue.
O-ios
Operating system: iOS
O-macos
Operating system: macOS
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
(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 likeMACOSX_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
andrustc --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 ifrustc
somehow did the right thing by default. At minimum, I think supportingMACOSX_DEPLOYMENT_TARGET
(and others?) and something to determine a more specific OS for the triple thandarwin
would be good; I'm less certain that groveling around in the SDK is a good thing, especially sincerustc
doesn't need the SDK in the same wayclang
does.cc @michaelwoerister
The text was updated successfully, but these errors were encountered: