d-bootstrap-rustflags
authorDebian Rust Maintainers <pkg-rust-maintainers@alioth-lists.debian.net>
Tue, 29 Mar 2022 11:23:46 +0000 (12:23 +0100)
committerXimin Luo <infinity0@debian.org>
Tue, 29 Mar 2022 11:23:46 +0000 (12:23 +0100)
Gbp-Pq: Name d-bootstrap-rustflags.patch

src/bootstrap/builder.rs

index edd5bf1b536d3dabb6d069c6699201ac2225dfb8..460f482d4a0174b7fb541b7fc0001c70c531ef9e 100644 (file)
@@ -993,6 +993,18 @@ impl<'a> Builder<'a> {
             rustflags.arg("-Zsymbol-mangling-version=legacy");
         }
 
+        // Debian-specific stuff here
+        // set linker flags from LDFLAGS
+        if let Ok(ldflags) = env::var("LDFLAGS") {
+            for flag in ldflags.split_whitespace() {
+                if target.contains("windows") && flag.contains("relro") {
+                    // relro is ELF-specific
+                    continue;
+                }
+                rustflags.arg(&format!("-Clink-args={}", flag));
+            }
+        }
+
         // FIXME: It might be better to use the same value for both `RUSTFLAGS` and `RUSTDOCFLAGS`,
         // but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See
         // #71458.