News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

patch to get the correct mingw gcc include search paths

Started by ollydbg, July 06, 2011, 04:45:59 PM

Previous topic - Next topic

ollydbg

Index: nativeparser.cpp
===================================================================
--- nativeparser.cpp (revision 7280)
+++ nativeparser.cpp (working copy)
@@ -1060,7 +1060,7 @@
     // both works fine in Windows and linux

#ifdef __WXMSW__
-    wxString Command = cpp_compiler + _T(" -v -E -x c++ -< nul");
+    wxString Command = _T("cmd /c \"") + cpp_compiler + _T(" -v -E -x c++ -< nul\"");
#else
     wxString Command = cpp_compiler + _T(" -v -E -x c++ -< /dev/null");
#endif


I found that if we use the old command, sometimes we will failed to correct the gcc include paths. e.g. with gcc4.6, it will failed to collect the include paths.
see below:
nativiparser.cpp, line 1079
when running the command:
if (wxExecute(Command, Output, Errors, wxEXEC_SYNC | wxEXEC_NODISABLE) == -1)
Quote
> output Errors
8 count of wxArrayString = {
 
  • = 0xb791a4 L"Using built-in specs.",
      [1] = 0xb79214 L"COLLECT_GCC=E:\\code\\cb\\gcc\\MinGW_gcc4.6.1release_static_win32\\MinGW\\bin\\g++.exe",
      [2] = 0xb792e4 L"COLLECT_LTO_WRAPPER=e:/code/cb/gcc/mingw_gcc4.6.1release_static_win32/mingw/bin/../libexec/gcc/i686-pc-mingw32/4.6.1/lto-wrapper.exe",
      [3] = 0xb79434 L"g++.exe: error: unrecognized option '-<'",
      [4] = 0xb794c4 L"Target: i686-pc-mingw32",
      [5] = 0xb7a014 L"Configured with: ./configure --prefix=/mingw --host=i686-pc-mingw32 --build=i686-pc-mingw32 --target=i686-pc-mingw32 --with-lto-plugin --with-host-libstdcxx=-lstdc++ --disable-bootstrap --disable-werror --with-arch=i686 --with-tune=generic --enable-languages=c,c++,fortran --enable-libgomp --enable-threads=win32 --enable-lto --with-system-zlib --enable-libstdcxx-debug --enable-version-specific-runtime-libs --enable-fully-dynamic-string --disable-sjlj-exceptions --with-dwarf2 --disable-symvers --enable-checking=release --enable-plugins --enable-cloog-backend=isl --enable-static --disable-shared --disable-nls --disable-win32-registry --with-pkgversion=pcx32",
      [6] = 0xb79f34 L"Thread model: win32",
      [7] = 0xb79534 L"gcc version 4.6.1 (pcx32) "
look, we will get failed on running this command on mingw gcc 4.6.1.

I have test this patch on both mingw gcc 4.5.x and gcc 4.6.1(pcx), both works fine.

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

oBFusCATed

Ollydbg: test also the "official" 4.4.x + older compilers 4.1 or something like that.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

xunxun

I 'm disposed to change to :

wxString Command = cpp_compiler + _T(" -v -E -x c++ -dD nul");

This can avoid "-<" output error in wxWidgets, and the content to output is much more, which contains all pre-defined compiler macros, and that can be a better supplement of CC plugin. The CC plugin may use "-dD" to distinguish the value of these pre-defined compiler macros.
Regards,
xunxun

ollydbg

what does "-<" means?
I can't find this option from: http://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html

But I don't think -dD is need, because CC has another function to collect the predefined macros.
look at:
bool NativeParser::AddCompilerPredefinedMacros(cbProject* project, Parser* parser)
it use:
const wxString args(_T(" -dM -E -< nul")); under mingw.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

ollydbg

add a ref:
http://forums.next.codeblocks.org/index.php/topic,10598.msg72620.html#msg72620
But there is no such "-<"?
Maybe, morten can say something about this. :D

Edit:
the command options list: (I can't find any usage of "-<")...
http://technet.microsoft.com/en-us/library/bb490982.aspx
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

xunxun

Quote from: ollydbg on July 08, 2011, 06:51:52 AM
what does "-<" means?
I can't find this option from: http://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html

But I don't think -dD is need, because CC has another function to collect the predefined macros.
look at:
bool NativeParser::AddCompilerPredefinedMacros(cbProject* project, Parser* parser)
it use:
const wxString args(_T(" -dM -E -< nul")); under mingw.

Yes, I know that. But "-< nul" has something error in wx. This also uses wxExecute:

wxExecute(cpp_compiler + args, output, wxEXEC_SYNC | wxEXEC_NODISABLE) == -1

"-dM -E -< nul" may have some errors in some compiler (including my gcc 4.6.1).
So I suggest all avoid "-<".
Regards,
xunxun

xunxun

Regards,
xunxun


ollydbg

Quote from: Loaden on July 08, 2011, 10:11:36 AM
Try this patch?
Test on mingw 4.6.x and 4.5.x, both work fine!
No time to test other mingw version :D...
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

xunxun

Quote from: ollydbg on July 08, 2011, 10:56:02 AM
Quote from: Loaden on July 08, 2011, 10:11:36 AM
Try this patch?
Test on mingw 4.6.x and 4.5.x, both work fine!
No time to test other mingw version :D...

I also test it, then my used editions work fine.
Regards,
xunxun