diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp index b16197aca9f..7ecf501dcec 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.cpp +++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp @@ -206,7 +206,8 @@ MingwBackend::Process () { size_t i; - DetectPCHSupport(); + DetectPipeSupport (); + DetectPCHSupport (); CreateMakefile (); GenerateHeader (); @@ -515,30 +516,65 @@ FixupTargetFilename ( const string& targetFilename ) } void -MingwBackend::DetectPCHSupport() +MingwBackend::DetectPipeSupport () { -#ifdef WIN32 - string sNUL = "NUL"; -#else - string sNUL = "/dev/null"; -#endif - string path = "tools" SSEP "rbuild" SSEP "backend" SSEP "mingw" SSEP "pch_detection.h"; - string cmd = ssprintf( - "gcc -c %s 2>%s", - path.c_str (), - sNUL.c_str () ); - system ( cmd.c_str() ); - path += ".gch"; + printf ( "Detecting compiler -pipe support..." ); - FILE* f = fopen ( path.c_str(), "rb" ); + string pipe_detection = "tools" SSEP "rbuild" SSEP "backend" SSEP "mingw" SSEP "pipe_detection.c"; + string pipe_detectionObjectFilename = ReplaceExtension ( pipe_detection, + ".o" ); + string command = ssprintf ( + "gcc -pipe -c %s -o %s 2>%s", + pipe_detection.c_str (), + pipe_detectionObjectFilename.c_str (), + NUL ); + int exitcode = system ( command.c_str () ); + FILE* f = fopen ( pipe_detectionObjectFilename.c_str (), "rb" ); if ( f ) { - use_pch = true; - fclose(f); - unlink ( path.c_str() ); + usePipe = (exitcode == 0); + fclose ( f ); + unlink ( pipe_detectionObjectFilename.c_str () ); } else - use_pch = false; + usePipe = false; + + if ( usePipe ) + printf ( "detected\n" ); + else + printf ( "not detected\n" ); + + // TODO FIXME - eventually check for ROS_USE_PCH env var and + // allow that to override use_pch if true +} + +void +MingwBackend::DetectPCHSupport () +{ + printf ( "Detecting compiler pre-compiled header support..." ); + + string path = "tools" SSEP "rbuild" SSEP "backend" SSEP "mingw" SSEP "pch_detection.h"; + string cmd = ssprintf ( + "gcc -c %s 2>%s", + path.c_str (), + NUL ); + system ( cmd.c_str () ); + path += ".gch"; + + FILE* f = fopen ( path.c_str (), "rb" ); + if ( f ) + { + use_pch = true; + fclose ( f ); + unlink ( path.c_str () ); + } + else + use_pch = false; + + if ( use_pch ) + printf ( "detected\n" ); + else + printf ( "not detected\n" ); // TODO FIXME - eventually check for ROS_USE_PCH env var and // allow that to override use_pch if true diff --git a/reactos/tools/rbuild/backend/mingw/mingw.h b/reactos/tools/rbuild/backend/mingw/mingw.h index 1ab974bcaac..96162123581 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.h +++ b/reactos/tools/rbuild/backend/mingw/mingw.h @@ -3,6 +3,12 @@ #include "../backend.h" +#ifdef WIN32 + #define NUL "NUL" +#else + #define NUL "/dev/null" +#endif + class Directory; class MingwModuleHandler; @@ -13,6 +19,7 @@ public: virtual ~MingwBackend (); virtual void Process (); std::string AddDirectoryTarget ( const std::string& directory, bool out ); + bool usePipe; private: void CreateMakefile (); void CloseMakefile () const; @@ -31,7 +38,8 @@ private: void GenerateXmlBuildFilesMacro() const; void CheckAutomaticDependencies (); bool IncludeDirectoryTarget ( const std::string& directory ) const; - void DetectPCHSupport(); + void DetectPipeSupport (); + void DetectPCHSupport (); FILE* fMakefile; bool use_pch; Directory *int_directories, *out_directories; diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index ce744933476..512a660e3a6 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -1278,10 +1278,15 @@ MingwModuleHandler::GenerateOtherMacros () } } + string globalCflags = "-g"; + if ( backend->usePipe ) + globalCflags += " -pipe"; + fprintf ( fMakefile, - "%s += $(PROJECT_CFLAGS) -g\n", - cflagsMacro.c_str () ); + "%s += $(PROJECT_CFLAGS) %s\n", + cflagsMacro.c_str (), + globalCflags.c_str () ); fprintf ( fMakefile,