Skip to content

Commit 130fb5c

Browse files
erikarvstedtandrewrk
authored andcommitted
cmake: support setting the dynamic linker
1 parent 22a97cd commit 130fb5c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

CMakeLists.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ endif()
109109

110110
set(ZIG_TARGET_TRIPLE "native" CACHE STRING "arch-os-abi to output binaries for")
111111
set(ZIG_TARGET_MCPU "native" CACHE STRING "-mcpu parameter to output binaries for")
112+
set(ZIG_TARGET_DYNAMIC_LINKER "" CACHE STRING
113+
"Override the dynamic linker used by the Zig binary. Default is to auto-detect the dynamic linker.")
112114
set(ZIG_SINGLE_THREADED off CACHE BOOL "limit the zig compiler to use only 1 thread")
113115
set(ZIG_AR_WORKAROUND off CACHE BOOL "append 'ar' subcommand to CMAKE_AR")
114116

@@ -897,12 +899,16 @@ if(ZIG_STATIC AND NOT MSVC)
897899
else()
898900
set(ZIG_STATIC_ARG "")
899901
endif()
900-
901902
if(CMAKE_POSITION_INDEPENDENT_CODE OR ZIG_PIE)
902903
set(ZIG_PIE_ARG "-Dpie")
903904
else()
904905
set(ZIG_PIE_ARG "")
905906
endif()
907+
if("${ZIG_TARGET_DYNAMIC_LINKER}" STREQUAL "")
908+
set(ZIG_DYNAMIC_LINKER_ARG "")
909+
else()
910+
set(ZIG_DYNAMIC_LINKER_ARG "-Ddynamic-linker=${ZIG_TARGET_DYNAMIC_LINKER}")
911+
endif()
906912

907913
# -Dno-langref is currently hardcoded because building the langref takes too damn long
908914
# To obtain these two forms of documentation, run zig build against stage3 rather than stage2.
@@ -918,6 +924,7 @@ set(ZIG_BUILD_ARGS
918924
${ZIG_PIE_ARG}
919925
"-Dtarget=${ZIG_TARGET_TRIPLE}"
920926
"-Dcpu=${ZIG_TARGET_MCPU}"
927+
${ZIG_DYNAMIC_LINKER_ARG}
921928
"-Dversion-string=${RESOLVED_ZIG_VERSION}"
922929
)
923930

0 commit comments

Comments
 (0)