From 4fef3a34fb7f2503e08c4dedd84817a7f79c5a2b Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Fri, 5 Feb 2021 16:59:23 -0800 Subject: [PATCH] fix #15955: --app:staticlib -d:nimLinkerWeakSymbols allows using weak symbols --- compiler/cgen.nim | 2 +- lib/nimbase.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/cgen.nim b/compiler/cgen.nim index b6095e694c559..67f44c539f54a 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -1360,7 +1360,7 @@ proc genMainProc(m: BModule) = "}$N$N" NimMainProc = - "N_CDECL(void, NimMain)(void) {$N" & + "N_LIB_PRIVATE N_CDECL(void, NimMain)(void) {$N" & "\tvoid (*volatile inner)(void);$N" & "$4" & "\tinner = NimMainInner;$N" & diff --git a/lib/nimbase.h b/lib/nimbase.h index cbd35605ba256..00c2d71460ef0 100644 --- a/lib/nimbase.h +++ b/lib/nimbase.h @@ -173,6 +173,7 @@ __AVR__ #if defined(WIN32) || defined(_WIN32) /* only Windows has this mess... */ # define N_LIB_PRIVATE +# define N_LIB_WEAK __declspec(selectany)# # define N_CDECL(rettype, name) rettype __cdecl name # define N_STDCALL(rettype, name) rettype __stdcall name # define N_SYSCALL(rettype, name) rettype __syscall name @@ -196,6 +197,7 @@ __AVR__ # define N_LIB_IMPORT extern __declspec(dllimport) #else # define N_LIB_PRIVATE __attribute__((visibility("hidden"))) +# define N_LIB_WEAK __attribute__((weak)) # if defined(__GNUC__) # define N_CDECL(rettype, name) rettype name # define N_STDCALL(rettype, name) rettype name