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

proc-macro-srv: drop unnecessary usage of RTLD_DEEPBIND #135586

Conversation

Fabian-Gruenbichler
Copy link
Contributor

the constant is wrong on some platforms (e.g., on mips64el it's 0x10, and 0x8 is RTLD_NOLOAD which makes all this functionality broken), and it is no longer needed because #60593 got fixed by #99944 in the meantime.

the constant is wrong on some platforms (e.g., on mips64el it's 0x10, and 0x8
is RTLD_NOLOAD which makes all this functionality broken), and it is no longer
needed because rust-lang#60593 got fixed by
rust-lang#99944 in the meantime.

Signed-off-by: Fabian Grünbichler <[email protected]>
@rustbot
Copy link
Collaborator

rustbot commented Jan 16, 2025

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 16, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jan 16, 2025

rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead.

cc @rust-lang/rust-analyzer

@Fabian-Gruenbichler
Copy link
Contributor Author

further references:

failing mips64el build in Debian caused by this: https://buildd.debian.org/status/fetch.php?pkg=rustc&arch=mips64el&ver=1.84.0%2Bdfsg1-1~exp1&stamp=1736831677&raw=1

alternatively, it would also be possible to have a hardcoded list of arch-specific constants instead..

@bjorn3
Copy link
Member

bjorn3 commented Jan 16, 2025

#99944 is not really a fix. It is still possible for a proc-macro to dynamically link against libstd.so, which would expose the issue again as the proc-macro would import functions from librustc_driver.so's copy of libstd without RTLD_DEEPBIND rather than the libstd.so that the proc-macro should actually link against.

$ echo | rustc - --crate-type dylib --crate-name foo -Cprefer-dynamic
$ echo 'extern crate foo;' | rustc - --crate-type proc-macro --extern foo=libfoo.so
$ ldd librust_out.so
        linux-vdso.so.1 (0x00007fffbd9fb000)
        libstd-22be60875a4ac8d7.so => not found

@Fabian-Gruenbichler
Copy link
Contributor Author

ack, then I'll open another MR that properly conditionalizes RTLD_DEEPBIND based on the target..

@bjorn3
Copy link
Member

bjorn3 commented Jan 16, 2025

If you do, you may be able to use the RTLD_DEEPBIND constant from the libc crate at the same time to handle differences between architectures. You did still need conditional compilation based on the used libc implementation though.

@Fabian-Gruenbichler
Copy link
Contributor Author

glibc and uclibc seem to agree (0x8 for everything but mips, 0x10 for mips), freebsd's is 0x04000, musl and bionic don't seem to have it at all.. I think deferring to libc and letting them differentiate further if needed makes the most sense?

@bjorn3
Copy link
Member

bjorn3 commented Jan 16, 2025

The libc crate will not define RTLD_DEEPBIND if the libc implementation for the target doesn't support it. As such you need conditional compilation based on the target to only use RTLD_DEEPBIND when the libc implementation supports it.

@Fabian-Gruenbichler
Copy link
Contributor Author

closed in favor of #135591 , hope that's about what you requested ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants