summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorEmery Hemingway <githubjunk@spam.works>2017-03-23 07:27:16 -0500
committerAndreas Rumpf <rumpf_a@web.de>2017-03-23 13:27:16 +0100
commitd508303fadc65bacbf15ada83da37660f5552107 (patch)
treec0972657e1625440c7594eba10f628beee65a090
parentbe174fc3c731f1aecf07d7750c038dbb7a018812 (diff)
downloadNim-d508303fadc65bacbf15ada83da37660f5552107.tar.gz
fix empty link file list during external compilation (#5577)
-rw-r--r--compiler/extccomp.nim26
1 files changed, 18 insertions, 8 deletions
diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim
index 70cd411fe..1af113be6 100644
--- a/compiler/extccomp.nim
+++ b/compiler/extccomp.nim
@@ -785,14 +785,24 @@ proc writeJsonBuildInstructions*(projectfile: string) =
       else:
         lit "],\L"
 
-  proc linkfiles(f: File; buf, objfiles: var string; toLink: seq[string]) =
-    for i, it in toLink:
-      let objfile = addFileExt(it, CC[cCompiler].objExt)
-      str(objfile)
+  proc linkfiles(f: File; buf, objfiles: var string) =
+    for i, it in externalToLink:
+      let
+        objFile = if noAbsolutePaths(): it.extractFilename else: it
+        objStr = addFileExt(objFile, CC[cCompiler].objExt)
       add(objfiles, ' ')
-      add(objfiles, quoteShell(objfile))
-      
-      if i == toLink.high:
+      add(objfiles, objStr)
+      str objStr
+      if toCompile.len == 0 and i == externalToLink.high:
+        lit "\L"
+      else:
+        lit ",\L"
+    for i, x in toCompile:
+      let objStr = quoteShell(x.obj)
+      add(objfiles, ' ')
+      add(objfiles, objStr)
+      str objStr
+      if i == toCompile.high:
         lit "\L"
       else:
         lit ",\L"
@@ -809,7 +819,7 @@ proc writeJsonBuildInstructions*(projectfile: string) =
     lit "],\L\"link\":[\L"
     var objfiles = ""
     # XXX add every file here that is to link
-    linkfiles(f, buf, objfiles, externalToLink)
+    linkfiles(f, buf, objfiles)
 
     lit "],\L\"linkcmd\": "
     str getLinkCmd(projectfile, objfiles)