summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorEtan Kissling <etan@status.im>2023-06-24 08:13:43 +0200
committerGitHub <noreply@github.com>2023-06-24 08:13:43 +0200
commitc6c85f84db3bd7bd2d1c5823020c7df007f1bb69 (patch)
tree0836375d1dfae691ad2b18b4db9d3bae78a0561b
parentbeaac609ab5756114a0938360a60eca0f605f4a1 (diff)
downloadNim-c6c85f84db3bd7bd2d1c5823020c7df007f1bb69.tar.gz
macOS `ar` doesn't support `@` syntax (#22146)
When the linker command line is long, Nim compiler generates a file for
passing the linker arguments. On `macOS`, that mechanism fails as the
`@` syntax is not supported by `ar`. Use `xargs` instead to pass the
linker arguments file.
-rw-r--r--compiler/extccomp.nim5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim
index 040fe35e1..832242456 100644
--- a/compiler/extccomp.nim
+++ b/compiler/extccomp.nim
@@ -834,7 +834,10 @@ proc linkViaResponseFile(conf: ConfigRef; cmd: string) =
   else:
     writeFile(linkerArgs, args)
   try:
-    execLinkCmd(conf, cmd.substr(0, last) & " @" & linkerArgs)
+    when defined(macosx):
+      execLinkCmd(conf, "xargs " & cmd.substr(0, last) & " < " & linkerArgs)
+    else:
+      execLinkCmd(conf, cmd.substr(0, last) & " @" & linkerArgs)
   finally:
     removeFile(linkerArgs)