diff options
Diffstat (limited to 'compiler/extccomp.nim')
-rw-r--r-- | compiler/extccomp.nim | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 5a1d33ade..ab42f4f52 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -223,7 +223,6 @@ compiler bcc: props: {hasSwitchRange, hasComputedGoto, hasCpp, hasGcGuard, hasAttribute}) - # Digital Mars C Compiler compiler dmc: result = ( @@ -376,6 +375,11 @@ proc nameToCC*(name: string): TSystemCC = return i result = ccNone +proc isVSCompatible*(conf: ConfigRef): bool = + return conf.cCompiler == ccVcc or + conf.cCompiler == ccClangCl or + (conf.cCompiler == ccIcl and conf.target.hostOS in osDos..osWindows) + proc getConfigVar(conf: ConfigRef; c: TSystemCC, suffix: string): string = # use ``cpu.os.cc`` for cross compilation, unless ``--compileOnly`` is given # for niminst support @@ -734,8 +738,9 @@ proc getLinkCmd(conf: ConfigRef; output: AbsoluteFile, # way of being able to debug and rebuild the program at the same time. This # is accomplished using the /PDB:<filename> flag (there also exists the # /PDBALTPATH:<filename> flag). The only downside is that the .pdb files are - # atleast 5-10mb big and will quickly accumulate. There is a hacky solution: - # we could try to delete all .pdb files with a pattern and swallow exceptions. + # atleast 300kb big (when linking statically to the runtime - or else 5mb+) + # and will quickly accumulate. There is a hacky solution: we could try to + # delete all .pdb files with a pattern and swallow exceptions. # # links about .pdb files and hot code reloading: # https://ourmachinery.com/post/dll-hot-reloading-in-theory-and-practice/ @@ -747,7 +752,7 @@ proc getLinkCmd(conf: ConfigRef; output: AbsoluteFile, # and a bit about the .pdb format in case that is ever needed: # https://github.com/crosire/blink # http://www.debuginfo.com/articles/debuginfomatch.html#pdbfiles - if conf.hcrOn and conf.cCompiler == ccVcc: + if conf.hcrOn and isVSCompatible(conf): let t = now() let pdb = output.string & "." & format(t, "MMMM-yyyy-HH-mm-") & $t.nanosecond & ".pdb" result.add " /link /PDB:" & pdb @@ -838,7 +843,7 @@ proc hcrLinkTargetName(conf: ConfigRef, objFile: string, isMain = false): Absolu let basename = splitFile(objFile).name let targetName = if isMain: basename & ".exe" else: platform.OS[conf.target.targetOS].dllFrmt % basename - result = conf.nimcacheDir / RelativeFile(targetName) + result = conf.getNimcacheDir / RelativeFile(targetName) proc callCCompiler*(conf: ConfigRef) = var @@ -883,7 +888,7 @@ proc callCCompiler*(conf: ConfigRef) = add(cmds, getLinkCmd(conf, linkTarget, objfiles & " " & quoteShell(objFile), buildDll)) # try to remove all .pdb files for the current binary so they don't accumulate endlessly in the nimcache # for more info check the comment inside of getLinkCmd() where the /PDB:<filename> MSVC flag is used - if conf.cCompiler == ccVcc: + if isVSCompatible(conf): for pdb in walkFiles(objFile & ".*.pdb"): discard tryRemoveFile(pdb) # execute link commands in parallel - output will be a bit different |