Skip to content

risc-v: Disable PIC by default for now #430

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Aug 8, 2019
Merged

risc-v: Disable PIC by default for now #430

merged 1 commit into from
Aug 8, 2019

Conversation

laanwj
Copy link
Contributor

@laanwj laanwj commented Aug 8, 2019

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.

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.
@alexcrichton alexcrichton merged commit 13e04b1 into rust-lang:master Aug 8, 2019
Centril added a commit to Centril/rust that referenced this pull request Nov 15, 2019
Update cc, git2, num_cpus.

This updates the `cc` crate, bringing in better parallel building support. Also updates `git2` which enables the parallel feature. (Note: I don't expect it will have a significant impact on build time, but seems good to update anyways.)

The main thorn is that `cc` gained knowledge about RISC-V architectures (rust-lang/cc-rs#428, rust-lang/cc-rs#429, rust-lang/cc-rs#430), but the builders on CI do not have the riscv C compiler installed. This means that bootstraps' cc detection was finding a C compiler that isn't installed, and fails.

The solution here is to override the cc detection to `false`. The C compiler isn't actually used on riscv platforms. AFAIK, the only location would be compiler_builtins, and it currently forces C support off (https://github.com/rust-lang/compiler-builtins/blob/a533ae9c5aa325db209659679535fe1f186eae81/build.rs#L49-L55).

Other possible solutions:
- Add the override in cc_detect for riscv (or any "no-C" platform like wasm32 and nvptx)
- Install and use the appropriate c compiler. I tried this the `g++-riscv64-linux-gnu` package, but it failed missing some header file.

Closes rust-lang#66232
bors added a commit to rust-lang/rust that referenced this pull request Nov 16, 2019
Update cc, git2, num_cpus.

This updates the `cc` crate, bringing in better parallel building support. Also updates `git2` which enables the parallel feature. (Note: I don't expect it will have a significant impact on build time, but seems good to update anyways.)

The main thorn is that `cc` gained knowledge about RISC-V architectures (rust-lang/cc-rs#428, rust-lang/cc-rs#429, rust-lang/cc-rs#430), but the builders on CI do not have the riscv C compiler installed. This means that bootstraps' cc detection was finding a C compiler that isn't installed, and fails.

The solution here is to override the cc detection to `false`. The C compiler isn't actually used on riscv platforms. AFAIK, the only location would be compiler_builtins, and it currently forces C support off (https://github.com/rust-lang/compiler-builtins/blob/a533ae9c5aa325db209659679535fe1f186eae81/build.rs#L49-L55).

Other possible solutions:
- Add the override in cc_detect for riscv (or any "no-C" platform like wasm32 and nvptx)
- Install and use the appropriate c compiler. I tried this the `g++-riscv64-linux-gnu` package, but it failed missing some header file.

Closes #66232
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants