Skip to content

Commit 782d196

Browse files
committed
set subsections_via_symbols for ld64 helper sections
1 parent 65fa0ab commit 782d196

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

Diff for: compiler/rustc_codegen_ssa/src/back/metadata.rs

+3
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
221221

222222
file.set_macho_build_version(macho_object_build_version_for_target(sess))
223223
}
224+
if binary_format == BinaryFormat::MachO {
225+
file.set_subsections_via_symbols();
226+
}
224227
if binary_format == BinaryFormat::Coff {
225228
// Disable the default mangler to avoid mangling the special "@feat.00" symbol name.
226229
let original_mangling = file.mangling();

Diff for: tests/run-make/executable-no-mangle-strip/main.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
unsafe extern "C" {
2+
unsafe static UNDEFINED: usize;
3+
}
4+
5+
#[unsafe(no_mangle)]
6+
pub fn used() {
7+
println!("UNDEFINED = {}", unsafe { UNDEFINED });
8+
}
9+
10+
pub fn marker() -> usize {
11+
0
12+
}
13+
14+
fn main() {
15+
assert_eq!(marker(), 0_usize);
16+
}

Diff for: tests/run-make/executable-no-mangle-strip/rmake.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Test that functions marked with `#[no_mangle]` are GC-ed
2+
3+
//@ only-apple
4+
5+
use run_make_support::rustc;
6+
7+
fn main() {
8+
rustc().arg("main.rs").run();
9+
}

0 commit comments

Comments
 (0)