Bug 975740 - Port WIN32_EXE_LDFLAGS to moz.build; r=mshal
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 24 Feb 2014 08:30:25 -0500
changeset 170527 01089b6e307aebad7df2ac579b84f5e63c025111
parent 170526 76407f0f10bab7b14e326fd566d5b48c5d0ae92b
child 170528 03f134f172216b30c2dbb306969c0ed27184d2e8
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersmshal
bugs975740
milestone30.0a1
Bug 975740 - Port WIN32_EXE_LDFLAGS to moz.build; r=mshal
b2g/app/Makefile.in
b2g/app/moz.build
browser/app/Makefile.in
browser/app/moz.build
dom/plugins/ipc/hangui/Makefile.in
dom/plugins/ipc/hangui/moz.build
ipc/app/Makefile.in
ipc/app/moz.build
ipc/ipdl/test/cxx/app/Makefile.in
ipc/ipdl/test/cxx/app/moz.build
js/xpconnect/shell/Makefile.in
js/xpconnect/shell/moz.build
python/mozbuild/mozbuild/frontend/emitter.py
python/mozbuild/mozbuild/frontend/sandbox_symbols.py
python/mozbuild/mozbuild/test/backend/data/variable_passthru/moz.build
python/mozbuild/mozbuild/test/backend/test_recursivemake.py
python/mozbuild/mozbuild/test/frontend/data/variable-passthru/moz.build
python/mozbuild/mozbuild/test/frontend/test_emitter.py
testing/tools/screenshot/Makefile.in
testing/tools/screenshot/moz.build
toolkit/components/maintenanceservice/Makefile.in
toolkit/components/maintenanceservice/moz.build
toolkit/mozapps/update/updater/Makefile.in
toolkit/mozapps/update/updater/moz.build
webapprt/win/Makefile.in
webapprt/win/moz.build
xulrunner/app/Makefile.in
xulrunner/app/moz.build
xulrunner/stub/Makefile.in
xulrunner/stub/moz.build
xulrunner/tools/redit/Makefile.in
xulrunner/tools/redit/moz.build
--- a/b2g/app/Makefile.in
+++ b/b2g/app/Makefile.in
@@ -42,22 +42,16 @@ LIBS += \
   -lbinder \
   -lutils \
   $(NULL)
 endif
 
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS += $(call EXPAND_LIBNAME,version)
 endif
-
-ifdef _MSC_VER
-# Always enter a Windows program through wmain, whether or not we're
-# a console application.
-WIN32_EXE_LDFLAGS += -ENTRY:wmainCRTStartup
-endif
 endif #LIBXUL_SDK
 
 UA_UPDATE_FILE = ua-update.json
 
 $(UA_UPDATE_FILE): % : %.in
 	# strip out comment lines, which are not valid in JSON
 	sed -e '/^ *\/\//d' -e '/^ *$$/d' $^ > $@
 
--- a/b2g/app/moz.build
+++ b/b2g/app/moz.build
@@ -7,16 +7,20 @@
 if not CONFIG['LIBXUL_SDK']:
     if CONFIG['GAIADIR']:
         PROGRAM = CONFIG['MOZ_APP_NAME'] + "-bin"
     else:
         PROGRAM = CONFIG['MOZ_APP_NAME']
     SOURCES += [
         'nsBrowserApp.cpp',
     ]
+    if CONFIG['_MSC_VER']:
+        # Always enter a Windows program through wmain, whether or not we're
+        # a console application.
+        WIN32_EXE_LDFLAGS += ['-ENTRY:wmainCRTStartup']
 
 if CONFIG['ENABLE_MARIONETTE']:
     DEFINES['ENABLE_MARIONETTE'] = 1
 
 DEFINES['XPCOM_GLUE'] = True
 
 for var in ('MOZ_APP_NAME', 'MOZ_APP_VERSION', 'MOZ_UPDATER'):
     DEFINES[var] = CONFIG[var]
--- a/browser/app/Makefile.in
+++ b/browser/app/Makefile.in
@@ -49,22 +49,16 @@ endif
 endif
 
 # This switches $(INSTALL) to copy mode, like $(SYSINSTALL), so things that
 # shouldn't get 755 perms need $(IFLAGS1) for either way of calling nsinstall.
 NSDISTMODE = copy
 
 include $(topsrcdir)/config/config.mk
 
-ifdef _MSC_VER
-# Always enter a Windows program through wmain, whether or not we're
-# a console application.
-WIN32_EXE_LDFLAGS += -ENTRY:wmainCRTStartup
-endif
-
 ifeq ($(OS_ARCH),WINNT)
 RCINCLUDE = splash.rc
 # Rebuild firefox.exe if the manifest changes - it's included by splash.rc.
 # (this dependency should really be just for firefox.exe, not other targets)
 # Note the manifest file exists in the tree, so we use the explicit filename
 # here.
 EXTRA_DEPS += firefox.exe.manifest
 ifndef GNU_CC
--- a/browser/app/moz.build
+++ b/browser/app/moz.build
@@ -27,8 +27,13 @@ GENERATED_INCLUDES += [
     '/build',
 ]
 
 LOCAL_INCLUDES += [
     '/toolkit/xre',
     '/xpcom/base',
     '/xpcom/build',
 ]
+
+if CONFIG['_MSC_VER']:
+    # Always enter a Windows program through wmain, whether or not we're
+    # a console application.
+    WIN32_EXE_LDFLAGS += ['-ENTRY:wmainCRTStartup']
--- a/dom/plugins/ipc/hangui/Makefile.in
+++ b/dom/plugins/ipc/hangui/Makefile.in
@@ -8,12 +8,8 @@ RCINCLUDE = HangUIDlg.rc
 
 STL_FLAGS = \
   -D_HAS_EXCEPTIONS=0 \
   $(NULL)
 
 MOZ_GLUE_LDFLAGS =
 
 include $(topsrcdir)/config/rules.mk
-
-ifdef GNU_CC
-WIN32_EXE_LDFLAGS = -municode
-endif
--- a/dom/plugins/ipc/hangui/moz.build
+++ b/dom/plugins/ipc/hangui/moz.build
@@ -10,8 +10,11 @@ PROGRAM = 'plugin-hang-ui'
 
 UNIFIED_SOURCES += [
     'MiniShmChild.cpp',
     'PluginHangUIChild.cpp',
 ]
 include('/ipc/chromium/chromium-config.mozbuild')
 
 DEFINES['NS_NO_XPCOM'] = True
+
+if CONFIG['GNU_CC']:
+    WIN32_EXE_LDFLAGS += ['-municode']
--- a/ipc/app/Makefile.in
+++ b/ipc/app/Makefile.in
@@ -31,22 +31,16 @@ endif
 endif
 
 # This switches $(INSTALL) to copy mode, like $(SYSINSTALL), so things that
 # shouldn't get 755 perms need $(IFLAGS1) for either way of calling nsinstall.
 NSDISTMODE = copy
 
 include $(topsrcdir)/config/config.mk
 
-ifdef _MSC_VER
-# Always enter a Windows program through wmain, whether or not we're
-# a console application.
-WIN32_EXE_LDFLAGS += -ENTRY:wmainCRTStartup
-endif
-
 include $(topsrcdir)/config/rules.mk
 
 LDFLAGS += $(MOZ_ALLOW_HEAP_EXECUTE_FLAGS)
 
 ifeq ($(OS_ARCH),WINNT) #{
 
 ifdef MOZ_CONTENT_SANDBOX
 LIBS += ../../security/sandbox/$(LIB_PREFIX)sandbox_s.$(LIB_SUFFIX)
--- a/ipc/app/moz.build
+++ b/ipc/app/moz.build
@@ -24,8 +24,13 @@ LOCAL_INCLUDES += [
 
 if CONFIG['MOZ_CONTENT_SANDBOX'] and CONFIG['OS_ARCH'] == 'WINNT':
     # For sandbox includes and the include dependencies those have
     LOCAL_INCLUDES += [
         '/security',
         '/security/sandbox',
         '/security/sandbox/chromium',
     ]
+
+if CONFIG['_MSC_VER']:
+    # Always enter a Windows program through wmain, whether or not we're
+    # a console application.
+    WIN32_EXE_LDFLAGS += ['-ENTRY:wmainCRTStartup']
--- a/ipc/ipdl/test/cxx/app/Makefile.in
+++ b/ipc/ipdl/test/cxx/app/Makefile.in
@@ -7,13 +7,9 @@ NSDISTMODE = copy
 LIBS = \
   $(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \
   $(LIBXUL_LIBS) \
   $(NSPR_LIBS) \
   $(NULL)
 
 include $(topsrcdir)/config/config.mk
 
-ifdef _MSC_VER
-WIN32_EXE_LDFLAGS += -ENTRY:wmainCRTStartup
-endif
-
 include $(topsrcdir)/config/rules.mk
--- a/ipc/ipdl/test/cxx/app/moz.build
+++ b/ipc/ipdl/test/cxx/app/moz.build
@@ -11,8 +11,10 @@ SOURCES += [
 ]
 include('/ipc/chromium/chromium-config.mozbuild')
 
 LOCAL_INCLUDES += [
     '/toolkit/xre',
     '/xpcom/base',
 ]
 
+if CONFIG['_MSC_VER']:
+    WIN32_EXE_LDFLAGS += ['-ENTRY:wmainCRTStartup']
--- a/js/xpconnect/shell/Makefile.in
+++ b/js/xpconnect/shell/Makefile.in
@@ -16,18 +16,12 @@ LIBS +=	$(NSPR_LIBS)
 NSDISTMODE = copy
 
 ifeq ($(OS_TEST),ia64)
 LIBS += $(JEMALLOC_LIBS)
 endif
 
 include $(topsrcdir)/config/rules.mk
 
-ifdef _MSC_VER
-# Always enter a Windows program through wmain, whether or not we're
-# a console application.
-WIN32_EXE_LDFLAGS += -ENTRY:wmainCRTStartup
-endif
-
 ifdef MOZ_VTUNE
 CXXFLAGS += -IC:/Program\ Files/Intel/VTune/Analyzer/Include
 LIBS += C:/Program\ Files/Intel/VTune/Analyzer/Lib/VtuneApi.lib
 endif
--- a/js/xpconnect/shell/moz.build
+++ b/js/xpconnect/shell/moz.build
@@ -27,8 +27,12 @@ if CONFIG['MOZ_VTUNE']:
     DEFINES['MOZ_VTUNE'] = True
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 LOCAL_INCLUDES += [
     '/toolkit/xre',
 ]
 
+if CONFIG['_MSC_VER']:
+    # Always enter a Windows program through wmain, whether or not we're
+    # a console application.
+    WIN32_EXE_LDFLAGS += ['-ENTRY:wmainCRTStartup']
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -240,16 +240,17 @@ class TreeMetadataEmitter(LoggingMixin):
             'OS_LIBS',
             'RCFILE',
             'RESFILE',
             'DEFFILE',
             'SDK_LIBRARY',
             'CFLAGS',
             'CXXFLAGS',
             'LDFLAGS',
+            'WIN32_EXE_LDFLAGS',
         ]
         for v in varlist:
             if v in sandbox and sandbox[v]:
                 passthru.variables[v] = sandbox[v]
 
         # NO_VISIBILITY_FLAGS is slightly different
         if sandbox['NO_VISIBILITY_FLAGS']:
             passthru.variables['VISIBILITY_FLAGS'] = ''
--- a/python/mozbuild/mozbuild/frontend/sandbox_symbols.py
+++ b/python/mozbuild/mozbuild/frontend/sandbox_symbols.py
@@ -705,16 +705,27 @@ VARIABLES = {
     'LDFLAGS': (list, list,
         """Flags passed to the linker when linking all of the libraries and
            executables declared in this directory.
 
            Note that the ordering of flags matter here, these flags will be
            added to the linker's command line in the same order as they
            appear in the moz.build file.
         """, 'libs'),
+
+    'WIN32_EXE_LDFLAGS': (list, list,
+        """Flags passed to the linker when linking a Windows .exe executable
+           declared in this directory.
+
+           Note that the ordering of flags matter here, these flags will be
+           added to the linker's command line in the same order as they
+           appear in the moz.build file.
+
+           This variable only has an effect on Windows.
+        """, 'libs'),
 }
 
 # The set of functions exposed to the sandbox.
 #
 # Each entry is a tuple of:
 #
 #  (method attribute, (argument types), docs)
 #
--- a/python/mozbuild/mozbuild/test/backend/data/variable_passthru/moz.build
+++ b/python/mozbuild/mozbuild/test/backend/data/variable_passthru/moz.build
@@ -40,8 +40,9 @@ RCFILE = 'foo.rc'
 RESFILE = 'bar.res'
 DEFFILE = 'baz.def'
 
 USE_STATIC_LIBS = True
 
 CFLAGS += ['-fno-exceptions', '-w']
 CXXFLAGS += ['-fcxx-exceptions', '-include foo.h']
 LDFLAGS += ['-framework Foo', '-x']
+WIN32_EXE_LDFLAGS += ['-subsystem:console']
--- a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py
+++ b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py
@@ -346,17 +346,20 @@ class TestRecursiveMakeBackend(BackendTe
             ],
             'CXXFLAGS': [
                 'CXXFLAGS += -fcxx-exceptions',
                 'CXXFLAGS += -include foo.h',
             ],
             'LDFLAGS': [
                 'LDFLAGS += -framework Foo',
                 'LDFLAGS += -x',
-            ]
+            ],
+            'WIN32_EXE_LDFLAGS': [
+                'WIN32_EXE_LDFLAGS += -subsystem:console',
+            ],
         }
 
         for var, val in expected.items():
             # print("test_variable_passthru[%s]" % (var))
             found = [str for str in lines if str.startswith(var)]
             self.assertEqual(found, val)
 
     def test_exports(self):
--- a/python/mozbuild/mozbuild/test/frontend/data/variable-passthru/moz.build
+++ b/python/mozbuild/mozbuild/test/frontend/data/variable-passthru/moz.build
@@ -46,8 +46,9 @@ RCFILE = 'foo.rc'
 RESFILE = 'bar.res'
 DEFFILE = 'baz.def'
 
 USE_STATIC_LIBS = True
 
 CFLAGS += ['-fno-exceptions', '-w']
 CXXFLAGS += ['-fcxx-exceptions', '-include foo.h']
 LDFLAGS += ['-framework Foo', '-x']
+WIN32_EXE_LDFLAGS += ['-subsystem:console']
--- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py
+++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py
@@ -174,16 +174,17 @@ class TestEmitterBasic(unittest.TestCase
             USE_DELAYIMP=True,
             RCFILE='foo.rc',
             RESFILE='bar.res',
             DEFFILE='baz.def',
             USE_STATIC_LIBS=True,
             CFLAGS=['-fno-exceptions', '-w'],
             CXXFLAGS=['-fcxx-exceptions', '-include foo.h'],
             LDFLAGS=['-framework Foo', '-x'],
+            WIN32_EXE_LDFLAGS=['-subsystem:console'],
         )
 
         variables = objs[0].variables
         maxDiff = self.maxDiff
         self.maxDiff = None
         self.assertEqual(wanted, variables)
         self.maxDiff = maxDiff
 
--- a/testing/tools/screenshot/Makefile.in
+++ b/testing/tools/screenshot/Makefile.in
@@ -11,13 +11,9 @@ OS_LIBS = $(TK_LIBS) $(XSS_LIBS)
 endif # X11
 endif # GTK
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
 
 OS_LIBS += $(call EXPAND_LIBNAME,gdiplus)
 MOZ_GLUE_PROGRAM_LDFLAGS =
 
-ifdef GNU_CC
-WIN32_EXE_LDFLAGS = -municode
-endif
-
 endif # windows
--- a/testing/tools/screenshot/moz.build
+++ b/testing/tools/screenshot/moz.build
@@ -10,8 +10,10 @@ if CONFIG['MOZ_WIDGET_GTK'] and CONFIG['
         'gdk-screenshot.cpp',
     ]
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     PROGRAM = 'screenshot'
     SOURCES += [
         'win32-screenshot.cpp',
     ]
     USE_STATIC_LIBS = True
+    if CONFIG['GNU_CC']:
+        WIN32_EXE_FLAGS += ['-municode']
--- a/toolkit/components/maintenanceservice/Makefile.in
+++ b/toolkit/components/maintenanceservice/Makefile.in
@@ -29,12 +29,8 @@ ifndef MOZ_WINCONSOLE
 ifdef MOZ_DEBUG
 MOZ_WINCONSOLE = 1
 else
 MOZ_WINCONSOLE = 0
 endif
 endif
 
 include $(topsrcdir)/config/rules.mk
-
-ifdef _MSC_VER
-WIN32_EXE_LDFLAGS += -ENTRY:wmainCRTStartup
-endif
--- a/toolkit/components/maintenanceservice/moz.build
+++ b/toolkit/components/maintenanceservice/moz.build
@@ -23,10 +23,12 @@ DEFINES['_UNICODE'] = True
 DEFINES['NS_NO_XPCOM'] = True
 
 # Pick up nsWindowsRestart.cpp
 LOCAL_INCLUDES += [
     '/toolkit/mozapps/update/common',
     '/toolkit/xre',
 ]
 
+USE_STATIC_LIBS = True
 
-USE_STATIC_LIBS = True
+if CONFIG['_MSC_VER']:
+    WIN32_EXE_LDFLAGS += ['-ENTRY:wmainCRTStartup']
--- a/toolkit/mozapps/update/updater/Makefile.in
+++ b/toolkit/mozapps/update/updater/Makefile.in
@@ -51,20 +51,16 @@ ifdef MOZ_DEBUG
 MOZ_WINCONSOLE = 1
 else
 MOZ_WINCONSOLE = 0
 endif
 endif
 
 include $(topsrcdir)/config/rules.mk
 
-ifdef _MSC_VER
-WIN32_EXE_LDFLAGS += -ENTRY:wmainCRTStartup
-endif
-
 ifdef MOZ_WIDGET_GTK
 libs:: updater.png
 	$(NSINSTALL) -D $(DIST)/bin/icons
 	$(INSTALL) $(IFLAGS1) $^ $(DIST)/bin/icons
 endif
 
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 libs::
--- a/toolkit/mozapps/update/updater/moz.build
+++ b/toolkit/mozapps/update/updater/moz.build
@@ -59,14 +59,16 @@ DEFINES['NS_NO_XPCOM'] = True
 for var in ('MAR_CHANNEL_ID', 'MOZ_APP_VERSION'):
     DEFINES[var] = '"%s"' % CONFIG[var]
 
 LOCAL_INCLUDES += [
     '../common',
     '/xpcom/glue',
 ]
 
-
 DELAYLOAD_DLLS += [
     'crypt32.dll',
     'userenv.dll',
     'wsock32.dll',
 ]
+
+if CONFIG['_MSC_VER']:
+    WIN32_EXE_LDFLAGS += ['-ENTRY:wmainCRTStartup']
--- a/webapprt/win/Makefile.in
+++ b/webapprt/win/Makefile.in
@@ -23,22 +23,16 @@ endif
 # Installer stuff
 include $(topsrcdir)/toolkit/mozapps/installer/package-name.mk
 
 CONFIG_DIR = instgen
 SFX_MODULE = $(topsrcdir)/other-licenses/7zstub/firefox/7zSD.sfx
 APP_VERSION := $(shell cat $(topsrcdir)/browser/config/version.txt)
 DEFINES += -DAPP_VERSION=$(APP_VERSION)
 
-ifdef _MSC_VER
-# Always enter a Windows program through wmain, whether or not we're
-# a console application.
-WIN32_EXE_LDFLAGS += -ENTRY:wmainCRTStartup
-endif
-
 OS_LIBS += $(call EXPAND_LIBNAME,shell32)
 
 RCINCLUDE = webapprt.rc
 ifndef GNU_CC
 RCFLAGS += -I$(srcdir)
 else
 RCFLAGS += --include-dir $(srcdir)
 endif
--- a/webapprt/win/moz.build
+++ b/webapprt/win/moz.build
@@ -16,8 +16,13 @@ DEFINES['XPCOM_GLUE'] = True
 USE_STATIC_LIBS = True
 
 GENERATED_INCLUDES += ['/build']
 LOCAL_INCLUDES += [
     '/toolkit/xre',
     '/xpcom/base',
     '/xpcom/build',
 ]
+
+if CONFIG['_MSC_VER']:
+    # Always enter a Windows program through wmain, whether or not we're
+    # a console application.
+    WIN32_EXE_LDFLAGS += ['-ENTRY:wmainCRTStartup']
--- a/xulrunner/app/Makefile.in
+++ b/xulrunner/app/Makefile.in
@@ -27,22 +27,16 @@ endif
 endif
 
 # This switches $(INSTALL) to copy mode, like $(SYSINSTALL), so things that
 # shouldn't get 755 perms need $(IFLAGS1) for either way of calling nsinstall.
 NSDISTMODE = copy
 
 include $(topsrcdir)/config/config.mk
 
-ifdef _MSC_VER
-# Always enter a Windows program through wmain, whether or not we're
-# a console application.
-WIN32_EXE_LDFLAGS += -ENTRY:wmainCRTStartup
-endif
-
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS += $(call EXPAND_LIBNAME,comctl32 comdlg32 uuid shell32 ole32 oleaut32 version winspool)
 RCINCLUDE = splash.rc
 ifndef GNU_CC
 RCFLAGS += -DMOZ_XULRUNNER -I$(srcdir)
 else
 RCFLAGS += -DMOZ_XULRUNNER --include-dir $(srcdir)
 endif
--- a/xulrunner/app/moz.build
+++ b/xulrunner/app/moz.build
@@ -20,8 +20,12 @@ if CONFIG['TARGET_XPCOM_ABI']:
 
 LOCAL_INCLUDES += [
     '/toolkit/profile',
     '/toolkit/xre',
     '/xpcom/base',
     '/xpcom/build',
 ]
 
+if CONFIG['_MSC_VER']:
+    # Always enter a Windows program through wmain, whether or not we're
+    # a console application.
+    WIN32_EXE_LDFLAGS += ['-ENTRY:wmainCRTStartup']
--- a/xulrunner/stub/Makefile.in
+++ b/xulrunner/stub/Makefile.in
@@ -32,17 +32,13 @@ ifdef MOZ_DEBUG
 MOZ_WINCONSOLE = 1
 else
 MOZ_WINCONSOLE = 0
 endif
 endif
 
 include $(topsrcdir)/config/config.mk
 
-ifdef _MSC_VER
-WIN32_EXE_LDFLAGS += -ENTRY:wmainCRTStartup
-endif
-
 include $(topsrcdir)/config/rules.mk
 
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS += $(call EXPAND_LIBNAME,shell32)
 endif
--- a/xulrunner/stub/moz.build
+++ b/xulrunner/stub/moz.build
@@ -25,8 +25,11 @@ LOCAL_INCLUDES += [
 ]
 
 
 # Statically link against the RTL on windows
 USE_STATIC_LIBS = True
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     LOCAL_INCLUDES += ['/toolkit/xre']
+
+if CONFIG['_MSC_VER']:
+    WIN32_EXE_LDFLAGS += ['-ENTRY:wmainCRTStartup']
--- a/xulrunner/tools/redit/Makefile.in
+++ b/xulrunner/tools/redit/Makefile.in
@@ -7,13 +7,9 @@ ifeq ($(OS_ARCH),WINNT)
 SDK_BINARY =  \
 	$(PROGRAM) \
 	$(NULL)
 
 LIBS = \
   $(XPCOM_STANDALONE_GLUE_LDOPTS) \
   $(NULL)
 
-ifdef GNU_CC
-WIN32_EXE_LDFLAGS = -municode
 endif
-
-endif
--- a/xulrunner/tools/redit/moz.build
+++ b/xulrunner/tools/redit/moz.build
@@ -6,8 +6,10 @@
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     PROGRAM  = 'redit'
     SOURCES += [
         'redit.cpp',
     ]
     for var in ('WIN32_LEAN_AND_MEAN', 'UNICODE', '_UNICODE', 'XPCOM_GLUE'):
         DEFINES[var] = True
+    if CONFIG['GNU_CC']:
+        WIN32_EXE_LDFLAGS += ['-municode']