Windows should distinguish between CFLAGS and CXXFLAGS
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
So far this is not a big problem: .c and .cpp files are passed to cl.exe (or clang-cl.exe), and the compiler figures our whether to compile as C or C++ according to the file extension. Always passing the same flags is also not an issue.
Enter newer C/C++ standards: recent versions of ICU require C++17, so ext/intl passes /std:c++17. cl.exe is still fine with this, but clang-cl.exe (18.1.8) complains about an unused argument when compiling .c files of ext/intl. Not a big deal. Now php-src requires C11, so I tried passing /std:c11. Besides hitting #17107, that generally works fine (get a warning in xxhash.h). However, when trying to build ext/intl, MSVC errors, reporting incompatible /std flags.
Thus I think we need at least a minimum support for CXXFLAGS. Full fledged support might be overkill, and likely raises issues with some external extensions. I'm not really sure how to support this, though. Ideas welcome!
Note that such support would be an issue for /MP enabled builds. Currently, these pass all source files added via a single ADD_SOURCES() call to the compiler in one go. Passing individual files basically circumvents /MP. If we split the sets (C files vs. C++ files), that would reduce the usefulness of /MP. Not a big deal for php-src, but might be some problem for external extensions.
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
No file or test is named. Start by tracing Windows compiler flag handling and the ADD_SOURCES() entry point; determine how C and C++ source groups are passed to cl.exe or clang-cl.exe. Done means CFLAGS and CXXFLAGS can differ without incompatible /std flags, while the documented /MP trade-off is addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100