summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaikari <[email protected]>2026-01-28 02:53:09 +0300
committerSaikari <[email protected]>2026-01-28 02:53:09 +0300
commit4489af7a955b9bef05968d69f29747cef2609e3b (patch)
tree318f5e6c74306b1210d5ecc8fc1d7d1adba458ee
parenta9761ddbd051326d11682be707e672158cd2710b (diff)
feat: add syslink handling for Nim targets and update xmake.lua configurations
-rw-r--r--tests/projects/nim/link_library/xmake.lua4
-rw-r--r--xmake/languages/nim/xmake.lua2
-rw-r--r--xmake/modules/core/tools/nim.lua13
3 files changed, 19 insertions, 0 deletions
diff --git a/tests/projects/nim/link_library/xmake.lua b/tests/projects/nim/link_library/xmake.lua
index cbcef108b..3d032a0f5 100644
--- a/tests/projects/nim/link_library/xmake.lua
+++ b/tests/projects/nim/link_library/xmake.lua
@@ -5,20 +5,24 @@ target("executablestatic")
set_kind("binary")
add_files("mainlib.nim")
add_deps("staticlib")
+ add_syslinks("pthread", "m")
target("executableshared")
set_kind("binary")
add_files("maindll.nim")
add_deps("sharedlib")
+ add_syslinks("pthread", "m")
target("staticlib")
set_kind("static")
add_files("static.nim")
add_includedirs("inc")
add_headerfiles("inc/*.h")
+ add_syslinks("pthread", "m")
target("sharedlib")
set_kind("shared")
add_files("shared.nim")
add_includedirs("inc")
add_headerfiles("inc/*.h")
+ add_syslinks("pthread", "m")
diff --git a/xmake/languages/nim/xmake.lua b/xmake/languages/nim/xmake.lua
index 65ad6429b..576ee4e0c 100644
--- a/xmake/languages/nim/xmake.lua
+++ b/xmake/languages/nim/xmake.lua
@@ -51,6 +51,7 @@ language("nim")
, "toolchain.rpathdirs"
, "config.links"
, "target.links"
+ , "target.syslinks"
, "toolchain.links"
}
, shared = {
@@ -61,6 +62,7 @@ language("nim")
, "toolchain.linkdirs"
, "config.links"
, "target.links"
+ , "target.syslinks"
, "toolchain.links"
}
, static = {
diff --git a/xmake/modules/core/tools/nim.lua b/xmake/modules/core/tools/nim.lua
index 5f1c509ce..8a76ec865 100644
--- a/xmake/modules/core/tools/nim.lua
+++ b/xmake/modules/core/tools/nim.lua
@@ -142,6 +142,19 @@ function nf_link(self, lib)
end
end
+-- make the syslink flag
+function nf_syslink(self, lib)
+ if self:is_plat("windows") then
+ return string.format("--passL:\"%s.lib\"", lib)
+ else
+ if lib == "pthread" then
+ return "--threads:on --passL:\"-lpthread\" --dynlibOverride:\"pthread\""
+ else
+ return string.format("--passL:\"-l%s\"", lib)
+ end
+ end
+end
+
-- make the linkdir flag
function nf_linkdir(self, dir)
if self:is_plat("windows") then