codyps
This is a re-post/elaboration of a [comment I made on reddit](https://www.reddit.com/r/rust/comments/jzf5a5/inlinec_a_small_crate_that_allows_a_user_to_write/ge2nqi1/) Looking at the use of `CFLAGS`, etc, env variables, it would be a good idea to mirror the pattern used in the `cc` crate. From the `cc` readme: > Each of these variables can also be supplied with certain prefixes and suffixes, in the following prioritized order: > >1. `<var>_<target>` - for example, `CC_x86_64-unknown-linux-gnu` >2. `<var>_<target_with_underscores>` - for example, `CC_x86_64_unknown_linux_gnu` >3. `<build-kind>_<var>` - for example, `HOST_CC` or `TARGET_CFLAGS` >4. `<var>` - a plain `CC`, `AR` as above. We used this specific mechanism (of resolving most specific to least specific without combining/appending) to best support the cross compilation of C code. The relevant code in inline-c appears here: https://github.com/Hywan/inline-c-rs/blob/7bd0f5e59f3e00534e0aeef1aeef6efe48804659/src/run.rs#L149-L162 Given the desire to integrate `CFLAGS`/etc that are provided by the program rather than the environment, I'm not sure exactly what should be done here. The `CFLAGS`/etc from the environment are usually supplied in order for compilation to be functional. Given this, it seems unwise to have program supplied values replace those from the environment. Appending the program supplied values to the environment supplied values might be the best choice. Additionally, it would be good to examine the splitting methodology used for these variables. In some cases, `CFLAGS`/etc may contain spaces. This is more common on windows when one might need to provide a path to some directory within the `LDFLAGS` or `CFLAGS` (or for plain `CC`). On a related note: the handling of `LDFLAGS` using `-Wl` probably isn't compatible with how other users interpret `LDFLAGS` (which are normally passed to the link step without extra munging).