[cmake] Some command line arguments not persisting to stage0 step
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Prerequisites
- Put an X between the brackets on this line if you have done all of the following:
- Check that your issue is not already filed.
- Reduce the issue to a minimal, self-contained, reproducible test case. Avoid dependencies to mathlib4 or std4.
Description
Some variables passed to cmake (such as CMAKE_C_COMPILER) at configuration step do not persist when the project is built.
Context
The first thing the CMakeLists.txt file does is iterate through all cached cmake variables and set some special variables that are passed on to step0. But when the project is created with the project command, some of these variables are set to default values.
Additionally, custom toolchain files are invalidated because they are not read until the project is created.
Steps to Reproduce
In a system with both clang and gcc installed, with gcc as the default compiler:
cmake -B build -DCMAKE_C_COMPILER=clang==> The C compiler identification is Clang 17.0.4make -C build==> -- The C compiler identification is GNU 13.2.0
--
I noticed other cmake-related issues could be directly related to this.
Would a PR to attempt to fix this be acceptable?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with cmake -B build -DCMAKE_C_COMPILER=clang followed by make -C build, then inspect the variable iteration and project handling in CMakeLists.txt. Done means the selected compiler and custom toolchain settings persist into the stage0 build, with the reported reproduction behaving consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100