Skip to content

Commit 4796871

Browse files
committed
Revert "musl: don't use the included startfiles with -crt-static"
This reverts commit a5a875d.
1 parent 4ac82b4 commit 4796871

File tree

3 files changed

+9
-37
lines changed

3 files changed

+9
-37
lines changed

src/librustc_codegen_llvm/back/link.rs

-16
Original file line numberDiff line numberDiff line change
@@ -625,11 +625,6 @@ fn link_natively(sess: &Session,
625625
if let Some(args) = sess.target.target.options.pre_link_args.get(&flavor) {
626626
cmd.args(args);
627627
}
628-
if let Some(args) = sess.target.target.options.pre_link_args_crt.get(&flavor) {
629-
if sess.crt_static() {
630-
cmd.args(args);
631-
}
632-
}
633628
if let Some(ref args) = sess.opts.debugging_opts.pre_link_args {
634629
cmd.args(args);
635630
}
@@ -644,12 +639,6 @@ fn link_natively(sess: &Session,
644639
cmd.arg(root.join(obj));
645640
}
646641

647-
if crate_type == config::CrateTypeExecutable && sess.crt_static() {
648-
for obj in &sess.target.target.options.pre_link_objects_exe_crt {
649-
cmd.arg(root.join(obj));
650-
}
651-
}
652-
653642
if sess.target.target.options.is_like_emscripten {
654643
cmd.arg("-s");
655644
cmd.arg(if sess.panic_strategy() == PanicStrategy::Abort {
@@ -671,11 +660,6 @@ fn link_natively(sess: &Session,
671660
for obj in &sess.target.target.options.post_link_objects {
672661
cmd.arg(root.join(obj));
673662
}
674-
if sess.crt_static() {
675-
for obj in &sess.target.target.options.post_link_objects_crt {
676-
cmd.arg(root.join(obj));
677-
}
678-
}
679663
if let Some(args) = sess.target.target.options.post_link_args.get(&flavor) {
680664
cmd.args(args);
681665
}

src/librustc_target/spec/linux_musl_base.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ pub fn opts() -> TargetOptions {
1515

1616
// Make sure that the linker/gcc really don't pull in anything, including
1717
// default objects, libs, etc.
18-
base.pre_link_args_crt.insert(LinkerFlavor::Gcc, Vec::new());
19-
base.pre_link_args_crt.get_mut(&LinkerFlavor::Gcc).unwrap().push("-nostdlib".to_string());
18+
base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-nostdlib".to_string());
2019

2120
// At least when this was tested, the linker would not add the
2221
// `GNU_EH_FRAME` program header to executables generated, which is required
@@ -56,9 +55,9 @@ pub fn opts() -> TargetOptions {
5655
//
5756
// Each target directory for musl has these object files included in it so
5857
// they'll be included from there.
59-
base.pre_link_objects_exe_crt.push("crt1.o".to_string());
60-
base.pre_link_objects_exe_crt.push("crti.o".to_string());
61-
base.post_link_objects_crt.push("crtn.o".to_string());
58+
base.pre_link_objects_exe.push("crt1.o".to_string());
59+
base.pre_link_objects_exe.push("crti.o".to_string());
60+
base.post_link_objects.push("crtn.o".to_string());
6261

6362
// These targets statically link libc by default
6463
base.crt_static_default = true;

src/librustc_target/spec/mod.rs

+5-16
Original file line numberDiff line numberDiff line change
@@ -422,22 +422,20 @@ pub struct TargetOptions {
422422
/// Linker to invoke
423423
pub linker: Option<String>,
424424

425-
/// Linker arguments that are passed *before* any user-defined libraries.
426-
pub pre_link_args: LinkArgs, // ... unconditionally
427-
pub pre_link_args_crt: LinkArgs, // ... when linking with a bundled crt
425+
/// Linker arguments that are unconditionally passed *before* any
426+
/// user-defined libraries.
427+
pub pre_link_args: LinkArgs,
428428
/// Objects to link before all others, always found within the
429429
/// sysroot folder.
430-
pub pre_link_objects_exe: Vec<String>, // ... when linking an executable, unconditionally
431-
pub pre_link_objects_exe_crt: Vec<String>, // ... when linking an executable with a bundled crt
430+
pub pre_link_objects_exe: Vec<String>, // ... when linking an executable
432431
pub pre_link_objects_dll: Vec<String>, // ... when linking a dylib
433432
/// Linker arguments that are unconditionally passed after any
434433
/// user-defined but before post_link_objects. Standard platform
435434
/// libraries that should be always be linked to, usually go here.
436435
pub late_link_args: LinkArgs,
437436
/// Objects to link after all others, always found within the
438437
/// sysroot folder.
439-
pub post_link_objects: Vec<String>, // ... unconditionally
440-
pub post_link_objects_crt: Vec<String>, // ... when linking with a bundled crt
438+
pub post_link_objects: Vec<String>,
441439
/// Linker arguments that are unconditionally passed *after* any
442440
/// user-defined libraries.
443441
pub post_link_args: LinkArgs,
@@ -637,7 +635,6 @@ impl Default for TargetOptions {
637635
is_builtin: false,
638636
linker: option_env!("CFG_DEFAULT_LINKER").map(|s| s.to_string()),
639637
pre_link_args: LinkArgs::new(),
640-
pre_link_args_crt: LinkArgs::new(),
641638
post_link_args: LinkArgs::new(),
642639
asm_args: Vec::new(),
643640
cpu: "generic".to_string(),
@@ -671,10 +668,8 @@ impl Default for TargetOptions {
671668
position_independent_executables: false,
672669
relro_level: RelroLevel::None,
673670
pre_link_objects_exe: Vec::new(),
674-
pre_link_objects_exe_crt: Vec::new(),
675671
pre_link_objects_dll: Vec::new(),
676672
post_link_objects: Vec::new(),
677-
post_link_objects_crt: Vec::new(),
678673
late_link_args: LinkArgs::new(),
679674
link_env: Vec::new(),
680675
archive_format: "gnu".to_string(),
@@ -893,13 +888,10 @@ impl Target {
893888
key!(is_builtin, bool);
894889
key!(linker, optional);
895890
key!(pre_link_args, link_args);
896-
key!(pre_link_args_crt, link_args);
897891
key!(pre_link_objects_exe, list);
898-
key!(pre_link_objects_exe_crt, list);
899892
key!(pre_link_objects_dll, list);
900893
key!(late_link_args, link_args);
901894
key!(post_link_objects, list);
902-
key!(post_link_objects_crt, list);
903895
key!(post_link_args, link_args);
904896
key!(link_env, env);
905897
key!(asm_args, list);
@@ -1101,13 +1093,10 @@ impl ToJson for Target {
11011093
target_option_val!(is_builtin);
11021094
target_option_val!(linker);
11031095
target_option_val!(link_args - pre_link_args);
1104-
target_option_val!(link_args - pre_link_args_crt);
11051096
target_option_val!(pre_link_objects_exe);
1106-
target_option_val!(pre_link_objects_exe_crt);
11071097
target_option_val!(pre_link_objects_dll);
11081098
target_option_val!(link_args - late_link_args);
11091099
target_option_val!(post_link_objects);
1110-
target_option_val!(post_link_objects_crt);
11111100
target_option_val!(link_args - post_link_args);
11121101
target_option_val!(env - link_env);
11131102
target_option_val!(asm_args);

0 commit comments

Comments
 (0)