Unexport even more symbols (#13214)

* system/gc: don't export markStackAndRegisters

* compiler/cgen: unexport internal symbols

As these functions are Nim-specific walkaround against C's optimization
schemes, they don't serve any purpose being exported.

* compiler/cgen: don't export global var unless marked

* compiler/ccgthreadvars: don't export threadvar unless marked

* tests/dll/visibility: also check for exports

This ensure that these changes don't break manual exports.

* compiler/cgen: hide all variables created for constants

* compiler/ccgtypes: don't export RTTI variables

* compiler/ccgexprs: make all complex const static

* nimbase.h: fix export for windows

* compiler/cgen, ccgthreadvars: export variables correctly

For C/C++ variables, `extern` means that the variable is defined in an
another unit. Added a new N_LIB_EXPORT_VAR to correctly export
variables.
This commit is contained in:
alaviss 2020-01-23 12:45:31 +00:00 • committed by Andreas Rumpf
commit f500895efe
7 changed files with 52 additions and 22 deletions

View file

@ -1325,7 +1325,7 @@ proc rawConstExpr(p: BProc, n: PNode; d: var TLoc) =
if id == p.module.labels:
# expression not found in the cache:
inc(p.module.labels)
p.module.s[cfsData].addf("NIM_CONST $1 $2 = $3;$n",
p.module.s[cfsData].addf("static NIM_CONST $1 $2 = $3;$n",
[getTypeDesc(p.module, t), d.r, genBracedInit(p, n, isConst = true)])
proc handleConstExpr(p: BProc, n: PNode, d: var TLoc): bool =
@ -2508,7 +2508,7 @@ proc exprComplexConst(p: BProc, n: PNode, d: var TLoc) =
if id == p.module.labels:
# expression not found in the cache:
inc(p.module.labels)
p.module.s[cfsData].addf("NIM_CONST $1 $2 = $3;$n",
p.module.s[cfsData].addf("static NIM_CONST $1 $2 = $3;$n",
[getTypeDesc(p.module, t), tmp, genBracedInit(p, n, isConst = true)])
if d.k == locNone:
@ -2896,7 +2896,7 @@ proc genConstSeq(p: BProc, n: PNode, t: PType; isConst: bool): Rope =
let base = t.skipTypes(abstractInst)[0]
appcg(p.module, cfsData,
"$5 struct {$n" &
"static $5 struct {$n" &
" #TGenericSeq Sup;$n" &
" $1 data[$2];$n" &
"} $3 = $4;$n", [