Skip to content

Commit cce394a

Browse files
committed
Reduce old GCC linker warnings
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7363 212acab6-be3b-0410-9dea-997c60f758d6
1 parent 4b52051 commit cce394a

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

SCons/Config/gnu

+15-5
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,21 @@ defenv['SUBSYS_WIN'] = '-Wl,--subsystem,windows'
4545
defenv['MSVCRT_FLAG'] = ''
4646
defenv['STDCALL'] = '"__attribute__((__stdcall__))"'
4747

48-
# Don't allow mingw to link with LIBGCC*.DLL and LIBSTDC++-*.DLL
48+
# Don't allow mingw to link with LIBGCC*.DLL and LIBSTDC++-*.DLL
49+
def configure_static_libs(env):
50+
env.Append(LINKFLAGS = ['-static-libgcc'])
51+
code = """
52+
#define G_V (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
53+
#if G_V >= 10000 && G_V < 40503 // Might not be correct, 4.5.2 is known not to support it
54+
#error !
55+
#endif
56+
"""
57+
conf = FlagsConfigure(env)
58+
conf.CheckLinkFlag('-static-libstdc++', codeprepend = code)
59+
conf.Finish()
60+
4961
if defenv['PLATFORM'] == 'win32':
50-
defenv.Append(LINKFLAGS = ['-static-libgcc'])
51-
defenv.Append(LINKFLAGS = ['-static-libstdc++'])
62+
configure_static_libs(defenv)
5263

5364
### defines
5465

@@ -144,8 +155,7 @@ if not defenv['DEBUG'] and defenv['STRIP'] and defenv['STRIP_W32']:
144155
plugin_env.Append(LINKFLAGS = ['-mwindows']) # build windows executables
145156
plugin_env.Append(LINKFLAGS = ['$ALIGN_FLAG']) # 512 bytes align
146157
plugin_env.Append(LINKFLAGS = ['$MAP_FLAG']) # generate map file
147-
plugin_env.Append(LINKFLAGS = ['-static-libgcc']) # remove libgcc*.dll dependency
148-
plugin_env.Append(LINKFLAGS = ['-static-libstdc++']) # remove libstdc++*.dll dependency
158+
configure_static_libs(plugin_env) # remove libgcc*.dll & libstdc++*.dll dependency
149159

150160
plugin_uenv = plugin_env.Clone()
151161
plugin_uenv.Append(CPPDEFINES = ['_UNICODE', 'UNICODE'])

SCons/utils.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def check_compile_flag(ctx, flag):
108108

109109
return result
110110

111-
def check_link_flag(ctx, flag, run = 0, extension = '.c', code = None):
111+
def check_link_flag(ctx, flag, run = 0, extension = '.c', code = None, codeprepend = ''):
112112
"""
113113
Checks if a linker flag is valid.
114114
"""
@@ -120,7 +120,11 @@ def check_link_flag(ctx, flag, run = 0, extension = '.c', code = None):
120120
if code:
121121
test = code
122122
else:
123-
test = """
123+
test = codeprepend + """
124+
#ifdef _WIN32
125+
#include <windows.h>
126+
extern int WINAPI WinMain(HINSTANCE hI,HINSTANCE hOld,char*cl,int sc) { return 0; } // '-Wl,-e,___main' substitute for -nostdlib (GCC 4.5.2)
127+
#endif
124128
int main() {
125129
return 0;
126130
}

SConstruct

+3-1
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,11 @@ Import('SilentActionEcho IsPEExecutable SetPESecurityFlagsWorker MakeReproducibl
453453
def SetPESecurityFlagsAction(target, source, env):
454454
for t in target:
455455
SetPESecurityFlagsWorker(t.path)
456+
g_pesecflagsecho = {}
456457
def SetPESecurityFlagsActionEcho(target, source, env):
457458
for t in target:
458-
if IsPEExecutable(t.path):
459+
if t.name[-4:].lower() == '.dll' and IsPEExecutable(t.path) and not t.path in g_pesecflagsecho:
460+
g_pesecflagsecho[t.path] = 1
459461
print('Setting PE flags on %s' % t.name)
460462
def SetPESecurityFlags(targets):
461463
for t in targets:

0 commit comments

Comments
 (0)