[RISC-V] Build coredistools (#387)
Needed for R2RDump --disasm Part of dotnet/runtime#84834 cc @wscho77 @HJLeee @clamp03 @JongHeonChoi @t-mustafin @gbalykov @viewizard @ashaurtaev @brucehoult @sirntar @yurai007 @bajtazar
This commit is contained in:
Родитель
74a49cad95
Коммит
9db9e22e01
|
@ -17,14 +17,13 @@ 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)
|
||||
# `llvm-strip` is available in CBL-Mariner container,
|
||||
# `llvm-strip-<version>` is available on standard cross build Ubuntu container,
|
||||
# `strip` is available on macOS.
|
||||
StripTool=$(command -v llvm-strip{,-{20..15}} strip | head -n 1)
|
||||
if [ -z "$StripTool" ]; then
|
||||
StripTool=$(command -v strip)
|
||||
if [ -z "$StripTool" ]; then
|
||||
echo "Strip tool not found"
|
||||
exit 1
|
||||
fi
|
||||
echo "Strip tool not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TblGenTool=$(command -v llvm-tblgen)
|
||||
|
@ -33,13 +32,14 @@ if [ -z "$TblGenTool" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
C_COMPILER=$(command -v clang)
|
||||
# Take first match from: clang clang-20 clang-19 .. clang-15
|
||||
C_COMPILER=$(command -v clang{,-{20..15}} | head -n 1)
|
||||
if [ -z "$C_COMPILER" ]; then
|
||||
echo "C compiler not found"
|
||||
# Keep going in case cmake can find one?
|
||||
fi
|
||||
|
||||
CXX_COMPILER=$(command -v clang++)
|
||||
CXX_COMPILER=$(command -v clang++{,-{20..15}} | head -n 1)
|
||||
if [ -z "$CXX_COMPILER" ]; then
|
||||
echo "C++ compiler not found"
|
||||
# Keep going in case cmake can find one?
|
||||
|
@ -79,6 +79,13 @@ case "$TargetOSArchitecture" in
|
|||
LLVMTargetsToBuild="LoongArch"
|
||||
;;
|
||||
|
||||
linux-riscv64)
|
||||
CMakeCrossCompiling=ON
|
||||
LLVMHostTriple=riscv64-linux-gnu
|
||||
LLVMTargetsToBuild="RISCV"
|
||||
EnsureCrossRootfsDirectoryExists
|
||||
;;
|
||||
|
||||
osx-arm64)
|
||||
CMakeCrossCompiling=ON
|
||||
CMakeOSXArchitectures=arm64
|
||||
|
|
|
@ -70,14 +70,18 @@ fi
|
|||
|
||||
pushd "$BinariesDirectory"
|
||||
|
||||
# Take first match from: clang clang-20 clang-19 .. clang-15
|
||||
C_COMPILER=$(command -v clang{,-{20..15}} | head -n 1)
|
||||
CXX_COMPILER=$(command -v clang++{,-{20..15}} | head -n 1)
|
||||
|
||||
if [ -z "$CrossRootfsDirectory" ]; then
|
||||
BUILD_FLAGS=""
|
||||
cmake \
|
||||
-G "Unix Makefiles" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_CROSSCOMPILING=$CMakeCrossCompiling \
|
||||
-DCMAKE_C_COMPILER=$(command -v clang) \
|
||||
-DCMAKE_CXX_COMPILER=$(command -v clang++) \
|
||||
-DCMAKE_C_COMPILER=$C_COMPILER \
|
||||
-DCMAKE_CXX_COMPILER=$CXX_COMPILER \
|
||||
-DCMAKE_C_FLAGS="${BUILD_FLAGS}" \
|
||||
-DCMAKE_CXX_FLAGS="${BUILD_FLAGS}" \
|
||||
-DCMAKE_INSTALL_PREFIX=$RootDirectory \
|
||||
|
@ -92,8 +96,8 @@ elif [ $CrossBuildUsingMariner -eq 1 ]; then
|
|||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=$RootDirectory \
|
||||
-DCMAKE_CROSSCOMPILING=$CMakeCrossCompiling \
|
||||
-DCMAKE_C_COMPILER=$(command -v clang) \
|
||||
-DCMAKE_CXX_COMPILER=$(command -v clang++) \
|
||||
-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" \
|
||||
|
@ -109,8 +113,8 @@ else
|
|||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=$RootDirectory \
|
||||
-DCMAKE_CROSSCOMPILING=$CMakeCrossCompiling \
|
||||
-DCMAKE_C_COMPILER=$(command -v clang) \
|
||||
-DCMAKE_CXX_COMPILER=$(command -v clang++) \
|
||||
-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 \
|
||||
|
|
|
@ -105,3 +105,17 @@ sudo tdnf install -y ncurses-compat
|
|||
export PATH=$(pwd)/bin:$PATH
|
||||
./build-coredistools.sh linux-arm /crossrootfs/arm
|
||||
```
|
||||
|
||||
8. Build `libcoredistools.so` for Linux riscv64 under Docker:
|
||||
There is no CBL Mariner container for RISC-V so use the standard Ubuntu cross build container used for e.g. dotnet/runtime.
|
||||
```
|
||||
docker run -it --rm --entrypoint /bin/bash -v ~/git/jitutils:/opt/code -w /opt/code mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-cross-riscv64
|
||||
apt install libtinfo5
|
||||
|
||||
# If you haven't built llvm-tblgen in step 5, you can do so in the same docker (pass "/" as crossrootfs).
|
||||
./build-tblgen.sh linux-x64 /
|
||||
|
||||
# Now, the main course
|
||||
export PATH=$(pwd)/bin:$PATH
|
||||
./build-coredistools.sh linux-riscv64 /crossrootfs/riscv64
|
||||
```
|
|
@ -286,6 +286,9 @@ bool CorDisasm::setTarget() {
|
|||
case Triple::loongarch64:
|
||||
TheTargetArch = Target_LoongArch64;
|
||||
break;
|
||||
case Triple::riscv64:
|
||||
TheTargetArch = Target_RiscV64;
|
||||
break;
|
||||
default:
|
||||
Print->Error("Unsupported Architecture: %s\n",
|
||||
Triple::getArchTypeName(TheTriple->getArch()));
|
||||
|
@ -309,6 +312,9 @@ bool CorDisasm::setTarget() {
|
|||
case Target_LoongArch64:
|
||||
TheTriple->setArch(Triple::loongarch64);
|
||||
break;
|
||||
case Target_RiscV64:
|
||||
TheTriple->setArch(Triple::riscv64);
|
||||
break;
|
||||
default:
|
||||
Print->Error("Unsupported Architecture: %s\n",
|
||||
Triple::getArchTypeName(TheTriple->getArch()));
|
||||
|
|
|
@ -42,7 +42,8 @@ enum TargetArch {
|
|||
Target_X64,
|
||||
Target_Thumb,
|
||||
Target_Arm64,
|
||||
Target_LoongArch64
|
||||
Target_LoongArch64,
|
||||
Target_RiscV64,
|
||||
};
|
||||
|
||||
struct CorDisasm;
|
||||
|
|
Загрузка…
Ссылка в новой задаче