rustc_target/spec/base/illumos.rs
1use crate::spec::{Cc, FramePointer, LinkerFlavor, TargetOptions, cvs};
2
3pub(crate) fn opts() -> TargetOptions {
4 let late_link_args = TargetOptions::link_args(
5 LinkerFlavor::Unix(Cc::Yes),
6 &[
7 // The illumos libc contains a stack unwinding implementation, as
8 // does libgcc_s. The latter implementation includes several
9 // additional symbols that are not always in base libc. To force
10 // the consistent use of just one unwinder, we ensure libc appears
11 // after libgcc_s in the NEEDED list for the resultant binary by
12 // ignoring any attempts to add it as a dynamic dependency until the
13 // very end.
14 // FIXME: This should be replaced by a more complete and generic
15 // mechanism for controlling the order of library arguments passed
16 // to the linker.
17 "-lc",
18 // LLVM will insert calls to the stack protector functions
19 // "__stack_chk_fail" and "__stack_chk_guard" into code in native
20 // object files. Some platforms include these symbols directly in
21 // libc, but at least historically these have been provided in
22 // libssp.so on illumos and Solaris systems.
23 "-lssp",
24 ],
25 );
26
27 TargetOptions {
28 os: "illumos".into(),
29 dynamic_linking: true,
30 has_rpath: true,
31 families: cvs!["unix"],
32 is_like_solaris: true,
33 linker_flavor: LinkerFlavor::Unix(Cc::Yes),
34 limit_rdylib_exports: false, // Linker doesn't support this
35 frame_pointer: FramePointer::Always,
36 eh_frame_header: false,
37 late_link_args,
38
39 // While we support ELF TLS, rust requires a way to register
40 // cleanup handlers (in C, this would be something along the lines of:
41 // void register_callback(void (*fn)(void *), void *arg);
42 // (see src/libstd/sys/pal/unix/fast_thread_local.rs) that is currently
43 // missing in illumos. For now at least, we must fallback to using
44 // pthread_{get,set}specific.
45 //has_thread_local: true,
46
47 // FIXME: Currently, rust is invoking cc to link, which ends up
48 // causing these to get included twice. We should eventually transition
49 // to having rustc invoke ld directly, in which case these will need to
50 // be uncommented.
51 //
52 // We want XPG6 behavior from libc and libm. See standards(5)
53 //pre_link_objects_exe: vec![
54 // "/usr/lib/amd64/values-Xc.o".into(),
55 // "/usr/lib/amd64/values-xpg6.o".into(),
56 //],
57 ..Default::default()
58 }
59}