diff options
author | Aleksey Kliger (λgeek) <akliger@gmail.com> | 2022-04-13 11:27:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-13 11:27:24 +0300 |
commit | d1be5205007e2546abeb7723799e51298880bf90 (patch) | |
tree | dccfae2239710a7b0e55c2f357041f8b3b2576b7 | |
parent | df76ff3b43b0a99f4d995de90c8dcab7b72ac2ee (diff) |
Build clang-tblgen for cross compiling; build libclang for arm64 (#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`.
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | azure-pipelines.yml | 14 | ||||
-rw-r--r-- | llvm.proj | 5 |
3 files changed, 17 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore index 1c8d4b15925d..603c1c1c942f 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,6 @@ autoconf/autom4te.cache /clang/utils/analyzer/projects/*/PatchedSource /clang/utils/analyzer/projects/*/ScanBuildResults /clang/utils/analyzer/projects/*/RefScanBuildResults + +/artifacts +/.packages diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f8228a2e09d2..79dcd549e514 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -38,6 +38,7 @@ stages: rootfs: archflag: --arch x64 LLVMTableGenArg: + ClangTableGenArg: arm64: assetManifestOS: linux assetManifestPlatform: arm64 @@ -45,6 +46,7 @@ stages: rootfs: /crossrootfs/arm64 archflag: --arch arm64 LLVMTableGenArg: /p:LLVMTableGenPath=$(Build.SourcesDirectory)/artifacts/obj/BuildRoot-x64/bin/llvm-tblgen + ClangTableGenArg: /p:ClangTableGenPath=$(Build.SourcesDirectory)/artifacts/obj/BuildRoot-x64/bin/clang-tblgen arm: assetManifestOS: linux assetManifestPlatform: arm @@ -52,6 +54,7 @@ stages: rootfs: /crossrootfs/arm archflag: --arch arm LLVMTableGenArg: /p:LLVMTableGenPath=$(Build.SourcesDirectory)/artifacts/obj/BuildRoot-x64/bin/llvm-tblgen + ClangTableGenArg: /p:ClangTableGenPath=$(Build.SourcesDirectory)/artifacts/obj/BuildRoot-x64/bin/clang-tblgen pool: ${{ if eq(variables['System.TeamProject'], 'public') }}: vmImage: ubuntu-20.04 @@ -73,7 +76,7 @@ stages: condition: and(succeeded(), ne(variables['assetManifestPlatform'], 'x64')) - bash: | - ./build.sh --ci --restore --build --pack $(archflag) --configuration $(_BuildConfig) $(_InternalBuildArgs) $(LLVMTableGenArg) + ./build.sh --ci --restore --build --pack $(archflag) --configuration $(_BuildConfig) $(_InternalBuildArgs) $(LLVMTableGenArg) $(ClangTableGenArg) displayName: 'Build and package' env: ROOTFS_DIR: $(rootfs) @@ -94,11 +97,13 @@ stages: assetManifestPlatform: x64 archflag: --arch x64 LLVMTableGenArg: + ClangTableGenArg: arm64: assetManifestOS: osx assetManifestPlatform: arm64 archflag: --arch arm64 LLVMTableGenArg: /p:LLVMTableGenPath=$(Build.SourcesDirectory)/artifacts/obj/BuildRoot-x64/bin/llvm-tblgen + ClangTableGenArg: /p:ClangTableGenPath=$(Build.SourcesDirectory)/artifacts/obj/BuildRoot-x64/bin/clang-tblgen pool: vmImage: macOS-10.15 steps: @@ -114,7 +119,7 @@ stages: condition: and(succeeded(), ne(variables['assetManifestPlatform'], 'x64')) - bash: | - ./build.sh --ci --restore --build --pack $(archflag) --configuration $(_BuildConfig) $(_InternalBuildArgs) $(LLVMTableGenArg) + ./build.sh --ci --restore --build --pack $(archflag) --configuration $(_BuildConfig) $(_InternalBuildArgs) $(LLVMTableGenArg) $(ClangTableGenArg) displayName: 'Build and package' - bash: @@ -133,16 +138,19 @@ stages: assetManifestPlatform: x64 archflag: -arch x64 LLVMTableGenArg: + ClangTableGenArg: arm64: assetManifestOS: win assetManifestPlatform: arm64 archflag: -arch arm64 LLVMTableGenArg: /p:LLVMTableGenPath=$(Build.SourcesDirectory)\artifacts\obj\BuildRoot-x64\bin\llvm-tblgen.exe + ClangTableGenArg: /p:ClangTableGenPath=$(Build.SourcesDirectory)\artifacts\obj\BuildRoot-x64\bin\clang-tblgen.exe arm: assetManifestOS: win assetManifestPlatform: arm archflag: -arch arm LLVMTableGenArg: /p:LLVMTableGenPath=$(Build.SourcesDirectory)\artifacts\obj\BuildRoot-x64\bin\llvm-tblgen.exe + ClangTableGenArg: /p:ClangTableGenPath=$(Build.SourcesDirectory)\artifacts\obj\BuildRoot-x64\bin\clang-tblgen.exe pool: ${{ if eq(variables['System.TeamProject'], 'public') }}: vmImage: windows-2019 @@ -159,7 +167,7 @@ stages: displayName: 'Build host llvm-tblgen for cross-compiling' condition: and(succeeded(), ne(variables['assetManifestPlatform'], 'x64')) - - powershell: eng\build.ps1 -ci -restore -build -pack $(archflag) -configuration $(_BuildConfig) $(_InternalBuildArgs) $(LLVMTableGenArg) + - powershell: eng\build.ps1 -ci -restore -build -pack $(archflag) -configuration $(_BuildConfig) $(_InternalBuildArgs) $(LLVMTableGenArg) $(ClangTableGenArg) displayName: 'Build and package' - powershell: eng\common\build.ps1 -ci -restore -publish -configuration $(_BuildConfig) $(_InternalBuildArgs) /p:AssetManifestOS=$(assetManifestOS) /p:PlatformName=$(assetManifestPlatform) -projects $(Build.SourcesDirectory)\llvm.proj diff --git a/llvm.proj b/llvm.proj index 47cf4dedffa9..0be19a1d217b 100644 --- a/llvm.proj +++ b/llvm.proj @@ -27,7 +27,7 @@ </_SetupEnvironment> <_CMakeConfigureCommand>$(_SetupEnvironment) cmake $(_LLVMSourceDir) -G "$(CMakeGenerator)" @(_LLVMBuildArgs->'%(Identity)',' ')</_CMakeConfigureCommand> - <_BuildSubset Condition="'$(BuildLLVMTableGenOnly)' == 'true'">llvm-tblgen</_BuildSubset> + <_BuildSubset Condition="'$(BuildLLVMTableGenOnly)' == 'true'">llvm-tblgen clang-tblgen</_BuildSubset> <_BuildCommand Condition="'$(CMakeGenerator)' == 'Unix Makefiles'">$(_SetupEnvironment) make $(_BuildSubset) -j$([System.Environment]::ProcessorCount)</_BuildCommand> <_BuildCommand Condition="'$(CMakeGenerator)' == 'Ninja'">$(_SetupEnvironment) ninja $(_BuildSubset)</_BuildCommand> <_CMakeInstallCommand>$(_SetupEnvironment) cmake -DCMAKE_INSTALL_DO_STRIP=1 -DCMAKE_INSTALL_PREFIX=$(_LLVMInstallDir) -P cmake_install.cmake</_CMakeInstallCommand> @@ -50,6 +50,7 @@ <_LLVMBuildArgs Condition="'$(TargetArchitecture)' == 'arm64' and '$(BuildOS)' == 'OSX'" Include="-DCMAKE_OSX_ARCHITECTURES=arm64"/> <_LLVMBuildArgs Condition="'$(TargetArchitecture)' == 'arm' or '$(TargetArchitecture)' == 'arm64'" Include="-DCMAKE_CROSSCOMPILING:BOOL=ON" /> <_LLVMBuildArgs Condition="'$(LLVMTableGenPath)' != ''" Include='-DLLVM_TABLEGEN="$(LLVMTableGenPath)"' /> + <_LLVMBuildArgs Condition="'$(ClangTableGenPath)' != ''" Include='-DCLANG_TABLEGEN="$(ClangTableGenPath)"' /> <_LLVMBuildArgs Include="-DCMAKE_BUILD_TYPE=$(Configuration)" /> <_LLVMBuildArgs Include="-DLLVM_BUILD_LLVM_C_DYLIB:BOOL=OFF" /> <_LLVMBuildArgs Include="-DLLVM_ENABLE_DIA_SDK:BOOL=OFF" /> @@ -70,7 +71,7 @@ <_LLVMBuildArgs Condition="'$(BuildOS)' == 'Windows_NT'" Include='-DLLVM_USE_CRT_RELEASE=MT' /> </ItemGroup> - <ItemGroup Condition="'$(TargetArchitecture)' != 'arm' and '$(TargetArchitecture)' != 'arm64'"> + <ItemGroup Condition="'$(BuildOS)' == 'OSX' or ('$(TargetArchitecture)' != 'arm' and '$(TargetArchitecture)' != 'arm64')"> <_LLVMBuildArgs Include='-DLLVM_ENABLE_PROJECTS=clang' /> <_LLVMBuildArgs Include='-DCLANG_BUILD_TOOLS:BOOL=OFF' /> <_LLVMBuildArgs Include='-DCLANG_INCLUDE_TESTS:BOOL=OFF' /> |