-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unstable
-Zdefault-hidden-visibility
cmdline flag for rustc
.
The new flag has been described in the Major Change Proposal at rust-lang/compiler-team#656
- Loading branch information
1 parent
56d25ba
commit 10db282
Showing
11 changed files
with
68 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/doc/unstable-book/src/compiler-flags/default-hidden-visibility.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# `default-hidden-visibility` | ||
|
||
The tracking issue for this feature is: https://github.com/rust-lang/compiler-team/issues/656 | ||
|
||
------------------------ | ||
|
||
This flag can be used to override the target's | ||
[`default_hidden_visibility`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_target/spec/struct.TargetOptions.html#structfield.default_hidden_visibility) | ||
setting. | ||
Using `-Zdefault_hidden_visibility=yes` is roughly equivalent to Clang's | ||
[`-fvisibility=hidden`](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fvisibility) | ||
cmdline flag. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Verifies that `Session::default_hidden_visibility` is affected when using the related cmdline | ||
// flag. This is a regression test for https://github.com/rust-lang/compiler-team/issues/656. See | ||
// also https://github.com/rust-lang/rust/issues/73295 and | ||
// https://github.com/rust-lang/rust/issues/37530. | ||
|
||
// revisions:DEFAULT YES NO | ||
//[YES] compile-flags: -Zdefault-hidden-visibility=yes | ||
//[NO] compile-flags: -Zdefault-hidden-visibility=no | ||
|
||
// The test scenario is specifically about visibility of symbols exported out of dynamically linked | ||
// libraries. | ||
#![crate_type = "dylib"] | ||
|
||
// The test scenario needs to use a Rust-public, but non-explicitly-exported symbol | ||
// (e.g. the test doesn't use `#[no_mangle]`, because currently it implies that | ||
// the symbol should be exported; we don't want that - we want to test the *default* | ||
// export setting instead). | ||
#[used] | ||
pub static tested_symbol: [u8; 6] = *b"foobar"; | ||
|
||
// Exact LLVM IR differs depending on the target triple (e.g. `hidden constant` | ||
// vs `internal constant` vs `constant`). Because of this, we only apply the | ||
// specific test expectations below to one specific target triple. If needed, | ||
// additional targets can be covered by adding copies of this test file with | ||
// a different `only-X` directive. | ||
// | ||
// only-x86_64 | ||
// only-linux | ||
|
||
// DEFAULT: @{{.*}}default_hidden_visibility{{.*}}tested_symbol{{.*}} = constant | ||
// YES: @{{.*}}default_hidden_visibility{{.*}}tested_symbol{{.*}} = hidden constant | ||
// NO: @{{.*}}default_hidden_visibility{{.*}}tested_symbol{{.*}} = constant |