]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
toolchain: Create a toolchain configuration file
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 18 Feb 2026 11:46:48 +0000 (11:46 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 19 Feb 2026 11:43:01 +0000 (11:43 +0000)
This is needed because we are currently cross-compiling the toolchain
for riscv64 on x86_64. However, cmake does not take the time to figure
out what it should actually be doing and needs to be explicitely told.

So that we don't have to reinvent the wheel more than one we create the
configuration file at the beginning and automatically extend the cmake
command line with the settings that we need.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
lfs/Config
lfs/stage1

index 8547f69c6372a6a7eacf3f858bcc92fe26ad03d4..56754f299a42310679461b678f117139932f6cd2 100644 (file)
@@ -130,6 +130,14 @@ ifeq "$(BUILD_ARCH)" "aarch64"
        GRUB_ARCH = arm64
 endif
 
+CMAKE = cmake
+
+# In the toolchain, we might be cross-compiling and need cmake to know
+ifeq "$(TOOLCHAIN)" "1"
+       CMAKE += \
+               -D CMAKE_TOOLCHAIN_FILE=$(TOOLS_DIR)/share/cmake/toolchain.cmake
+endif
+
 # Go
 export GOARCH
 export GOOS   = linux
index 2f8db61a1c07f9d770fd8c367629463694691876..1d289abbe33d1516cd27a81ce93ef1094cb0a162 100644 (file)
@@ -55,4 +55,15 @@ ifeq "$(BUILD_ARCH)" "riscv64"
        ln -svf . $(TOOLS_DIR)/lib/lp64d
 endif
 
+       # Write a cmake toolchain file so cmake knows we're targeting $(BUILD_ARCH)
+       -mkdir -pv $(TOOLS_DIR)/share/cmake
+       echo "set(CMAKE_SYSTEM_NAME      Linux)" > \
+               $(TOOLS_DIR)/share/cmake/toolchain.cmake
+       echo "set(CMAKE_SYSTEM_PROCESSOR $(BUILD_ARCH))" >> \
+               $(TOOLS_DIR)/share/cmake/toolchain.cmake
+       echo "set(CMAKE_C_COMPILER       $(TOOLS_DIR)/bin/cc)"  >> \
+               $(TOOLS_DIR)/share/cmake/toolchain.cmake
+       echo "set(CMAKE_CXX_COMPILER     $(TOOLS_DIR)/bin/c++)" >> \
+               $(TOOLS_DIR)/share/cmake/toolchain.cmake
+
        @$(POSTBUILD)