From f500895efe84525c131beadd2e83b30caa6674a3 Mon Sep 17 00:00:00 2001 From: alaviss Date: Thu, 23 Jan 2020 12:45:31 +0000 Subject: 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. --- tests/dll/visibility.nim | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'tests/dll/visibility.nim') diff --git a/tests/dll/visibility.nim b/tests/dll/visibility.nim index 7341e3311..ec15dad29 100644 --- a/tests/dll/visibility.nim +++ b/tests/dll/visibility.nim @@ -1,6 +1,5 @@ discard """ - output: "could not import: foo" - exitcode: 1 + output: "" """ const LibName {.used.} = @@ -12,8 +11,33 @@ const LibName {.used.} = "libvisibility.so" when compileOption("app", "lib"): - proc foo() {.exportc.} = - echo "failed" + var + bar {.exportc.}: int + thr {.exportc, threadvar.}: int + proc foo() {.exportc.} = discard + + var + exported {.exportc, dynlib.}: int + exported_thr {.exportc, threadvar, dynlib.}: int + proc exported_func() {.exportc, dynlib.} = discard elif isMainModule: - proc foo() {.importc, dynlib: LibName.} - foo() + import dynlib + + let handle = loadLib(LibName) + + template check(sym: untyped) = + const s = astToStr(sym) + if handle.symAddr(s) != nil: + echo s, " is exported" + template checkE(sym: untyped) = + const s = astToStr(sym) + if handle.symAddr(s) == nil: + echo s, " is not exported" + + check foo + check bar + check thr + + checkE exported + checkE exported_thr + checkE exported_func -- cgit 1.4.1-2-gfad0 : root/tests/stdlib/tsugar.nim
blob: 2ea96cfbbf6e740d63268509ba2792fac1994815 (plain) (tree)
1
2
3
4
5
6
7
8
9