Skip to content

Commit

Permalink
When using MSVC set the subsystem to force minimal XP target OS.
Browse files Browse the repository at this point in the history
Basically this makes the linker use the option /SUBSYSTEM, with its 4
combinations:

/SUBSYSTEM:WINDOWS,5.01
/SUBSYSTEM:CONSOLE,5.01
/SUBSYSTEM:WINDOWS,5.02
/SUBSYSTEM:CONSOLE,5.02

Where 5,01 is used for 32bit arch and 5,02 for 64bit this specifies XP as
a minimal targeted OS version.

https://blogs.msdn.microsoft.com/vcblog/2012/10/08/windows-xp-targeting-with-c-in-visual-studio-2012/
  • Loading branch information
tenuki committed Nov 25, 2017
1 parent d258d28 commit a344c85
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions bootloader/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,10 @@ def configure(ctx):
# Use Unicode entry point wmain/wWinMain and wchar_t WinAPI
ctx.env.append_value('CFLAGS', '-DUNICODE')
ctx.env.append_value('CFLAGS', '-D_UNICODE')
# set XP target as minimal target OS ver. when using Windows w/MSVC
# https://blogs.msdn.microsoft.com/vcblog/2012/10/08/windows-xp-targeting-with-c-in-visual-studio-2012/
ctx.env.append_value('LINKFLAGS', '/SUBSYSTEM:CONSOLE,%s' % (
'5.01' if ctx.env.PYI_ARCH == '32bit' else '5.02'))
else:
# Use Visual C++ compatible alignment
ctx.env.append_value('CFLAGS', '-mms-bitfields')
Expand All @@ -645,11 +649,19 @@ def configure(ctx):
ctx.setenv(name, baseenv) # Inherit from `baseenv`.
ctx.env.append_value('DEFINES', 'WINDOWED')

if ctx.env.DEST_OS == 'win32' and ctx.env.CC_NAME != 'msvc':
# For MinGW disable console window on Windows - MinGW option
# TODO Is it necessary to have -mwindows for C and LINK flags?
ctx.env.append_value('LINKFLAGS', '-mwindows')
ctx.env.append_value('CFLAGS', '-mwindows')
if ctx.env.DEST_OS == 'win32':
if ctx.env.CC_NAME != 'msvc':
# For MinGW disable console window on Windows - MinGW option
# TODO Is it necessary to have -mwindows for C and LINK flags?
ctx.env.append_value('LINKFLAGS', '-mwindows')
ctx.env.append_value('CFLAGS', '-mwindows')
else:
_link_flags = ctx.env._get_list_value_for_modification('LINKFLAGS')
_subsystem = [x for x in _link_flags if x.startswith('/SUBSYSTEM:')]
for parameter in _subsystem:
_link_flags.remove(parameter)
ctx.env.append_value('LINKFLAGS', '/SUBSYSTEM:WINDOWS,%s' % (
'5.01' if ctx.env.PYI_ARCH == '32bit' else '5.02'))
elif ctx.env.DEST_OS == 'darwin':
# To support catching AppleEvents and running as ordinary OSX GUI
# app, we have to link against the Carbon framework.
Expand Down

0 comments on commit a344c85

Please sign in to comment.