How can I compile rust with non-standard compile flags?
The build system by using x.py
feels very opaque. Is there a document somewhere how everything is put together and how to change the compile flags (which is what I am after)?
How can I compile rust with non-standard compile flags?
The build system by using x.py
feels very opaque. Is there a document somewhere how everything is put together and how to change the compile flags (which is what I am after)?
Perhaps the rustc guide can be helpful? https://rust-lang.github.io/rustc-guide/about-this-guide.html
Hmm… I don’t think we have anything about the internals of x.py… may be a good thing to add.
I believe rustc’s build does respect the RUSTFLAGS
environment variable.
The closest thing I find in the guide is: https://rust-lang.github.io/rustc-guide/how-to-build-and-run.html and yet there’s no mention of different compiler flags.
So, if you want to compile, say with -Oz, would you do RUSTFLAGS=-Oz python x.py build
? I assume this is the counterpart to CFLAGS
. Is there a counterpart to LDFLAGS
?
CFLAGS
, CXXFLAGS
, and LDFLAGS
might still get used by some C/C++ components, but for the linker as invoked by rustc
, I think you can stuff it in RUSTFLAGS="-Clink-arg=-foo -Clink-arg=-bar ..."
. Also remember that cc
is used as the linker for most targets, so if you want to add a direct ld
option, it would be like -Clink-arg=-Wl,option
.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.