Skip to content
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

Build with zlib on Unix #456

Merged
merged 13 commits into from
Aug 1, 2023
9 changes: 7 additions & 2 deletions eng/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion llvm.proj
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@
<_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;-DZLIB_ROOT=$(LibsRoot)' />
am11 marked this conversation as resolved.
Show resolved Hide resolved
<_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' />
Expand Down
6 changes: 5 additions & 1 deletion llvm/cmake/config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ endif()

if(LLVM_ENABLE_ZLIB)
if(LLVM_ENABLE_ZLIB STREQUAL FORCE_ON)
find_package(ZLIB REQUIRED)
if("${ZLIB_ROOT}" STREQUAL "")
find_package(ZLIB REQUIRED)
else()
include(FindZLIB)
endif()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in https://reviews.llvm.org/D70519 there was an attempt to use FindZLIB and it was noted it changes the value in llvm-config --system-libs, is that still the case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will select $ZLIB_ROOT/libz.so which is enough for our purposes. As long as RPATH is correct (which I haven't checked as full cross-build was taking ages on my machine), it will load on any system with libz. On NativeAOT, libz is a system prerequisite on build machine, so ilc will be ok.

elseif(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
find_package(ZLIB)
endif()
Expand Down