rust-lang / rust-lang/cc-rs

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

Open
#855 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
2.2k
Forks
617
Avg merge
22h 32m
Merged PRs (30d)
41

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the cc::Build flag_if_supported and flag entry points and trace how their arguments are collected into the compiler command line. Confirm that calls preserve their relative ordering, including the example with -xc, -xc++, and -std=c++11; done means the generated invocation matches call order.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.