-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
rustc LTO bitcode incompatible with clang LTO bitcode files by default on OS X #60235
Copy link
Copy link
Closed
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.Category: This is a bug.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.O-iosOperating system: iOSOperating system: iOSO-macosOperating system: macOSOperating system: macOST-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.Category: This is a bug.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.O-iosOperating system: iOSOperating system: iOSO-macosOperating system: macOSOperating system: macOST-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
(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=Xdoesn'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_TARGETand 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-darwinandrustc --target=x86_64-apple-darwinin 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-Xclangoptions override the driver magic above), but it would be nice ifrustcsomehow 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 thandarwinwould be good; I'm less certain that groveling around in the SDK is a good thing, especially sincerustcdoesn't need the SDK in the same wayclangdoes.cc @michaelwoerister