-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix Clang configuration in the Windows build system #11313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
@@ -3067,7 +3067,7 @@ function toolset_get_compiler_version() | |||
var command = 'cmd /c ""' + PHP_CL + '" -v"'; | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this group at all? We're not actually using it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 -v
now looks like this: