Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes incorrect install names on darwin platforms #13427

Closed
wants to merge 1 commit into from
Closed

Fixes incorrect install names on darwin platforms #13427

wants to merge 1 commit into from

Conversation

csmulhern
Copy link
Contributor

#12304 added support to bazel for setting install names for dynamic
libraries on darwin platforms. This would set LC_ID_DYLIB to
@rpath/{library_name}, so that RPATH would be used to locate these
libraries at runtime. However, the code was using a utility method that
assumed the library name was mangled, which is often not the case. Given
that the output path should already have been determined with the
mangled or unmangled name, we should be able to just use the base name
of the artifact. The test that was added in #12304 has been updated to
actually use dynamic libaries, and passes with the changes made in this
commit.

#12304 added support to bazel for setting install names for dynamic
libraries on darwin platforms. This would set LC_ID_DYLIB to
@rpath/{library_name}, so that RPATH would be used to locate these
libraries at runtime. However, the code was using a utility method that
assumed the library name was mangled, which is often not the case. Given
that the output path should already have been determined with the
mangled or unmangled name, we should be able to just use the base name
of the artifact. The test that was added in #12304 has been updated to
actually use dynamic libaries, and passes with the changes made in this
commit.
@csmulhern
Copy link
Contributor Author

@oquenchil, have you had the chance to look at this?

@oquenchil
Copy link
Contributor

It looks like this change affects more than darwin, but all Bazel presubmits and internal tests pass so it can go in.

I may have to rollback though.

Copy link
Contributor

@oquenchil oquenchil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bazel-io bazel-io closed this in b06f495 Jun 4, 2021
UebelAndre pushed a commit to bazelbuild/rules_rust that referenced this pull request Jun 14, 2021
Runtime linking with rpaths works correctly on darwin with only this
change, for dylibs that have the correct extension (dylib) and the
correct rpath configuration. Runtime linking against dynamic libraries
created by bazel targets remains broken, due to them not having install
names set correctly. That is fixed by using
--incompatible_macos_set_install_name after
bazelbuild/bazel#13427.
katre pushed a commit that referenced this pull request Jul 12, 2021
#12304 added support to bazel for setting install names for dynamic
libraries on darwin platforms. This would set LC_ID_DYLIB to
@rpath/{library_name}, so that RPATH would be used to locate these
libraries at runtime. However, the code was using a utility method that
assumed the library name was mangled, which is often not the case. Given
that the output path should already have been determined with the
mangled or unmangled name, we should be able to just use the base name
of the artifact. The test that was added in #12304 has been updated to
actually use dynamic libaries, and passes with the changes made in this
commit.

Closes #13427.

PiperOrigin-RevId: 377504015
@det
Copy link
Contributor

det commented Apr 11, 2022

I just ran into this issue (runtime_solib_name is not the mangled name) after upgrading to bazel 5.1 from 4.2. Any reason this did not land?

edit: actually it turns out this PR caused my issues, see #15214

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants