Skip to content

Add new unstable attribute: #[export_visibility = ...].#151431

Open
anforowicz wants to merge 4 commits intorust-lang:mainfrom
anforowicz:export-visibility
Open

Add new unstable attribute: #[export_visibility = ...].#151431
anforowicz wants to merge 4 commits intorust-lang:mainfrom
anforowicz:export-visibility

Conversation

@anforowicz
Copy link
Copy Markdown
Contributor

@anforowicz anforowicz commented Jan 20, 2026

View all comments

This PR is an implementation of the RFC tracked in #151425

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jan 20, 2026

Some changes occurred in compiler/rustc_hir/src/attrs

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 20, 2026
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jan 20, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jan 20, 2026

r? @chenyukang

rustbot has assigned @chenyukang.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@Kivooeo
Copy link
Copy Markdown
Member

Kivooeo commented Jan 20, 2026

i had a quick look, mostly looks good, but i'd like to maybe @JonathanBrouwer take a look on this as well, i may overlooked something

r? JonathanBrouwer

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

Would like to take a look, will do so tomorrow :)

@rust-bors

This comment has been minimized.

Copy link
Copy Markdown
Contributor

@JonathanBrouwer JonathanBrouwer left a comment

Choose a reason for hiding this comment

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

Some minor questions, looks good on a high level :)

View changes since this review

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 21, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jan 21, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot

This comment has been minimized.

@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Jan 27, 2026
@anforowicz anforowicz force-pushed the export-visibility branch 3 times, most recently from 88ddd87 to a741ebc Compare January 27, 2026 22:55
@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 27, 2026
…forowicz

Add new unstable attribute: `#[export_visibility = ...]`.

This PR is an implementation of the RFC tracked in rust-lang#151425
@JonathanBrouwer
Copy link
Copy Markdown
Contributor

JonathanBrouwer commented Feb 27, 2026

@bors r=JonathanBrouwer
Re-approving this is fine, but make sure to set the reviewer :) r+ will default to yourself

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Feb 27, 2026

📌 Commit b12629f has been approved by JonathanBrouwer

It is now in the queue for this repository.

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 27, 2026
…nathanBrouwer

Add new unstable attribute: `#[export_visibility = ...]`.

This PR is an implementation of the RFC tracked in rust-lang#151425
rust-bors bot pushed a commit that referenced this pull request Feb 27, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #151431 (Add new unstable attribute: `#[export_visibility = ...]`.)
 - #153012 (Stop using `LinkedGraph` in `lexical_region_resolve`)
 - #153179 (Force a CI LLVM stamp bump)
 - #150828 (Improved security section in rustdoc for `current_exe`)
 - #152673 (rustc_public: rewrite `bridge_impl` to reduce boilerplate)
 - #152674 (rustc_public: remove the `CrateDefItems` trait)
 - #153073 (Fix mem::conjure_zst panic message to use any::type_name instead)
 - #153117 (Remove mutation from macro path URL construction)
 - #153128 (Recover feature lang_items for emscripten)
 - #153138 (Print path root when printing path)
 - #153159 (Work around a false `err.emit();` type error in rust-analyzer)
@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@bors r-
#153171 (comment)

@rust-bors rust-bors bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 27, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Feb 27, 2026

Commit b12629f has been unapproved.

This PR was contained in a rollup (#153180), which was also unapproved.

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

@bors delegate-
Would like to take another look after this is fixed

@anforowicz
Copy link
Copy Markdown
Contributor Author

There have been 3 failures mentioned in #153171 (comment). All the failures seem underneath the new test/run-make/cdylib-export-visibility test:

  • The linking with cc failed on aarch64-apple with an error saying: Undefined symbols for architecture arm64: dyld_stub_binder, referenced from: <initial-undefines>.
    • This seems unrelated to the essence of this PR, so I plan to edit the new rmake test to just skip this platform
  • x86_64-mingw-1 and x86_64-msvc-1 failed one of the testcases in the new rmake test: Test Thread a session or semantic context through IL #1: Expecting test_fn_export_visibility_asks_for_target_default to not be exported from foo.dll.
    • I need to think more about this one - it does seem related to this PR.
    • I wonder if I need a Windows machine to try reproing this. On a Linux host:
      • Running $ ./x.py test --target x86_64-msvc-1 tests/run-make/cdylib-export-visibility complained that "x86_64-msvc-1: No such target exists in the target list"
      • Running $ ./x.py test --target x86_64-pc-windows-gnu tests/run-make/cdylib-export-visibility said: couldn't find required command: "x86_64-w64-mingw32-gcc"
    • If I could repro, one test that I would attempt would be to check if --Zdefault-visibility=hidden prevents exporting of a non-#no_mangle function in the given test environment.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@anforowicz
Copy link
Copy Markdown
Contributor Author

exported_dynamic_symbol_names doesn't work on wasm. It uses object::File::exports, which isn't implemented yet for wasm.

I've opened #153364 for this.

I think it's fine to [...] just drop the run-make-support bit since wasm is now skipped.

Done.

@JonathanBrouwer
Copy link
Copy Markdown
Contributor

Trying commonly failed jobs
@bors try jobs=test-various,x86_64-gnu-aux,x86_64-gnu-llvm-21-3,x86_64-msvc-1,aarch64-apple,x86_64-mingw-1

@rust-bors

This comment was marked as outdated.

rust-bors bot pushed a commit that referenced this pull request Mar 3, 2026
Add new unstable attribute: `#[export_visibility = ...]`.


try-job: test-various
try-job: x86_64-gnu-aux
try-job: x86_64-gnu-llvm-21-3
try-job: x86_64-msvc-1
try-job: aarch64-apple
try-job: x86_64-mingw-1
@JonathanBrouwer
Copy link
Copy Markdown
Contributor

Oh wait I don't think the windows problem is solved yet right?
@bors try cancel

@rust-bors

This comment was marked as outdated.

@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job x86_64-gnu-gcc failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
/dev/sda15      105M  6.2M   99M   6% /boot/efi
tmpfs           1.6G   12K  1.6G   1% /run/user/1001
================================================================================

Sufficient disk space available (95818424KB >= 52428800KB). Skipping cleanup.
##[group]Run echo "[CI_PR_NUMBER=$num]"
echo "[CI_PR_NUMBER=$num]"
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
---
   1: core::panicking::panic_fmt
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/core/src/panicking.rs:80:14
   2: compiletest::make_test
   3: compiletest::collect_tests_from_dir
   4: <rayon::iter::map::MapFolder<rayon::iter::reduce::ReduceFolder<compiletest::collect_tests_from_dir::{closure#2}, core::result::Result<compiletest::TestCollector, std::io::error::Error>>, compiletest::collect_tests_from_dir::{closure#0}> as rayon::iter::plumbing::Folder<core::result::Result<std::fs::DirEntry, std::io::error::Error>>>::consume
   5: <&rayon::iter::par_bridge::IterParallelProducer<std::fs::ReadDir> as rayon::iter::plumbing::UnindexedProducer>::fold_with::<rayon::iter::map::MapFolder<rayon::iter::reduce::ReduceFolder<compiletest::collect_tests_from_dir::{closure#2}, core::result::Result<compiletest::TestCollector, std::io::error::Error>>, compiletest::collect_tests_from_dir::{closure#0}>>
   6: rayon::iter::plumbing::bridge_unindexed_producer_consumer::<&rayon::iter::par_bridge::IterParallelProducer<std::fs::ReadDir>, rayon::iter::map::MapConsumer<rayon::iter::reduce::ReduceConsumer<compiletest::collect_tests_from_dir::{closure#2}, compiletest::collect_tests_from_dir::{closure#1}>, compiletest::collect_tests_from_dir::{closure#0}>>
   7: <rayon_core::job::StackJob<rayon_core::latch::SpinLatch, rayon_core::join::join_context::call_b<core::result::Result<compiletest::TestCollector, std::io::error::Error>, rayon::iter::plumbing::bridge_unindexed_producer_consumer<&rayon::iter::par_bridge::IterParallelProducer<std::fs::ReadDir>, rayon::iter::map::MapConsumer<rayon::iter::reduce::ReduceConsumer<compiletest::collect_tests_from_dir::{closure#2}, compiletest::collect_tests_from_dir::{closure#1}>, compiletest::collect_tests_from_dir::{closure#0}>>::{closure#1}>::{closure#0}, core::result::Result<compiletest::TestCollector, std::io::error::Error>> as rayon_core::job::Job>::execute
   8: <rayon_core::registry::WorkerThread>::wait_until_cold
   9: <rayon_core::registry::ThreadBuilder>::run
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Bootstrap failed while executing `--stage 2 test tests --test-codegen-backend gcc --skip tests/coverage --skip tests/coverage-run-rustdoc --skip tests/rustdoc-html --skip tests/rustdoc-gui --skip tests/rustdoc-js --skip tests/rustdoc-js-std --skip tests/rustdoc-json --skip tests/rustdoc-ui --set rust.codegen-backends=["llvm","gcc"]`
Build completed unsuccessfully in 0:51:57
  local time: Tue Mar  3 22:14:17 UTC 2026
  network time: Tue, 03 Mar 2026 22:14:17 GMT

For more information how to resolve CI failures of this job, visit this link.

@anforowicz
Copy link
Copy Markdown
Contributor Author

Oh wait I don't think the windows problem is solved yet right? @bors try cancel

Yes, I still need to take a close look, sorry.

@folkertdev
Copy link
Copy Markdown
Contributor

I might be missing it, but I think you also need some custom support for naked functions. They are very specific with what attributes are allowed on them, but this looks like one that would be useful.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 7, 2026

☔ The latest upstream changes (presumably #154958) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.