@@ -462,7 +462,7 @@ cmake llvm -G"Visual Studio 16 2019 Win64" ^
462462 -Bbuild-x86_64 ^
463463 -DCMAKE_BUILD_TYPE=Release ^
464464 -DCMAKE_INSTALL_PREFIX=%CD%\build-x86_64\install ^
465- -DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" ^
465+ -DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64;RISCV " ^
466466 -DLLVM_ENABLE_PROJECTS=clang ^
467467```
468468
@@ -741,7 +741,7 @@ Note that this is not part of the regular testing of OCK, but should work.
741741All CMake cross-compilation configurations set ` CMAKE_TOOLCHAIN_FILE ` to inform
742742CMake how to compile for the target architecture, this sets up various CMake
743743variables which specify the locations of executables such as the C and C++
744- compilers, assembler, linker, target file system root, etc.
744+ compilers, target file system root, etc.
745745
746746The examples provided should be sufficient to get up and running, for more fine
747747grained control of how to compile the oneAPI Construction Kit consult the list of
@@ -761,32 +761,27 @@ LLVMNativeInstall=${CMAKE_INSTALL_PREFIX}
761761
762762### Cross-compiling LLVM
763763
764- #### Cross-compiling LLVM from Upstream
765-
766764To cross-compile LLVM the appropriate CMake toolchain file from the oneAPI
767- Construction Kit repository is required, the path to this will be specified
768- by the ` $ONEAPI_CON_KIT ` variable in the following examples.
765+ Construction Kit repository may be used; the path to this repository will be
766+ specified by the ` $ONEAPI_CON_KIT ` variable in the following examples.
769767
770- ##### Cross-compiling LLVM for Arm from Upstream
768+ ##### Cross-compiling LLVM for ARM
771769
772- For cross-compilation targeting Arm only the ` ARM ` target back end is enabled.
773- Run the following command to configure an LLVM build targeting Arm from the root
774- of the repository.
770+ For cross-compilation targeting ARM, only the ` ARM ` target back end needs to be
771+ enabled. Run the following command to configure an LLVM build targeting ARM from
772+ the root of the LLVM repository.
775773
776774``` sh
777- cmake . -GNinja \
775+ cmake llvm -GNinja \
778776 -Bbuild-arm \
779777 -DCMAKE_BUILD_TYPE=Release \
780- -DCMAKE_TOOLCHAIN_FILE=$ONEAPI_CON_KIT /scripts/toolchains /arm-toolchain.cmake \
778+ -DCMAKE_TOOLCHAIN_FILE=$ONEAPI_CON_KIT /platform/arm-linux /arm-toolchain.cmake \
781779 -DCMAKE_INSTALL_PREFIX=$PWD /build-arm/install \
782- -DLLVM_TARGET_ARCH=ARM \
780+ -DLLVM_HOST_TRIPLE=arm-unknown-linux-gnueabihf \
783781 -DLLVM_TARGETS_TO_BUILD=ARM \
784- -DLLVM_HOST_TRIPLE=arm-unknown-linux-gnu \
785- -DLLVM_DEFAULT_TARGET_TRIPLE=arm-unknown-linux-gnu \
786- -DLLVM_ENABLE_ZLIB=OFF \
787- -DLLVM_ENABLE_ZSTD=OFF \
788- -DLLVM_TABLEGEN=$LLVMNativeInstall /bin/llvm-tblgen \
789- -DCLANG_TABLEGEN=$LLVMNativeBuild /bin/clang-tblgen
782+ -DLLVM_ENABLE_PROJECTS=clang \
783+ -DLLVM_BUILD_LLVM_DYLIB=ON \
784+ -DLLVM_LINK_LLVM_DYLIB=ON
790785```
791786
792787Now the build directory is configured, build the ` install ` target.
@@ -795,26 +790,23 @@ Now the build directory is configured, build the `install` target.
795790ninja -C build-arm install
796791```
797792
798- ##### Cross-compiling LLVM for AArch64 from Upstream
793+ ##### Cross-compiling LLVM for AArch64
799794
800- For cross-compilation targeting AArch64 only the ` AArch64 ` target back end is
801- enabled. Run the following command to configure an LLVM build targeting Arm from
802- the root of the repository.
795+ For cross-compilation targeting AArch64 only the ` AArch64 ` target back end needs
796+ to be enabled. Run the following command to configure an LLVM build targeting
797+ AArch64 from the root of the repository.
803798
804799``` sh
805- cmake . -GNinja \
800+ cmake llvm -GNinja \
806801 -Bbuild-aarch64 \
807802 -DCMAKE_BUILD_TYPE=Release \
808- -DCMAKE_TOOLCHAIN_FILE=$ONEAPI_CON_KIT /scripts/toolchains /aarch64-toolchain.cmake \
803+ -DCMAKE_TOOLCHAIN_FILE=$ONEAPI_CON_KIT /platform/arm-linux /aarch64-toolchain.cmake \
809804 -DCMAKE_INSTALL_PREFIX=$PWD /build-aarch64/install \
810- -DLLVM_TARGET_ARCH=AArch64 \
811- -DLLVM_TARGETS_TO_BUILD=AArch64 \
812805 -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-gnu \
813- -DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-unknown-linux-gnu \
814- -DLLVM_ENABLE_ZLIB=OFF \
815- -DLLVM_ENABLE_ZSTD=OFF \
816- -DLLVM_TABLEGEN=$LLVMNativeInstall /bin/llvm-tblgen \
817- -DCLANG_TABLEGEN=$LLVMNativeBuild /bin/clang-tblgen
806+ -DLLVM_TARGETS_TO_BUILD=AArch64 \
807+ -DLLVM_ENABLE_PROJECTS=clang \
808+ -DLLVM_BUILD_LLVM_DYLIB=ON \
809+ -DLLVM_LINK_LLVM_DYLIB=ON
818810```
819811
820812Now the build directory is configured, build the ` install ` target.
@@ -823,21 +815,70 @@ Now the build directory is configured, build the `install` target.
823815ninja -C build-aarch64 install
824816```
825817
818+ ##### Cross-compiling LLVM for RISC-V
819+
820+ For cross-compilation targeting RISC-V only the ` RISCV ` target back end needs
821+ to be enabled. Run the following command to configure an LLVM build targeting
822+ AArch64 from the root of the repository.
823+
824+ ``` sh
825+ cmake llvm -GNinja \
826+ -Bbuild-riscv64 \
827+ -DCMAKE_BUILD_TYPE=Release \
828+ -DCMAKE_TOOLCHAIN_FILE=$ONEAPI_CON_KIT /platform/riscv64-linux/riscv64-gcc-toolchain.cmake \
829+ -DCMAKE_INSTALL_PREFIX=$PWD /build-riscv64/install \
830+ -DLLVM_HOST_TRIPLE=riscv64-unknown-linux-gnu \
831+ -DLLVM_TARGETS_TO_BUILD=RISCV \
832+ -DLLVM_ENABLE_PROJECTS=clang \
833+ -DLLVM_BUILD_LLVM_DYLIB=ON \
834+ -DLLVM_LINK_LLVM_DYLIB=ON
835+ ```
836+
837+ Now the build directory is configured, build the ` install ` target.
838+
839+ ``` sh
840+ ninja -C build-riscv64 install
841+ ```
842+
826843### Cross-compiling the oneAPI Construction Kit
827844
828- Cross-compiling the oneAPI Construction Kit requires a LLVM install to link
845+ Cross-compiling the oneAPI Construction Kit requires an LLVM install to link
829846against, follow the [ LLVM guide] ( #cross-compiling-llvm ) to build a suitable
830847install, the ` $LLVMInstall ` variable specifies the path to this install.
831848
832849oneAPI Construction Kit uses tools from an LLVM install during the build
833- process. For a native x86_64 build no additional install is required, although
834- build times can be [ improved] ( #compiling-debug-oneapi-construction-kit-on-linux )
835- by doing so. For cross-compilation a native LLVM install is also required, the
836- ` $LLVMNativeInstall ` variable specifies the path to this install.
850+ process. For this, an additional native LLVM install is usually required, and
851+ even when not required, build times can be improved by providing one.
852+
853+ #### Compiling the native LLVM
854+
855+ For building the native LLVM, no specific target back end needs to be enabled.
856+ However, it is important for the ` LLVM_ENABLE_ZLIB ` and ` LLVM_ENABLE_ZSTD `
857+ settings to not be enabled unless the cross-compiled LLVM is also built with
858+ support for this.
859+
860+ ``` sh
861+ cmake llvm -GNinja \
862+ -Bbuild-native \
863+ -DCMAKE_BUILD_TYPE=Release \
864+ -DCMAKE_INSTALL_PREFIX=$PWD /build-native/install \
865+ -DLLVM_TARGETS_TO_BUILD= \
866+ -DLLVM_ENABLE_PROJECTS=clang \
867+ -DLLVM_ENABLE_ZLIB=OFF \
868+ -DLLVM_ENABLE_ZSTD=OFF \
869+ -DLLVM_BUILD_LLVM_DYLIB=ON \
870+ -DLLVM_LINK_LLVM_DYLIB=ON
871+ ```
872+
873+ Now the build directory is configured, build the ` install ` target.
874+
875+ ``` sh
876+ ninja -C build-native install
877+ ```
837878
838- #### Cross-compiling the oneAPI Construction Kit for Arm
879+ #### Cross-compiling the oneAPI Construction Kit for ARM
839880
840- Configure an Arm cross-compile build using the following command.
881+ Configure an ARM cross-compile build using the following command.
841882
842883``` sh
843884cmake . -GNinja \
@@ -855,10 +896,9 @@ Now the build directory is configured, build the `install` target.
855896ninja -C build-arm install
856897```
857898
858- If ` qemu-arm ` is installed on the system ` arm-toolchain.cmake ` will
859- automatically detect it and set the ` CMAKE_CROSSCOMPILING_EMULATOR ` variable,
860- the oneAPI Construction Kit uses this to enable emulated testing using the
861- ` check ` target.
899+ The provided ` arm-toolchain.cmake ` will set the ` CMAKE_CROSSCOMPILING_EMULATOR `
900+ variable to ` qemu-armhf ` ; if available, the oneAPI Construction Kit can use this
901+ to enable emulated testing using the ` check ` target.
862902
863903``` sh
864904ninja -C build-arm check
@@ -884,15 +924,49 @@ Now the build directory is configured, build the `install` target.
884924ninja -C build-aarch64 install
885925```
886926
887- If ` qemu-aarch64 ` is installed on the system ` aarch64-toolchain.cmake ` will
888- automatically detect it and set the ` CMAKE_CROSSCOMPILING_EMULATOR ` variable,
889- the oneAPI Construction Kit uses this to enable emulated testing using the
927+ The provided ` aarch64-toolchain.cmake ` will set the
928+ ` CMAKE_CROSSCOMPILING_EMULATOR ` variable to ` qemu-aarch64 ` ; if available, the
929+ oneAPI Construction Kit can use this to enable emulated testing using the
890930` check ` target.
891931
892932``` sh
893933ninja -C build-aarch64 check
894934```
895935
936+ #### Cross-compiling the oneAPI Construction Kit for RISC-V
937+
938+ Configure a RISC-V 64-bit cross-compile build using the following command.
939+
940+ ``` sh
941+ cmake . -GNinja \
942+ -Bbuild-riscv64 \
943+ -DCMAKE_BUILD_TYPE=Release \
944+ -DCMAKE_TOOLCHAIN_FILE=$PWD /platform/riscv64-linux/riscv64-gcc-toolchain.cmake \
945+ -DCMAKE_INSTALL_PREFIX=$PWD /build-riscv64/install \
946+ -DCA_LLVM_INSTALL_DIR=$LLVMInstall \
947+ -DCA_BUILTINS_TOOLS_DIR=$LLVMNativeInstall /bin
948+ ```
949+
950+ This uses the [ default platform settings for ` riscv64-linux-gnu ` ] ( https://wiki.debian.org/RISC-V#Hardware_baseline_and_ABI_choice )
951+ which is ` RV64GC ` . To enable additional extensions by default, such as RVV, the
952+ ` CA_HOST_TARGET_RISCV64_FEATURES ` variable may additionally be set in the above
953+ command.
954+
955+ Now the build directory is configured, build the ` install ` target.
956+
957+ ``` sh
958+ ninja -C build-riscv64 install
959+ ```
960+
961+ The provided ` riscv64-gcc-toolchain.cmake ` will set the
962+ ` CMAKE_CROSSCOMPILING_EMULATOR ` variable to ` qemu-riscv64 ` ; if available, the
963+ oneAPI Construction Kit can use this to enable emulated testing using the
964+ ` check ` target.
965+
966+ ``` sh
967+ ninja -C build-riscv64 check
968+ ```
969+
896970#### Cross-compiling the oneAPI Construction Kit for Windows with the MinGW toolchain
897971
898972oneAPI Construction Kit for Windows can be built on Linux using MinGW. This
0 commit comments