From f96dc2dea9fa4ef1028cdff0b47d3878198e2b10 Mon Sep 17 00:00:00 2001 From: Harald van Dijk Date: Tue, 17 Dec 2024 22:15:21 +0000 Subject: [PATCH] Simplify toolchain files, update cross build docs. This commit updates platform/**/*.cmake to be much reduced in complexity for the platforms we currently actively target, and has been tested using these toolchain files both for LLVM builds and for oneAPI Construction Kit builds. This commit also corrects the developer guide to use the correct toolchain files, and adds a section for cross-compiling for RISC-V. --- doc/developer-guide.md | 166 +++++++++++++----- platform/arm-linux/aarch64-toolchain.cmake | 106 +---------- .../arm-linux-gnueabihf-toolchain/PKGBUILD | 55 ------ platform/arm-linux/arm-toolchain.cmake | 106 +---------- .../riscv64-linux/riscv64-gcc-toolchain.cmake | 106 +---------- 5 files changed, 141 insertions(+), 398 deletions(-) delete mode 100755 platform/arm-linux/arm-linux-gnueabihf-toolchain/PKGBUILD diff --git a/doc/developer-guide.md b/doc/developer-guide.md index c8aa14a41..e4aa60a85 100644 --- a/doc/developer-guide.md +++ b/doc/developer-guide.md @@ -462,7 +462,7 @@ cmake llvm -G"Visual Studio 16 2019 Win64" ^ -Bbuild-x86_64 ^ -DCMAKE_BUILD_TYPE=Release ^ -DCMAKE_INSTALL_PREFIX=%CD%\build-x86_64\install ^ - -DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64" ^ + -DLLVM_TARGETS_TO_BUILD="X86;ARM;AArch64;RISCV" ^ -DLLVM_ENABLE_PROJECTS=clang ^ ``` @@ -741,7 +741,7 @@ Note that this is not part of the regular testing of OCK, but should work. All CMake cross-compilation configurations set `CMAKE_TOOLCHAIN_FILE` to inform CMake how to compile for the target architecture, this sets up various CMake variables which specify the locations of executables such as the C and C++ -compilers, assembler, linker, target file system root, etc. +compilers, target file system root, etc. The examples provided should be sufficient to get up and running, for more fine grained control of how to compile the oneAPI Construction Kit consult the list of @@ -761,32 +761,27 @@ LLVMNativeInstall=${CMAKE_INSTALL_PREFIX} ### Cross-compiling LLVM -#### Cross-compiling LLVM from Upstream - To cross-compile LLVM the appropriate CMake toolchain file from the oneAPI -Construction Kit repository is required, the path to this will be specified -by the `$ONEAPI_CON_KIT` variable in the following examples. +Construction Kit repository may be used; the path to this repository will be +specified by the `$ONEAPI_CON_KIT` variable in the following examples. -##### Cross-compiling LLVM for Arm from Upstream +##### Cross-compiling LLVM for ARM -For cross-compilation targeting Arm only the `ARM` target back end is enabled. -Run the following command to configure an LLVM build targeting Arm from the root -of the repository. +For cross-compilation targeting ARM, only the `ARM` target back end needs to be +enabled. Run the following command to configure an LLVM build targeting ARM from +the root of the LLVM repository. ```sh -cmake . -GNinja \ +cmake llvm -GNinja \ -Bbuild-arm \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_TOOLCHAIN_FILE=$ONEAPI_CON_KIT/scripts/toolchains/arm-toolchain.cmake \ + -DCMAKE_TOOLCHAIN_FILE=$ONEAPI_CON_KIT/platform/arm-linux/arm-toolchain.cmake \ -DCMAKE_INSTALL_PREFIX=$PWD/build-arm/install \ - -DLLVM_TARGET_ARCH=ARM \ + -DLLVM_HOST_TRIPLE=arm-unknown-linux-gnueabihf \ -DLLVM_TARGETS_TO_BUILD=ARM \ - -DLLVM_HOST_TRIPLE=arm-unknown-linux-gnu \ - -DLLVM_DEFAULT_TARGET_TRIPLE=arm-unknown-linux-gnu \ - -DLLVM_ENABLE_ZLIB=OFF \ - -DLLVM_ENABLE_ZSTD=OFF \ - -DLLVM_TABLEGEN=$LLVMNativeInstall/bin/llvm-tblgen \ - -DCLANG_TABLEGEN=$LLVMNativeBuild/bin/clang-tblgen + -DLLVM_ENABLE_PROJECTS=clang \ + -DLLVM_BUILD_LLVM_DYLIB=ON \ + -DLLVM_LINK_LLVM_DYLIB=ON ``` Now the build directory is configured, build the `install` target. @@ -795,26 +790,23 @@ Now the build directory is configured, build the `install` target. ninja -C build-arm install ``` -##### Cross-compiling LLVM for AArch64 from Upstream +##### Cross-compiling LLVM for AArch64 -For cross-compilation targeting AArch64 only the `AArch64` target back end is -enabled. Run the following command to configure an LLVM build targeting Arm from -the root of the repository. +For cross-compilation targeting AArch64 only the `AArch64` target back end needs +to be enabled. Run the following command to configure an LLVM build targeting +AArch64 from the root of the repository. ```sh -cmake . -GNinja \ +cmake llvm -GNinja \ -Bbuild-aarch64 \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_TOOLCHAIN_FILE=$ONEAPI_CON_KIT/scripts/toolchains/aarch64-toolchain.cmake \ + -DCMAKE_TOOLCHAIN_FILE=$ONEAPI_CON_KIT/platform/arm-linux/aarch64-toolchain.cmake \ -DCMAKE_INSTALL_PREFIX=$PWD/build-aarch64/install \ - -DLLVM_TARGET_ARCH=AArch64 \ - -DLLVM_TARGETS_TO_BUILD=AArch64 \ -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-gnu \ - -DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-unknown-linux-gnu \ - -DLLVM_ENABLE_ZLIB=OFF \ - -DLLVM_ENABLE_ZSTD=OFF \ - -DLLVM_TABLEGEN=$LLVMNativeInstall/bin/llvm-tblgen \ - -DCLANG_TABLEGEN=$LLVMNativeBuild/bin/clang-tblgen + -DLLVM_TARGETS_TO_BUILD=AArch64 \ + -DLLVM_ENABLE_PROJECTS=clang \ + -DLLVM_BUILD_LLVM_DYLIB=ON \ + -DLLVM_LINK_LLVM_DYLIB=ON ``` Now the build directory is configured, build the `install` target. @@ -823,21 +815,70 @@ Now the build directory is configured, build the `install` target. ninja -C build-aarch64 install ``` +##### Cross-compiling LLVM for RISC-V + +For cross-compilation targeting RISC-V only the `RISCV` target back end needs +to be enabled. Run the following command to configure an LLVM build targeting +AArch64 from the root of the repository. + +```sh +cmake llvm -GNinja \ + -Bbuild-riscv64 \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_TOOLCHAIN_FILE=$ONEAPI_CON_KIT/platform/riscv64-linux/riscv64-gcc-toolchain.cmake \ + -DCMAKE_INSTALL_PREFIX=$PWD/build-riscv64/install \ + -DLLVM_HOST_TRIPLE=riscv64-unknown-linux-gnu \ + -DLLVM_TARGETS_TO_BUILD=RISCV \ + -DLLVM_ENABLE_PROJECTS=clang \ + -DLLVM_BUILD_LLVM_DYLIB=ON \ + -DLLVM_LINK_LLVM_DYLIB=ON +``` + +Now the build directory is configured, build the `install` target. + +```sh +ninja -C build-riscv64 install +``` + ### Cross-compiling the oneAPI Construction Kit -Cross-compiling the oneAPI Construction Kit requires a LLVM install to link +Cross-compiling the oneAPI Construction Kit requires an LLVM install to link against, follow the [LLVM guide](#cross-compiling-llvm) to build a suitable install, the `$LLVMInstall` variable specifies the path to this install. oneAPI Construction Kit uses tools from an LLVM install during the build -process. For a native x86_64 build no additional install is required, although -build times can be [improved](#compiling-debug-oneapi-construction-kit-on-linux) -by doing so. For cross-compilation a native LLVM install is also required, the -`$LLVMNativeInstall` variable specifies the path to this install. +process. For this, an additional native LLVM install is usually required, and +even when not required, build times can be improved by providing one. + +#### Compiling the native LLVM + +For building the native LLVM, no specific target back end needs to be enabled. +However, it is important for the `LLVM_ENABLE_ZLIB` and `LLVM_ENABLE_ZSTD` +settings to not be enabled unless the cross-compiled LLVM is also built with +support for this. + +```sh +cmake llvm -GNinja \ + -Bbuild-native \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=$PWD/build-native/install \ + -DLLVM_TARGETS_TO_BUILD= \ + -DLLVM_ENABLE_PROJECTS=clang \ + -DLLVM_ENABLE_ZLIB=OFF \ + -DLLVM_ENABLE_ZSTD=OFF \ + -DLLVM_BUILD_LLVM_DYLIB=ON \ + -DLLVM_LINK_LLVM_DYLIB=ON +``` + +Now the build directory is configured, build the `install` target. + +```sh +ninja -C build-native install +``` -#### Cross-compiling the oneAPI Construction Kit for Arm +#### Cross-compiling the oneAPI Construction Kit for ARM -Configure an Arm cross-compile build using the following command. +Configure an ARM cross-compile build using the following command. ```sh cmake . -GNinja \ @@ -855,10 +896,9 @@ Now the build directory is configured, build the `install` target. ninja -C build-arm install ``` -If `qemu-arm` is installed on the system `arm-toolchain.cmake` will -automatically detect it and set the `CMAKE_CROSSCOMPILING_EMULATOR` variable, -the oneAPI Construction Kit uses this to enable emulated testing using the -`check` target. +The provided `arm-toolchain.cmake` will set the `CMAKE_CROSSCOMPILING_EMULATOR` +variable to `qemu-armhf`; if available, the oneAPI Construction Kit can use this +to enable emulated testing using the `check` target. ```sh ninja -C build-arm check @@ -884,15 +924,49 @@ Now the build directory is configured, build the `install` target. ninja -C build-aarch64 install ``` -If `qemu-aarch64` is installed on the system `aarch64-toolchain.cmake` will -automatically detect it and set the `CMAKE_CROSSCOMPILING_EMULATOR` variable, -the oneAPI Construction Kit uses this to enable emulated testing using the +The provided `aarch64-toolchain.cmake` will set the +`CMAKE_CROSSCOMPILING_EMULATOR` variable to `qemu-aarch64`; if available, the +oneAPI Construction Kit can use this to enable emulated testing using the `check` target. ```sh ninja -C build-aarch64 check ``` +#### Cross-compiling the oneAPI Construction Kit for RISC-V + +Configure a RISC-V 64-bit cross-compile build using the following command. + +```sh +cmake . -GNinja \ + -Bbuild-riscv64 \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_TOOLCHAIN_FILE=$PWD/platform/riscv64-linux/riscv64-gcc-toolchain.cmake \ + -DCMAKE_INSTALL_PREFIX=$PWD/build-riscv64/install \ + -DCA_LLVM_INSTALL_DIR=$LLVMInstall \ + -DCA_BUILTINS_TOOLS_DIR=$LLVMNativeInstall/bin +``` + +This uses the [default platform settings for `riscv64-linux-gnu`](https://wiki.debian.org/RISC-V#Hardware_baseline_and_ABI_choice) +which is `RV64GC`. To enable additional extensions by default, such as RVV, the +`CA_HOST_TARGET_RISCV64_FEATURES` variable may additionally be set in the above +command. + +Now the build directory is configured, build the `install` target. + +```sh +ninja -C build-riscv64 install +``` + +The provided `riscv64-gcc-toolchain.cmake` will set the +`CMAKE_CROSSCOMPILING_EMULATOR` variable to `qemu-riscv64`; if available, the +oneAPI Construction Kit can use this to enable emulated testing using the +`check` target. + +```sh +ninja -C build-riscv64 check +``` + #### Cross-compiling the oneAPI Construction Kit for Windows with the MinGW toolchain oneAPI Construction Kit for Windows can be built on Linux using MinGW. This diff --git a/platform/arm-linux/aarch64-toolchain.cmake b/platform/arm-linux/aarch64-toolchain.cmake index 6bb2d39de..32dbe9e2b 100644 --- a/platform/arm-linux/aarch64-toolchain.cmake +++ b/platform/arm-linux/aarch64-toolchain.cmake @@ -14,107 +14,15 @@ # # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -set(CMAKE_SYSTEM_VERSION 1) +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) +set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc CACHE STRING "") +set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++ CACHE STRING "") +set(PKG_CONFIG_EXECUTABLE aarch64-linux-gnu-pkg-config) -set(TRIPLE "aarch64-linux-gnu") -set(TOOLCHAIN_ROOT /usr) - -if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows) - set(TOOL_OS_SUFFIX .exe) -else() - set(TOOL_OS_SUFFIX) -endif() - -set(CMAKE_SYSTEM_NAME Linux - CACHE STRING "operating system" FORCE) -set(CMAKE_SYSTEM_PROCESSOR aarch64 - CACHE STRING "processor architecture" FORCE) - -find_program(CMAKE_C_COMPILER NAMES - "${TRIPLE}-gcc${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-14${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-13${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-12${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-11${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-10${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-9${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-8${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-7${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-6${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-5${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-4.9${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-4.8${TOOL_OS_SUFFIX}" - "gcc-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-14-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-13-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-12-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-11-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-10-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-9-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-8-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-7-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-6-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-5-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-4.9-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-4.8-${TRIPLE}${TOOL_OS_SUFFIX}" - PATHS "${TOOLCHAIN_ROOT}/bin/" DOC "gcc") - -find_program(CMAKE_CXX_COMPILER NAMES - "${TRIPLE}-g++${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-14${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-13${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-12${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-11${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-10${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-9${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-8${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-7${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-6${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-5${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-4.9${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-4.8${TOOL_OS_SUFFIX}" - "g++-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-14-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-13-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-12-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-11-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-10-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-9-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-8-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-7-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-6-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-5-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-4.9-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-4.8-${TRIPLE}${TOOL_OS_SUFFIX}" - PATHS "${TOOLCHAIN_ROOT}/bin/" DOC "g++") - -set(CMAKE_AR "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-ar${TOOL_OS_SUFFIX}" - CACHE PATH "archive" FORCE) -set(CMAKE_LINKER "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-ld${TOOL_OS_SUFFIX}" - CACHE PATH "linker" FORCE) -set(CMAKE_NM "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-nm${TOOL_OS_SUFFIX}" - CACHE PATH "nm" FORCE) -set(CMAKE_OBJCOPY "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-objcopy${TOOL_OS_SUFFIX}" - CACHE PATH "objcopy" FORCE) -set(CMAKE_OBJDUMP "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-objdump${TOOL_OS_SUFFIX}" - CACHE PATH "objdump" FORCE) -set(CMAKE_STRIP "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-strip${TOOL_OS_SUFFIX}" - CACHE PATH "strip" FORCE) -set(CMAKE_RANLIB "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-ranlib${TOOL_OS_SUFFIX}" - CACHE PATH "ranlib" FORCE) - -set(CMAKE_FIND_ROOT_PATH /usr/${TRIPLE}) +set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_CXX_LINK_EXECUTABLE " \ - -o ${LINKER_LIBS}" - CACHE STRING "Linker command line" FORCE) - -find_program(QEMU_AARCH64_EXECUTABLE qemu-aarch64) -if(NOT QEMU_AARCH64_EXECUTABLE MATCHES NOTFOUND) - set(CMAKE_CROSSCOMPILING_EMULATOR - ${QEMU_AARCH64_EXECUTABLE} -L ${CMAKE_FIND_ROOT_PATH} - CACHE STRING "qemu" FORCE) -endif() +set(CMAKE_CROSSCOMPILING_EMULATOR qemu-aarch64 -L ${CMAKE_FIND_ROOT_PATH} CACHE STRING "") diff --git a/platform/arm-linux/arm-linux-gnueabihf-toolchain/PKGBUILD b/platform/arm-linux/arm-linux-gnueabihf-toolchain/PKGBUILD deleted file mode 100755 index 6f1a1edc6..000000000 --- a/platform/arm-linux/arm-linux-gnueabihf-toolchain/PKGBUILD +++ /dev/null @@ -1,55 +0,0 @@ -pkgname=arm-linux-gnueabihf-toolchain -pkgver=4.8.2 -pkgrel=1 -pkgdesc="Cross-compilation toolchain targeting ARM" -arch=('x86_64') -url="http://packages.ubuntu.com/trusty/devel/gcc-4.8-arm-linux-gnu" -license=('GPL') -depends=() -makedepends=('deb2targz') -options=(!strip libtool staticlibs) -source=(http://cz.archive.ubuntu.com/ubuntu/pool/main/b/binutils-armhf-cross/binutils-arm-linux-gnueabihf_2.24-2ubuntu3cross1.98_amd64.deb - http://cz.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8-armhf-cross/cpp-4.8-arm-linux-gnueabihf_4.8.2-16ubuntu4cross0.11_amd64.deb - http://cz.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8-armhf-cross/g++-4.8-arm-linux-gnueabihf_4.8.2-16ubuntu4cross0.11_amd64.deb - http://cz.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8-armhf-cross/gcc-4.8-multilib-arm-linux-gnueabihf_4.8.2-16ubuntu4cross0.11_amd64.deb - http://cz.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8-armhf-cross/gcc-4.8-arm-linux-gnueabihf_4.8.2-16ubuntu4cross0.11_amd64.deb - http://cz.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8-armhf-cross/gcc-4.8-arm-linux-gnueabihf-base_4.8.2-16ubuntu4cross0.11_amd64.deb - http://cz.archive.ubuntu.com/ubuntu/pool/main/g/gcc-defaults-armhf-cross/gcc-arm-linux-gnueabihf_4.8.2-1_amd64.deb - http://cz.archive.ubuntu.com/ubuntu/pool/main/g/gcc-defaults-armhf-cross/g++-arm-linux-gnueabihf_4.8.2-1_amd64.deb - http://cz.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8-armhf-cross/libatomic1-armhf-cross_4.8.2-16ubuntu4cross0.11_all.deb - http://cz.archive.ubuntu.com/ubuntu/pool/main/a/armhf-cross-toolchain-base/libc6-dev-armhf-cross_2.19-0ubuntu2cross1.104_all.deb - http://cz.archive.ubuntu.com/ubuntu/pool/main/a/armhf-cross-toolchain-base/libc6-armhf-cross_2.19-0ubuntu2cross1.104_all.deb - http://cz.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8-armhf-cross/libgcc1-armhf-cross_4.8.2-16ubuntu4cross0.11_all.deb - http://cz.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8-armhf-cross/libgcc-4.8-dev-armhf-cross_4.8.2-16ubuntu4cross0.11_all.deb - http://cz.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8-armhf-cross/libstdc++-4.8-dev-armhf-cross_4.8.2-16ubuntu4cross0.11_all.deb - http://cz.archive.ubuntu.com/ubuntu/pool/main/g/gcc-4.8-armhf-cross/libstdc++6-armhf-cross_4.8.2-16ubuntu4cross0.11_all.deb - http://cz.archive.ubuntu.com/ubuntu/pool/main/a/armhf-cross-toolchain-base/linux-libc-dev-armhf-cross_3.13.0-12.32cross1.104_all.deb - http://cz.archive.ubuntu.com/ubuntu/pool/main/g/gcc-defaults-armhf-cross/pkg-config-arm-linux-gnueabihf_4.8.2-1_amd64.deb) -noextract=("${source[@]%%::*}") -md5sums=('82f8e221d556c669dfba6afe1b466b3b' - '930c0f7c603cd495713815a3155db98d' - 'f5a3fb1964be9b5add1745d9bc08fc31' - '5b355c1ad8db3f3d5049fa3ca11436a5' - '6321b4f2e7dc77c2360326e422abfecb' - '44038e3315f9f6cce1a93837d1fbe501' - '612d900163d73a2128978f05a2988cab' - 'aaa45d19b6d705540c8f293809d979ed' - 'a3ad12300426a6783cf2d450ec7b8bbb' - '9942268c1d8d2ce50e609804c23020ac' - '76602a7c49f9954a995cbf17e57222c7' - 'a96f1e852a83d4fa1c1f0606b70e324c' - '09d74e8aa5a50405093bb638a14834ad' - '793b1eb0c087ec67c26055159f614abd' - '152d3e8b858b5e0b5290fcdc3303156a' - '64de4e6404e1d0d1af24a75bed89edf8' - 'ebb146b9a023086f633f8c31c4469cb0') - -package() { - cd "${srcdir}" - for FILE in *.deb; do - deb2targz $FILE - tar xf ${FILE%.deb}.tar.xz --directory "${pkgdir}" - done - #mv "${pkgdir}/usr/lib/x86_64-linux-gnu/"* "${pkgdir}/usr/lib" -} -# vim:set ts=2 sw=2 et: diff --git a/platform/arm-linux/arm-toolchain.cmake b/platform/arm-linux/arm-toolchain.cmake index 38ee0bc34..b863d2fe8 100644 --- a/platform/arm-linux/arm-toolchain.cmake +++ b/platform/arm-linux/arm-toolchain.cmake @@ -14,107 +14,15 @@ # # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -set(CMAKE_SYSTEM_VERSION 1) +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm) +set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc CACHE STRING "") +set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++ CACHE STRING "") +set(PKG_CONFIG_EXECUTABLE arm-linux-gnueabihf-pkg-config) -set(TRIPLE "arm-linux-gnueabihf") -set(TOOLCHAIN_ROOT /usr) - -if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows) - set(TOOL_OS_SUFFIX .exe) -else() - set(TOOL_OS_SUFFIX) -endif() - -set(CMAKE_SYSTEM_NAME Linux - CACHE STRING "operating system" FORCE) -set(CMAKE_SYSTEM_PROCESSOR ARM - CACHE STRING "processor architecture" FORCE) - -find_program(CMAKE_C_COMPILER NAMES - "${TRIPLE}-gcc${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-14${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-13${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-12${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-11${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-10${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-9${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-8${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-7${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-6${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-5${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-4.9${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-4.8${TOOL_OS_SUFFIX}" - "gcc-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-14-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-13-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-12-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-11-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-10-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-9-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-8-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-7-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-6-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-5-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-4.9-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-4.8-${TRIPLE}${TOOL_OS_SUFFIX}" - PATHS "${TOOLCHAIN_ROOT}/bin/" DOC "gcc") - -find_program(CMAKE_CXX_COMPILER NAMES - "${TRIPLE}-g++${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-14${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-13${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-12${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-11${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-10${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-9${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-8${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-7${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-6${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-5${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-4.9${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-4.8${TOOL_OS_SUFFIX}" - "g++-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-14-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-13-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-12-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-11-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-10-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-9-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-8-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-7-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-6-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-5-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-4.9-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-4.8-${TRIPLE}${TOOL_OS_SUFFIX}" - PATHS "${TOOLCHAIN_ROOT}/bin/" DOC "g++") - -set(CMAKE_AR "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-ar${TOOL_OS_SUFFIX}" - CACHE PATH "archive" FORCE) -set(CMAKE_LINKER "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-ld${TOOL_OS_SUFFIX}" - CACHE PATH "linker" FORCE) -set(CMAKE_NM "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-nm${TOOL_OS_SUFFIX}" - CACHE PATH "nm" FORCE) -set(CMAKE_OBJCOPY "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-objcopy${TOOL_OS_SUFFIX}" - CACHE PATH "objcopy" FORCE) -set(CMAKE_OBJDUMP "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-objdump${TOOL_OS_SUFFIX}" - CACHE PATH "objdump" FORCE) -set(CMAKE_STRIP "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-strip${TOOL_OS_SUFFIX}" - CACHE PATH "strip" FORCE) -set(CMAKE_RANLIB "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-ranlib${TOOL_OS_SUFFIX}" - CACHE PATH "ranlib" FORCE) - -set(CMAKE_FIND_ROOT_PATH /usr/${TRIPLE}) +set(CMAKE_FIND_ROOT_PATH /usr/arm-linux-gnueabihf) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_CXX_LINK_EXECUTABLE " \ - -o ${LINKER_LIBS}" - CACHE STRING "Linker command line" FORCE) - -find_program(QEMU_ARM_EXECUTABLE qemu-arm) -if(NOT QEMU_ARM_EXECUTABLE MATCHES NOTFOUND) - set(CMAKE_CROSSCOMPILING_EMULATOR - ${QEMU_ARM_EXECUTABLE} -L ${CMAKE_FIND_ROOT_PATH} - CACHE STRING "qemu" FORCE) -endif() +set(CMAKE_CROSSCOMPILING_EMULATOR qemu-armhf -L ${CMAKE_FIND_ROOT_PATH} CACHE STRING "") diff --git a/platform/riscv64-linux/riscv64-gcc-toolchain.cmake b/platform/riscv64-linux/riscv64-gcc-toolchain.cmake index 7003f52f5..b41abbf0f 100644 --- a/platform/riscv64-linux/riscv64-gcc-toolchain.cmake +++ b/platform/riscv64-linux/riscv64-gcc-toolchain.cmake @@ -14,107 +14,15 @@ # # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -set(CMAKE_SYSTEM_VERSION 1) +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR riscv64) +set(CMAKE_C_COMPILER riscv64-linux-gnu-gcc CACHE STRING "") +set(CMAKE_CXX_COMPILER riscv64-linux-gnu-g++ CACHE STRING "") +set(PKG_CONFIG_EXECUTABLE riscv64-linux-gnu-pkg-config) -set(TRIPLE "riscv64-linux-gnu") -set(TOOLCHAIN_ROOT /usr) - -if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows) - set(TOOL_OS_SUFFIX .exe) -else() - set(TOOL_OS_SUFFIX) -endif() - -set(CMAKE_SYSTEM_NAME Linux - CACHE STRING "operating system" FORCE) -set(CMAKE_SYSTEM_PROCESSOR riscv64 - CACHE STRING "processor architecture" FORCE) - -find_program(CMAKE_C_COMPILER NAMES - "${TRIPLE}-gcc${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-14${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-13${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-12${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-11${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-10${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-9${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-8${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-7${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-6${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-5${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-4.9${TOOL_OS_SUFFIX}" - "${TRIPLE}-gcc-4.8${TOOL_OS_SUFFIX}" - "gcc-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-14-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-13-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-12-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-11-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-10-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-9-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-8-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-7-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-6-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-5-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-4.9-${TRIPLE}${TOOL_OS_SUFFIX}" - "gcc-4.8-${TRIPLE}${TOOL_OS_SUFFIX}" - PATHS "${TOOLCHAIN_ROOT}/bin/" DOC "gcc") - -find_program(CMAKE_CXX_COMPILER NAMES - "${TRIPLE}-g++${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-14${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-13${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-12${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-11${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-10${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-9${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-8${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-7${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-6${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-5${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-4.9${TOOL_OS_SUFFIX}" - "${TRIPLE}-g++-4.8${TOOL_OS_SUFFIX}" - "g++-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-14-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-13-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-12-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-11-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-10-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-9-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-8-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-7-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-6-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-5-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-4.9-${TRIPLE}${TOOL_OS_SUFFIX}" - "g++-4.8-${TRIPLE}${TOOL_OS_SUFFIX}" - PATHS "${TOOLCHAIN_ROOT}/bin/" DOC "g++") - -set(CMAKE_AR "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-ar${TOOL_OS_SUFFIX}" - CACHE PATH "archive" FORCE) -set(CMAKE_LINKER "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-ld${TOOL_OS_SUFFIX}" - CACHE PATH "linker" FORCE) -set(CMAKE_NM "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-nm${TOOL_OS_SUFFIX}" - CACHE PATH "nm" FORCE) -set(CMAKE_OBJCOPY "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-objcopy${TOOL_OS_SUFFIX}" - CACHE PATH "objcopy" FORCE) -set(CMAKE_OBJDUMP "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-objdump${TOOL_OS_SUFFIX}" - CACHE PATH "objdump" FORCE) -set(CMAKE_STRIP "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-strip${TOOL_OS_SUFFIX}" - CACHE PATH "strip" FORCE) -set(CMAKE_RANLIB "${TOOLCHAIN_ROOT}/bin/${TRIPLE}-ranlib${TOOL_OS_SUFFIX}" - CACHE PATH "ranlib" FORCE) - -set(CMAKE_FIND_ROOT_PATH /usr/${TRIPLE}) +set(CMAKE_FIND_ROOT_PATH /usr/riscv64-linux-gnu) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_CXX_LINK_EXECUTABLE " \ - -o ${LINKER_LIBS}" - CACHE STRING "Linker command line" FORCE) - -find_program(QEMU_RISCV64_EXECUTABLE qemu-riscv64) -if(NOT QEMU_RISCV64_EXECUTABLE MATCHES NOTFOUND) - set(CMAKE_CROSSCOMPILING_EMULATOR - ${QEMU_RISCV64_EXECUTABLE} -L ${CMAKE_FIND_ROOT_PATH} - CACHE STRING "qemu" FORCE) -endif() +set(CMAKE_CROSSCOMPILING_EMULATOR qemu-riscv64 -L ${CMAKE_FIND_ROOT_PATH} CACHE STRING "")