This is an archive of the discontinued LLVM Phabricator instance.

[runtimes] Avoid overwriting the rpath unconditionally
ClosedPublic

Authored by ldionne on Nov 9 2020, 1:18 PM.

Details

Reviewers
hintonda
phosek
Group Reviewers
Restricted Project
Restricted Project
Restricted Project
Commits
rG8d51969bd40a: [runtimes] Avoid overwriting the rpath unconditionally
Summary

When building the runtimes, it's very important not to add rpaths unless
the user explicitly asks for them (the standard way being CMAKE_INSTALL_RPATH),
or to change the install name dir unless the user requests it (via
CMAKE_INSTALL_NAME_DIR).

llvm_setup_rpath() would override the install_name_dir of the runtimes
even if CMAKE_INSTALL_NAME_DIR was specified to something, which is wrong
and in fact even "dangerous" for the runtimes.

This issue was discovered when trying to build libc++ and libc++abi as
system libraries for Apple, where we set the install name dir to /usr/lib
explicitly. llvm_setup_rpath() would cause libc++ to have the wrong install
name dir, and for basically everything on the system to fail to load.
This was discovered just now because we previously used something closer
to a standalone build, where llvm_setup_rpath() wouldn't exist, and hence
not be used.

This is a revert of the following commits:

libunwind: 3a667b9bd8b741f5ac1d8d47857140a3d70737fb
libc++abi: 4877063e195dfcc128451bbf3dd7b03d04d2562f
libc++: 88434fe05fdb112a33052c4d8a91c9e989cb032d

Those added llvm_setup_rpath() for consistency, so it seems reasonable
to revert.

Diff Detail

Event Timeline

ldionne created this revision.Nov 9 2020, 1:18 PM
Herald added projects: Restricted Project, Restricted Project, Restricted Project. · View Herald TranscriptNov 9 2020, 1:18 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Herald added a reviewer: Restricted Project. · View Herald Transcript
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne requested review of this revision.Nov 9 2020, 1:18 PM
phosek accepted this revision.Nov 9 2020, 1:50 PM
phosek added a subscriber: phosek.

LGTM

hintonda accepted this revision.Nov 9 2020, 1:51 PM

LGTM...

ldionne accepted this revision as: Restricted Project.Nov 9 2020, 1:54 PM
This revision is now accepted and ready to land.Nov 9 2020, 1:54 PM
This revision was landed with ongoing or failed builds.Nov 9 2020, 1:56 PM
This revision was automatically updated to reflect the committed changes.
hvdijk added a subscriber: hvdijk.Jun 22 2021, 6:29 AM

The corresponding compiler-rt change, D42462 (rG78fd93e0396a19cb89d4b874c7cc42255888df56), should have been reverted as well as part of this change, we still have nonsense RPATHs for those. I am not right now in a position to commit that as obvious myself; if someone else wants to revert it, please do, else I will do so once I am able.

The corresponding compiler-rt change, D42462 (rG78fd93e0396a19cb89d4b874c7cc42255888df56), should have been reverted as well as part of this change, we still have nonsense RPATHs for those. I am not right now in a position to commit that as obvious myself; if someone else wants to revert it, please do, else I will do so once I am able.

Done in rG21c008d5a5b1e0c2ec3c1659cff961f4b0ccea2c.