Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: MortenMacFly on March 14, 2010, 08:33:08 pm

Title: FYI: GCC 4.5.0 on Mingw.org
Post by: MortenMacFly on March 14, 2010, 08:33:08 pm
Hi all,
GCC 4.5.0 is available officially at:
http://sourceforge.net/projects/mingw/files/
Any trials/report concerning:
- compiling/debugging wxWidgets
- compiling/debugging C::B
- compiling/debugging boost
are welcome.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: stahta01 on March 14, 2010, 09:35:18 pm
Current version info is

Code
gcc version 4.5.0 20100311 (experimental) (GCC)

Going to start wxWidgets build in a few minutes

It failed to compile wxWidgets 2.8.11rc2 could not find the stdio.h file.
Does not seem ready for real testing on Windows 7

Tim S.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: thomas on March 15, 2010, 12:55:05 pm
Unusable, sadly.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: ollydbg on March 15, 2010, 03:34:35 pm
Unusable, sadly.
agreed, because a lot of patches need to be applied to the GCC4.5 source.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: ironhead on March 18, 2010, 09:39:09 pm
I'd recommend trying the '-2' release.  I've successfully built wxWidgets and I'm in the process of building C::B with it.

Edit:  I just tried building wxWidgets on my development laptop (with only 1 GB of RAM) as opposed to my development machine at work, and linking failed due to insufficient memory (which never happened before).  I'm following up on the MinGW list.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: stahta01 on March 19, 2010, 04:29:36 am
I'd recommend trying the '-2' release.  I've successfully built wxWidgets and I'm in the process of building C::B with it.

I am having issues using -g "debug" option under code::blocks with the c++ console template program.

Can anyone compile a simple C++ code using header <iostream> without error with GCC 4.5.0 -2?

Edit: I upgraded my binutils to 2.20
Tim S.

From Readme on MinGW GCC 4.5
Code
Runtime requirements:
  binutils-2.20.1-2-mingw32-bin.tar.gz
  libmpc-0.8.1-1-mingw32-dll-2.tar.lzma
  libmpfr-2.4.1-1-mingw32-dll-1.tar.lzma
  libgmp-5.0.1-1-mingw32-dll-10.tar.lzma
  libpthread-2.8.0-3-mingw32-dll-2.tar.lzma (for OpenMP)
  mingwrt-3.18-mingw32-dev.tar.gz
  w32api-3.14-mingw32-dev.tar.gz
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: stahta01 on March 21, 2010, 10:11:59 pm
What version ld.exe are you using?
The one I am using is currently using 1.5GB of memory.
I assume it runs out at 2GB. This is linking wxWidgets 2.8 Branch.

It seems to have leveled off at 1.5GB. I am waiting till it finishes/crashes/errors out before getting the version number.

It ran out of memory.

Code
GNU ld (GNU Binutils) 2.20

Tim S.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: MortenMacFly on March 22, 2010, 07:06:23 am
...for the record: There is a "gcc-4.5.0_20100311-2" version now. I wonder if it has "all bugs fixed"... :lol:
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: idblew on April 22, 2010, 03:33:51 pm
Has anyone got around the issue of ld running out of memory?

I keep getting the error:

Quote
ld.exe: out of memory allocating 28770816 bytes
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: MortenMacFly on April 22, 2010, 03:55:26 pm
...for the record: There is a "gcc-4.5.0_20100311-2" version now.
...now it's:
gcc-4.5.0-1 (2010-04-19)

Has anyone got around the issue of ld running out of memory?
Did you try the above already?
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: Loaden on April 22, 2010, 04:08:52 pm
...now it's:
gcc-4.5.0-1 (2010-04-19)
I try it, but it not working in here.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: idblew on April 22, 2010, 04:30:11 pm
Already testing with gcc-4.5.0-1 (2010-04-19)

Even tried setting the following in config.gcc

Quote
LDFLAGS ?= --no-keep-memory --reduce-memory-overheads

Windows Vista (32-bit)
4GB RAM
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on April 23, 2010, 03:31:19 am
its a problem with inlined code in wxwidgets gcc-4.5.0 produces some pretty massive object files when heavy inlining is used unfortunatly the linker cant cope with it :(

theres a discussion somewhere on the wx forums about it.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on April 24, 2010, 02:05:21 pm
gcc-4.5.0 is released btw.

http://gcc.gnu.org/

wx compilation still runs out of memory though :S looking on how to fix that atm.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on April 24, 2010, 06:23:03 pm
Inline functions decorated with __declspec(dllexport) are now always
   generated and included in object files. This also applies to methods
   defined in classes decorated with __declspec(dllexport).
   This may cause a general increase in object size, since gcc generates
   copies of each dllexport'd inline function in all object files whose
   source includes the header defining the function.

from mingw site about gcc-4.5.0

i foresee problems  :lol:
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: stahta01 on April 24, 2010, 08:00:41 pm
gcc-4.5.0 is released btw.

http://gcc.gnu.org/

wx compilation still runs out of memory though :S looking on how to fix that atm.

It failed for me on Monolithic DLL build; but, worked on MultiLib DLL build.
Win7 32 Bit

Tim S.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on April 25, 2010, 02:51:44 am
aye the monolithic version simply gets to big for ld to handle :/

multilib works fine though.

i can build cb with the multilibs but i doubt the cb guys would love that option ?
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: ollydbg on April 25, 2010, 01:55:46 pm
i can build cb with the multilibs but i doubt the cb guys would love that option ?
I personally perfer monolithic wxWidget library for Codeblocks.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on April 26, 2010, 05:47:46 am
me 2 tbh.

even better since i can now skip the dependency on the mingw dll would be static linking but so far i had no luck with that  :(

had a look at the gcc variables and there seems to be some switches for inline code. im gonna have a go at trying them out if i find anything of use ill post back.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on April 27, 2010, 07:03:56 am
i found the bugger using a sbrk port to win32 in binutils its wxmediactrl.o running us out of memory i will try compiling with it disabled hold on.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: thynson on April 27, 2010, 08:14:57 am
Hi, all

First, pardon for my poor english.

I have succesfully built wxWidgets2.8.11 with MinGW-W64 GCC 4.5.0 cross compiler.
As gcc 4.5.0 changed its code-generation, now the code dllexport-inline function  shall be generated in object files. However, in the headers of wxWidgets, there are so many dllexport-inline functions, so the object file could be as large as 1MB. In my 2GB RAM laptop, Windows Server 2008 R2, it runs with an end of out of memory exception while linking. So I got a cross compiler from MinGW-W64 project, and start building wxWidgets in Ubuntu Linux with 2GB SWAP space(finally it seems cost about 2.8GB memory for linking). This time I built it successful. And I added --disable-precompile-headers whlie configuration to reduce the size of those object files(cause if precompiled header is used, code for all dllexport-inline functions in header of wx would be generated in EACH OBJECT FILES), and edit the Makefile with flags --no-keep-memory , --reduce-memroy-overheads and --enable-runtime-pseudo-reloc-v2 passed to linker to avoid the situation out of memory and to ensure dll loaded properly.  

By the way I tested this library in code::blocks (windows, of cause), compiling and linking went well. But the program could not run and with a 0x0000000c error. I know this problem could be solved by pass a flag of --enable-runtime-pseudo-reloc-v2 to the linker, and I tested this flags in command line and it works. But I don't know where to add this flag in project build option. I added the flag in 'Compiler settings - other options' tab, but it didn't work. I added the flag in 'Linker setting -Other linker option' box, it didn't work, too. So I think if this, flags couldn't be passed to the linker, is a bug of codeblocks, and plz fix it. Or it's a problem of my codeblocks.
  And I also test 64bit-compiler, but 64-bits linker seems to link resource file wrongly(without .res file, the executable is linked properly, but add a resource file it could not run with an error of 0x0000007d)
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on April 27, 2010, 11:00:38 am
if you add it to CXXFLAGS  do it like this CXXFLAGS="-W1,--enable-runtime-pseudo-reloc-v2" to pass it to the linker in case you use LDFLAGS you can get away with this LDFLAGS="-enable-runtime-pseudo-reloc-v2"

the link is indeed  huge memory wise mine bailed out at 2 gig (seems to be the limit for commands in win7 64 bit as anything i tried that went above that crashed).


Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: idblew on April 30, 2010, 10:29:34 am
Wouldn't the solution be to compile/link ld.exe with --large-address-aware ?

PS: Under Windows/MinGW 4.5.0 there is no option called --enable-runtime-pseudo-reloc-v2 only --enable-runtime-pseudo-reloc, is that the same?

UPDATE:  Just tried the above, still doesn't work!
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on April 30, 2010, 08:13:20 pm
--enable-runtime-pseudo-reloc-v2 is from newer binutils not gcc itself ;)
you can try with --enable-runtime-pseudo-reloc but the v2 had a few more fixes.

not sure but i think the v2 was introduced in version 2.20 of binutils.

heres a patch btw if you prefer v2 to allways be on as default.

--- binutils-2.20/ld/emultempl/pe.em   2009-10-30 15:36:58.000000000 +0100
+++ binutils-2.20/ld/emultempl/pe.em   2009-10-30 15:38:07.000000000 +0100
@@ -161,7 +161,7 @@
 
 fragment <<EOF
   link_info.pei386_auto_import = ${default_auto_import};
-  link_info.pei386_runtime_pseudo_reloc = 1; /* Use by default version 1.  */
+  link_info.pei386_runtime_pseudo_reloc = 2; /* Use by default version 2.  */
 
 #if (PE_DEF_SUBSYSTEM == 9) || (PE_DEF_SUBSYSTEM == 2)
 #if defined TARGET_IS_mipspe || defined TARGET_IS_armpe || defined TARGET_IS_arm_wince_pe
@@ -715,7 +715,7 @@
       link_info.pei386_auto_import = 0;
       break;
     case OPTION_DLL_ENABLE_RUNTIME_PSEUDO_RELOC:
-      link_info.pei386_runtime_pseudo_reloc = 1;
+      link_info.pei386_runtime_pseudo_reloc = 2;
       break;
     case OPTION_DLL_ENABLE_RUNTIME_PSEUDO_RELOC_V1:
       link_info.pei386_runtime_pseudo_reloc = 1;

large adress awareness is just a switch to make the code able to use above the 2 gigabyte limitation it does nothing in itself about the size of the object files (which is the problem here).

Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: idblew on May 01, 2010, 12:40:47 pm
I already have 2.20 (see ld.exe -V output below) but don't have the v2 option.

Quote
GNU ld (GNU Binutils) 2.20
  Supported emulations:
   i386pe

I'm on Windows Vista (SP2) - perhaps the option isn't available in the pre-compiled package for Windows?!
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on May 01, 2010, 07:57:40 pm
should be the same for any os ;)

well i was'nt sure it was 2.20 i use 2.20.1 and i have it :)

im on windows 7 64 bit so should be the same for vista.

gonna have to watch out for patches against gcc-4.5.0 if something turns up ill provide a version with the fixes.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: Loaden on May 03, 2010, 02:21:20 am
Hi, all

First, pardon for my poor english.

I have succesfully built wxWidgets2.8.11 with MinGW-W64 GCC 4.5.0 cross compiler.
As gcc 4.5.0 changed its code-generation, now the code dllexport-inline function  shall be generated in object files. However, in the headers of wxWidgets, there are so many dllexport-inline functions, so the object file could be as large as 1MB. In my 2GB RAM laptop, Windows Server 2008 R2, it runs with an end of out of memory exception while linking. So I got a cross compiler from MinGW-W64 project, and start building wxWidgets in Ubuntu Linux with 2GB SWAP space(finally it seems cost about 2.8GB memory for linking). This time I built it successful. And I added --disable-precompile-headers whlie configuration to reduce the size of those object files(cause if precompiled header is used, code for all dllexport-inline functions in header of wx would be generated in EACH OBJECT FILES), and edit the Makefile with flags --no-keep-memory , --reduce-memroy-overheads and --enable-runtime-pseudo-reloc-v2 passed to linker to avoid the situation out of memory and to ensure dll loaded properly.  

By the way I tested this library in code::blocks (windows, of cause), compiling and linking went well. But the program could not run and with a 0x0000000c error. I know this problem could be solved by pass a flag of --enable-runtime-pseudo-reloc-v2 to the linker, and I tested this flags in command line and it works. But I don't know where to add this flag in project build option. I added the flag in 'Compiler settings - other options' tab, but it didn't work. I added the flag in 'Linker setting -Other linker option' box, it didn't work, too. So I think if this, flags couldn't be passed to the linker, is a bug of codeblocks, and plz fix it. Or it's a problem of my codeblocks.
  And I also test 64bit-compiler, but 64-bits linker seems to link resource file wrongly(without .res file, the executable is linked properly, but add a resource file it could not run with an error of 0x0000007d)

I find the reason, When linking, we need this option too.
So, add these option BOTH compiler option and linker option.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: Loaden on May 03, 2010, 03:58:42 am
Build wxWidgets 2.8.10 failed.

Quote
luuid -lrpcrt4 -ladvapi32 -lwsock32 -lodbc32
collect2: ld returned 5 exit status
mingw32-make: *** [..\..\lib\gcc_dll\wxmsw28u.dll] Error 1

config:
Code
# Standard preprocessor flags (common for CC and CXX) 
CPPFLAGS ?= -static-libgcc -static-libstdc++

# Standard linker flags
LDFLAGS ?= -static-libgcc -static-libstdc++

build:
Code
mingw32-make -f makefile.gcc LDFLAGS=-s SHARED=1 BUILD=release UNICODE=1 MONOLITHIC=1 OFFICIAL_BUILD=1 RUNTIME_LIBS=static
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: Loaden on May 03, 2010, 09:40:09 am
If we have some DLL module, we can't use -static-libgcc both in DLL and EXE!
So, I change build config to:
Code
mingw32-make -f makefile.gcc CXXFLAGS="-Wl,--enable-auto-import" LDFLAGS="-Wl,--enable-auto-import -s" SHARED=1 BUILD=release UNICODE=1 MONOLITHIC=1 OFFICIAL_BUILD=1 RUNTIME_LIBS=static

And, I build MinGW 4.5 on archlinux. I am test it on XPSP3, it's works well.
DOWNLOAD: http://qp-gcc.googlecode.com/files/mingw4.5.0.7z (http://qp-gcc.googlecode.com/files/mingw4.5.0.7z)

And enable header's breakpoint now. :D
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on May 03, 2010, 12:31:49 pm
might also be the only option at the moment to crossbuild wxwidgets on linux as theres no way known to increase the stack size for the commandline on windows.

linux does have that option :)

anyway it builds fine with precompiled wxwidgets so its not to much of a hazzle if you got that.

everything else works rather well i agree :)
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: Loaden on May 03, 2010, 12:33:28 pm
The current MinGW 4.5 is not recommended!
http://lists-archives.org/mingw-users/16641-gcc-4-5-change-to-generate-code-for-dllexport-d-inline-functions-in-the-dll.html (http://lists-archives.org/mingw-users/16641-gcc-4-5-change-to-generate-code-for-dllexport-d-inline-functions-in-the-dll.html)
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: ollydbg on May 03, 2010, 02:30:45 pm
@loaden
reckless has explain this before, see Re: FYI: GCC 4.5.0 on Mingw.org (http://forums.codeblocks.org/index.php/topic,12183.msg84321.html#msg84321) and Re: FYI: GCC 4.5.0 on Mingw.org (http://forums.codeblocks.org/index.php/topic,12183.msg84343.html#msg84343).

So, till now, is there a reliable mingw 4.5 package we can use to build wxWidgets library?
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on May 03, 2010, 09:37:43 pm
nothing so far no :( i need to check the diffs between 4.4.3 and 4.5.0 to see whats changed.

Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on May 04, 2010, 04:00:30 pm
about to release a prebuilt wxwidgets (made with gcc-4.4.3) for my fork of gcc-4.5.0 if anyone wants a dwarf2 build for gcc-4.5.0 loaden could maybe provide one ? as my fork uses sjlj

all options on besides opengl but i can build that to if requested.

includes gdiplus.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on May 04, 2010, 04:11:24 pm
ftp://90.184.233.166:21/wxWidgets-prebuilt.lha (ftp://90.184.233.166:21/wxWidgets-prebuilt.lha)

use lzarch to uncompress then point codeblocks to where you unpacked it.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: a14331990 on May 14, 2010, 08:42:53 am
nothing so far no :( i need to check the diffs between 4.4.3 and 4.5.0 to see whats changed.


I would suggest test wxWidgets with all GCC 4.5 snapshots here,
http://gcc.cybermirror.org/snapshots/
to find when this behavior appear, maybe bisection method is helpful.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on May 14, 2010, 08:57:52 am
whoa had no idea they kept a repository of all the diffs  :shock:

nice find thank you :)
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: a14331990 on May 14, 2010, 09:46:06 am
I'm trying to find when this behavior appear in GCC svn log
svn log svn://gcc.gnu.org/svn/gcc/trunk > changs.txt
then
delete anything before March 2009 or after May 2010 in changes.txt(because GCC-4.5 snapshots begin at 4.5-20090402 and end at 4.5-20100513)
and filter dllexport related information,
cat changes.txt|grep dllexport > dllexport.txt
finally lookup entries in dllexport.txt in changes.txt for details of these revisions
------------------------------------------------------------------------
r152511 | dannysmith | 2009-10-07 10:57:21 +0800 (Wed, 07 Oct 2009) | 13 lines

   PR target/41512
   * config/i386/winnt.c (i386_pe_determine_dllexport_p): Don't propagate
   dllexport to class members here.
   (i386_pe_determine_dllimport_p): Only check static class data for
   definition.
   (i386_pe_encode_section_info): Don't recheck DECL_DLLIMPORT_P.
   * config/i386/winnt-cxx.c (i386_pe_type_dllimport_p): Only check
   functions for vague linkage.
   (i386_pe_type_dllexport_p): Fix formatting.
   (maybe_add_dllexport) New function.
   (i386_pe_adjust_class_at_definition): Use it to propagate dllexport
   to class members.

------------------------------------------------------------------------

------------------------------------------------------------------------
r149525 | dannysmith | 2009-07-12 14:09:39 +0800 (Sun, 12 Jul 2009) | 4 lines

   * config/i386/winnt.c (i386_pe_determine_dllexport_p): Don't
   dllexport if !TREE_PUBLIC.
   (i386_pe_maybe_record_exported_symbol): Assert TREE_PUBLIC.

------------------------------------------------------------------------

------------------------------------------------------------------------
r147799 | nathan | 2009-05-22 22:57:15 +0800 (Fri, 22 May 2009) | 16 lines

   gcc/
   * tree.c (handle_dll_attribute): Mark dllexport'd inlines as
   non-external.

   gcc/cp
   * decl2.c (decl_needed_p): Consider dllexport'd functions needed.
   * semantics.c (expand_or_defer_fn): Similarly.

   gcc/testsuite/
   * gcc.dg/dll-6.c: New test.
   * gcc.dg/dll-6a.c: Likewise.
   * gcc.dg/dll-7.c: Likewise.
   * gcc.dg/dll-7a.c: Likewise.
   * g++.dg/ext/dllexport2.C: Likewise.
   * g++.dg/ext/dllexport2a.cc: Likewise.

------------------------------------------------------------------------
Please help me test wxWidgets with GCC 4.5 snapshots around the above date.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: a14331990 on May 15, 2010, 01:23:44 am
Here is a patch to undo the change by nathan at 2009-05-22
Code
--- gcc/tree.c	2010-04-02 00:18:08 +0800 revert some code to gcc-4.5-20090521, don't emit exported inline functions
+++ gcc/tree-2.c 2010-05-14 22:56:44 +0800
@@ -5377,11 +5377,6 @@
       if (*no_add_attrs == false)
         DECL_DLLIMPORT_P (node) = 1;
     }
-  else if (TREE_CODE (node) == FUNCTION_DECL
-    && DECL_DECLARED_INLINE_P (node))
-    /* An exported function, even if inline, must be emitted.  */
-    DECL_EXTERNAL (node) = 0;
-
   /*  Report error if symbol is not accessible at global scope.  */
   if (!TREE_PUBLIC (node)
       && (TREE_CODE (node) == VAR_DECL
--- gcc/cp/decl2.c 2010-03-24 06:29:54 +0800
+++ gcc/cp/decl2-2.c 2010-05-14 23:00:42 +0800
@@ -1782,10 +1782,6 @@
       || (DECL_ASSEMBLER_NAME_SET_P (decl)
    && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
       return true;
-  /* Functions marked "dllexport" must be emitted so that they are
-     visible to other DLLs.  */
-  if (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.  */
   return false;
--- gcc/cp/semantics.c 2010-04-02 02:48:34 +0800
+++ gcc/cp/semantics-2.c 2010-05-14 23:14:04 +0800
@@ -3447,10 +3447,8 @@
 
       /* If the user wants us to keep all inline functions, then mark
  this function as needed so that finish_file will make sure to
- output it later.  Similarly, all dllexport'd functions must
- be emitted; there may be callers in other DLLs.  */
-      if ((flag_keep_inline_functions && DECL_DECLARED_INLINE_P (fn))
-   || lookup_attribute ("dllexport", DECL_ATTRIBUTES (fn)))
+ output it later.  */
+      if (flag_keep_inline_functions && DECL_DECLARED_INLINE_P (fn))
  mark_needed (fn);
     }
 
     But according to infomation here
[Mingw-users] gcc 4.5 change to generate code for dllexport'd inline functions in the DLL
http://lists-archives.org/mingw-users/16635-gcc-4-5-change-to-generate-code-for-dllexport-d-inline-functions-in-the-dll.html
Quote
For C DLLs the solution seems simple enough: just don't dllexport inline
functions and no code for them will be generated. But this doesn't work for
C++ DLLs because, AFAIK, all C++ libraries use the same approach for DLL
export, namely they declare the entire classes as being dllexport'd which
inevitably leads to all of its inline functions being dllexport'd as well.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: stahta01 on May 15, 2010, 02:15:52 am
Bug report on gcc.gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43601

Edit: Added trial of visibility=hidden

Has anyone tried using "-fvisibility=hidden" option? It Failed for me.
I am trying it now; may know in an hour or two if it helps.
I just read the info on http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#Function-Attributes and it says what I am trying wont work; but, it also says the problem does not exist.

After that fails will try "-fvisibility-inlines-hidden" the descriptions sounds like the right fix.
The number of warnings seem to been increased over 100 fold.
I aborted the build it appeared to still be too build of object size.
 
http://gcc.gnu.org/wiki/Visibility
Quote
Lastly, there's one other new command line switch: -fvisibility-inlines-hidden. This causes all inlined class member functions to have hidden visibility, causing significant export symbol table size & binary size reductions though not as much as using -fvisibility=hidden. However, -fvisibility-inlines-hidden can be used with no source alterations, unless you need to override it for inlines where address identity is important either for the function itself or any function local static data.



Tim S.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: a14331990 on May 15, 2010, 02:58:18 am
I have enabled auto-import in ld with this patch.
Code
--- 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)
       {
It is supposed to be used together with the patch in my previous reply.
     In this way, gcc 4.5 don't emit exported inline functions and ld can auto-import symbols.
     I'm testing wxMSW 2.8.11 now with this config
Code
...
SHARED ?= 1
...
UNICODE ?= 1
...
BUILD ?= release
...
MONOLITHIC ?= 1
...
OFFICIAL_BUILD ?= 1
...
    the object files generated are small, 100k per one, don't know linking will work or not, my machine is slow.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: a14331990 on May 15, 2010, 03:10:11 am
Success! :D
The build generated small object files of size 61.5MB in total
and can produce the dll
wxmsw28u_gcc.dll
of size 9.84MB.
    This dll is woking, I tested it with demos/life successfully.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: ollydbg on May 15, 2010, 04:30:17 am
Success! :D
The build generate small object files of size 61.5MB in total
and can produce the dll
wxmsw28u_gcc.dll
of size 9.84MB.
    This dll is woking, I tested it with demos/life successfully.
Nice!!
So, it seems after applying your patch, it is a really workable GCC mingw 4.5.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: a14331990 on May 15, 2010, 05:00:36 am
First, some credits,
the patch about auto-import comes from this post by Dave Korn and slightly modified by me
[PATCH] Silence ld auto-import warnings for pe-i386.
http://sourceware.org/ml/binutils/2009-02/msg00341.html
and the patch about dllexport is just a removal of nathan's code.
r147799 | nathan | 2009-05-22 22:57:15 +0800 (Fri, 22 May 2009) | 16 lines

   gcc/
   * tree.c (handle_dll_attribute): Mark dllexport'd inlines as
   non-external.

   gcc/cp
   * decl2.c (decl_needed_p): Consider dllexport'd functions needed.
   * semantics.c (expand_or_defer_fn): Similarly.

   gcc/testsuite/
   * gcc.dg/dll-6.c: New test.
   * gcc.dg/dll-6a.c: Likewise.
   * gcc.dg/dll-7.c: Likewise.
   * gcc.dg/dll-7a.c: Likewise.
   * g++.dg/ext/dllexport2.C: Likewise.
   * g++.dg/ext/dllexport2a.cc: Likewise.
    I have just built codeblocks r6216 (gcc-4.5,wxmsw 2.8.11), startup ok, cannot open code editor (maybe too slow), I then check another build of codeblocks r6216 (gcc-4.4,wxmsw 2.8.11), same problem. I think I should try wxmsw 2.8.10.
    Update: I close many programs and codeblocks works fine now.
 
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on May 16, 2010, 03:25:44 pm
youre a god thank you very much  :D

Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on May 16, 2010, 07:28:45 pm
cooking up a patch since the problem only seems to affect c++ so check for c++ and if found use old way if not use nathans.

seems like the way to do it correctly ?
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: a14331990 on May 17, 2010, 02:07:21 am
cooking up a patch since the problem only seems to affect c++ so check for c++ and if found use old way if not use nathans.

seems like the way to do it correctly ?
Hello, reckless. Please have a look at this post
[Mingw-users] gcc 4.5 change to generate code for dllexport'd inline functions in the DLL
http://lists-archives.org/mingw-users/16635-gcc-4-5-change-to-generate-code-for-dllexport-d-inline-functions-in-the-dll.html
it says
Quote
For C DLLs the solution seems simple enough: just don't dllexport inline
functions and no code for them will be generated. But this doesn't work for
C++ DLLs
I think nathan's code is for C++ dlls especially libstdc++6.dll, before nathan's code there is no OLD way for libstdc++6.dll.   
it says more
Quote
Cesar Strauss did suggest another approach in private email: don't use
dllexport at all but rely on MinGW auto-import mechanism.
This idea works very good! Thanks Cesar's idea and Dave Korn's patch for Cygwin.
The auto-import approach do have some drawbacks:
Quote
but it's hardly ideal: all classes and
functions defined in the DLL are then exported, even those that are not
supposed to be used outside of it. This unnecessarily bloats (already
big) export tables and just seems like a step backwards. Indeed, if a
consequence of an improvement to dllexport mechanism is that now it can't
be used at all, what was the point of this improvement in the first case?
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: a14331990 on May 17, 2010, 02:14:54 am
Leo's build of gcc, binutils, wxmsw, and cb6233 here.  8)
At Mr.Loaden's googlecode project,(I don't have enough time to manage patch/build/troubleshoot issues, thanks Mr.Loaden.)
http://code.google.com/p/qp-gcc/
located at Wiki and Downloads columns:
http://code.google.com/p/qp-gcc/wiki/GCC45BuildbyLeo
http://code.google.com/p/qp-gcc/wiki/InstallNotesForGCC45BuildByLeo
http://code.google.com/p/qp-gcc/downloads/list
Please help test them.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: ollydbg on May 17, 2010, 03:08:05 am
Leo's build of gcc, binutils, wxmsw, and cb6233 here.  8)
At Mr.Loaden's googlecode project,(I don't have enough time to manage patch/build/troubleshoot issues, thanks Mr.Loaden.)
http://code.google.com/p/qp-gcc/
located at Wiki and Downloads columns:
http://code.google.com/p/qp-gcc/wiki/GCC45BuildbyLeo
http://code.google.com/p/qp-gcc/wiki/InstallNotesForGCC45BuildByLeo
http://code.google.com/p/qp-gcc/downloads/list
Please help test them.
Nice, I will test it!! You're so smart!!!
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on May 17, 2010, 04:46:24 am
okidoki :)

can test the changes soon rebuild should be done in about an hour.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on May 17, 2010, 06:32:52 am
done and working wx builds fine now :D

also updated my compiler to use sysroots (saves me some trouble when i need to rebuild the mingw64 runtime) also keeps the crt clean of any mess a user installs  :lol:
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: stahta01 on May 17, 2010, 10:32:16 pm
GCC 4.5.0 related bug reported to wxWidgets has a work around that I did not need on Multi-Lib Build but I did not test the DLLs.

http://trac.wxwidgets.org/ticket/12064

Tim S.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: a14331990 on May 18, 2010, 04:52:26 am
GCC 4.5.0 related bug reported to wxWidgets has a work around that I did not need on Multi-Lib Build but I did not test the DLLs.

http://trac.wxwidgets.org/ticket/12064

Tim S.
I have enabled --enable-auto-import in ld by default.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: a14331990 on May 19, 2010, 02:19:24 am
News for my build of MinGW GCC 4.5.0, I recently tested Dave Korn's LTO patch for MinGW/Cygwin [1], and it works.
    Enable instructions and prebuilt binary at qp-gcc googlecode page. Have a look at here for details.
http://code.google.com/p/qp-gcc/wiki/GCC45BuildByLeoWithLTO

[1] GCC Bugzilla Bug 42776 LTO doesn't work on non-ELF platforms.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42776
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on May 19, 2010, 06:13:51 am
had my looks on that one also :)  and it does indeed work.

the autotools for the mingw package works btw msys ones have been broken for ages i use these instead for most of the grunt work.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on May 19, 2010, 07:32:39 am
packing up patched source of gcc-4.5.0 for those who wants to try compiling it themself :)

skip java if you like by removing --enable-libgcj from the pkgbuild script (does not work to well anyway).

the mingw64 guys might have a ball on this one since its based on there runtime but i managed to build the entire package with it so there should be some gold to dig out from it  :D atleast they should now have something to bootstrap there ada compiler :)

Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: a14331990 on May 19, 2010, 09:35:36 am
OK. Thanks for your suggestion. Packed the patched and autoconf'd source of gcc 4.5.0 at qp-gcc downloads column.
http://code.google.com/p/qp-gcc/downloads/list
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on May 19, 2010, 12:15:49 pm
packaging my version as i write.

btw for those who want to try lto dont use it while bootstrapping a gcc build ;) ada goes bonkers if you do. its C/C++ only.

Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on May 19, 2010, 12:26:48 pm
ok its up.

http://code.google.com/p/mingw-wine/
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: tyeken8 on May 24, 2010, 03:45:23 am
What version ld.exe are you using?
The one I am using is currently using 1.5GB of memory.
I assume it runs out at 2GB. This is linking wxWidgets 2.8 Branch.

It seems to have leveled off at 1.5GB. I am waiting till it finishes/crashes/errors out before getting the version number.

It ran out of memory.

Code
GNU ld (GNU Binutils) 2.20

Tim S.

That's solved!!!
I used a "hacked" ld.exe using the M$ Visual Studio tool "Editbin" to enable the Large Address Awareness feature, so that it can use up to 4GB Virtual memory (possibly need --large-address-aware option in ld).

Code
editbin /LARGEADDRESSAWARE c:\gcc\bin\ld.exe

with ld flags(passed to G++):
Code
-Wl,--enable-auto-import,--enable-runtime-pseudo-reloc-v2,--no-keep-memory,--reduce-memory-overheads,--large-address-aware

see this, http://www.microsoft.com/whdc/system/platform/server/PAE/PAEmem.mspx (http://www.microsoft.com/whdc/system/platform/server/PAE/PAEmem.mspx)

(http://tydus.googlecode.com/files/GCC.jpg)
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on May 24, 2010, 02:46:29 pm
sounds plausible seing as mingw64 eventually will run into this problem at some time also (damn more patching)  :lol:
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: idblew on May 24, 2010, 03:22:19 pm
It will work on Windows 64-bit (tested and confirmed working), but not on Windows 32-bit unless you specify the /3GB swtich in BOOT.INI (untested)
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: mgpensar on May 24, 2010, 11:05:57 pm
Hi,

I was able to compile wxwidgets 2.8.11 with gcc-4.5.0, however, the minimal application crashes with 0xc00000005 error (app not properly initialized).
Windows XP professional service pack 3 on a Pentium 4 CPU 2.8GHz 1GB RAM.

Does anybody was able to get wx working with mingw gcc-4.5.0-1 release (2010-04-19 in source forge) ?
Should I try to use a version from the version control repository ? I do not see a 4.5.0-2 in the souceforge download site.

Any suggestion is very much welcome. Thanks !
Mau.

mgpensar at gmail.com
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on May 25, 2010, 03:08:38 am
a few of us have uploaded versions of gcc-4.5.0 and binutils-0.20.1 with this fixed i have a version and loaden has one loadens is probably the easiest to get going with since mine uses a different runtime than mingw and relies on sysroots.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: Loaden on August 02, 2010, 04:04:56 am
4.5.1 released.
http://gcc.gnu.org/gcc-4.5/ (http://gcc.gnu.org/gcc-4.5/)
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: ptDev on August 02, 2010, 09:45:04 am
4.5.1 released.
http://gcc.gnu.org/gcc-4.5/ (http://gcc.gnu.org/gcc-4.5/)

From the change list:

Quote from: GCC4.5.1
This is the list of problem reports (PRs) from GCC's bug tracking system that are known to be fixed in the 4.5.1 release. This list might not be complete (that is, it is possible that some PRs that have been fixed are not listed here).

All languages

GCC's new link-time optimizer (-flto) now also works on a few non-ELF targets:

Cygwin (*-cygwin*)
MinGW (*-mingw*)
Darwin on x86-64 (x86_64-apple-darwin*)
LTO is not enabled by default for these targets. To enable LTO, you should configure with the --enable-lto option.

nice :)
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: a14331990 on August 02, 2010, 05:23:27 pm
Successfully built (using my build of mingw gcc 4.5.0, gcc45-leo.7z, located at http://code.google.com/p/qp-gcc/downloads/list)
binutils 2.20.51.20100801
gcc 4.5.1
gdb-7.2.50.20100802
wxWidgets 2.8.10
boost 1.43
codeblocks r6435
on this afternoon. 8)
dll linking and LTO are all OK. :D
All patches utilized will be uploaded to somewhere soon.
Dear moderator of this forum, can I upload it here?  
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: MortenMacFly on August 02, 2010, 08:04:07 pm
All patches utilized will be uploaded to somewhere soon.
Dear moderator of this forum, can I upload it here? 
If these are C::B patches, then yes. Otherwise: No. We don't have endless forums space you know. But you can surely use a filesharing homepage for this...
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on August 02, 2010, 10:21:51 pm
also uploaded latest version on http://code.google.com/p/mingw-wine look for mingw-w32.exe (kgb self extracting archive. done due to site size limit issue).

will make a diff of my modifications to the mingw64 runtime (rather simple really just removes using mingw path/host/include and lib etc. and instead use gcc's include and lib paths).

binutils 2.20.51 from mingw.org includes the patches allready :)

gcc was patched with johns patches for tdm and the lto patch.

crt includes directx and ddk. note the ddk from mingw64 has some headers in other places than the ddk from mingw so you may have to doublecheck your code if you need the ddk.

skipped java in this build as its pretty broken atm on win32. left ada in as it might be handy and it works.

works very well so far :)

 
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: a14331990 on August 03, 2010, 12:19:56 am
All patches utilized will be uploaded to somewhere soon.
Dear moderator of this forum, can I upload it here?  
If these are C::B patches, then yes. Otherwise: No. We don't have endless forums space you know. But you can surely use a filesharing homepage for this...
Thanks for reminding me.
    All patches have been already uploaded to qp-gcc's page and my page
http://code.google.com/p/qp-gcc/downloads/list
http://code.google.com/p/a1mingwgcc/downloads/list
Please help testing them.
     Binaries and Sources will also be uploaded to qp-gcc's page or my page soon
http://code.google.com/p/a1mingwgcc/
Best Regards.
a14331990 a.k.a Leo

Already uploaded 8)
http://code.google.com/p/a1mingwgcc/wiki/InstructionsForMinGWGCC451
http://code.google.com/p/a1mingwgcc/downloads/list
Please help testing them.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on August 08, 2010, 12:32:55 am
hmm spoke to soon wxwidgets cant be compiled as a monolithic dll again with 4.5.1 they changed the code so the patch to undo it can not be applied ouch.

looks like they tried to get smart about checking if inline was really needed commendable but its broken with wxwidgets  :lol:
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: stahta01 on August 08, 2010, 02:16:30 am
What version of 7z was used on binutils-2.20.51.20100801-bin.7z? I could not unzip it.

From http://a1mingwgcc.googlecode.com/files/binutils-2.20.51.20100801-bin.7z

I was able to unzip gcc451-bin-leo.7z

Trying to download binutils a second time. Error-ed out the second time also.

Tim S.

Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: ollydbg on August 09, 2010, 01:45:23 am
What version of 7z was used on binutils-2.20.51.20100801-bin.7z? I could not unzip it.

From http://a1mingwgcc.googlecode.com/files/binutils-2.20.51.20100801-bin.7z

I was able to unzip gcc451-bin-leo.7z

Trying to download binutils a second time. Error-ed out the second time also.

Tim S.



Hi, I can unzip it correctly, I'm using 7-zip 9.15 beta version.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: a14331990 on August 09, 2010, 03:08:52 am
hmm spoke to soon wxwidgets cant be compiled as a monolithic dll again with 4.5.1 they changed the code so the patch to undo it can not be applied ouch.

looks like they tried to get smart about checking if inline was really needed commendable but its broken with wxwidgets  :lol:

The patch regarding "dllexport inline functions" issue is modified by me again.
You can download all patches applied in my build of MinGW GCC 4.5.1 at here:
http://code.google.com/p/a1mingwgcc/downloads/list
http://code.google.com/p/a1mingwgcc/downloads/detail?name=leo-current-patches%284.5.1%29.7z&can=2&q=
Note: If failed, please use the latest 7z beta to unzip.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: a14331990 on August 09, 2010, 03:12:47 am
If failed, please use the latest 7z beta to unzip.
Sorry for the inconvenience.
I'll mention this detail on my page.
Also repacked binutils using the stable 7z ( 7z 4.6.5).

Best Regards.
a14331990 a.ka. Leo
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless on August 10, 2010, 07:44:20 am
thanks leo :)
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: a14331990 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.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: cobines on October 15, 2010, 12:06:06 am
The solution posted here (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43601#c12) 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.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: wangdong1226 on March 20, 2011, 01:05:27 am
The solution posted here (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43601#c12) 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.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: reckless 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.

Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: xunxun 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. :)
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: wangdong1226 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 (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.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: xunxun 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  
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: xunxun 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.
Title: Re: FYI: GCC 4.5.0 on Mingw.org
Post by: Jenna 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 !