authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-02-26 10:11:15+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-02-26 20:48:29+01:00
log2d867223be4139ac55b1be1f5c19eee8a393c62a
tree32873d23bbce1f0bb3436b5a03a6f0e0f3942343
parent7bc6546fdfadf3e3c91ee2be1387913599a63e4a

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.

2 files changed, 2 insertions(+), 2 deletions(-)

CMakeLists.txt+1-1
......@@ -609,7 +609,7 @@ else()
609609 set(ZIG1_COMPILE_FLAGS "-std=c99 -Os")
610610 set(ZIG2_COMPILE_FLAGS "-std=c99 -O0 -fno-sanitize=undefined -fno-stack-protector")
611611 # Must match the condition in build.zig.
612 if(ZIG_HOST_TARGET_ARCH MATCHES "^powerpc(64)?(le)?$")
612 if(ZIG_HOST_TARGET_ARCH MATCHES "^(arm|thumb)(eb)?$" OR ZIG_HOST_TARGET_ARCH MATCHES "^powerpc(64)?(le)?$")
613613 set(ZIG1_COMPILE_FLAGS "${ZIG1_COMPILE_FLAGS} -ffunction-sections -fdata-sections")
614614 set(ZIG2_COMPILE_FLAGS "${ZIG2_COMPILE_FLAGS} -ffunction-sections -fdata-sections")
615615 endif()
build.zig+1-1
......@@ -773,7 +773,7 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerModOptions) *std.Build.Ste
773773 exe.stack_size = stack_size;
774774
775775 // Must match the condition in CMakeLists.txt.
776 const function_data_sections = options.target.result.cpu.arch.isPowerPC();
776 const function_data_sections = options.target.result.cpu.arch.isArm() or options.target.result.cpu.arch.isPowerPC();
777777
778778 exe.link_function_sections = function_data_sections;
779779 exe.link_data_sections = function_data_sections;