Closed daniestevez closed 1 year ago
The config value may be an array of string or a space-separated string. IIRC both
rustflags = ["-C", "target-feature=+avx2"]
and rustflags = "-C target-feature=+avx2"
should work. Could you give them an attempt?
Thanks! Both of those work correctly. Closing as solved.
Problem
I have noticed that setting a rustc codegen option such as
-C target-feature=+avx2
in.cargo/config.toml
wont' work. It appears that the flag is passed in quotes to rustc, which complains about this and terminates.Steps
To reproduce:
cargo new mycrate && cd mycrate
.cargo/config.toml
with the following contents:cargo build
. This will give the following:Caused by: process didn't exit successfully:
rustc - --crate-name ___ --print=file-names '-C target-feature=+avx2' --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg
(exit status: 1) --- stderr error: unknown codegen option:target-feature
lib.rlib lib.so lib.so lib.a lib___.so /home/daniel/.rustup/toolchains/stable-x86_64-unknown-linux-gnu off packed unpacked
debug_assertions panic="unwind" proc_macro target_arch="x86_64" target_endian="little" target_env="gnu" target_family="unix" target_feature="avx" target_feature="avx2" target_feature="fxsr" target_feature="sse" target_feature="sse2" target_feature="sse3" target_feature="sse4.1" target_feature="ssse3" target_has_atomic="16" target_has_atomic="32" target_has_atomic="64" target_has_atomic="8" target_has_atomic="ptr" target_os="linux" target_pointer_width="64" target_vendor="unknown" unix
$ RUSTFLAGS="-C target-feature=+avx2" cargo build --verbose Dirty mycrate v0.1.0 (/tmp/mycrate): the rustflags changed Compiling mycrate v0.1.0 (/tmp/mycrate) Running
rustc --crate-name mycrate --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=158 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=b81e7d9b4e90224b -C extra-filename=-b81e7d9b4e90224b --out-dir /tmp/mycrate/target/debug/deps -C incremental=/tmp/mycrate/target/debug/incremental -L dependency=/tmp/mycrate/target/debug/deps -C target-feature=+avx2
Finished dev [unoptimized + debuginfo] target(s) in 0.11s