From 8604946a9fb2528b7e5cf58981008c8b0882903b Mon Sep 17 00:00:00 2001 From: Adeel Mujahid <3840695+am11@users.noreply.github.com> Date: Tue, 1 Aug 2023 17:22:48 +0300 Subject: [PATCH] Build with zlib on Unix (#456) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Köplinger --- eng/azure-pipelines-codeql.yml | 3 ++- eng/azure-pipelines.yml | 9 +++++++-- llvm.proj | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/eng/azure-pipelines-codeql.yml b/eng/azure-pipelines-codeql.yml index a43d4be6d7f2fb..f5a6d1ca0fb6cd 100644 --- a/eng/azure-pipelines-codeql.yml +++ b/eng/azure-pipelines-codeql.yml @@ -42,6 +42,7 @@ stages: assetManifestPlatform: x64 imagename: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-amd64 rootfs: /crossrootfs/x64 + ExtraArgs: -p:LibsRoot=/crossrootfs/x64/usr/lib/x86_64-linux-gnu ClangTargetArg: /p:ClangTarget=x86_64-linux-gnu ClangBinDirArg: /p:ClangBinDir=/usr/local/bin archflag: --arch x64 @@ -65,7 +66,7 @@ stages: displayName: Initialize CodeQL (manually-injected) - bash: | - ./build.sh --ci --restore --build --pack $(archflag) --configuration $(_BuildConfig) $(_InternalBuildArgs) $(ClangBinDirArg) $(ClangTargetArg) + ./build.sh --ci --restore --build --pack $(archflag) --configuration $(_BuildConfig) $(_InternalBuildArgs) $(ClangBinDirArg) $(ClangTargetArg) $(ExtraArgs) displayName: 'Build and package' env: ROOTFS_DIR: $(rootfs) diff --git a/eng/azure-pipelines.yml b/eng/azure-pipelines.yml index 1d9971238d48eb..8ba7ccc1e5f49c 100644 --- a/eng/azure-pipelines.yml +++ b/eng/azure-pipelines.yml @@ -42,6 +42,7 @@ stages: assetManifestPlatform: x64 imagename: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-amd64 rootfs: /crossrootfs/x64 + ExtraArgs: -p:LibsRoot=/crossrootfs/x64/usr/lib/x86_64-linux-gnu ClangTargetArg: /p:ClangTarget=x86_64-linux-gnu ClangBinDirArg: /p:ClangBinDir=/usr/local/bin archflag: --arch x64 @@ -50,6 +51,7 @@ stages: assetManifestPlatform: arm64 imagename: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-arm64 rootfs: /crossrootfs/arm64 + ExtraArgs: -p:LibsRoot=/crossrootfs/arm64/usr/lib/aarch64-linux-gnu ClangTargetArg: /p:ClangTarget=aarch64-linux-gnu ClangBinDirArg: /p:ClangBinDir=/usr/local/bin archflag: --arch arm64 @@ -58,6 +60,7 @@ stages: assetManifestPlatform: arm imagename: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-arm rootfs: /crossrootfs/arm + ExtraArgs: -p:LibsRoot=/crossrootfs/arm/usr/lib/arm-linux-gnueabihf ClangTargetArg: /p:ClangTarget=arm-linux-gnueabihf ClangBinDirArg: /p:ClangBinDir=/usr/local/bin archflag: --arch arm @@ -78,7 +81,7 @@ stages: displayName: 'Clean up working directory' - bash: | - ./build.sh --ci --restore --build --pack $(archflag) --configuration $(_BuildConfig) $(_InternalBuildArgs) $(ClangBinDirArg) $(ClangTargetArg) + ./build.sh --ci --restore --build --pack $(archflag) --configuration $(_BuildConfig) $(_InternalBuildArgs) $(ClangBinDirArg) $(ClangTargetArg) $(ExtraArgs) displayName: 'Build and package' env: ROOTFS_DIR: $(rootfs) @@ -101,6 +104,7 @@ stages: assetManifestPlatform: x64 imagename: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-amd64-alpine rootfs: /crossrootfs/x64 + ExtraArgs: -p:LibsRoot=/crossrootfs/x64/lib ClangTargetArg: /p:ClangTarget=x86_64-alpine-linux-musl ClangBinDirArg: /p:ClangBinDir=/usr/local/bin archflag: --arch x64 @@ -109,6 +113,7 @@ stages: assetManifestPlatform: arm64 imagename: mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-arm64-alpine rootfs: /crossrootfs/arm64 + ExtraArgs: -p:LibsRoot=/crossrootfs/arm64/lib ClangTargetArg: /p:ClangTarget=aarch64-alpine-linux-musl ClangBinDirArg: /p:ClangBinDir=/usr/local/bin archflag: --arch arm64 @@ -129,7 +134,7 @@ stages: displayName: 'Clean up working directory' - bash: | - ./build.sh --ci --restore --build --pack $(archflag) --configuration $(_BuildConfig) $(_InternalBuildArgs) /p:OutputRid=linux-musl-$(assetManifestPlatform) $(ClangBinDirArg) $(ClangTargetArg) + ./build.sh --ci --restore --build --pack $(archflag) --configuration $(_BuildConfig) $(_InternalBuildArgs) /p:OutputRid=linux-musl-$(assetManifestPlatform) $(ClangBinDirArg) $(ClangTargetArg) $(ExtraArgs) displayName: 'Build and package' env: ROOTFS_DIR: $(rootfs) diff --git a/llvm.proj b/llvm.proj index 4f7e2c011a7ae0..3fb400081b8c0f 100644 --- a/llvm.proj +++ b/llvm.proj @@ -89,8 +89,10 @@ <_LLVMBuildArgs Condition="'$(BuildOS)' == 'Windows_NT' and '$(Configuration)' == 'Release'" Include='-DLLVM_USE_CRT_RELEASE=MT' /> <_LLVMBuildArgs Condition="'$(BuildOS)' == 'Windows_NT' and '$(Configuration)' == 'Debug'" Include='-DLLVM_USE_CRT_DEBUG=MTd' /> <_LLVMBuildArgs Condition="'$(BuildOS)' == 'Windows_NT' and '$(Configuration)' == 'Debug'" Include='-DLLVM_USE_CRT_RELEASE=MTd' /> - <_LLVMBuildArgs Condition="'$(BuildOS)' == 'Windows_NT'" Include='-DLLVM_ENABLE_ZLIB=OFF' /> <_LLVMBuildArgs Condition="'$(BuildOS)' == 'Windows_NT'" Include='-DLLVM_NATIVE_TOOL_DIR=$(NativeTablegenDir)' /> + <_LLVMBuildArgs Condition="'$(BuildOS)' != 'Windows_NT'" Include='-DLLVM_ENABLE_ZLIB=FORCE_ON' /> + <_LLVMBuildArgs Condition="'$(BuildOS)' != 'Windows_NT' and '$(LibsRoot)' != ''" Include='-DZLIB_ROOT=$(LibsRoot)' /> + <_LLVMBuildArgs Condition="'$(BuildOS)' == 'Windows_NT'" Include='-DLLVM_ENABLE_ZLIB=OFF' /> <_LLVMBuildArgs Include='-DLLVM_ENABLE_PROJECTS="lld%3Bclang%3Bclang-tools-extra"' /> <_LLVMBuildArgs Include='-DLLVM_BUILD_TOOLS:BOOL=ON' /> <_LLVMBuildArgs Include='-DLLVM_INSTALL_UTILS:BOOL=ON' />