This is an archive of the discontinued LLVM Phabricator instance.

[clang][driver] Pass `-femulated-tls` through to the linker in LTO mode
ClosedPublic

Authored by paulkirth on Apr 7 2023, 7:06 PM.

Details

Summary

Currently the driver does not propagate the -f[no-]emulated-tls flags
to the linker under LTO. This can be surprising when the platform
defaults differ from the flags being passed. A related discussion can be
found in https://reviews.llvm.org/D143619. While the focus there was
RISC-V support, the root cause was that setting -femualted-tls and
-flto when compiling with Clang resulted in missing symbols because
the platform defaults for Android differed from the flags being passed
to Clang.

This patch changes the Clang driver's behavior to pass the emulated-tls
flags through to the linker when compiling with LTO/ThinLTO.

Diff Detail

Event Timeline

paulkirth created this revision.Apr 7 2023, 7:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 7 2023, 7:06 PM
paulkirth requested review of this revision.Apr 7 2023, 7:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 7 2023, 7:06 PM
vit9696 accepted this revision.Apr 8 2023, 3:24 AM

Looks good to me, thank you!

clang/test/Driver/emulated-tls.cpp
55

Maybe add a space before LTO here?

This revision is now accepted and ready to land.Apr 8 2023, 3:24 AM
paulkirth marked an inline comment as done.

Fix formatting in CHECK lines.

paulkirth added inline comments.Apr 10 2023, 10:04 AM
clang/test/Driver/emulated-tls.cpp
55

Good catch. For whatever reason I thought clang-format had fixed that, but obviously not. :)

Remove extra newlines in emulated-tls.cpp

phosek accepted this revision.Apr 10 2023, 10:37 AM

LGTM

This revision was landed with ongoing or failed builds.Apr 10 2023, 10:44 AM
This revision was automatically updated to reflect the committed changes.