-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update coredistools from LLVM 13.0.1 to 16.0.1
1. LLVM doesn't release a full set of binary drops, so we need to build llvm-tblgen on some platforms, namely Mac. 2. Build using standard CBL-Mariner Docker containers (used by dotnet/runtime as well). This also converts linux-x64 builds to be container-based cross builds.
- Loading branch information
1 parent
c38952c
commit d07dbed
Showing
5 changed files
with
184 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Build the Linux/Mac llvm-tblgen tool. Note that this will be run during the | ||
# Linux/Mac coredistools build. So, we only build the versions that we'll use | ||
# during those builds. Thus, we need a linux-x64 version (used for | ||
# linux-x64, linux-arm, linux-arm64 builds) and osx-x64 version (used for | ||
# osx-x64 and osx-arm64 builds). | ||
# | ||
# The linux-x64 build is itself a cross-build, using CBL-Mariner container to build. | ||
|
||
TargetOSArchitecture=$1 | ||
CrossRootfsDirectory=$2 | ||
|
||
EnsureCrossRootfsDirectoryExists () { | ||
if [ ! -d "$CrossRootfsDirectory" ]; then | ||
echo "Invalid or unspecified CrossRootfsDirectory: $CrossRootfsDirectory" | ||
exit 1 | ||
fi | ||
} | ||
|
||
CMakeOSXArchitectures= | ||
LLVMTargetsToBuild="AArch64;ARM;X86" | ||
|
||
case "$TargetOSArchitecture" in | ||
linux-x64) | ||
CMakeCrossCompiling=ON | ||
LLVMHostTriple=x86_64-linux-gnu | ||
EnsureCrossRootfsDirectoryExists | ||
;; | ||
|
||
linux-loongarch64) | ||
CMakeCrossCompiling=OFF | ||
LLVMHostTriple=loongarch64-linux-gnu | ||
LLVMTargetsToBuild="LoongArch" | ||
;; | ||
|
||
osx-x64) | ||
CMakeCrossCompiling=OFF | ||
CMakeOSXArchitectures=x86_64 | ||
LLVMHostTriple=x86_64-apple-darwin | ||
;; | ||
|
||
*) | ||
echo "Unknown target OS and architecture: $TargetOSArchitecture" | ||
exit 1 | ||
esac | ||
|
||
RootDirectory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
SourcesDirectory=$RootDirectory/src | ||
BinariesDirectory=$RootDirectory/obj | ||
StagingDirectory=$RootDirectory/bin | ||
|
||
command -v cmake >/dev/null 2>&1 | ||
|
||
if [ "$?" -ne 0 ]; then | ||
echo "ERROR: cmake is not found in the PATH" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -d $BinariesDirectory ]; then | ||
mkdir -p $BinariesDirectory | ||
fi | ||
|
||
pushd "$BinariesDirectory" | ||
|
||
if [ -z "$CrossRootfsDirectory" ]; then | ||
cmake \ | ||
-G "Unix Makefiles" \ | ||
-DCMAKE_CROSSCOMPILING=$CMakeCrossCompiling \ | ||
-DCMAKE_C_COMPILER=$(command -v clang) \ | ||
-DCMAKE_CXX_COMPILER=$(command -v clang++) \ | ||
-DCMAKE_INSTALL_PREFIX=$RootDirectory \ | ||
-DCMAKE_OSX_ARCHITECTURES=$CMakeOSXArchitectures \ | ||
-DLLVM_TARGETS_TO_BUILD=$LLVMTargetsToBuild \ | ||
$SourcesDirectory/llvm-project/llvm | ||
else | ||
cmake \ | ||
-G "Unix Makefiles" \ | ||
-DCMAKE_INSTALL_PREFIX=$RootDirectory \ | ||
-DCMAKE_CROSSCOMPILING=$CMakeCrossCompiling \ | ||
-DCMAKE_C_COMPILER=$(command -v clang) \ | ||
-DCMAKE_C_FLAGS="--sysroot=$CrossRootfsDirectory" \ | ||
-DCMAKE_CXX_COMPILER=$(command -v clang++) \ | ||
-DCMAKE_CXX_FLAGS="--sysroot=$CrossRootfsDirectory" \ | ||
-DCMAKE_INCLUDE_PATH=$CrossRootfsDirectory/usr/include \ | ||
-DCMAKE_INSTALL_PREFIX=$RootDirectory \ | ||
-DCMAKE_LIBRARY_PATH=$CrossRootfsDirectory/usr/lib/$LLVMHostTriple \ | ||
-DLLVM_TARGETS_TO_BUILD=$LLVMTargetsToBuild \ | ||
$SourcesDirectory/llvm-project/llvm | ||
fi | ||
|
||
popd | ||
|
||
if [ "$?" -ne 0 ]; then | ||
echo "ERROR: cmake exited with code $1" | ||
exit 1 | ||
fi | ||
|
||
cmake \ | ||
--build $BinariesDirectory \ | ||
--target llvm-tblgen \ | ||
--config Release | ||
|
||
if [ "$?" -ne 0 ]; then | ||
echo "ERROR: cmake exited with code $1" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -d $StagingDirectory ]; then | ||
mkdir -p $StagingDirectory | ||
fi | ||
|
||
# Copy llvm-tblgen from BinariesDirectory to StagingDirectory | ||
find $BinariesDirectory -name llvm-tblgen | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.