Fix Clang configuration in the Windows build system#11313
Fix Clang configuration in the Windows build system#11313dktapps wants to merge 1 commit intophp:PHP-8.1from dktapps:windows-clang
Conversation
I had various other issues and haven't had a successful compilation yet, but this at least allows attempting to use clang 12 with VS 2019 to build PHP.
| var full = execute(command + '" 2>&1"'); | ||
|
|
||
| if (full.match(/clang version ([\d\.]+) \((.*)\)/)) { | ||
| if (full.match(/clang version ([\d\.]+)(?: \((.*)\))?/)) { |
There was a problem hiding this comment.
Do we need this group at all? We're not actually using it.
There was a problem hiding this comment.
No, probably not. I don't know what this was capturing, it doesn't match anything in modern versions of clang-cl.
There was a problem hiding this comment.
clang 9.0.0 says:
clang version 9.0.0 (tags/RELEASE_900/final)`
So the \((.*)\) was likely meant to catch the info in parens, although it is indeed not used, and as such could be completely removed. And actually, even the version is not used (well, it could be used in config.w32, but likely almost anybody assumes that these are for VS).
For what it's worth, I've just managed to do a successful minimal build (--with-toolset=clang --disable-all --enable-cli) of PHP-8.0 with clang 9.0.0, but PHP-8.1 failed; I'll check what a recent version of clang produces.
Prior to clang 10.0.0, `clang-cl -v` apparently always appended some fine grained version information in parentheses[1]; this is no longer the case, so the build fails early because the compiler version could not be detected. Since we never used this fine grained version info, we no longer check for it. As of clang 13.0.0, the `/fallback` command option has been removed[2], so we only set the flag for older clang versions. [1] <php#11313 (comment)> [2] <https://releases.llvm.org/13.0.0/tools/clang/docs/ReleaseNotes.html#removed-compiler-flags>
Prior to clang 10.0.0, `clang-cl -v` apparently always appended some fine grained version information in parentheses[1]; this is no longer the case, so the build fails early because the compiler version could not be detected. Since we never used this fine grained version info, we no longer check for it. As of clang 13.0.0, the `/fallback` command option has been removed[2], so we only set the flag for older clang versions. [1] <#11313 (comment)> [2] <https://releases.llvm.org/13.0.0/tools/clang/docs/ReleaseNotes.html#removed-compiler-flags>
I had various other issues and haven't had a successful compilation yet, but this at least allows attempting to use clang 12 with VS 2019 to build PHP.
lld-link must be used alongside clang-cl since clang-cl mangles symbols differently to cl.
The output of
clang-cl -vnow looks like this: