build: use -ffunction-sections -fdata-sections for the Zig compiler on ARM

See 7daf0b6f46; builds for ARM can run into the
same problems due to limited branch range.
This commit is contained in:
Alex Rønne Petersen 2026-02-26 10:11:15 +01:00 committed by Andrew Kelley
parent 7bc6546fdf
commit 2d867223be
2 changed files with 2 additions and 2 deletions

View file

@ -609,7 +609,7 @@ else()
set(ZIG1_COMPILE_FLAGS "-std=c99 -Os") set(ZIG1_COMPILE_FLAGS "-std=c99 -Os")
set(ZIG2_COMPILE_FLAGS "-std=c99 -O0 -fno-sanitize=undefined -fno-stack-protector") set(ZIG2_COMPILE_FLAGS "-std=c99 -O0 -fno-sanitize=undefined -fno-stack-protector")
# Must match the condition in build.zig. # 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(ZIG1_COMPILE_FLAGS "${ZIG1_COMPILE_FLAGS} -ffunction-sections -fdata-sections")
set(ZIG2_COMPILE_FLAGS "${ZIG2_COMPILE_FLAGS} -ffunction-sections -fdata-sections") set(ZIG2_COMPILE_FLAGS "${ZIG2_COMPILE_FLAGS} -ffunction-sections -fdata-sections")
endif() endif()

View file

@ -773,7 +773,7 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerModOptions) *std.Build.Ste
exe.stack_size = stack_size; exe.stack_size = stack_size;
// Must match the condition in CMakeLists.txt. // 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_function_sections = function_data_sections;
exe.link_data_sections = function_data_sections; exe.link_data_sections = function_data_sections;