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

Rollup of 3 pull requests #59576

Closed
wants to merge 12 commits into from
8 changes: 7 additions & 1 deletion src/librustc_codegen_llvm/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,15 @@ pub fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
if cx.sess().instrument_mcount() {
// Similar to `clang -pg` behavior. Handled by the
// `post-inline-ee-instrument` LLVM pass.

// The function name varies on platforms.
// See test/CodeGen/mcount.c in clang.
let mcount_name = CString::new(
cx.sess().target.target.options.target_mcount.as_str().as_bytes()).unwrap();

llvm::AddFunctionAttrStringValue(
llfn, llvm::AttributePlace::Function,
const_cstr!("instrument-function-entry-inlined"), const_cstr!("mcount"));
const_cstr!("instrument-function-entry-inlined"), &mcount_name);
}
}

Expand Down
17 changes: 14 additions & 3 deletions src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic,
SuggestionStyle, SourceMapperDyn, DiagnosticId,
};
use crate::Level::Error;
use crate::snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, StyledString, Style};
use crate::styled_buffer::StyledBuffer;

Expand Down Expand Up @@ -72,6 +73,7 @@ impl Emitter for EmitterWriter {

self.fix_multispans_in_std_macros(&mut primary_span,
&mut children,
&db.level,
db.handler.flags.external_macro_backtrace);

self.emit_messages_default(&db.level,
Expand Down Expand Up @@ -888,18 +890,27 @@ impl EmitterWriter {
fn fix_multispans_in_std_macros(&mut self,
span: &mut MultiSpan,
children: &mut Vec<SubDiagnostic>,
level: &Level,
backtrace: bool) {
let mut spans_updated = self.fix_multispan_in_std_macros(span, backtrace);
for child in children.iter_mut() {
spans_updated |= self.fix_multispan_in_std_macros(&mut child.span, backtrace);
}
let msg = if level == &Error {
"this error originates in a macro outside of the current crate \
(in Nightly builds, run with -Z external-macro-backtrace \
for more info)".to_string()
} else {
"this warning originates in a macro outside of the current crate \
(in Nightly builds, run with -Z external-macro-backtrace \
for more info)".to_string()
};

if spans_updated {
children.push(SubDiagnostic {
level: Level::Note,
message: vec![
("this error originates in a macro outside of the current crate \
(in Nightly builds, run with -Z external-macro-backtrace \
for more info)".to_string(),
(msg,
Style::NoStyle),
],
span: MultiSpan::new(),
Expand Down
1 change: 1 addition & 0 deletions src/librustc_target/spec/aarch64_unknown_linux_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn target() -> TargetResult {
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {
abi_blacklist: super::arm_base::abi_blacklist(),
target_mcount: "\01_mcount".to_string(),
.. base
},
})
Expand Down
1 change: 1 addition & 0 deletions src/librustc_target/spec/aarch64_unknown_linux_musl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn target() -> TargetResult {
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {
abi_blacklist: super::arm_base::abi_blacklist(),
target_mcount: "\01_mcount".to_string(),
.. base
},
})
Expand Down
7 changes: 5 additions & 2 deletions src/librustc_target/spec/aarch64_unknown_netbsd.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{LinkerFlavor, Target, TargetResult};
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::netbsd_base::opts();
Expand All @@ -16,6 +16,9 @@ pub fn target() -> TargetResult {
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,
options: TargetOptions {
target_mcount: "__mcount".to_string(),
.. base
},
})
}
1 change: 1 addition & 0 deletions src/librustc_target/spec/arm_unknown_linux_gnueabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub fn target() -> TargetResult {
options: TargetOptions {
features: "+strict-align,+v6".to_string(),
abi_blacklist: super::arm_base::abi_blacklist(),
target_mcount: "\01__gnu_mcount_nc".to_string(),
.. base
},
})
Expand Down
1 change: 1 addition & 0 deletions src/librustc_target/spec/arm_unknown_linux_gnueabihf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub fn target() -> TargetResult {
options: TargetOptions {
features: "+strict-align,+v6,+vfp2".to_string(),
abi_blacklist: super::arm_base::abi_blacklist(),
target_mcount: "\01__gnu_mcount_nc".to_string(),
.. base
}
})
Expand Down
1 change: 1 addition & 0 deletions src/librustc_target/spec/arm_unknown_linux_musleabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub fn target() -> TargetResult {
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {
abi_blacklist: super::arm_base::abi_blacklist(),
target_mcount: "\01mcount".to_string(),
.. base
},
})
Expand Down
1 change: 1 addition & 0 deletions src/librustc_target/spec/arm_unknown_linux_musleabihf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub fn target() -> TargetResult {
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions {
abi_blacklist: super::arm_base::abi_blacklist(),
target_mcount: "\01mcount".to_string(),
.. base
},
})
Expand Down
1 change: 1 addition & 0 deletions src/librustc_target/spec/armv4t_unknown_linux_gnueabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub fn target() -> TargetResult {
// Atomic operations provided by compiler-builtins
max_atomic_width: Some(32),
abi_blacklist: super::arm_base::abi_blacklist(),
target_mcount: "\01__gnu_mcount_nc".to_string(),
.. base
}
})
Expand Down
1 change: 1 addition & 0 deletions src/librustc_target/spec/armv5te_unknown_linux_gnueabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub fn target() -> TargetResult {
// Atomic operations provided by compiler-builtins
max_atomic_width: Some(32),
abi_blacklist: super::arm_base::abi_blacklist(),
target_mcount: "\01__gnu_mcount_nc".to_string(),
.. base
}
})
Expand Down
1 change: 1 addition & 0 deletions src/librustc_target/spec/armv5te_unknown_linux_musleabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub fn target() -> TargetResult {
// Atomic operations provided by compiler-builtins
max_atomic_width: Some(32),
abi_blacklist: super::arm_base::abi_blacklist(),
target_mcount: "\01mcount".to_string(),
.. base
}
})
Expand Down
1 change: 1 addition & 0 deletions src/librustc_target/spec/armv6_unknown_freebsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub fn target() -> TargetResult {
features: "+v6,+vfp2".to_string(),
max_atomic_width: Some(64),
abi_blacklist: super::arm_base::abi_blacklist(),
target_mcount: "\01__gnu_mcount_nc".to_string(),
.. base
}
})
Expand Down
1 change: 1 addition & 0 deletions src/librustc_target/spec/armv6_unknown_netbsd_eabihf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub fn target() -> TargetResult {
options: TargetOptions {
features: "+v6,+vfp2".to_string(),
abi_blacklist: super::arm_base::abi_blacklist(),
target_mcount: "__mcount".to_string(),
.. base
}
})
Expand Down
7 changes: 5 additions & 2 deletions src/librustc_target/spec/armv7_unknown_cloudabi_eabihf.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{LinkerFlavor, Target, TargetResult};
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::cloudabi_base::opts();
Expand All @@ -19,6 +19,9 @@ pub fn target() -> TargetResult {
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,
options: TargetOptions {
target_mcount: "\01mcount".to_string(),
.. base
},
})
}
1 change: 1 addition & 0 deletions src/librustc_target/spec/armv7_unknown_freebsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub fn target() -> TargetResult {
features: "+v7,+vfp3,+d16,+thumb2,-neon".to_string(),
max_atomic_width: Some(64),
abi_blacklist: super::arm_base::abi_blacklist(),
target_mcount: "\01__gnu_mcount_nc".to_string(),
.. base
}
})
Expand Down
1 change: 1 addition & 0 deletions src/librustc_target/spec/armv7_unknown_linux_gnueabihf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub fn target() -> TargetResult {
cpu: "generic".to_string(),
max_atomic_width: Some(64),
abi_blacklist: super::arm_base::abi_blacklist(),
target_mcount: "\01__gnu_mcount_nc".to_string(),
.. base
}
})
Expand Down
1 change: 1 addition & 0 deletions src/librustc_target/spec/armv7_unknown_linux_musleabihf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub fn target() -> TargetResult {
cpu: "generic".to_string(),
max_atomic_width: Some(64),
abi_blacklist: super::arm_base::abi_blacklist(),
target_mcount: "\01mcount".to_string(),
.. base
}
})
Expand Down
1 change: 1 addition & 0 deletions src/librustc_target/spec/armv7_unknown_netbsd_eabihf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub fn target() -> TargetResult {
cpu: "generic".to_string(),
max_atomic_width: Some(64),
abi_blacklist: super::arm_base::abi_blacklist(),
target_mcount: "__mcount".to_string(),
.. base
}
})
Expand Down
7 changes: 5 additions & 2 deletions src/librustc_target/spec/i686_apple_darwin.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{LinkerFlavor, Target, TargetResult};
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::apple_base::opts();
Expand All @@ -19,6 +19,9 @@ pub fn target() -> TargetResult {
target_env: String::new(),
target_vendor: "apple".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,
options: TargetOptions {
target_mcount: "\01mcount".to_string(),
.. base
},
})
}
7 changes: 5 additions & 2 deletions src/librustc_target/spec/i686_unknown_netbsd.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{LinkerFlavor, Target, TargetResult};
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::netbsd_base::opts();
Expand All @@ -18,6 +18,9 @@ pub fn target() -> TargetResult {
target_env: String::new(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,
options: TargetOptions {
target_mcount: "__mcount".to_string(),
.. base
},
})
}
1 change: 1 addition & 0 deletions src/librustc_target/spec/mips64_unknown_linux_gnuabi64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn target() -> TargetResult {
cpu: "mips64r2".to_string(),
features: "+mips64r2".to_string(),
max_atomic_width: Some(64),
target_mcount: "_mcount".to_string(),

..super::linux_base::opts()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn target() -> TargetResult {
cpu: "mips64r2".to_string(),
features: "+mips64r2".to_string(),
max_atomic_width: Some(64),
target_mcount: "_mcount".to_string(),

..super::linux_base::opts()
},
Expand Down
1 change: 1 addition & 0 deletions src/librustc_target/spec/mips_unknown_linux_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub fn target() -> TargetResult {
cpu: "mips32r2".to_string(),
features: "+mips32r2,+fpxx,+nooddspreg".to_string(),
max_atomic_width: Some(32),
target_mcount: "_mcount".to_string(),

..super::linux_base::opts()
},
Expand Down
7 changes: 5 additions & 2 deletions src/librustc_target/spec/mips_unknown_linux_musl.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{LinkerFlavor, Target, TargetResult};
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::linux_musl_base::opts();
Expand All @@ -17,6 +17,9 @@ pub fn target() -> TargetResult {
target_env: "musl".to_string(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,
options: TargetOptions {
target_mcount: "_mcount".to_string(),
.. base
},
})
}
1 change: 1 addition & 0 deletions src/librustc_target/spec/mips_unknown_linux_uclibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub fn target() -> TargetResult {
cpu: "mips32r2".to_string(),
features: "+mips32r2,+soft-float".to_string(),
max_atomic_width: Some(32),
target_mcount: "_mcount".to_string(),

..super::linux_base::opts()
},
Expand Down
1 change: 1 addition & 0 deletions src/librustc_target/spec/mipsel_unknown_linux_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn target() -> TargetResult {
cpu: "mips32r2".to_string(),
features: "+mips32r2,+fpxx,+nooddspreg".to_string(),
max_atomic_width: Some(32),
target_mcount: "_mcount".to_string(),

..super::linux_base::opts()
},
Expand Down
7 changes: 5 additions & 2 deletions src/librustc_target/spec/mipsel_unknown_linux_musl.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{LinkerFlavor, Target, TargetResult};
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::linux_musl_base::opts();
Expand All @@ -17,6 +17,9 @@ pub fn target() -> TargetResult {
target_env: "musl".to_string(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,
options: TargetOptions {
target_mcount: "_mcount".to_string(),
.. base
},
})
}
1 change: 1 addition & 0 deletions src/librustc_target/spec/mipsel_unknown_linux_uclibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn target() -> TargetResult {
cpu: "mips32r2".to_string(),
features: "+mips32r2,+soft-float".to_string(),
max_atomic_width: Some(32),
target_mcount: "_mcount".to_string(),

..super::linux_base::opts()
},
Expand Down
1 change: 1 addition & 0 deletions src/librustc_target/spec/mipsisa32r6_unknown_linux_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub fn target() -> TargetResult {
cpu: "mips32r6".to_string(),
features: "+mips32r6".to_string(),
max_atomic_width: Some(32),
target_mcount: "_mcount".to_string(),

..super::linux_base::opts()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn target() -> TargetResult {
cpu: "mips32r6".to_string(),
features: "+mips32r6".to_string(),
max_atomic_width: Some(32),
target_mcount: "_mcount".to_string(),

..super::linux_base::opts()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn target() -> TargetResult {
cpu: "mips64r6".to_string(),
features: "+mips64r6".to_string(),
max_atomic_width: Some(64),
target_mcount: "_mcount".to_string(),

..super::linux_base::opts()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn target() -> TargetResult {
cpu: "mips64r6".to_string(),
features: "+mips64r6".to_string(),
max_atomic_width: Some(64),
target_mcount: "_mcount".to_string(),

..super::linux_base::opts()
},
Expand Down
Loading