Skip to content

Commit 263870d

Browse files
committed
Explicitely set the architecture based on $(Platform)
to be independent from the selected architecture or the PlatformToolset
1 parent 81b4c1d commit 263870d

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

PCbuild/pyproject-clangcl.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
<ItemDefinitionGroup>
4040
<ClCompile>
4141
<AdditionalOptions>-Wno-deprecated-non-prototype -Wno-unused-label -Wno-pointer-sign -Wno-incompatible-pointer-types-discards-qualifiers -Wno-unused-function %(AdditionalOptions)</AdditionalOptions>
42+
<AdditionalOptions Condition="'$(Platform)' == 'Win32'">-m32 %(AdditionalOptions)</AdditionalOptions>
43+
<AdditionalOptions Condition="'$(Platform)' == 'x64'">-m64 %(AdditionalOptions)</AdditionalOptions>
4244
<AdditionalOptions Condition="$(Configuration) != 'Debug'">-flto %(AdditionalOptions)</AdditionalOptions>
4345
<AdditionalOptions Condition="$(SupportPGO) and $(Configuration) == 'PGInstrument'">-fprofile-instr-generate=$(_CLANG_PROFILE_PATH)$(TargetName)_%m.profraw %(AdditionalOptions)</AdditionalOptions>
4446
<AdditionalOptions Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">-fprofile-instr-use=$(OutDir)instrumented\profdata.profdata -Wno-profile-instr-unprofiled %(AdditionalOptions)</AdditionalOptions>

PCbuild/readme.txt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,19 @@ You can use the IDE to switch to clang-cl for local development,
6161
but because this alters the *.vcxproj files, the recommended way is
6262
to use build.bat:
6363

64-
build.bat "/p:PlatformToolset=ClangCL" "/p:PreferredToolArchitecture=x64"
64+
build.bat "/p:PlatformToolset=ClangCL"
6565

6666
All other build.bat options continue to work as with MSVC, so this
67-
will create a 64bit release binary. PreferredToolArchitecture is needed,
68-
because msbuild by default selects the 32bit architecture of the toolset,
69-
which uses -m32 as the default target architecture.
67+
will create a 64bit release binary.
7068

7169
You can also use a specific version of clang-cl downloaded from
7270
https://github.com/llvm/llvm-project/releases, e.g.
7371
clang+llvm-18.1.8-x86_64-pc-windows-msvc.tar.xz.
7472
Given you have extracted that to <my-clang-dir>, you can use it like so
7573
build.bat --pgo "/p:PlatformToolset=ClangCL" "/p:LLVMInstallDir=<my-clang-dir> "/p:LLVMToolsVersion=18"
7674

77-
Here, PreferredToolArchitecture is not needed, because this is a 64bit
78-
platform toolset, but LLVMToolsVersion has to be set accordingly.
79-
Setting the major version is enough, although you can be specific
80-
and use 18.1.8 in the above example, too.
75+
Setting LLVMToolsVersion to the major version is enough, although you
76+
can be specific and use 18.1.8 in the above example, too.
8177

8278
Use the --pgo option to build with PGO (Profile Guided Optimization).
8379

0 commit comments

Comments
 (0)