diff options
| author | Frank Denis <github@pureftpd.org> | 2023-02-21 14:52:20 +0100 |
|---|---|---|
| committer | Frank Denis <github@pureftpd.org> | 2023-02-21 14:52:20 +0100 |
| commit | 8e250c3c6462991ef618ba07d8ce3208ec585a8f (patch) | |
| tree | 5ddc88b3e38483431f567c568332348cbfa041bd /compiler | |
| parent | bda32a4023b1d3f96e56e1b2fc7510324f430316 (diff) | |
| download | rust-8e250c3c6462991ef618ba07d8ce3208ec585a8f.tar.gz rust-8e250c3c6462991ef618ba07d8ce3208ec585a8f.zip | |
Linker: use -z <params> instead of -z<params>
The GNU linker accepts -z<params>, but this is undocumented, and not supported by other linkers. In particular, `zig cc`, when used as the C compiler/linker (e.g. when using `cargo-zigbuild`), will not accept this undocumented syntax. In `linker.rs`, both syntaxes are also used inconsistently. The Go compiler used to have the same issue, but fixed it: https://github.com/golang/go/commit/38607c553878da21b5042e63997ecb3b7201e684
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/linker.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index eaf1e9817c2..52c01b423a7 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -473,13 +473,13 @@ impl<'a> Linker for GccLinker<'a> { self.cmd.arg(path); } fn full_relro(&mut self) { - self.linker_args(&["-zrelro", "-znow"]); + self.linker_args(&["-z", "relro", "-z", "now"]); } fn partial_relro(&mut self) { - self.linker_arg("-zrelro"); + self.linker_args(&["-z", "relro"]); } fn no_relro(&mut self) { - self.linker_arg("-znorelro"); + self.linker_args(&["-z", "norelro"]); } fn link_rust_dylib(&mut self, lib: &str, _path: &Path) { @@ -758,7 +758,7 @@ impl<'a> Linker for GccLinker<'a> { if self.sess.target.is_like_windows { self.linker_arg("--nxcompat"); } else if self.is_gnu { - self.linker_arg("-znoexecstack"); + self.linker_args(&["-z", "noexecstack"]); } } @@ -1364,16 +1364,16 @@ impl<'a> Linker for L4Bender<'a> { } fn full_relro(&mut self) { - self.cmd.arg("-zrelro"); - self.cmd.arg("-znow"); + self.cmd.arg("-z").arg("relro"); + self.cmd.arg("-z").arg("now"); } fn partial_relro(&mut self) { - self.cmd.arg("-zrelro"); + self.cmd.arg("-z").arg("relro"); } fn no_relro(&mut self) { - self.cmd.arg("-znorelro"); + self.cmd.arg("-z").arg("norelro"); } fn cmd(&mut self) -> &mut Command { |
