No-strict-aliasing used in rust

i do link c++ library in my rust program. and the c++ library should use no-strict aliasing flag.

i try to add rustflags = ["-C", "target-cpu=native", "-C", "no-strict-aliasing"] in Cargo.toml
and got error: unknown codegen option: no-strict-aliasing`.

and i find "-Z mutable-noalias=yes" here.

Are they equivalent ?

[somewheve@localhost hft]$ rustc --version
rustc 1.70.0-nightly (ec2f40c6b 2023-03-30)

Strict aliasing is a C++ specific rule about aliasing between different pointer types. -Z mutable-noalias is a Rust specific flag about emitting LLVM noalias attribute on &mut. They are not relevant. As long as you compile your C++ code with -fno-strict-aliasing then it's fine.

1 Like

(And the current Rust stakeholders are rather adamant about not adding an equivalent to Rust itself.)

#[cfg(all(feature = "fifo"))]
fn fifo_build_link(c: &PathBuf) {
    let function_path = c.join("fifo.cpp");
``` it should work like this?
1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.