Skip to content

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

Closed
wants to merge 1 commit into from
Closed

Fix Clang configuration in the Windows build system #11313

wants to merge 1 commit into from

Conversation

dktapps
Copy link
Contributor

@dktapps dktapps commented May 24, 2023

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:

clang version 12.0.0
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\Llvm\x64\bin

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\.]+)(?: \((.*)\))?/)) {
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

@cmb69 cmb69 Aug 9, 2024

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.

@dktapps dktapps closed this by deleting the head repository Jan 3, 2024
cmb69 added a commit to cmb69/php-src that referenced this pull request Aug 10, 2024
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>
cmb69 added a commit that referenced this pull request Aug 10, 2024
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants