From 104778fa617e6eb5afd8386267f37c45b3f607e0 Mon Sep 17 00:00:00 2001 From: Sami Ahmed Date: Sun, 5 Apr 2026 04:04:48 -0700 Subject: [PATCH] Fix macOS build: restrict -z relro/now to Linux only The -Wl,-z,relro and -Wl,-z,now flags are ELF-specific and not supported by macOS's linker. Guard them with if(NOT APPLE). Co-Authored-By: Claude Opus 4.6 --- cmake/AddCompilerFlags.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmake/AddCompilerFlags.cmake b/cmake/AddCompilerFlags.cmake index f0f8969..16a2667 100644 --- a/cmake/AddCompilerFlags.cmake +++ b/cmake/AddCompilerFlags.cmake @@ -22,7 +22,10 @@ if(NOT WIN32) add_compile_options(-fno-stack-protector) add_compile_options(-fstack-protector-all -Wstack-protector) add_compile_definitions(_FORTIFY_SOURCE=2) - add_link_options(-Wl,-z,relro -Wl,-z,now) + # -z relro/now is ELF-only (Linux); macOS linker doesn't support it + if(NOT APPLE) + add_link_options(-Wl,-z,relro -Wl,-z,now) + endif() endif() # ── PIE (position-independent executables) ──