forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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
5facb42
commit b824fc4
Showing
10 changed files
with
69 additions
and
8 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
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,34 @@ | ||
// Verifies that `TargetOptions::default_hidden_visibility` is set 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:NONE 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 in Rust static libraries. | ||
// | ||
// This mimics the relevant part from https://github.com/rust-lang/rust/issues/73295 which | ||
// says: | ||
// | ||
// > We build Rust code into these DSOs in the approved way, which is to aggregate a bunch of Rust | ||
// > libraries (rlibs) into a separate Rust ***staticlib*** for each of the DSOs. (For example, | ||
// > libbase_rust_deps.a and libservices_rust_deps.a). The final C++ linker links exactly one of | ||
// > these staticlibs together with the C++ .a and .o in the final construction of the DSO. | ||
#![crate_type = "staticlib"] | ||
|
||
// The test scenario needs to use a public, but non-`#[no_mangle]` Rust symbol. | ||
// | ||
// We want to check the visibility of this symbol: | ||
// | ||
// FIXME: 1) confirm that this test file actually repros the problem at hand (I am not at all | ||
// confident that it does) | ||
// FIXME: 2) fix test expectations below ("internal" below seems unexpected for NONE scenario? no | ||
// idea what should be the expectation for YES scenario) | ||
// | ||
// NONE: @_ZN25default_hidden_visibility15exported_symbol17hc5deee4a42a30cf5E = internal constant | ||
// YES: @_ZN25default_hidden_visibility15exported_symbol17hc5deee4a42a30cf5E = internal constant | ||
// NO: @_ZN25default_hidden_visibility15exported_symbol17hc5deee4a42a30cf5E = internal constant | ||
#[used] | ||
pub static exported_symbol: [u8; 6] = *b"foobar"; |