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

Update coredistools #370

Merged
merged 41 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
679a472
Update coredistools from LLVM 13.0.1 to 16.0.1
BruceForstall Apr 18, 2023
0cff1f3
Update documentation
BruceForstall Apr 19, 2023
8e59b24
Fix macOS build
BruceForstall Apr 20, 2023
6d78ba6
Minor build fixes for CBL-Mariner
BruceForstall Apr 20, 2023
563c7db
TEST: display paths; debug Mac path issue
BruceForstall Apr 20, 2023
d315458
More diagnostic output
BruceForstall Apr 20, 2023
d0959db
Try again
BruceForstall Apr 20, 2023
2efca46
Try again
BruceForstall Apr 20, 2023
fea8d48
Make llvm-tblgen executable
BruceForstall Apr 20, 2023
5a00612
Build llvm-tblgen from source for Linux
BruceForstall Apr 21, 2023
e092482
Support building tblgen for Linux-x64
BruceForstall Apr 21, 2023
6447421
Support non-CBL-Mariner builds
BruceForstall Apr 21, 2023
7846935
Fix Linux arm/arm64 container names to match CBL-Mariner names
BruceForstall Apr 21, 2023
188d60b
Use clang-9 on cross-build containers
BruceForstall Apr 21, 2023
f1e128c
For non-Mariner, use ubuntu-18.04 build pool
BruceForstall Apr 21, 2023
652a7aa
AzDO pipelines no longer have ubuntu-18.04. Try ubuntu-20.04
BruceForstall Apr 21, 2023
e839237
Build using CBL-Mariner and LLVM 16.0.3
BruceForstall May 11, 2023
36f400c
Try llvmorg-16.0.6
BruceForstall Sep 7, 2023
b685fdd
Update CBL-Mariner docker containers to use
BruceForstall Sep 7, 2023
bfc9ca8
More build fixes
BruceForstall Sep 8, 2023
7ed048a
Install runtime dependency of llvm-tblgen
BruceForstall Sep 8, 2023
0a06a1c
Try using sudo
BruceForstall Sep 8, 2023
0347ce6
Update cmake linker flags again
BruceForstall Sep 8, 2023
13f613f
Explicitly specify 60 minute timeout for building coredistools job
BruceForstall Sep 8, 2023
4dfebad
Bump coredistools version from 1.1.0 to 1.2.0
BruceForstall Sep 8, 2023
e915089
Update from llvmorg-16.0.6 to llvmorg-17.0.6
BruceForstall Dec 21, 2023
78556fc
Fix build
BruceForstall Dec 21, 2023
1d3432a
Fix build warning
BruceForstall Dec 21, 2023
13316c5
More fixes
BruceForstall Dec 21, 2023
3f0865a
Fix task display name for "matrix" Linux build
BruceForstall Dec 22, 2023
e67a98e
Add task to install nuget.exe
BruceForstall Dec 22, 2023
72f4188
Bump up timeout
BruceForstall Dec 22, 2023
e093dc1
Temporary (?): use cmake verbose switch to build
BruceForstall Dec 22, 2023
46f7d89
Remove -v build flag. Reduce timeout to 60 minutes.
BruceForstall Dec 22, 2023
0475ccd
Various updates
BruceForstall Dec 23, 2023
15485b0
Change to version 1.3.0
BruceForstall Dec 23, 2023
a546297
Update version
BruceForstall Dec 29, 2023
d9b0b34
Bump version to 1.4.0
BruceForstall Jan 3, 2024
3d37674
Restore x86 special prefix handling
BruceForstall Jan 3, 2024
e43879c
Remove clang warning disable from header file
BruceForstall Jan 3, 2024
b8c1031
Fix clang build warning
BruceForstall Jan 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 37 additions & 4 deletions build-coredistools.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ if /i "%TargetOSArchitecture%" == "win-arm64" (
set LLVMTargetsToBuild=ARM;X86
) else (
echo ERROR: Unknown target OS and architecture: %TargetOSArchitecture%
echo Use one of win-arm64, win-x64, win-x86.
exit /b 1
)

set BuildFlavor=%2
if "%BuildFlavor%"=="" set BuildFlavor=Release

if /i "%BuildFlavor%" == "Release" (
@REM ok
) else if /i "%BuildFlavor%" == "Debug" (
@REM ok
) else (
echo ERROR: Unknown build flavor: %BuildFlavor%
exit /b 1
)

Expand All @@ -37,11 +50,19 @@ if %ERRORLEVEL% neq 0 (

where /q llvm-tblgen.exe

if %ERRORLEVEL% neq 0 (
if %ERRORLEVEL% equ 0 goto found_llvm_tblgen

@REM We expect it to be in the `bin` directory, so add that to the PATH if it's there.
if not exist %RootDirectory%bin\llvm-tblgen.exe (
echo ERROR: llvm-tblgen.exe is not found in the PATH
exit /b 1
)

echo Found llvm-tblgen.exe in %RootDirectory%bin; adding that directory to PATH.
set PATH=%RootDirectory%bin;%PATH%

:found_llvm_tblgen

for /f %%I in ('where llvm-tblgen.exe') do (
set LLVMTableGen=%%~I
)
Expand All @@ -51,11 +72,22 @@ if not exist "%BinariesDirectory%" (
)

pushd "%BinariesDirectory%"

@REM To use the Debug CRT, use:
@REM -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug
@REM
@REM To build a Debug version (asserts, debug info):
@REM -DCMAKE_BUILD_TYPE=Debug
@REM To build a Release version (no asserts, no debug info):
@REM -DCMAKE_BUILD_TYPE=Release
@REM
@REM Misc. LLVM CMake documentation: https://llvm.org/docs/CMake.html

cmake.exe ^
-G "Visual Studio 17 2022" ^
-A %GeneratorPlatform% ^
-DCMAKE_INSTALL_PREFIX="%StagingDirectory%" ^
-DCMAKE_BUILD_TYPE=%BuildFlavor% ^
-DLLVM_DEFAULT_TARGET_TRIPLE=%LLVMDefaultTargetTriple% ^
-DLLVM_EXTERNAL_PROJECTS=coredistools ^
-DLLVM_EXTERNAL_COREDISTOOLS_SOURCE_DIR="%SourcesDirectory%\coredistools" ^
Expand All @@ -64,18 +96,19 @@ cmake.exe ^
-DLLVM_TABLEGEN="%LLVMTableGen%" ^
-DLLVM_TARGETS_TO_BUILD=%LLVMTargetsToBuild% ^
-DLLVM_TOOL_COREDISTOOLS_BUILD=ON ^
-DLLVM_USE_CRT_DEBUG=MTd ^
-DLLVM_USE_CRT_RELEASE=MT ^
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ^
"%SourcesDirectory%\llvm-project\llvm"

popd

if %ERRORLEVEL% neq 0 goto :CMakeNonZeroExitStatus

@REM Use `--config Release` for release build, `--config Debug` for debug build

cmake.exe ^
--build "%BinariesDirectory%" ^
--target coredistools ^
--config Release
--config %BuildFlavor%

if %ERRORLEVEL% neq 0 goto :CMakeNonZeroExitStatus

Expand Down
99 changes: 84 additions & 15 deletions build-coredistools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
TargetOSArchitecture=$1
CrossRootfsDirectory=$2

# Set this to 1 to build using CBL-Mariner
CrossBuildUsingMariner=1

EnsureCrossRootfsDirectoryExists () {
if [ ! -d "$CrossRootfsDirectory" ]; then
echo "Invalid or unspecified CrossRootfsDirectory: $CrossRootfsDirectory"
Expand All @@ -13,12 +16,44 @@ EnsureCrossRootfsDirectoryExists () {
CMakeOSXArchitectures=
LLVMTargetsToBuild="AArch64;ARM;X86"

# Figure out which `strip` to use. Prefer `llvm-strip` if it is available.
# `llvm-strip` is available in CBL-Mariner container; `strip` is available on macOS.
StripTool=$(command -v llvm-strip)
if [ -z "$StripTool" ]; then
StripTool=$(command -v strip)
if [ -z "$StripTool" ]; then
echo "Strip tool not found"
exit 1
fi
fi

TblGenTool=$(command -v llvm-tblgen)
if [ -z "$TblGenTool" ]; then
echo "llvm-tblgen tool not found"
exit 1
fi

C_COMPILER=$(command -v clang)
if [ -z "$C_COMPILER" ]; then
echo "C compiler not found"
# Keep going in case cmake can find one?
fi

CXX_COMPILER=$(command -v clang++)
if [ -z "$CXX_COMPILER" ]; then
echo "C++ compiler not found"
# Keep going in case cmake can find one?
fi

echo "Using C compiler: $C_COMPILER"
echo "Using C++ compiler: $CXX_COMPILER"

case "$TargetOSArchitecture" in
linux-arm)
CMakeCrossCompiling=ON
LLVMDefaultTargetTriple=thumbv7-linux-gnueabihf
LLVMHostTriple=arm-linux-gnueabihf
LLVMTargetsToBuild=ARM
LLVMTargetsToBuild="ARM"
EnsureCrossRootfsDirectoryExists
;;

Expand All @@ -29,8 +64,13 @@ case "$TargetOSArchitecture" in
;;

linux-x64)
CMakeCrossCompiling=OFF
LLVMHostTriple=x86_64-linux-gnu
if [ $CrossBuildUsingMariner -eq 1 ]; then
CMakeCrossCompiling=ON
EnsureCrossRootfsDirectoryExists
else
CMakeCrossCompiling=OFF
fi
;;

linux-loongarch64)
Expand Down Expand Up @@ -63,7 +103,7 @@ SourcesDirectory=$RootDirectory/src
BinariesDirectory=$RootDirectory/obj/$TargetOSArchitecture
StagingDirectory=$RootDirectory/artifacts/$TargetOSArchitecture

which cmake >/dev/null 2>&1
command -v cmake >/dev/null 2>&1

if [ "$?" -ne 0 ]; then
echo "ERROR: cmake is not found in the PATH"
Expand All @@ -77,47 +117,76 @@ fi
pushd "$BinariesDirectory"

if [ -z "$CrossRootfsDirectory" ]; then
BUILD_FLAGS="-target $LLVMHostTriple"
cmake \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CROSSCOMPILING=$CMakeCrossCompiling \
-DCMAKE_C_COMPILER=$(which clang) \
-DCMAKE_C_FLAGS="-target $LLVMHostTriple" \
-DCMAKE_CXX_COMPILER=$(which clang++) \
-DCMAKE_CXX_FLAGS="-target $LLVMHostTriple" \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_C_FLAGS="${BUILD_FLAGS}" \
-DCMAKE_CXX_FLAGS="${BUILD_FLAGS}" \
-DCMAKE_INSTALL_PREFIX=$StagingDirectory \
-DCMAKE_OSX_ARCHITECTURES=$CMakeOSXArchitectures \
-DCMAKE_STRIP=$(which strip) \
-DCMAKE_STRIP=$StripTool \
-DLLVM_DEFAULT_TARGET_TRIPLE=$LLVMDefaultTargetTriple \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_EXTERNAL_PROJECTS=coredistools \
-DLLVM_EXTERNAL_COREDISTOOLS_SOURCE_DIR=$SourcesDirectory/coredistools \
-DLLVM_HOST_TRIPLE=$LLVMHostTriple \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_TABLEGEN=$TblGenTool \
-DLLVM_TARGETS_TO_BUILD=$LLVMTargetsToBuild \
-DLLVM_TOOL_COREDISTOOLS_BUILD=ON \
$SourcesDirectory/llvm-project/llvm
elif [ $CrossBuildUsingMariner -eq 1 ]; then
BUILD_FLAGS="--sysroot=$CrossRootfsDirectory -target $LLVMHostTriple"
# CBL-Mariner doesn't have `ld` so need to tell clang to use `lld` with "-fuse-ld=lld"
cmake \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CROSSCOMPILING=$CMakeCrossCompiling \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_C_FLAGS="${BUILD_FLAGS}" \
-DCMAKE_CXX_FLAGS="${BUILD_FLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" \
-DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=lld" \
-DCMAKE_INCLUDE_PATH=$CrossRootfsDirectory/usr/include \
-DCMAKE_INSTALL_PREFIX=$StagingDirectory \
-DCMAKE_LIBRARY_PATH=$CrossRootfsDirectory/usr/lib/$LLVMHostTriple \
-DCMAKE_STRIP=$StripTool \
-DLLVM_DEFAULT_TARGET_TRIPLE=$LLVMDefaultTargetTriple \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_EXTERNAL_PROJECTS=coredistools \
-DLLVM_EXTERNAL_COREDISTOOLS_SOURCE_DIR=$SourcesDirectory/coredistools \
-DLLVM_HOST_TRIPLE=$LLVMHostTriple \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_TABLEGEN=$(which llvm-tblgen) \
-DLLVM_TABLEGEN=$TblGenTool \
-DLLVM_TARGETS_TO_BUILD=$LLVMTargetsToBuild \
-DLLVM_TOOL_COREDISTOOLS_BUILD=ON \
$SourcesDirectory/llvm-project/llvm
else
BUILD_FLAGS="--sysroot=$CrossRootfsDirectory -target $LLVMHostTriple"
cmake \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CROSSCOMPILING=$CMakeCrossCompiling \
-DCMAKE_C_COMPILER=$(which clang) \
-DCMAKE_C_FLAGS="-target $LLVMHostTriple --sysroot=$CrossRootfsDirectory" \
-DCMAKE_CXX_COMPILER=$(which clang++) \
-DCMAKE_CXX_FLAGS="-target $LLVMHostTriple --sysroot=$CrossRootfsDirectory" \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_C_FLAGS="${BUILD_FLAGS}" \
-DCMAKE_CXX_FLAGS="${BUILD_FLAGS}" \
-DCMAKE_INCLUDE_PATH=$CrossRootfsDirectory/usr/include \
-DCMAKE_INSTALL_PREFIX=$StagingDirectory \
-DCMAKE_LIBRARY_PATH=$CrossRootfsDirectory/usr/lib/$LLVMHostTriple \
-DCMAKE_STRIP=/usr/$LLVMHostTriple/bin/strip \
-DCMAKE_STRIP=$StripTool \
-DLLVM_DEFAULT_TARGET_TRIPLE=$LLVMDefaultTargetTriple \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_EXTERNAL_PROJECTS=coredistools \
-DLLVM_EXTERNAL_COREDISTOOLS_SOURCE_DIR=$SourcesDirectory/coredistools \
-DLLVM_HOST_TRIPLE=$LLVMHostTriple \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_TABLEGEN=$(which llvm-tblgen) \
-DLLVM_TABLEGEN=$TblGenTool \
-DLLVM_TARGETS_TO_BUILD=$LLVMTargetsToBuild \
-DLLVM_TOOL_COREDISTOOLS_BUILD=ON \
$SourcesDirectory/llvm-project/llvm
Expand Down
Loading