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 <noreply@anthropic.com>
This commit is contained in:
2026-04-05 04:04:48 -07:00
parent 6a124cb411
commit 1b416ae704
+4 -1
View File
@@ -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) ──