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

-Z default-visibility option #782

Closed
3 tasks done
davidlattimore opened this issue Sep 6, 2024 · 3 comments
Closed
3 tasks done

-Z default-visibility option #782

davidlattimore opened this issue Sep 6, 2024 · 3 comments
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team

Comments

@davidlattimore
Copy link

davidlattimore commented Sep 6, 2024

Proposal

  • Replace the existing -Z default-hidden-visibility with -Z default-visibility, which takes one of several different visibility levels as an argument.
  • The motivation for doing this is to allow building shared objects with symbols that use protected visibility rather than default visibility.
  • Using protected visibility means that those symbols cannot be interposed by the executable or by other shared objects earlier in the load order. This allows the compiler to emit direct references to those symbols when used within the same shared object that defines them. This is more efficient.
  • Ideally all symbols emitted by rustc into shared objects would be protected by default unless there was a need for a particular symbol to be able to be interposed. i.e. we shouldn't pay the cost of having interposable symbols if we're not actually using that feature.
  • Unfortunately GNU ld used to error if there were direct references to protected symbols and this was only fixed in GNU ld 2.40, so we can't emit symbols with protected visibility by default.
  • We could probably however make protected symbols the default when linking with LLD.
  • ELF on Linux names the visibility levels as "default", "protected" and "hidden"
  • We could use these names as the values that are accepted by the -Z default-visibility option, however I'm a little uncomfortable with naming one of the options "default" if it may eventually not be the default. i.e. if we change the default to protected.
  • One option would be to call this option something else, such as "interposable".
  • Alternatively, we can just call it "default", but document that it isn't actually the default (if / when that happens).

Tracking issue for default-hidden-visibility: #656

PR that makes this change, but as a separate flag: rust-lang/rust#130005

Original issue that proposed changing to protected, but without a flag: rust-lang/rust#105518

Mentors or Reviewers

None

Process

The main points of the Major Change Process are as follows:

  • File an issue describing the proposal.
  • A compiler team member or contributor who is knowledgeable in the area can second by writing @rustbot second.
    • Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a -C flag, then full team check-off is required.
    • Compiler team members can initiate a check-off via @rfcbot fcp merge on either the MCP or the PR.
  • Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.

You can read more about Major Change Proposals on forge.

Comments

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

@davidlattimore davidlattimore added major-change A proposal to make a major change to rustc T-compiler Add this label so rfcbot knows to poll the compiler team labels Sep 6, 2024
@rustbot
Copy link
Collaborator

rustbot commented Sep 6, 2024

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

Concerns or objections to the proposal should be discussed on Zulip and formally registered here by adding a comment with the following syntax:

@rustbot concern reason-for-concern 
<description of the concern> 

Concerns can be lifted with:

@rustbot resolve reason-for-concern 

See documentation at https://forge.rust-lang.org

cc @rust-lang/compiler @rust-lang/compiler-contributors

@rustbot rustbot added the to-announce Announce this issue on triage meeting label Sep 6, 2024
@lqd
Copy link
Member

lqd commented Sep 19, 2024

@rustbot second

@rustbot rustbot added the final-comment-period The FCP has started, most (if not all) team members are in agreement label Sep 19, 2024
@apiraino
Copy link
Contributor

@rustbot label -final-comment-period +major-change-accepted

@rustbot rustbot added major-change-accepted A major change proposal that was accepted and removed final-comment-period The FCP has started, most (if not all) team members are in agreement labels Sep 30, 2024
davidlattimore added a commit to davidlattimore/rust that referenced this issue Sep 30, 2024
MCP: rust-lang/compiler-team#782

Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
davidlattimore added a commit to davidlattimore/rust that referenced this issue Oct 1, 2024
MCP: rust-lang/compiler-team#782

Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
davidlattimore added a commit to davidlattimore/rust that referenced this issue Oct 1, 2024
MCP: rust-lang/compiler-team#782

Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
davidlattimore added a commit to davidlattimore/rust that referenced this issue Oct 1, 2024
MCP: rust-lang/compiler-team#782

Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
antoyo pushed a commit to rust-lang/rustc_codegen_gcc that referenced this issue Oct 9, 2024
MCP: rust-lang/compiler-team#782

Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 13, 2024
Use protected visibility when LLD feature is enabled and enable it when building rustc

rust-lang/compiler-team#782

I wasn't sure about having two commits in a PR, but I figured, at least initially it might make sense to discuss these commits together. Happy to squash, or move the second commit to a separate PR.

I contemplated trying to enable protected visibility for more cases when LLD will be used other than just `-Zlinker-features=+lld`, but that would be more a complex change that probably still wouldn't cover all cases when LLD is used, so went with the simplest option of just checking if the linker-feature is enabled.

r? lqd
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Oct 17, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Oct 31, 2024
Use protected visibility when building rustc

rust-lang/compiler-team#782

I wasn't sure about having two commits in a PR, but I figured, at least initially it might make sense to discuss these commits together. Happy to squash, or move the second commit to a separate PR.

I contemplated trying to enable protected visibility for more cases when LLD will be used other than just `-Zlinker-features=+lld`, but that would be more a complex change that probably still wouldn't cover all cases when LLD is used, so went with the simplest option of just checking if the linker-feature is enabled.

r? lqd
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 1, 2024
Use protected visibility when building rustc with LLD

rust-lang/compiler-team#782

I wasn't sure about having two commits in a PR, but I figured, at least initially it might make sense to discuss these commits together. Happy to squash, or move the second commit to a separate PR.

I contemplated trying to enable protected visibility for more cases when LLD will be used other than just `-Zlinker-features=+lld`, but that would be more a complex change that probably still wouldn't cover all cases when LLD is used, so went with the simplest option of just checking if the linker-feature is enabled.

r? lqd
lnicola pushed a commit to lnicola/rust-analyzer that referenced this issue Nov 1, 2024
Use protected visibility when building rustc with LLD

rust-lang/compiler-team#782

I wasn't sure about having two commits in a PR, but I figured, at least initially it might make sense to discuss these commits together. Happy to squash, or move the second commit to a separate PR.

I contemplated trying to enable protected visibility for more cases when LLD will be used other than just `-Zlinker-features=+lld`, but that would be more a complex change that probably still wouldn't cover all cases when LLD is used, so went with the simplest option of just checking if the linker-feature is enabled.

r? lqd
RalfJung pushed a commit to RalfJung/miri that referenced this issue Nov 2, 2024
Use protected visibility when building rustc with LLD

rust-lang/compiler-team#782

I wasn't sure about having two commits in a PR, but I figured, at least initially it might make sense to discuss these commits together. Happy to squash, or move the second commit to a separate PR.

I contemplated trying to enable protected visibility for more cases when LLD will be used other than just `-Zlinker-features=+lld`, but that would be more a complex change that probably still wouldn't cover all cases when LLD is used, so went with the simplest option of just checking if the linker-feature is enabled.

r? lqd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team
Projects
None yet
Development

No branches or pull requests

4 participants