risc-v: Disable PIC by default for now
authorWladimir J. van der Laan <laanwj@gmail.com>
Thu, 8 Aug 2019 06:27:30 +0000 (06:27 +0000)
committerXimin Luo <infinity0@debian.org>
Sun, 5 Jan 2020 13:35:46 +0000 (13:35 +0000)
Rust's linker cannot currently handle gcc's fPIC compilation units
for RISC-V targets:

      = note: rust-lld: error:
          .got section detected in the input files. Dynamic relocations are not
          supported. If you are linking to C code compiled using the `gcc` crate
          then modify your build script to compile the C code _without_ the
          -fPIC flag. See the documentation of the `gcc::Config.fpic` method for
          details.

So disable PIC by default for now for `riscv` targets.

Gbp-Pq: Name u-riscv64-cc-430.patch

vendor/cc/src/lib.rs

index 5b36f7d7c04054d067d19305a5a4efdf1a198363..9d8ef9644353ef715e8f1d455951529fcf115037 100644 (file)
@@ -818,7 +818,7 @@ impl Build {
 
     /// Configures whether the compiler will emit position independent code.
     ///
-    /// This option defaults to `false` for `windows-gnu` targets and
+    /// This option defaults to `false` for `windows-gnu` and `riscv` targets and
     /// to `true` for all other targets.
     pub fn pic(&mut self, pic: bool) -> &mut Build {
         self.pic = Some(pic);
@@ -1219,7 +1219,8 @@ impl Build {
                     cmd.push_cc_arg("-ffunction-sections".into());
                     cmd.push_cc_arg("-fdata-sections".into());
                 }
-                if self.pic.unwrap_or(!target.contains("windows-gnu")) {
+                // Disable generation of PIC on RISC-V for now: rust-lld doesn't support this yet
+                if self.pic.unwrap_or(!target.contains("windows-gnu") && !target.contains("riscv")) {
                     cmd.push_cc_arg("-fPIC".into());
                     // PLT only applies if code is compiled with PIC support,
                     // and only for ELF targets.