1 use crate::spec::{LinkerFlavor, TargetOptions};
3 pub fn opts() -> TargetOptions {
4 let mut base = super::linux_base::opts();
6 // Make sure that the linker/gcc really don't pull in anything, including
7 // default objects, libs, etc.
8 base.pre_link_args_crt.insert(LinkerFlavor::Gcc, Vec::new());
9 base.pre_link_args_crt.get_mut(&LinkerFlavor::Gcc).unwrap().push("-nostdlib".to_string());
11 // At least when this was tested, the linker would not add the
12 // `GNU_EH_FRAME` program header to executables generated, which is required
13 // when unwinding to locate the unwinding information. I'm not sure why this
14 // argument is *not* necessary for normal builds, but it can't hurt!
15 base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-Wl,--eh-frame-hdr".to_string());
17 // When generating a statically linked executable there's generally some
18 // small setup needed which is listed in these files. These are provided by
19 // a musl toolchain and are linked by default by the `musl-gcc` script. Note
20 // that `gcc` also does this by default, it just uses some different files.
22 // Each target directory for musl has these object files included in it so
23 // they'll be included from there.
24 base.pre_link_objects_exe_crt.push("crt1.o".to_string());
25 base.pre_link_objects_exe_crt.push("crti.o".to_string());
26 base.post_link_objects_crt.push("crtn.o".to_string());
28 // These targets statically link libc by default
29 base.crt_static_default = true;
30 // These targets allow the user to choose between static and dynamic linking.
31 base.crt_static_respected = true;