commit c166c49b1917bb682d6949150feb59e54d6c0b2d (tree)
parent dde76ae5f7f74f9173650d4b420ed44e183b1337
Author: Alex Rønne Petersen <alex@alexrp.com>
Date: Mon, 27 Apr 2026 13:45:35 +0200
build: use -ffunction-sections -fdata-sections for the Zig compiler on Hexagon
Diffstat:
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
@@ -609,7 +609,7 @@ else()
set(ZIG1_COMPILE_FLAGS "-std=c99 -Os -fno-strict-aliasing")
set(ZIG2_COMPILE_FLAGS "-std=c99 -O0 -fno-sanitize=undefined -fno-stack-protector -fno-strict-aliasing")
# Must match the condition in build.zig.
- if(ZIG_HOST_TARGET_ARCH MATCHES "^(arm|thumb)(eb)?$" OR ZIG_HOST_TARGET_ARCH MATCHES "^powerpc(64)?(le)?$")
+ if(ZIG_HOST_TARGET_ARCH MATCHES "^(arm|thumb)(eb)?$" OR ZIG_HOST_TARGET_ARCH EQUAL "hexagon" 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
@@ -780,7 +780,19 @@ 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.isArm() or options.target.result.cpu.arch.isPowerPC();
+ const function_data_sections = switch (options.target.result.cpu.arch) {
+ .arm,
+ .armeb,
+ .thumb,
+ .thumbeb,
+ .hexagon,
+ .powerpc,
+ .powerpcle,
+ .powerpc64,
+ .powerpc64le,
+ => true,
+ else => false,
+ };
exe.link_function_sections = function_data_sections;
exe.link_data_sections = function_data_sections;