authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-04-27 13:45:35+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-04-27 13:55:38+02:00
logc166c49b1917bb682d6949150feb59e54d6c0b2d
tree0048e3bc334b5b6f1a705632a90037cd0688694d
parentdde76ae5f7f74f9173650d4b420ed44e183b1337
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

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


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

CMakeLists.txt+1-1
...@@ -609,7 +609,7 @@ else()...@@ -609,7 +609,7 @@ else()
609 set(ZIG1_COMPILE_FLAGS "-std=c99 -Os -fno-strict-aliasing")609 set(ZIG1_COMPILE_FLAGS "-std=c99 -Os -fno-strict-aliasing")
610 set(ZIG2_COMPILE_FLAGS "-std=c99 -O0 -fno-sanitize=undefined -fno-stack-protector -fno-strict-aliasing")610 set(ZIG2_COMPILE_FLAGS "-std=c99 -O0 -fno-sanitize=undefined -fno-stack-protector -fno-strict-aliasing")
611 # Must match the condition in build.zig.611 # Must match the condition in build.zig.
612 if(ZIG_HOST_TARGET_ARCH MATCHES "^(arm|thumb)(eb)?$" OR ZIG_HOST_TARGET_ARCH MATCHES "^powerpc(64)?(le)?$")612 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)?$")
613 set(ZIG1_COMPILE_FLAGS "${ZIG1_COMPILE_FLAGS} -ffunction-sections -fdata-sections")613 set(ZIG1_COMPILE_FLAGS "${ZIG1_COMPILE_FLAGS} -ffunction-sections -fdata-sections")
614 set(ZIG2_COMPILE_FLAGS "${ZIG2_COMPILE_FLAGS} -ffunction-sections -fdata-sections")614 set(ZIG2_COMPILE_FLAGS "${ZIG2_COMPILE_FLAGS} -ffunction-sections -fdata-sections")
615 endif()615 endif()
build.zig+13-1
...@@ -780,7 +780,19 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerModOptions) *std.Build.Ste...@@ -780,7 +780,19 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerModOptions) *std.Build.Ste
780 exe.stack_size = stack_size;780 exe.stack_size = stack_size;
781781
782 // Must match the condition in CMakeLists.txt.782 // Must match the condition in CMakeLists.txt.
783 const function_data_sections = options.target.result.cpu.arch.isArm() or options.target.result.cpu.arch.isPowerPC();783 const function_data_sections = switch (options.target.result.cpu.arch) {
784 .arm,
785 .armeb,
786 .thumb,
787 .thumbeb,
788 .hexagon,
789 .powerpc,
790 .powerpcle,
791 .powerpc64,
792 .powerpc64le,
793 => true,
794 else => false,
795 };
784796
785 exe.link_function_sections = function_data_sections;797 exe.link_function_sections = function_data_sections;
786 exe.link_data_sections = function_data_sections;798 exe.link_data_sections = function_data_sections;