Author Topic: FYI: GCC 4.5.0 on Mingw.org  (Read 86165 times)

Offline reckless

  • Regular
  • ***
  • Posts: 338
Re: FYI: GCC 4.5.0 on Mingw.org
« Reply #75 on: August 10, 2010, 07:44:20 am »
thanks leo :)

Offline a14331990

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: FYI: GCC 4.5.0 on Mingw.org
« Reply #76 on: August 13, 2010, 02:53:14 pm »
Also packed all dlls in dir /mingw/bin as dlls-7z465.7z, available at downloads column of a1mingwgcc googlecode page.

cobines

  • Guest
Re: FYI: GCC 4.5.0 on Mingw.org
« Reply #77 on: October 15, 2010, 12:06:06 am »
The solution posted here seems to work, which is not using __declspec(dllexport) but rather --enable-auto-import in the linker. Defined WXEXPORT as empty and added --enable-auto-import to LDFLAGS, using MinGW's GCC 4.5.0-1 with MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release, DLL is about 9MB.

Offline wangdong1226

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: FYI: GCC 4.5.0 on Mingw.org
« Reply #78 on: March 20, 2011, 01:05:27 am »
The solution posted here seems to work, which is not using __declspec(dllexport) but rather --enable-auto-import in the linker. Defined WXEXPORT as empty and added --enable-auto-import to LDFLAGS, using MinGW's GCC 4.5.0-1 with MONOLITHIC=1 SHARED=1 UNICODE=1 BUILD=release, DLL is about 9MB.


I've tried several times, my config file (Laoden's copyright  :) ):
Quote
mingw32-make -f makefile.gcc CXXFLAGS="-enable-auto-import -O2 -pipe -mthreads -fvisibility=hidden -fvisibility-inlines-hidden" LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--copy-dt-needed-entries -Wl,-enable-auto-import -s" SHARED=1 BUILD=release UNICODE=1 DEBUG_INFO=0 DEBUG_FLAG=0 MONOLITHIC=1 USE_STC=0 USE_PROPGRID=1 USE_EXCEPTIONS=0 USE_RTTI=0 OFFICIAL_BUILD=1 RUNTIME_LIBS=static

but every time, I got error (ld returns 1 or ld returns 5 or out of memory ...) and can not produce wxmsw28u_gcc.dll file.

I use GCC4.6 with 'auto-import.diff' and gcc patch 'pr43601-try.diff' (this patch was applied by GCC4.6 officially, no need to apply by myself):

'auto-import.diff' file:
Quote

--- ld/emultempl/pe.em   2009-09-14 19:43:30 +0800
+++ ld/emultempl/pe.em   2010-01-29 10:49:20 +0800
@@ -155,7 +155,7 @@
     default_auto_import=1
     ;;
   *)
-    default_auto_import=-1
+    default_auto_import=1
     ;;
 esac
 
@@ -946,7 +946,8 @@
 
       if (pe_enable_stdcall_fixup == -1)
         {
-          einfo (_("Warning: resolving %s by linking to %s\n"),
+          if (link_info.pei386_auto_import == -1)
+               info_msg (_("Info: resolving %s by linking to %s (auto-import)\n"),
             undef->root.string, cname);
           if (! gave_warning_message)
             {
@@ -973,7 +974,8 @@
 
       if (pe_enable_stdcall_fixup == -1)
         {
-          einfo (_("Warning: resolving %s by linking to %s\n"),
+          if (link_info.pei386_auto_import == -1)
+               info_msg (_("Info: resolving %s by linking to %s (auto-import)\n"),
             undef->root.string, sym->root.string);
           if (! gave_warning_message)
             {

'pr43601-try.diff' file:
Quote

Index: gcc/c-family/c.opt
===================================================================
--- gcc/c-family/c.opt   (revision 168608)
+++ gcc/c-family/c.opt   (working copy)
@@ -814,6 +814,10 @@ ffriend-injection
 C++ ObjC++ Var(flag_friend_injection)
 Inject friend functions into enclosing namespace
 
+fkeep-inline-dllexport
+C C++ ObjC ObjC++ Var(flag_keep_inline_dllexport) Init(1) Report Condition(TARGET_DLLIMPORT_DECL_ATTRIBUTES)
+Don't emit dllexported inline functions unless needed
+
 flabels-ok
 C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
 
Index: gcc/tree.c
===================================================================
--- gcc/tree.c   (revision 168608)
+++ gcc/tree.c   (working copy)
@@ -5509,7 +5509,8 @@ handle_dll_attribute (tree * pnode, tree name, tre
         DECL_DLLIMPORT_P (node) = 1;
     }
   else if (TREE_CODE (node) == FUNCTION_DECL
-      && DECL_DECLARED_INLINE_P (node))
+      && DECL_DECLARED_INLINE_P (node)
+      && flag_keep_inline_dllexport)
     /* An exported function, even if inline, must be emitted.  */
     DECL_EXTERNAL (node) = 0;
 
Index: gcc/cp/semantics.c
===================================================================
--- gcc/cp/semantics.c   (revision 168608)
+++ gcc/cp/semantics.c   (working copy)
@@ -3446,7 +3446,8 @@ expand_or_defer_fn_1 (tree fn)
       if ((flag_keep_inline_functions
       && DECL_DECLARED_INLINE_P (fn)
       && !DECL_REALLY_EXTERN (fn))
-     || lookup_attribute ("dllexport", DECL_ATTRIBUTES (fn)))
+     || (flag_keep_inline_dllexport
+         && lookup_attribute ("dllexport", DECL_ATTRIBUTES (fn))))
    mark_needed (fn);
     }
 
Index: gcc/cp/decl2.c
===================================================================
--- gcc/cp/decl2.c   (revision 168608)
+++ gcc/cp/decl2.c   (working copy)
@@ -1780,7 +1780,8 @@ decl_needed_p (tree decl)
       return true;
   /* Functions marked "dllexport" must be emitted so that they are
      visible to other DLLs.  */
-  if (lookup_attribute ("dllexport", DECL_ATTRIBUTES (decl)))
+  if (flag_keep_inline_dllexport
+      && lookup_attribute ("dllexport", DECL_ATTRIBUTES (decl)))
     return true;
   /* Otherwise, DECL does not need to be emitted -- yet.  A subsequent
      reference to DECL might cause it to be emitted later.  */

my gcc (officially with 'pr43601-try.diff' patch applied) info:
Quote

C:\Documents and Settings\David>gcc -v

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=d:/program/mingw/bin/../libexec/gcc/mingw32/4.6.0/lto-wrappe
r.exe
Target: mingw32
Configured with: ../source/GCC46/configure --prefix=/mingw --build=mingw32 --hos
t=mingw32 --target=mingw32 --enable-languages=c,c++ --enable-libgomp --enable-li
biconv --disable-werror --enable-threads=win32 --disable-nls --disable-win32-reg
istry --disable-sjlj-exceptions --with-dwarf2 --enable-lto --enable-fully-dynami
c-string --with-system-zlib --with-host-libstdcxx=-lstdc++ --enable-libstdcxx-de
bug --enable-cxx-flags='-fno-function-sections -fno-data-sections' --disable-lib
stdcxx-pch --disable-symvers --enable-version-specific-runtime-libs --enable-boo
tstrap --enable-static --disable-shared --with-pkgversion=pcx32
Thread model: win32
gcc version 4.6.0 20110318 (prerelease) (pcx32)

my ld (with 'auto-import.diff' patch applied by myself) info:
Quote

C:\Documents and Settings\David>ld -v
GNU ld (pcx32) 2.21.51.20110313

Could someone be kindly to tell me what's the reason or any solution?

And I also want to know, if I want to use LTO of GCC4.6 to build wxWidgets, how to modify the config file?
like this ?
Quote
mingw32-make -f makefile.gcc CXXFLAGS="-enable-auto-import -O2 -pipe -mthreads -fvisibility=hidden -fvisibility-inlines-hidden -flto" LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--copy-dt-needed-entries -Wl,-enable-auto-import -Wl,-flto -s" SHARED=1 BUILD=release UNICODE=1 DEBUG_INFO=0 DEBUG_FLAG=0 MONOLITHIC=1 USE_STC=0 USE_PROPGRID=1 USE_EXCEPTIONS=0 USE_RTTI=0 OFFICIAL_BUILD=1 RUNTIME_LIBS=static

waiting for kindly help.

Best regards.
David.
« Last Edit: March 20, 2011, 01:32:26 am by wangdong1226 »

Offline reckless

  • Regular
  • ***
  • Posts: 338
Re: FYI: GCC 4.5.0 on Mingw.org
« Reply #79 on: March 20, 2011, 08:19:19 am »
hmm the dll inline patch you use seems to be a backport of the gcc-4.6 branch while its supposedly fixed i found that dll's still grow to huge proportions with the 4.6 version of gcc, so it seems its not totally fixed yet.

lto is btw broken with the 32 bit mingw version of gcc-4.6.0 but its still not released so i hope they iron it out before it hits release.

stage 1 bootstrap seems to be broken with the 64 bit mingw version also if you try to build it with freshly built version of the gcc-4.6.0 release candidate (collect2 ld returns 116 exit status) it builds fine with older gcc but it should be able to bootstrap itself which it cant.


Offline xunxun

  • Almost regular
  • **
  • Posts: 187
Re: FYI: GCC 4.5.0 on Mingw.org
« Reply #80 on: March 20, 2011, 08:56:26 am »
To wangdong1226:
    I have compiled gcc4.6 successfully on Windows (revert Nathan's patch), but the edition can produce a very large wx release dll (mine is 17M), and when I use "-flto -fuse-linker-plugin", the dll will be 7M. So I currently recommend 4.6 only to test, not to be a production.

ps: pcx32 is my copyright. :)
Regards,
xunxun

Offline wangdong1226

  • Multiple posting newcomer
  • *
  • Posts: 46
Re: FYI: GCC 4.5.0 on Mingw.org
« Reply #81 on: March 20, 2011, 09:04:59 am »
To wangdong1226:
    I have compiled gcc4.6 successfully on Windows (revert Nathan's patch), but the edition can produce a very large wx release dll (mine is 17M), and when I use "-flto -fuse-linker-plugin", the dll will be 7M. So I currently recommend 4.6 only to test, not to be a production.

ps: pcx32 is my copyright. :)

Dear xunxun1982, thanks for your kindly suggestion. I'll go back to gcc 4.5.2

I used your released gcc 4.5.2 (http://forums.codeblocks.org/index.php/topic,13761.msg96721/topicseen.html#msg96721)to build wxWidgets 2.8.12, but I got error either:
Quote

c_mswudll\monodll_richtextstyles.o gcc_mswudll\monodll_richtextxml.o gcc_mswudll
\monodll_richtexthtml.o gcc_mswudll\monodll_richtextformatdlg.o gcc_mswudll\mono
dll_richtextsymboldlg.o gcc_mswudll\monodll_richtextstyledlg.o gcc_mswudll\monod
ll_richtextprint.o gcc_mswudll\monodll_xml.o gcc_mswudll\monodll_xtixml.o   -mth
reads -L..\..\lib\gcc_dll -Wl,--out-implib=..\..\lib\gcc_dll\libwxmsw28u.a  -Wl,
-flto -Wl,-fwhole-program -Wl,-O1 -Wl,--sort-common -Wl,--copy-dt-needed-entries
 -Wl,-enable-auto-import -s  -lwxtiff -lwxjpeg -lwxpng  -lwxzlib  -lwxregexu -lw
xexpat     -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -
lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lodbc32
Creating library file: ..\..\lib\gcc_dll\libwxmsw28u.a
lto-wrapper: invalid LTO mode
collect2: lto-wrapper returned 1 exit status
mingw32-make: *** [..\..\lib\gcc_dll\wxmsw28u_gcc.dll] Error 1

D:\Program\wxWidgets2.8.12\build\msw>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=d:/program/mingw/bin/../libexec/gcc/i686-pc-mingw32/4.5.2/lt
o-wrapper.exe
Target: i686-pc-mingw32
Configured with: ./configure --prefix=/mingw --build=i686-pc-mingw32 --host=i686
-pc-mingw32 --target=i686-pc-mingw32 --enable-languages=c,c++,fortran --enable-l
ibgomp --enable-libiconv --disable-werror --enable-threads=win32 --disable-nls -
-disable-win32-registry --disable-sjlj-exceptions --with-dwarf2 --enable-lto --e
nable-fully-dynamic-string --with-system-zlib --with-host-libstdcxx=-lstdc++ --e
nable-libstdcxx-debug --enable-cxx-flags='-fno-function-sections -fno-data-secti
ons' --disable-libstdcxx-pch --disable-symvers --enable-version-specific-runtime
-libs --disable-bootstrap --with-libelf --enable-static --disable-shared --with-
pkgversion=pcx32
Thread model: win32
gcc version 4.5.2 20101118 (prerelease) (pcx32)

my build file:
Quote
mingw32-make -f makefile.gcc CFLAGS="-flto -fwhole-program" LFLAGS="-Wl,-flto -Wl,-fwhole-program" CXXFLAGS="-flto -fwhole-program -enable-auto-import -O2 -pipe -mthreads" LDFLAGS="-Wl,-flto -Wl,-fwhole-program -Wl,-O1 -Wl,--sort-common -Wl,--copy-dt-needed-entries -Wl,-enable-auto-import -s" SHARED=1 BUILD=release UNICODE=1 DEBUG_INFO=0 DEBUG_FLAG=0 MONOLITHIC=1 USE_STC=0 USE_PROPGRID=1 USE_EXCEPTIONS=0 USE_RTTI=0 OFFICIAL_BUILD=1 RUNTIME_LIBS=static

BTW, when I using your released gcc 4.5.2, in "D:\Program\wxWidgets2.8.12\build\msw", it produce "gcc_mswudll" folder same as other versions gcc did, but the size of it is only 187MB. When I use official MinGW GCC 4.5.2, it will produce "gcc_mswudll" folder about 460~480MB; the gcc 4.6.0 which I produced acc. to your guide "Build mingw gcc 4.5.x 32bit from snapshots" from your blog, it will produce "gcc_mswudll" folder about 460~480MB also.

I want to know what's the difference between your released gcc 4.5.2 and official MinGW GCC 4.5.2

When I remove the lto options in my build file:
Quote
mingw32-make -f makefile.gcc CXXFLAGS="-enable-auto-import -O2 -pipe -mthreads" LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--copy-dt-needed-entries -Wl,-enable-auto-import -s" SHARED=1 BUILD=release UNICODE=1 DEBUG_INFO=0 DEBUG_FLAG=0 MONOLITHIC=1 USE_STC=0 USE_PROPGRID=1 USE_EXCEPTIONS=0 USE_RTTI=0 OFFICIAL_BUILD=1 RUNTIME_LIBS=static
it will successfully produce wxmsw28u_gcc.dll file, but the size of it only 5.49MB, not 'official' approx. 9MB.
« Last Edit: March 20, 2011, 09:21:15 am by wangdong1226 »

Offline xunxun

  • Almost regular
  • **
  • Posts: 187
Re: FYI: GCC 4.5.0 on Mingw.org
« Reply #82 on: March 20, 2011, 09:22:50 am »
You can't use -fwhole-program

You can try:
Code
 mingw32-make -f makefile.gcc CPPFLAGS="-Os -flto -pipe -mthreads" CXXFLAGS="-fvisibility=hidden -fvisibility-inlines-hidden -Wno-attributes" LDFLAGS="-Wl,-O1 -Wl,--sort-common -Wl,--as-needed -s -flto" SHARED=1 BUILD=release UNICODE=1 DEBUG_INFO=0 DEBUG_FLAG=0 MONOLITHIC=1 USE_EXCEPTIONS=0 USE_RTTI=0 OFFICIAL_BUILD=1 RUNTIME_LIBS=static  
Regards,
xunxun

Offline xunxun

  • Almost regular
  • **
  • Posts: 187
Re: FYI: GCC 4.5.0 on Mingw.org
« Reply #83 on: March 20, 2011, 09:26:45 am »
btw, my edition has reverted Nathan's patch which can produce very large obj files to compile wx smoothly and patch the LTO patch, so you can use -flto to compile the wx dll smoothly, too.
Regards,
xunxun

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: FYI: GCC 4.5.0 on Mingw.org
« Reply #84 on: March 20, 2011, 09:32:49 am »
Please stop discussing not C::B related stuff here.

Otherwise this topic (and related topics) get locked !