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

Target modifiers (special marked options) are recorded in metainfo #133138

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Target modifiers: Small fixes & re-work to generated OptionsTargetMod…
…ifiers enum
  • Loading branch information
azhogin committed Dec 18, 2024
commit 4ecef0caee3ec95bfca0b21dda56c3acf4810aa1
6 changes: 3 additions & 3 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ use rustc_metadata::locator;
use rustc_middle::ty::TyCtxt;
use rustc_parse::{new_parser_from_file, new_parser_from_source_str, unwrap_or_emit_fatal};
use rustc_session::config::{
CG_OPTIONS, ErrorOutputType, Input, OutFileName, OutputType, UnstableOptions, Z_OPTIONS,
nightly_options,
CG_OPTIONS, ErrorOutputType, Input, OptionsTargetModifiers, OutFileName, OutputType,
UnstableOptions, Z_OPTIONS, nightly_options,
};
use rustc_session::getopts::{self, Matches};
use rustc_session::lint::{Lint, LintId};
Expand Down Expand Up @@ -1165,7 +1165,7 @@ fn describe_codegen_flags() {

fn print_flag_list<T>(
cmdline_opt: &str,
flag_list: &[(&'static str, T, &'static str, &'static str, bool)],
flag_list: &[(&'static str, T, &'static str, &'static str, Option<OptionsTargetModifiers>)],
) {
let max_len =
flag_list.iter().map(|&(name, _, _, _, _)| name.chars().count()).max().unwrap_or(0);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ metadata_incompatible_rustc =
metadata_incompatible_target_modifiers =
mixing `{$flag_name_prefixed}` will cause an ABI mismatch
.note = `{$flag_name_prefixed}={$flag_local_value}` in this crate is incompatible with `{$flag_name_prefixed}={$flag_extern_value}` in dependency `{$extern_crate}`
.help = `{$flag_name_prefixed}` modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely
.help = this error occurs because the `{$flag_name_prefixed}` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely

metadata_incompatible_target_modifiers_help_allow = alternatively, use `-Cunsafe-allow-abi-mismatch={$flag_name}` to silence this error
metadata_incompatible_target_modifiers_help_fix = set `{$flag_name_prefixed}={$flag_extern_value}` in this crate or `{$flag_name_prefixed}={$flag_local_value}` in `{$extern_crate}`
Expand Down
11 changes: 2 additions & 9 deletions compiler/rustc_metadata/src/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,7 @@ impl CStore {
let sess = tcx.sess;
let allowed_flag_mismatches = &sess.opts.cg.unsafe_allow_abi_mismatch;
let span = krate.spans.inner_span.shrink_to_lo();
let tmod_extender = |tmod: &TargetModifier| {
(
sess.opts
.target_modifier_info_by_hash(tmod.name_hash, &tmod.value_name)
.expect("Target modifier not found by name hash"),
tmod.clone(),
)
};
let tmod_extender = |tmod: &TargetModifier| (tmod.extend(), tmod.clone());

let name = tcx.crate_name(LOCAL_CRATE);
let mods = sess.opts.gather_target_modifiers();
Expand Down Expand Up @@ -342,7 +335,7 @@ impl CStore {
left_name_val = left_name_val.or_else(|| it1.next());
right_name_val = right_name_val.or_else(|| it2.next());
match (&left_name_val, &right_name_val) {
(Some(l), Some(r)) => match l.1.name_hash.cmp(&r.1.name_hash) {
(Some(l), Some(r)) => match l.1.opt.cmp(&r.1.opt) {
cmp::Ordering::Equal => {
if l.0.tech_value != r.0.tech_value {
report_diff(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2334,7 +2334,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
let crate_types = parse_crate_types_from_list(unparsed_crate_types)
.unwrap_or_else(|e| early_dcx.early_fatal(e));

let mut target_modifiers = BTreeMap::<String, String>::new();
let mut target_modifiers = BTreeMap::<OptionsTargetModifiers, String>::new();

let mut unstable_opts = UnstableOptions::build(early_dcx, matches, &mut target_modifiers);
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(early_dcx, matches);
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_session/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#![feature(let_chains)]
#![feature(map_many_mut)]
#![feature(rustc_attrs)]
#![recursion_limit = "256"]
#![warn(unreachable_pub)]
// tidy-alphabetical-end

Expand Down
Loading
Loading