0

I want to link the rust project with the flag --no-relax.

Here is what I tried:

  1. First try:
RUSTFLAGS="--cfg aes_force_soft --cfg polyval_force_soft -Clink-args="-Wl,--no-relax"" CARGO_TARGET_DIR=../target cargo xbuild --target x86_64-qkernel.json  --verbose

As you can see, I do get -Clink-args=-Wl,--no-relax during rustc compilation

Running `rustc --crate-name qkernel src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type staticlib --emit=dep-info,link -C opt-level=3 -C panic=abort -C lto -C codegen-units=1 -C debuginfo=0 -C metadata=97ea9ce0f16c5783 -C extra-filename=-97ea9ce0f16c5783 --out-dir /home/yaoxin/master-thesis-quark/qkernel/../target/x86_64-qkernel/release/deps --target /home/yaoxin/master-thesis-quark/qkernel/x86_64-qkernel.json -L dependency=/home/yaoxin/master-thesis-quark/qkernel/../target/x86_64-qkernel/release/deps -L dependency=/home/yaoxin/master-thesis-quark/qkernel/../target/release/deps --extern aes_gcm=/home/yaoxin/master-thesis-quark/qkernel/../target/x86_64-qkernel/release/deps/libaes_gcm-717643e861007e33.rlib b --cfg aes_force_soft --cfg polyval_force_soft -Clink-args=-Wl,--no-relax

But I still get the flowing error

Finished release [optimized] target(s) in 1m 05s
ld: failed to convert GOTPCREL relocation; relink with --no-relax
make[1]: *** [makefile:20: ../build/qkernel.bin] Error 1
make[1]: Leaving directory '/home/yaoxin/master-thesis-quark/qkernel'
make: *** [makefile:5: release] Error 2

It seems like the compiler doesn't recognize the flag, any idea how I should pass the flag to the compiler?

cafce25
  • 15,907
  • 4
  • 25
  • 31
yaoxin jing
  • 55
  • 1
  • 4
  • Might be that you need to escape the inner `"`: `RUSTFLAGS="--cfg aes_force_soft --cfg polyval_force_soft -Clink-args=\"-Wl,--no-relax\""` – cafce25 Mar 22 '23 at 13:57
  • No, it doesn't work, in this case, I got `rustc ..... '-Clink-args="-Wl,--no-relax"' `, and I still get the same error message – yaoxin jing Mar 22 '23 at 14:07

0 Answers0