Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

externalToLink: use quoteShell to avoid issues with spaces in paths for {.link.} pragmas #17875

Merged
merged 1 commit into from
Apr 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions compiler/extccomp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,7 @@ proc jsonBuildInstructionsFile*(conf: ConfigRef): AbsoluteFile =
result = getNimcacheDir(conf) / conf.outFile.changeFileExt("json")

proc writeJsonBuildInstructions*(conf: ConfigRef) =
# xxx use std/json instead, will result in simpler, more maintainable code.
template lit(x: string) = f.write x
template str(x: string) =
buf.setLen 0
Expand All @@ -964,23 +965,18 @@ proc writeJsonBuildInstructions*(conf: ConfigRef) =
proc linkfiles(conf: ConfigRef; f: File; buf, objfiles: var string; clist: CfileList;
llist: seq[string]) =
var pastStart = false
for it in llist:
let objfile = if noAbsolutePaths(conf): it.extractFilename
else: it
let objstr = addFileExt(objfile, CC[conf.cCompiler].objExt)
template impl(path) =
let path2 = quoteShell(path)
objfiles.add(' ')
objfiles.add(objstr)
objfiles.add(path2)
if pastStart: lit ",\L"
str objstr
str path2
pastStart = true

for it in llist:
let objfile = if noAbsolutePaths(conf): it.extractFilename else: it
impl(addFileExt(objfile, CC[conf.cCompiler].objExt))
for it in clist:
let objstr = quoteShell(it.obj)
objfiles.add(' ')
objfiles.add(objstr)
if pastStart: lit ",\L"
str objstr
pastStart = true
impl(it.obj)
lit "\L"

proc depfiles(conf: ConfigRef; f: File; buf: var string) =
Expand Down