From 2d867223be4139ac55b1be1f5c19eee8a393c62a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Thu, 26 Feb 2026 10:11:15 +0100 Subject: [PATCH] build: use -ffunction-sections -fdata-sections for the Zig compiler on ARM See 7daf0b6f4660245ac518c663f8971aad7e540da8; builds for ARM can run into the same problems due to limited branch range. --- CMakeLists.txt | 2 +- build.zig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ace474448..06cc1cd8dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -609,7 +609,7 @@ else() set(ZIG1_COMPILE_FLAGS "-std=c99 -Os") set(ZIG2_COMPILE_FLAGS "-std=c99 -O0 -fno-sanitize=undefined -fno-stack-protector") # Must match the condition in build.zig. - if(ZIG_HOST_TARGET_ARCH MATCHES "^powerpc(64)?(le)?$") + if(ZIG_HOST_TARGET_ARCH MATCHES "^(arm|thumb)(eb)?$" OR ZIG_HOST_TARGET_ARCH MATCHES "^powerpc(64)?(le)?$") set(ZIG1_COMPILE_FLAGS "${ZIG1_COMPILE_FLAGS} -ffunction-sections -fdata-sections") set(ZIG2_COMPILE_FLAGS "${ZIG2_COMPILE_FLAGS} -ffunction-sections -fdata-sections") endif() diff --git a/build.zig b/build.zig index 5b723ad5b2..152ae161d8 100644 --- a/build.zig +++ b/build.zig @@ -773,7 +773,7 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerModOptions) *std.Build.Ste exe.stack_size = stack_size; // Must match the condition in CMakeLists.txt. - const function_data_sections = options.target.result.cpu.arch.isPowerPC(); + const function_data_sections = options.target.result.cpu.arch.isArm() or options.target.result.cpu.arch.isPowerPC(); exe.link_function_sections = function_data_sections; exe.link_data_sections = function_data_sections;