0

I am compiling code through Rust cargo. I need to enable the llc option --nozero-initialized-in-bss to work around a bug in lld.

I tried to pass the argument through

RUSTFLAGS="-C llvm-args=--nozero-initialized-in-bss" cargo build

but it did not work, generating the following error

error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `rustc - --crate-name ___ --print=file-names -C llvm-args=--nozero-initialized-in-bss --target thumbv7em-none-eabi --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg` (exit status: 1)
  --- stderr
  rustc -Cllvm-args="..." with: Unknown command line argument '--nozero-initialized-in-bss'.  Try: 'rustc -Cllvm-args="..." with --help'
  rustc -Cllvm-args="..." with: Did you mean '--lower-interleaved-accesses'?

Is it because rustc only recognizes a subset of all llc options? Or my way of passing llc options is incorrect?

Zhiyao
  • 4,152
  • 2
  • 12
  • 21
  • `lld` is the linker so you need to pass it via `link-args`. See [How can I specify linker flags/arguments in a build script?](/q/50642574/15710392) for inspiration. Does that help? – kmdreko Jan 16 '23 at 23:23
  • @kmdreko Thanks but I didn't make a mistake here. `lld` has a bug in certain scenarios dealing with `.bss` section, so the workaround is to let `llc` not emitting variables into `.bss`. That's why I need to pass the `llc` option. – Zhiyao Jan 17 '23 at 00:59

0 Answers0