Debug vs release
From reading through the code so far I am unsure if there is a way to turn on debug on which requires the -g option for gccrs. Also not sure how to turn on optimizations -O0, -O1, -O2, -O3 etc.
If there is a debug / release thing I would suggest debug should be -g -O0 and for release -g -O2 for now if you need default options.
A question, is there options in cargo to pass extra flags to rustc outside of cargo using an environment variable? Just wondering if we need a mechanism to be able to override these defaults with an environment variable.
If there is a debug / release thing I would suggest debug should be -g -O0 and for release -g -O2 for now if you need default options.
Cargo will pass -Cdebuginfo=0/1/2 and -Copt-level=0/1/2/3/s/z to rustc/cargo-gccrs according to the used cargo profile. I believe -Copt-level=3 is the default for the release profile, though the CARGO_PROFILE_RELEASE_OPT_LEVEL env var can be used to override it without changing Cargo.toml.
Side note are their options in cargo to pass extra flags to rustc outside of cargo using an environment variable?
That is the RUSTFLAGS env var.
This ties a bit into #20
I think it's important that we handle stuff such as RUSTFLAGS so that users can ideally use cargo build and cargo gccrs build without setting any extra environment variables or having to modify their Cargo.toml.
However, we should also handle some specific gcc options with variables such as GCCRSFLAGS or something, in case the users do want some specific behavior when using cargo gccrs ...
RUSTFLAGS is handled by cargo automatically. Rustc doesn't know about RUSTFLAGS either.
However, we should also handle some specific gcc options with variables such as GCCRSFLAGS or something, in case the users do want some specific behavior when using
cargo gccrs ...
Makes sense. It could also be using -Cllvm-args. (Yes I know, it is a bad name. I use it in cg_clif too. cc https://github.com/rust-lang/compiler-team/issues/421)