cc-rs icon indicating copy to clipboard operation
cc-rs copied to clipboard

Ordering between `flag` and `flag_if_supported` is not maintained

Open nagisa opened this issue 10 months ago • 3 comments

C and C++ compilers consider the ordering of arguments important and semantic. However, if you construct a builder like this:

cc::Build::new().flag_if_supported("-xc").flag("-xc++").flag("-std=c++11")

the constructed command line will look like this:

$CC -xc++ -std=c++11 -xc ...

which will then error (or warn...), even though the otherwise nonsensical, but valid invocation would be

$CC -xc -xc++ -std=c++11

Some valid use-cases of this ordering generally involve overriding previous arguments.

nagisa avatar Aug 13 '23 22:08 nagisa