compiler/ccgtypes: hide exportc proc unless it has dynlib (#13199)

This hides most of stdlib's internal functions from resulting
binaries/libraries, where they aren't needed on *nix. Static libraries
are not affected by this change (visibility doesn't apply to them).
This commit is contained in:
alaviss 2020-01-20 09:51:21 +00:00 • committed by Andreas Rumpf
commit 470faa97c6
3 changed files with 24 additions and 1 deletions

19
tests/dll/visibility.nim Normal file
View file

@ -0,0 +1,19 @@
discard """
output: "could not import: foo"
exitcode: 1
"""
const LibName {.used.} =
when defined(windows):
"visibility.dll"
elif defined(macosx):
"libvisibility.dylib"
else:
"libvisibility.so"
when compileOption("app", "lib"):
proc foo() {.exportc.} =
echo "failed"
elif isMainModule:
proc foo() {.importc, dynlib: LibName.}
foo()