From a9e1e43b561aa1c3d5500b5b8b82c6e3ba05cc6c Mon Sep 17 00:00:00 2001 From: Zalathar Date: Thu, 2 Nov 2023 17:40:40 +1100 Subject: [PATCH 1/2] Add UI tests for values accepted by `-C symbol-mangling-version` --- src/tools/tidy/src/ui_tests.rs | 2 +- tests/ui/symbol-mangling-version/bad-value.bad.stderr | 2 ++ tests/ui/symbol-mangling-version/bad-value.blank.stderr | 2 ++ tests/ui/symbol-mangling-version/bad-value.no-value.stderr | 2 ++ tests/ui/symbol-mangling-version/bad-value.rs | 6 ++++++ tests/ui/symbol-mangling-version/stable.rs | 5 +++++ tests/ui/symbol-mangling-version/unstable.legacy.stderr | 2 ++ tests/ui/symbol-mangling-version/unstable.rs | 6 ++++++ 8 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/ui/symbol-mangling-version/bad-value.bad.stderr create mode 100644 tests/ui/symbol-mangling-version/bad-value.blank.stderr create mode 100644 tests/ui/symbol-mangling-version/bad-value.no-value.stderr create mode 100644 tests/ui/symbol-mangling-version/bad-value.rs create mode 100644 tests/ui/symbol-mangling-version/stable.rs create mode 100644 tests/ui/symbol-mangling-version/unstable.legacy.stderr create mode 100644 tests/ui/symbol-mangling-version/unstable.rs diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index dcf218bc189..7e24793adee 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -11,7 +11,7 @@ use std::path::{Path, PathBuf}; const ENTRY_LIMIT: usize = 900; // FIXME: The following limits should be reduced eventually. const ISSUES_ENTRY_LIMIT: usize = 1854; -const ROOT_ENTRY_LIMIT: usize = 866; +const ROOT_ENTRY_LIMIT: usize = 867; const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[ "rs", // test source files diff --git a/tests/ui/symbol-mangling-version/bad-value.bad.stderr b/tests/ui/symbol-mangling-version/bad-value.bad.stderr new file mode 100644 index 00000000000..c36c73c6069 --- /dev/null +++ b/tests/ui/symbol-mangling-version/bad-value.bad.stderr @@ -0,0 +1,2 @@ +error: incorrect value `bad-value` for codegen option `symbol-mangling-version` - either `legacy` or `v0` (RFC 2603) was expected + diff --git a/tests/ui/symbol-mangling-version/bad-value.blank.stderr b/tests/ui/symbol-mangling-version/bad-value.blank.stderr new file mode 100644 index 00000000000..0e70af5b8ff --- /dev/null +++ b/tests/ui/symbol-mangling-version/bad-value.blank.stderr @@ -0,0 +1,2 @@ +error: incorrect value `` for codegen option `symbol-mangling-version` - either `legacy` or `v0` (RFC 2603) was expected + diff --git a/tests/ui/symbol-mangling-version/bad-value.no-value.stderr b/tests/ui/symbol-mangling-version/bad-value.no-value.stderr new file mode 100644 index 00000000000..77013b72b6c --- /dev/null +++ b/tests/ui/symbol-mangling-version/bad-value.no-value.stderr @@ -0,0 +1,2 @@ +error: codegen option `symbol-mangling-version` requires either `legacy` or `v0` (RFC 2603) (C symbol-mangling-version=) + diff --git a/tests/ui/symbol-mangling-version/bad-value.rs b/tests/ui/symbol-mangling-version/bad-value.rs new file mode 100644 index 00000000000..7623857d49e --- /dev/null +++ b/tests/ui/symbol-mangling-version/bad-value.rs @@ -0,0 +1,6 @@ +// revisions: no-value blank bad +// [no-value] compile-flags: -Csymbol-mangling-version +// [blank] compile-flags: -Csymbol-mangling-version= +// [bad] compile-flags: -Csymbol-mangling-version=bad-value + +fn main() {} diff --git a/tests/ui/symbol-mangling-version/stable.rs b/tests/ui/symbol-mangling-version/stable.rs new file mode 100644 index 00000000000..dac9bb18d1c --- /dev/null +++ b/tests/ui/symbol-mangling-version/stable.rs @@ -0,0 +1,5 @@ +// check-pass +// revisions: v0 +// [v0] compile-flags: -Csymbol-mangling-version=v0 + +fn main() {} diff --git a/tests/ui/symbol-mangling-version/unstable.legacy.stderr b/tests/ui/symbol-mangling-version/unstable.legacy.stderr new file mode 100644 index 00000000000..c5b359b41bd --- /dev/null +++ b/tests/ui/symbol-mangling-version/unstable.legacy.stderr @@ -0,0 +1,2 @@ +error: `-C symbol-mangling-version=legacy` requires `-Z unstable-options` + diff --git a/tests/ui/symbol-mangling-version/unstable.rs b/tests/ui/symbol-mangling-version/unstable.rs new file mode 100644 index 00000000000..df87a39cdfb --- /dev/null +++ b/tests/ui/symbol-mangling-version/unstable.rs @@ -0,0 +1,6 @@ +// revisions: legacy legacy-ok +// [legacy] compile-flags: -Csymbol-mangling-version=legacy +// [legacy-ok] check-pass +// [legacy-ok] compile-flags: -Zunstable-options -Csymbol-mangling-version=legacy + +fn main() {} From 76103a8f6e838ca5bd9cf16b6236519c7c78e81d Mon Sep 17 00:00:00 2001 From: Zalathar Date: Thu, 2 Nov 2023 17:34:05 +1100 Subject: [PATCH 2/2] Remove support for alias `-Z symbol-mangling-version` --- compiler/rustc_interface/src/tests.rs | 1 - compiler/rustc_session/src/config.rs | 33 +++++++------------ compiler/rustc_session/src/options.rs | 3 -- .../crate-hash-rustc-version/Makefile | 2 +- 4 files changed, 13 insertions(+), 26 deletions(-) diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 594283168c9..8e66083a390 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -817,7 +817,6 @@ fn test_unstable_options_tracking_hash() { tracked!(split_lto_unit, Some(true)); tracked!(src_hash_algorithm, Some(SourceFileHashAlgorithm::Sha1)); tracked!(stack_protector, StackProtector::All); - tracked!(symbol_mangling_version, Some(SymbolManglingVersion::V0)); tracked!(teach, true); tracked!(thinlto, Some(true)); tracked!(thir_unsafeck, true); diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index a8ebab4ae33..715a7f9cb63 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -2674,28 +2674,19 @@ pub fn build_session_options( ); } - // Handle both `-Z symbol-mangling-version` and `-C symbol-mangling-version`; the latter takes - // precedence. - match (cg.symbol_mangling_version, unstable_opts.symbol_mangling_version) { - (Some(smv_c), Some(smv_z)) if smv_c != smv_z => { - handler.early_error( - "incompatible values passed for `-C symbol-mangling-version` \ - and `-Z symbol-mangling-version`", - ); + // Check for unstable values of `-C symbol-mangling-version`. + // This is what prevents them from being used on stable compilers. + match cg.symbol_mangling_version { + // Stable values: + None | Some(SymbolManglingVersion::V0) => {} + // Unstable values: + Some(SymbolManglingVersion::Legacy) => { + if !unstable_opts.unstable_options { + handler.early_error( + "`-C symbol-mangling-version=legacy` requires `-Z unstable-options`", + ); + } } - (Some(SymbolManglingVersion::V0), _) => {} - (Some(_), _) if !unstable_opts.unstable_options => { - handler - .early_error("`-C symbol-mangling-version=legacy` requires `-Z unstable-options`"); - } - (None, None) => {} - (None, smv) => { - handler.early_warn( - "`-Z symbol-mangling-version` is deprecated; use `-C symbol-mangling-version`", - ); - cg.symbol_mangling_version = smv; - } - _ => {} } // Check for unstable values of `-C instrument-coverage`. diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 30c8b9d6700..8669c37e35a 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1823,9 +1823,6 @@ written to standard error output)"), "control if mem::uninitialized and mem::zeroed panic on more UB"), strip: Strip = (Strip::None, parse_strip, [UNTRACKED], "tell the linker which information to strip (`none` (default), `debuginfo` or `symbols`)"), - symbol_mangling_version: Option = (None, - parse_symbol_mangling_version, [TRACKED], - "which mangling version to use for symbol names ('legacy' (default) or 'v0')"), #[rustc_lint_opt_deny_field_access("use `Session::teach` instead of this field")] teach: bool = (false, parse_bool, [TRACKED], "show extended diagnostic help (default: no)"), diff --git a/tests/run-make/crate-hash-rustc-version/Makefile b/tests/run-make/crate-hash-rustc-version/Makefile index f1d2a360410..6bf504bf01b 100644 --- a/tests/run-make/crate-hash-rustc-version/Makefile +++ b/tests/run-make/crate-hash-rustc-version/Makefile @@ -4,7 +4,7 @@ include ../tools.mk # Ensure that crates compiled with different rustc versions cannot # be dynamically linked. -FLAGS := -Cprefer-dynamic -Zsymbol-mangling-version=v0 +FLAGS := -Cprefer-dynamic -Csymbol-mangling-version=v0 UNAME := $(shell uname) ifeq ($(UNAME),Linux) EXT=".so"