Skip to content

Commit 463e427

Browse files
committed
Auto merge of #31735 - aliclark:freebsd-link-defs, r=alexcrichton
The FreeBSD linker config is missing some options present in the other BSD configs. This seems accidental, with other BSDs having the flags added in platform-specific commits, or with the flags present from day 1. Some other BSD commits for reference: aliclark@fcb30a0#diff-db69d903e469b7769aefaa31786fc2c4R1 aliclark@0b7c4f5#diff-1c7b74536ce0291d1f89953035f26a71R1 aliclark@cfd2a5c
2 parents 917db28 + 6115f2e commit 463e427

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/librustc_back/target/freebsd_base.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,20 @@ pub fn opts() -> TargetOptions {
1616
linker: "cc".to_string(),
1717
dynamic_linking: true,
1818
executables: true,
19+
linker_is_gnu: true,
1920
has_rpath: true,
20-
pre_link_args: vec![
21+
pre_link_args: vec!(
22+
// GNU-style linkers will use this to omit linking to libraries
23+
// which don't actually fulfill any relocations, but only for
24+
// libraries which follow this flag. Thus, use it before
25+
// specifying libraries to link to.
26+
"-Wl,--as-needed".to_string(),
27+
2128
// Always enable NX protection when it is available
2229
"-Wl,-z,noexecstack".to_string(),
23-
],
30+
),
31+
position_independent_executables: true,
2432
exe_allocation_crate: super::maybe_jemalloc(),
25-
2633
.. Default::default()
2734
}
2835
}

0 commit comments

Comments
 (0)