Skip to content

Commit 0a8b3e6

Browse files
lambdageekakoeplinger
authored andcommitted
Build clang-tblgen for cross compiling; build libclang for arm64 (llvm#190)
This should make it possible to use an Apple M1 mac to work on WebAssembly. The trick is that for cross-compiling `libclang` we need a host `clang-tblgen` not just a host `llvm-tblgen`.
1 parent bfaa7ec commit 0a8b3e6

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,6 @@ autoconf/autom4te.cache
6161
/clang/utils/analyzer/projects/*/PatchedSource
6262
/clang/utils/analyzer/projects/*/ScanBuildResults
6363
/clang/utils/analyzer/projects/*/RefScanBuildResults
64+
65+
/artifacts
66+
/.packages

eng/azure-pipelines.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,23 @@ stages:
4040
rootfs:
4141
archflag: --arch x64
4242
LLVMTableGenArg:
43+
ClangTableGenArg:
4344
arm64:
4445
assetManifestOS: linux
4546
assetManifestPlatform: arm64
4647
imagename: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-arm64-cfdd435-20200121150126
4748
rootfs: /crossrootfs/arm64
4849
archflag: --arch arm64
4950
LLVMTableGenArg: /p:LLVMTableGenPath=$(Build.SourcesDirectory)/artifacts/obj/BuildRoot-x64/bin/llvm-tblgen
51+
ClangTableGenArg: /p:ClangTableGenPath=$(Build.SourcesDirectory)/artifacts/obj/BuildRoot-x64/bin/clang-tblgen
5052
arm:
5153
assetManifestOS: linux
5254
assetManifestPlatform: arm
5355
imagename: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-16.04-cross-09ec757-20200320131433
5456
rootfs: /crossrootfs/arm
5557
archflag: --arch arm
5658
LLVMTableGenArg: /p:LLVMTableGenPath=$(Build.SourcesDirectory)/artifacts/obj/BuildRoot-x64/bin/llvm-tblgen
59+
ClangTableGenArg: /p:ClangTableGenPath=$(Build.SourcesDirectory)/artifacts/obj/BuildRoot-x64/bin/clang-tblgen
5760
pool:
5861
${{ if eq(variables['System.TeamProject'], 'public') }}:
5962
vmImage: ubuntu-20.04
@@ -75,7 +78,7 @@ stages:
7578
condition: and(succeeded(), ne(variables['assetManifestPlatform'], 'x64'))
7679
7780
- bash: |
78-
./build.sh --ci --restore --build --pack $(archflag) --configuration $(_BuildConfig) $(_InternalBuildArgs) $(LLVMTableGenArg)
81+
./build.sh --ci --restore --build --pack $(archflag) --configuration $(_BuildConfig) $(_InternalBuildArgs) $(LLVMTableGenArg) $(ClangTableGenArg)
7982
displayName: 'Build and package'
8083
env:
8184
ROOTFS_DIR: $(rootfs)
@@ -96,11 +99,13 @@ stages:
9699
assetManifestPlatform: x64
97100
archflag: --arch x64
98101
LLVMTableGenArg:
102+
ClangTableGenArg:
99103
arm64:
100104
assetManifestOS: osx
101105
assetManifestPlatform: arm64
102106
archflag: --arch arm64
103107
LLVMTableGenArg: /p:LLVMTableGenPath=$(Build.SourcesDirectory)/artifacts/obj/BuildRoot-x64/bin/llvm-tblgen
108+
ClangTableGenArg: /p:ClangTableGenPath=$(Build.SourcesDirectory)/artifacts/obj/BuildRoot-x64/bin/clang-tblgen
104109
pool:
105110
vmImage: macOS-10.15
106111
steps:
@@ -116,7 +121,7 @@ stages:
116121
condition: and(succeeded(), ne(variables['assetManifestPlatform'], 'x64'))
117122
118123
- bash: |
119-
./build.sh --ci --restore --build --pack $(archflag) --configuration $(_BuildConfig) $(_InternalBuildArgs) $(LLVMTableGenArg)
124+
./build.sh --ci --restore --build --pack $(archflag) --configuration $(_BuildConfig) $(_InternalBuildArgs) $(LLVMTableGenArg) $(ClangTableGenArg)
120125
displayName: 'Build and package'
121126
122127
- bash:
@@ -135,16 +140,19 @@ stages:
135140
assetManifestPlatform: x64
136141
archflag: -arch x64
137142
LLVMTableGenArg:
143+
ClangTableGenArg:
138144
arm64:
139145
assetManifestOS: win
140146
assetManifestPlatform: arm64
141147
archflag: -arch arm64
142148
LLVMTableGenArg: /p:LLVMTableGenPath=$(Build.SourcesDirectory)\artifacts\obj\BuildRoot-x64\bin\llvm-tblgen.exe
149+
ClangTableGenArg: /p:ClangTableGenPath=$(Build.SourcesDirectory)\artifacts\obj\BuildRoot-x64\bin\clang-tblgen.exe
143150
arm:
144151
assetManifestOS: win
145152
assetManifestPlatform: arm
146153
archflag: -arch arm
147154
LLVMTableGenArg: /p:LLVMTableGenPath=$(Build.SourcesDirectory)\artifacts\obj\BuildRoot-x64\bin\llvm-tblgen.exe
155+
ClangTableGenArg: /p:ClangTableGenPath=$(Build.SourcesDirectory)\artifacts\obj\BuildRoot-x64\bin\clang-tblgen.exe
148156
pool:
149157
${{ if eq(variables['System.TeamProject'], 'public') }}:
150158
vmImage: windows-2019
@@ -161,7 +169,7 @@ stages:
161169
displayName: 'Build host llvm-tblgen for cross-compiling'
162170
condition: and(succeeded(), ne(variables['assetManifestPlatform'], 'x64'))
163171

164-
- powershell: eng\build.ps1 -ci -restore -build -pack $(archflag) -configuration $(_BuildConfig) $(_InternalBuildArgs) $(LLVMTableGenArg)
172+
- powershell: eng\build.ps1 -ci -restore -build -pack $(archflag) -configuration $(_BuildConfig) $(_InternalBuildArgs) $(LLVMTableGenArg) $(ClangTableGenArg)
165173
displayName: 'Build and package'
166174

167175
- powershell: eng\common\build.ps1 -ci -restore -publish -configuration $(_BuildConfig) $(_InternalBuildArgs) /p:AssetManifestOS=$(assetManifestOS) /p:PlatformName=$(assetManifestPlatform) -projects $(Build.SourcesDirectory)\llvm.proj

llvm.proj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
</_SetupEnvironment>
2929
<_CMakeConfigureCommand>$(_SetupEnvironment) cmake $(_LLVMSourceDir) -G "$(CMakeGenerator)" @(_LLVMBuildArgs->'%(Identity)',' ')</_CMakeConfigureCommand>
30-
<_BuildSubset Condition="'$(BuildLLVMTableGenOnly)' == 'true'">llvm-tblgen</_BuildSubset>
30+
<_BuildSubset Condition="'$(BuildLLVMTableGenOnly)' == 'true'">llvm-tblgen clang-tblgen</_BuildSubset>
3131
<_BuildCommand Condition="'$(CMakeGenerator)' == 'Unix Makefiles'">$(_SetupEnvironment) make $(_BuildSubset) -j$([System.Environment]::ProcessorCount)</_BuildCommand>
3232
<_BuildCommand Condition="'$(CMakeGenerator)' == 'Ninja'">$(_SetupEnvironment) ninja $(_BuildSubset)</_BuildCommand>
3333
<_CMakeInstallCommand>$(_SetupEnvironment) cmake -DCMAKE_INSTALL_PREFIX=$(_LLVMInstallDir) -P cmake_install.cmake</_CMakeInstallCommand>
@@ -46,6 +46,7 @@
4646
<_LLVMBuildArgs Condition="'$(TargetArchitecture)' == 'arm64' and '$(BuildOS)' == 'OSX'" Include="-DCMAKE_OSX_ARCHITECTURES=arm64"/>
4747
<_LLVMBuildArgs Condition="'$(TargetArchitecture)' == 'arm' or '$(TargetArchitecture)' == 'arm64'" Include="-DCMAKE_CROSSCOMPILING:BOOL=ON" />
4848
<_LLVMBuildArgs Condition="'$(LLVMTableGenPath)' != ''" Include='-DLLVM_TABLEGEN="$(LLVMTableGenPath)"' />
49+
<_LLVMBuildArgs Condition="'$(ClangTableGenPath)' != ''" Include='-DCLANG_TABLEGEN="$(ClangTableGenPath)"' />
4950
<_LLVMBuildArgs Include="-DCMAKE_BUILD_TYPE=Release" />
5051
<_LLVMBuildArgs Include="-DLLVM_BUILD_LLVM_C_DYLIB:BOOL=OFF" />
5152
<_LLVMBuildArgs Include="-DLLVM_ENABLE_DIA_SDK:BOOL=OFF" />
@@ -64,7 +65,7 @@
6465
<ItemGroup>
6566
<_LLVMBuildArgs Condition="'$(BuildOS)' == 'Linux'" Include='-DCMAKE_SHARED_LINKER_FLAGS=-Wl,--build-id' />
6667
</ItemGroup>
67-
<ItemGroup Condition="'$(TargetArchitecture)' != 'arm' and '$(TargetArchitecture)' != 'arm64'">
68+
<ItemGroup Condition="'$(BuildOS)' == 'OSX' or ('$(TargetArchitecture)' != 'arm' and '$(TargetArchitecture)' != 'arm64')">
6869
<_LLVMBuildArgs Include='-DLLVM_ENABLE_PROJECTS=clang' />
6970
<_LLVMBuildArgs Include='-DCLANG_BUILD_TOOLS:BOOL=OFF' />
7071
<_LLVMBuildArgs Include='-DCLANG_INCLUDE_TESTS:BOOL=OFF' />

0 commit comments

Comments
 (0)