Index: base/applications/games/solitaire/solitaire.cpp =================================================================== --- base/applications/games/solitaire/solitaire.cpp (revision 43997) +++ base/applications/games/solitaire/solitaire.cpp (working copy) @@ -196,8 +196,6 @@ SaveSettings(); - try { throw 0; } catch (int i) { } /* HACK */ - return msg.wParam; } Index: base/applications/games/spider/spider.cpp =================================================================== --- base/applications/games/spider/spider.cpp (revision 43997) +++ base/applications/games/spider/spider.cpp (working copy) @@ -154,9 +154,6 @@ DispatchMessage(&msg); } } - - try { throw 0; } catch (int i) { } /* HACK */ - return msg.wParam; } Index: dll/directx/ddraw/ddraw.rbuild =================================================================== --- dll/directx/ddraw/ddraw.rbuild (revision 43997) +++ dll/directx/ddraw/ddraw.rbuild (working copy) @@ -70,6 +70,4 @@ DirectD3D3_Vtable.c DirectD3D7_Vtable.c - - -fno-unit-at-a-time Index: dll/directx/wine/ddraw/ddraw.rbuild =================================================================== --- dll/directx/wine/ddraw/ddraw.rbuild (revision 43997) +++ dll/directx/wine/ddraw/ddraw.rbuild (working copy) @@ -42,7 +42,4 @@ viewport.c wineheaders - - - -fno-unit-at-a-time Index: dll/win32/actxprxy/actxprxy.rbuild =================================================================== --- dll/win32/actxprxy/actxprxy.rbuild (revision 43997) +++ dll/win32/actxprxy/actxprxy.rbuild (working copy) @@ -16,7 +16,6 @@ rpcrt4 pseh usrmarshal.c - -fno-unit-at-a-time actxprxy_servprov.idl Index: dll/win32/advapi32/advapi32.rbuild =================================================================== --- dll/win32/advapi32/advapi32.rbuild (revision 43997) +++ dll/win32/advapi32/advapi32.rbuild (working copy) @@ -60,5 +60,4 @@ token.c advapi32.rc - -fno-unit-at-a-time Index: dll/win32/crypt32/crypt32.rbuild =================================================================== --- dll/win32/crypt32/crypt32.rbuild (revision 43997) +++ dll/win32/crypt32/crypt32.rbuild (working copy) @@ -37,6 +37,4 @@ message.c crypt32.rc version.rc - - -fno-unit-at-a-time Index: dll/win32/gdi32/gdi32.rbuild =================================================================== --- dll/win32/gdi32/gdi32.rbuild (revision 43997) +++ dll/win32/gdi32/gdi32.rbuild (working copy) @@ -9,11 +9,9 @@ pseh dxguid ntdll - dllmain.c @@ -50,6 +48,4 @@ path.c gdi32.rc - - -fno-unit-at-a-time Index: dll/win32/kernel32/kernel32.rbuild =================================================================== --- dll/win32/kernel32/kernel32.rbuild (revision 43997) +++ dll/win32/kernel32/kernel32.rbuild (working copy) @@ -13,12 +13,8 @@ 0x0600 errcodes - - - -fno-unit-at-a-time -fno-exceptions -fno-rtti Index: dll/win32/ole32/ole32.rbuild =================================================================== --- dll/win32/ole32/ole32.rbuild (revision 43997) +++ dll/win32/ole32/ole32.rbuild (working copy) @@ -64,8 +64,6 @@ dcom.idl irot.idl . - - -fno-unit-at-a-time irot.idl Index: dll/win32/psapi/psapi.rbuild =================================================================== --- dll/win32/psapi/psapi.rbuild (revision 43997) +++ dll/win32/psapi/psapi.rbuild (working copy) @@ -6,12 +6,8 @@ pseh ntdll kernel32 - malloc.c psapi.c psapi.rc - - -fno-unit-at-a-time Index: dll/win32/qmgrprxy/qmgrprxy.rbuild =================================================================== --- dll/win32/qmgrprxy/qmgrprxy.rbuild (revision 43997) +++ dll/win32/qmgrprxy/qmgrprxy.rbuild (working copy) @@ -16,7 +16,6 @@ rpcrt4 pseh version.rc - -fno-unit-at-a-time qmgrprxy.idl Index: dll/win32/rpcrt4/rpcrt4.rbuild =================================================================== --- dll/win32/rpcrt4/rpcrt4.rbuild (revision 43997) +++ dll/win32/rpcrt4/rpcrt4.rbuild (working copy) @@ -40,8 +40,6 @@ rpcrt4.rc epm.idl . - - -fno-unit-at-a-time epm.idl Index: dll/win32/setupapi/setupapi.rbuild =================================================================== --- dll/win32/setupapi/setupapi.rbuild (revision 43997) +++ dll/win32/setupapi/setupapi.rbuild (working copy) @@ -36,6 +36,4 @@ stubs.c rpc.c setupapi.rc - - -fno-unit-at-a-time Index: dll/win32/syssetup/syssetup.rbuild =================================================================== --- dll/win32/syssetup/syssetup.rbuild (revision 43997) +++ dll/win32/syssetup/syssetup.rbuild (working copy) @@ -21,6 +21,4 @@ logfile.c wizard.c syssetup.rc - - -fno-unit-at-a-time Index: dll/win32/user32/user32.rbuild =================================================================== --- dll/win32/user32/user32.rbuild (revision 43997) +++ dll/win32/user32/user32.rbuild (working copy) @@ -12,11 +12,9 @@ pseh ntdll -fms-extensions - button.c combo.c @@ -77,6 +75,4 @@ winpos.c user32.rc - - -fno-unit-at-a-time Index: dll/win32/wintrust/wintrust.rbuild =================================================================== --- dll/win32/wintrust/wintrust.rbuild (revision 43997) +++ dll/win32/wintrust/wintrust.rbuild (working copy) @@ -19,6 +19,4 @@ asn.c softpub.c version.rc - - -fno-unit-at-a-time Index: dll/win32/wlanapi/wlanapi.rbuild =================================================================== --- dll/win32/wlanapi/wlanapi.rbuild (revision 43997) +++ dll/win32/wlanapi/wlanapi.rbuild (working copy) @@ -9,6 +9,4 @@ pseh ntdll main.c - - -fno-unit-at-a-time Index: drivers/input/kbdclass/kbdclass.rbuild =================================================================== --- drivers/input/kbdclass/kbdclass.rbuild (revision 43997) +++ drivers/input/kbdclass/kbdclass.rbuild (working copy) @@ -9,6 +9,4 @@ misc.c setup.c kbdclass.rc - - -fno-unit-at-a-time Index: drivers/input/mouclass/mouclass.rbuild =================================================================== --- drivers/input/mouclass/mouclass.rbuild (revision 43997) +++ drivers/input/mouclass/mouclass.rbuild (working copy) @@ -8,6 +8,4 @@ misc.c mouclass.c mouclass.rc - - -fno-unit-at-a-time Index: drivers/network/afd/afd.rbuild =================================================================== --- drivers/network/afd/afd.rbuild (revision 43997) +++ drivers/network/afd/afd.rbuild (working copy) @@ -8,9 +8,7 @@ ntoskrnl hal - bind.c @@ -27,6 +25,4 @@ write.c afd.rc - - -fno-unit-at-a-time Index: drivers/network/tcpip/tcpip.rbuild =================================================================== --- drivers/network/tcpip/tcpip.rbuild (revision 43997) +++ drivers/network/tcpip/tcpip.rbuild (working copy) @@ -13,11 +13,9 @@ chew ntoskrnl hal - lan.c @@ -40,6 +38,4 @@ wait.c tcpip.rc - - -fno-unit-at-a-time Index: lib/rtl/rtl.rbuild =================================================================== --- lib/rtl/rtl.rbuild (revision 43997) +++ lib/rtl/rtl.rbuild (working copy) @@ -96,9 +96,5 @@ version.c wait.c workitem.c - - - -fno-unit-at-a-time Index: ntoskrnl/ntoskrnl-generic.rbuild =================================================================== --- ntoskrnl/ntoskrnl-generic.rbuild (revision 43997) +++ ntoskrnl/ntoskrnl-generic.rbuild (working copy) @@ -30,11 +30,9 @@ bootvid wdmguid bugcodes - @@ -504,7 +502,4 @@ ntoskrnl.rc ntoskrnl_$(ARCH).lnk - - - -fno-unit-at-a-time Index: ReactOS-generic.rbuild =================================================================== --- ReactOS-generic.rbuild (revision 43997) +++ ReactOS-generic.rbuild (working copy) @@ -122,11 +122,6 @@ -Wno-strict-aliasing -Wpointer-arith -Wno-multichar - Index: subsystems/win32/win32k/objects/gdiobj.c =================================================================== --- subsystems/win32/win32k/objects/gdiobj.c (revision 43997) +++ subsystems/win32/win32k/objects/gdiobj.c (working copy) @@ -30,7 +30,7 @@ #include "gdidbg.c" -/* static */ /* FIXME: -fno-unit-at-a-time breaks this */ +static BOOL INTERNAL_CALL GDI_CleanupDummy(PVOID ObjectBody); /** GLOBALS *******************************************************************/ @@ -87,7 +87,7 @@ /* * Dummy GDI Cleanup Callback */ -/* static */ /* FIXME: -fno-unit-at-a-time breaks this */ +static BOOL INTERNAL_CALL GDI_CleanupDummy(PVOID ObjectBody) { Index: subsystems/win32/win32k/win32k.rbuild =================================================================== --- subsystems/win32/win32k/win32k.rbuild (revision 43997) +++ subsystems/win32/win32k/win32k.rbuild (working copy) @@ -13,9 +13,7 @@ /wd4276 - dib8gen.c @@ -198,9 +196,6 @@ stubs.c umpdstubs.c - - - -fno-unit-at-a-time Index: tools/rbuild/backend/mingw/compilers/gcc.mak =================================================================== --- tools/rbuild/backend/mingw/compilers/gcc.mak (revision 43997) +++ tools/rbuild/backend/mingw/compilers/gcc.mak (working copy) @@ -9,7 +9,7 @@ # FIXME: disabled until RosBE stops sucking # BUILTIN_CPPFLAGS+= -nostdinc -BUILTIN_CFLAGS+= -fno-optimize-sibling-calls +BUILTIN_CFLAGS+= -fno-optimize-sibling-calls -fno-set-stack-executable BUILTIN_CXXFLAGS+= -fno-optimize-sibling-calls #(module, source, dependencies, cflags, output) Index: tools/rbuild/backend/mingw/mingw.cpp =================================================================== --- tools/rbuild/backend/mingw/mingw.cpp (revision 43997) +++ tools/rbuild/backend/mingw/mingw.cpp (working copy) @@ -490,7 +490,7 @@ // TODO: linker flags fprintf ( fMakefile, "PROJECT_LFLAGS := '$(shell ${TARGET_CC} -print-libgcc-file-name)' %s\n", GenerateProjectLFLAGS ().c_str () ); - fprintf ( fMakefile, "PROJECT_LPPFLAGS := '$(shell ${TARGET_CPP} -print-file-name=libstdc++.a)' '$(shell ${TARGET_CPP} -print-file-name=libgcc.a)' '$(shell ${TARGET_CPP} -print-file-name=libmingw32.a)' '$(shell ${TARGET_CPP} -print-file-name=libmingwex.a)' '$(shell ${TARGET_CPP} -print-file-name=libcoldname.a)'\n" ); + fprintf ( fMakefile, "PROJECT_LPPFLAGS := '$(shell ${TARGET_CPP} -print-file-name=libstdc++.a)' '$(shell ${TARGET_CPP} -print-file-name=libgcc.a)' '$(shell ${TARGET_CPP} -print-file-name=libmingw32.a)' '$(shell ${TARGET_CPP} -print-file-name=libmingwex.a)' '$(shell ${TARGET_CPP} -print-file-name=ofmt_stub.a)' '$(shell ${TARGET_CPP} -print-file-name=libcoldname.a)'\n" ); /* hack to get libgcc_eh.a, should check mingw version or something */ if (Environment::GetArch() == "amd64") { @@ -835,7 +835,7 @@ buffer[i] = '\0'; pclose ( fp ); - char separators[] = " ()"; + char separators[] = " ()\n"; char *token; char *prevtoken = NULL; @@ -899,7 +899,7 @@ bool MingwBackend::IsSupportedCompilerVersion ( const string& compilerVersion ) { - if ( strcmp ( compilerVersion.c_str (), "3.4.2") < 0 ) + if ( strcmp ( compilerVersion.c_str (), "4.4.2") < 0 ) return false; else return true; @@ -961,27 +961,32 @@ bool MingwBackend::IsSupportedBinutilsVersion ( const string& binutilsVersion ) { - if ( manualBinutilsSetting ) return true; - - /* linux */ - if ( binutilsVersion.find('.') != std::string::npos ) + int digit = binutilsVersion.find_last_of("."); + if(digit == -1) { - /* TODO: blacklist versions on version number instead of date */ - return true; + printf("Unable to detect binutils version!\n"); + return false; } - - /* - * - Binutils older than 2003/10/01 have broken windres which can't handle - * icons with alpha channel. - * - Binutils between 2004/09/02 and 2004/10/08 have broken handling of - * forward exports in dlltool. - */ - if ( ( ( strcmp ( binutilsVersion.c_str (), "20040902") >= 0 ) && - ( strcmp ( binutilsVersion.c_str (), "20041008") <= 0 ) ) || - ( strcmp ( binutilsVersion.c_str (), "20031001") < 0 ) ) - return false; + + string date = string(binutilsVersion, digit + 1); + if(date.length() == 8) + { + /* This is a real date in the format YYYYMMDD. + Check whether we have at least Binutils 20091017 (older versions + don't support the -exclude-all-symbols option we use). */ + if(strcmp(date.c_str(), "20091017") < 0) + return false; + } else - return true; + { + /* This is no date, so binutilsVersion should just contain the version + number. + Binutils 2.20 will hopefully contain the required features. */ + if(strcmp(binutilsVersion.c_str(), "2.20") < 0) + return false; + } + + return true; } void Index: tools/rbuild/backend/mingw/modulehandler.cpp =================================================================== --- tools/rbuild/backend/mingw/modulehandler.cpp (revision 43997) +++ tools/rbuild/backend/mingw/modulehandler.cpp (working copy) @@ -1489,13 +1489,6 @@ else linkerScriptArgument = ""; - /* check if we need to add default C++ libraries, ie if we have - * a C++ user-mode module without the -nostdlib linker flag - */ - bool link_defaultlibs = module.cplusplus && - linkerParameters.find ("-nostdlib") == string::npos && - !(module.type == KernelModeDLL || module.type == KernelModeDriver); - if ( !module.HasImportLibrary() ) { fprintf ( fMakefile, @@ -1507,12 +1500,11 @@ fprintf ( fMakefile, "\t$(ECHO_LD)\n" ); fprintf ( fMakefile, - "\t%s %s%s %s %s %s %s -o %s\n", + "\t%s %s%s %s %s %s -o %s\n", linker.c_str (), linkerParameters.c_str (), linkerScriptArgument.c_str (), objectsMacro.c_str (), - link_defaultlibs ? "$(PROJECT_LPPFLAGS) " : "", libsMacro.c_str (), GetLinkerMacro ().c_str (), target_macro.c_str () ); @@ -1547,14 +1539,12 @@ fprintf ( fMakefile, "\t$(ECHO_LD)\n" ); fprintf ( fMakefile, - "\t%s %s%s %s %s %s %s %s -o %s\n", - + "\t%s %s%s %s %s %s %s -o %s\n", linker.c_str (), linkerParameters.c_str (), linkerScriptArgument.c_str (), backend->GetFullName ( temp_exp ).c_str (), objectsMacro.c_str (), - link_defaultlibs ? "$(PROJECT_LPPFLAGS) " : "", libsMacro.c_str (), GetLinkerMacro ().c_str (), target_macro.c_str () ); @@ -1911,9 +1901,23 @@ if ( ModuleHandlerInformations[module.type].DefaultHost == HostFalse ) { if ( module.cplusplus ) + { fprintf ( fMakefile, - "%s+= $(PROJECT_LPPFLAGS)\n\n", + "%s+= $(PROJECT_LPPFLAGS)\n", linkerflagsMacro.c_str () ); + + if (module.type != KernelModeDLL && module.type != KernelModeDriver) + { + /* Added for GCC 4.4.2: As imported C++ libraries (e.g. cardlib) can use additional functions from libgcc which link to + kernel32 and msvcrt, we have to add these libraries at the very end of the linking order. + */ + fprintf(fMakefile, + "%s+= '$(shell ${TARGET_CPP} -print-file-name=libkernel32.a)' '$(shell ${TARGET_CPP} -print-file-name=libmsvcrt.a)'\n", + linkerflagsMacro.c_str()); + } + + fprintf(fMakefile, "\n"); + } else fprintf ( fMakefile, "%s+= $(PROJECT_LFLAGS)\n\n", @@ -2469,6 +2473,13 @@ string linkerParameters = ssprintf ( "-subsystem=native -entry=%s -image-base=%s -file-alignment=0x1000 -section-alignment=0x1000 -shared", module.GetEntryPoint(!(Environment::GetArch() == "arm")).c_str (), module.baseaddress.c_str () ); + + /* MingwKernelModeDLLModuleHandler is also used for kernel-mode drives, which usually don't export any symbols. + Nevertheless, LD automatically exports all symbols by default if -shared is specified. Prevent it from doing this + by adding the option -exclude-all-symbols in this case (available since Binutils 20091017). */ + if(!module.importLibrary) + linkerParameters += " -exclude-all-symbols"; + GenerateLinkerCommand ( dependencies, linkerParameters, " -sections" ); Index: tools/rbuild/backend/mingw/rules.mak =================================================================== --- tools/rbuild/backend/mingw/rules.mak (revision 43997) +++ tools/rbuild/backend/mingw/rules.mak (working copy) @@ -248,7 +248,7 @@ $$(ECHO_WIDL) $$(Q)$$(WIDL_TARGET) ${call RBUILD_midlflags,$(1),$(4),-I${call RBUILD_dir,$(2)}} -h -H ${call RBUILD_intermediate_path_noext,$(2)}_c.h -c -C ${call RBUILD_intermediate_path_noext,$(2)}_c.c $(2) -${call RBUILD_CC,$(1),${call RBUILD_intermediate_path_noext,$(2)}_c.c,,-fno-unit-at-a-time,${call RBUILD_intermediate_path_noext,$(2)}_c.o} +${call RBUILD_CC,$(1),${call RBUILD_intermediate_path_noext,$(2)}_c.c,,,${call RBUILD_intermediate_path_noext,$(2)}_c.o} endef @@ -261,7 +261,7 @@ $$(ECHO_WIDL) $$(Q)$$(WIDL_TARGET) ${call RBUILD_midlflags,$(1),$(4),-I${call RBUILD_dir,$(2)}} -h -H ${call RBUILD_intermediate_path_noext,$(2)}_s.h -s -S ${call RBUILD_intermediate_path_noext,$(2)}_s.c $(2) -${call RBUILD_CC,$(1),${call RBUILD_intermediate_path_noext,$(2)}_s.c,,-fno-unit-at-a-time,${call RBUILD_intermediate_path_noext,$(2)}_s.o} +${call RBUILD_CC,$(1),${call RBUILD_intermediate_path_noext,$(2)}_s.c,,,${call RBUILD_intermediate_path_noext,$(2)}_s.o} endef @@ -274,7 +274,7 @@ $$(ECHO_WIDL) $$(Q)$$(WIDL_TARGET) ${call RBUILD_midlflags,$(1),$(4),-I${call RBUILD_dir,$(2)}} -h -H ${call RBUILD_intermediate_path_noext,$(2)}_p.h -p -P ${call RBUILD_intermediate_path_noext,$(2)}_p.c $(2) -${call RBUILD_CC,$(1),${call RBUILD_intermediate_path_noext,$(2)}_p.c,,-fno-unit-at-a-time,${call RBUILD_intermediate_path_noext,$(2)}_p.o} +${call RBUILD_CC,$(1),${call RBUILD_intermediate_path_noext,$(2)}_p.c,,,${call RBUILD_intermediate_path_noext,$(2)}_p.o} endef @@ -287,7 +287,7 @@ $$(ECHO_WIDL) $$(Q)$$(WIDL_TARGET) ${call RBUILD_midlflags,$(1),$(4),-I${call RBUILD_dir,$(2)}} -u -U $$@ $$< -${call RBUILD_CC,$(1),${call RBUILD_intermediate_path_noext,$(2)}_i.c,,-fno-unit-at-a-time,${call RBUILD_intermediate_path_noext,$(2)}_i.o} +${call RBUILD_CC,$(1),${call RBUILD_intermediate_path_noext,$(2)}_i.c,,,${call RBUILD_intermediate_path_noext,$(2)}_i.o} endef