diff options
author | Jaremy Creechley <creechley@gmail.com> | 2023-04-17 05:17:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-17 14:17:02 +0200 |
commit | 1af21c26680ae1251e09852b3a643c31e8f45c21 (patch) | |
tree | 3155912a0289628340a2c97e190ed756eb3653df | |
parent | 938f5c5e990cd09d934d1d489e23fc0300152407 (diff) | |
download | Nim-1af21c26680ae1251e09852b3a643c31e8f45c21.tar.gz |
change compile pragma to use mangled compile objects (#21678)
change compile pragma to use mangle
-rw-r--r-- | compiler/pragmas.nim | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 2efef6fee..c752c5263 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -12,7 +12,7 @@ import os, condsyms, ast, astalgo, idents, semdata, msgs, renderer, wordrecg, ropes, options, strutils, extccomp, math, magicsys, trees, - types, lookups, lineinfos, pathutils, linter + types, lookups, lineinfos, pathutils, linter, modulepaths when defined(nimPreviewSlimSystem): import std/assertions @@ -517,6 +517,10 @@ proc relativeFile(c: PContext; n: PNode; ext=""): AbsoluteFile = if result.isEmpty: result = AbsoluteFile s proc processCompile(c: PContext, n: PNode) = + ## This pragma can take two forms. The first is a simple file input: + ## {.compile: "file.c".} + ## The second is a tuple where the second arg is the output name strutils formatter: + ## {.compile: ("file.c", "$1.o").} proc docompile(c: PContext; it: PNode; src, dest: AbsoluteFile; customArgs: string) = var cf = Cfile(nimname: splitFile(src).name, cname: src, obj: dest, flags: {CfileFlag.External}, @@ -565,7 +569,8 @@ proc processCompile(c: PContext, n: PNode) = else: found = findFile(c.config, s) if found.isEmpty: found = AbsoluteFile s - let obj = toObjFile(c.config, completeCfilePath(c.config, found, false)) + let mangled = completeCfilePath(c.config, mangleModuleName(c.config, found).AbsoluteFile) + let obj = toObjFile(c.config, mangled) docompile(c, it, found, obj, customArgs) proc processLink(c: PContext, n: PNode) = |