Generate dynlib strings as a single rope (#8247)
In order not to trip the optimization in genInfixCall we have to do so. The same trick is also used in setExternName. Fixes #8241
This commit is contained in:
parent
03c8fdc6cb
commit
d0b60f1fe3
2 changed files with 10 additions and 1 deletions
|
|
@ -574,11 +574,13 @@ proc loadDynamicLib(m: BModule, lib: PLib) =
|
||||||
if lib.name == nil: internalError(m.config, "loadDynamicLib")
|
if lib.name == nil: internalError(m.config, "loadDynamicLib")
|
||||||
|
|
||||||
proc mangleDynLibProc(sym: PSym): Rope =
|
proc mangleDynLibProc(sym: PSym): Rope =
|
||||||
|
# we have to build this as a single rope in order not to trip the
|
||||||
|
# optimization in genInfixCall
|
||||||
if sfCompilerProc in sym.flags:
|
if sfCompilerProc in sym.flags:
|
||||||
# NOTE: sym.loc.r is the external name!
|
# NOTE: sym.loc.r is the external name!
|
||||||
result = rope(sym.name.s)
|
result = rope(sym.name.s)
|
||||||
else:
|
else:
|
||||||
result = "Dl_$1_" % [rope(sym.id)]
|
result = rope(strutils.`%`("Dl_$1_", $sym.id))
|
||||||
|
|
||||||
proc symInDynamicLib(m: BModule, sym: PSym) =
|
proc symInDynamicLib(m: BModule, sym: PSym) =
|
||||||
var lib = sym.annex
|
var lib = sym.annex
|
||||||
|
|
|
||||||
7
tests/cpp/t8241.nim
Normal file
7
tests/cpp/t8241.nim
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
discard """
|
||||||
|
targets: "cpp"
|
||||||
|
action: "compile"
|
||||||
|
"""
|
||||||
|
|
||||||
|
proc foo(): cstring {.importcpp: "", dynlib: "".}
|
||||||
|
echo foo()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue