Re: Issue with LTO/-fwhole-program

2010-06-14 Thread Ian Lance Taylor
Richard Guenther writes: > Commons between shared libraries and a program can't work. Technically speaking, shared libraries never have common symbols. They can have defined symbols which are labelled as, in essence, "formerly common," and those can be made to work correctly under certain restr

Re: Issue with LTO/-fwhole-program

2010-06-14 Thread Ian Lance Taylor
"Bingfeng Mei" writes: > Actually, gold plugin is used in the original example. However, resolution > produced by plugin is bypassed due to a bug-fix by Richard. Do you have any > comment on that: > http://gcc.gnu.org/ml/gcc-patches/2010-06/msg01116.html Sorry, I missed that. There is a bug in

Re: Issue with LTO/-fwhole-program

2010-06-14 Thread Richard Guenther
On Mon, Jun 14, 2010 at 11:27 AM, David Brown wrote: > On 14/06/2010 11:22, Dave Korn wrote: >> >> On 14/06/2010 05:43, Ian Lance Taylor wrote: >>> >>> David Brown  writes: >>> After doing a bit more reading and thinking, it seems to me that -fwhole-program will be used in most cases whe

Re: Issue with LTO/-fwhole-program

2010-06-14 Thread Richard Guenther
On Mon, Jun 14, 2010 at 9:26 AM, David Brown wrote: > On 14/06/2010 06:43, Ian Lance Taylor wrote: >> >> David Brown  writes: >> >>> After doing a bit more reading and thinking, it seems to me that >>> -fwhole-program will be used in most cases where LTO is used.  You use >>> -flto when compiling

Re: Issue with LTO/-fwhole-program

2010-06-14 Thread David Brown
On 14/06/2010 11:22, Dave Korn wrote: On 14/06/2010 05:43, Ian Lance Taylor wrote: David Brown writes: After doing a bit more reading and thinking, it seems to me that -fwhole-program will be used in most cases where LTO is used. You use -flto when compiling each source file, then link them

RE: Issue with LTO/-fwhole-program

2010-06-14 Thread Bingfeng Mei
> -Original Message- > From: gcc-ow...@gcc.gnu.org [mailto:gcc-ow...@gcc.gnu.org] On Behalf Of > Ian Lance Taylor > Sent: 14 June 2010 05:43 > To: David Brown > Cc: gcc@gcc.gnu.org > Subject: Re: Issue with LTO/-fwhole-program > > David Brown writes: &g

Re: Issue with LTO/-fwhole-program

2010-06-14 Thread Dave Korn
On 14/06/2010 05:43, Ian Lance Taylor wrote: > David Brown writes: > >> After doing a bit more reading and thinking, it seems to me that >> -fwhole-program will be used in most cases where LTO is used. You use >> -flto when compiling each source file, then link them with gcc with >> -flto and -f

Re: Issue with LTO/-fwhole-program

2010-06-14 Thread David Brown
On 14/06/2010 06:43, Ian Lance Taylor wrote: David Brown writes: After doing a bit more reading and thinking, it seems to me that -fwhole-program will be used in most cases where LTO is used. You use -flto when compiling each source file, then link them with gcc with -flto and -fwhole-program

Re: Issue with LTO/-fwhole-program

2010-06-13 Thread Ian Lance Taylor
David Brown writes: > After doing a bit more reading and thinking, it seems to me that > -fwhole-program will be used in most cases where LTO is used. You use > -flto when compiling each source file, then link them with gcc with > -flto and -fwhole-program. Except in the case of libraries or ot

Re: Issue with LTO/-fwhole-program

2010-06-13 Thread David Brown
Dave Korn wrote: On 13/06/2010 23:22, David Brown wrote: I agree that banning common symbols is not a complete solution. But perhaps it may be a partial solution until some more complete solution is found and implemented? How about having a warning flag -Wcommon-lto Incidentally, the orig

Re: Issue with LTO/-fwhole-program

2010-06-13 Thread Joseph S. Myers
On Mon, 14 Jun 2010, Dave Korn wrote: > On 13/06/2010 23:20, Joseph S. Myers wrote: > > On Sun, 13 Jun 2010, Dave Korn wrote: > > > >> On 13/06/2010 20:55, Ian Lance Taylor wrote: > >>> David Brown writes: > >>> > If -flto were to activate the -fno-common flag, would that then catch >

Re: Issue with LTO/-fwhole-program

2010-06-13 Thread Dave Korn
On 13/06/2010 23:20, Joseph S. Myers wrote: > On Sun, 13 Jun 2010, Dave Korn wrote: > >> On 13/06/2010 20:55, Ian Lance Taylor wrote: >>> David Brown writes: >>> If -flto were to activate the -fno-common flag, would that then catch these potential problems with a linker error? >>> We c

Re: Issue with LTO/-fwhole-program

2010-06-13 Thread Dave Korn
On 13/06/2010 23:22, David Brown wrote: > I agree that banning common symbols is not a complete solution. But > perhaps it may be a partial solution until some more complete solution > is found and implemented? > > How about having a warning flag -Wcommon-lto > Incidentally, the original poste

Re: Issue with LTO/-fwhole-program

2010-06-13 Thread David Brown
Dave Korn wrote: On 13/06/2010 20:55, Ian Lance Taylor wrote: David Brown writes: If -flto were to activate the -fno-common flag, would that then catch these potential problems with a linker error? We could perhaps do that for C/C++ code, but Fortran relies on common symbols. Well we shoul

Re: Issue with LTO/-fwhole-program

2010-06-13 Thread Joseph S. Myers
On Sun, 13 Jun 2010, Dave Korn wrote: > On 13/06/2010 20:55, Ian Lance Taylor wrote: > > David Brown writes: > > > >> If -flto were to activate the -fno-common flag, would that then catch > >> these potential problems with a linker error? > > > > We could perhaps do that for C/C++ code, but Fo

Re: Issue with LTO/-fwhole-program

2010-06-13 Thread Dave Korn
On 13/06/2010 20:55, Ian Lance Taylor wrote: > David Brown writes: > >> If -flto were to activate the -fno-common flag, would that then catch >> these potential problems with a linker error? > > We could perhaps do that for C/C++ code, but Fortran relies on common > symbols. Well we shouldn't

Re: Issue with LTO/-fwhole-program

2010-06-13 Thread Ian Lance Taylor
David Brown writes: > If -flto were to activate the -fno-common flag, would that then catch > these potential problems with a linker error? We could perhaps do that for C/C++ code, but Fortran relies on common symbols. Ian

Re: Issue with LTO/-fwhole-program

2010-06-13 Thread David Brown
On 12/06/2010 16:52, Richard Guenther wrote: On Sat, Jun 12, 2010 at 3:32 PM, David Brown wrote: Ian Lance Taylor wrote: Manuel López-Ibáñez writes: This also means that linking your program with non-LTO+whole-program code may lead to miscompilations without any warning, which is really ba

Re: Issue with LTO/-fwhole-program

2010-06-12 Thread Ian Lance Taylor
David Brown writes: > Assuming I'm correct here, then perhaps there could be a warning or > error message that is triggered by breaking the ODR, and which could > be enabled automatically by the -flto flag. Perhaps existing checking > mechanisms from C++ can be used here. It's a good idea but u

Re: Issue with LTO/-fwhole-program

2010-06-12 Thread Richard Guenther
On Sat, Jun 12, 2010 at 3:32 PM, David Brown wrote: > Ian Lance Taylor wrote: >> >> Manuel López-Ibáñez writes: >> >>> This also means that linking your program with non-LTO+whole-program >>> code may lead to miscompilations without any warning, which is really >>> bad. I don't think it is a reas

Re: Issue with LTO/-fwhole-program

2010-06-12 Thread David Brown
Ian Lance Taylor wrote: Manuel López-Ibáñez writes: This also means that linking your program with non-LTO+whole-program code may lead to miscompilations without any warning, which is really bad. I don't think it is a reasonable limitation and we will get bad press when programs start breaking

Re: Issue with LTO/-fwhole-program

2010-06-12 Thread Manuel López-Ibáñez
On 12 June 2010 01:27, Richard Guenther wrote: > On Fri, Jun 11, 2010 at 9:41 PM, Manuel López-Ibáñez > wrote: >> On 11 June 2010 20:48, Cary Coutant wrote: But if I understand correctly, mixed LTO/non-LTO + whole-program is almost never correct. So we should really emit a warning for

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Richard Guenther
On Fri, Jun 11, 2010 at 9:41 PM, Manuel López-Ibáñez wrote: > On 11 June 2010 20:48, Cary Coutant wrote: >>> But if I understand correctly, mixed LTO/non-LTO + whole-program is >>> almost never correct. So we should really emit a warning for this >>> specific combination. I think making this mist

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Ian Lance Taylor
Manuel López-Ibáñez writes: > This also means that linking your program with non-LTO+whole-program > code may lead to miscompilations without any warning, which is really > bad. I don't think it is a reasonable limitation and we will get bad > press when programs start breaking for users. They wo

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread H.J. Lu
On Fri, Jun 11, 2010 at 12:50 PM, Manuel López-Ibáñez wrote: > On 11 June 2010 21:41, Manuel López-Ibáñez wrote: >> On 11 June 2010 20:48, Cary Coutant wrote: But if I understand correctly, mixed LTO/non-LTO + whole-program is almost never correct. So we should really emit a warning fo

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Manuel López-Ibáñez
On 11 June 2010 21:41, Manuel López-Ibáñez wrote: > On 11 June 2010 20:48, Cary Coutant wrote: >>> But if I understand correctly, mixed LTO/non-LTO + whole-program is >>> almost never correct. So we should really emit a warning for this >>> specific combination. I think making this mistake would

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Manuel López-Ibáñez
On 11 June 2010 20:48, Cary Coutant wrote: >> But if I understand correctly, mixed LTO/non-LTO + whole-program is >> almost never correct. So we should really emit a warning for this >> specific combination. I think making this mistake would be quite easy >> but hard to debug. > > It's not only co

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Paolo Bonzini
On 06/11/2010 03:26 PM, Jan Hubicka wrote: Ah, so the problem is the missing -flto in the second compilation step? I think this is a bug in the compiler for not reporting this somehow. Is there are PR open for this? Compiler can not report it because it does not see the other object files. It i

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Cary Coutant
> But if I understand correctly, mixed LTO/non-LTO + whole-program is > almost never correct. So we should really emit a warning for this > specific combination. I think making this mistake would be quite easy > but hard to debug. It's not only correct, it's essential. "Whole Program" doesn't mean

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Joern Rennecke
Quoting Jan Hubicka : Perhaps we can somehow poison the object names that are brought local with -fwhole-program so linking explode, but I am not sure there is way to do so. The linker will generally emit a diagnostic when the size or alignment of a symbol increases, or the type changes.

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Ralf Wildenhues
* Jan Hubicka wrote on Fri, Jun 11, 2010 at 03:26:12PM CEST: > > Ah, so the problem is the missing -flto in the second compilation > > step? I think this is a bug in the compiler for not reporting this > > somehow. Is there are PR open for this? > > Compiler can not report it because it does not s

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Ian Lance Taylor
Manuel López-Ibáñez writes: > On 11 June 2010 15:04, Bingfeng Mei wrote: >> Well, mixed LTO/non-LTO is quite useful. For example, we have mixed >> C/assembly >> Application. Gold support for our target is still far away. I found >> -fwhole-program >> is very important for our size optimization

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Ian Lance Taylor
Manuel López-Ibáñez writes: > On 11 June 2010 15:26, Jan Hubicka wrote: >>> Ah, so the problem is the missing -flto in the second compilation >>> step? I think this is a bug in the compiler for not reporting this >>> somehow. Is there are PR open for this? >> >> Compiler can not report it becaus

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Jan Hubicka
> On 11/06/2010 14:26, Jan Hubicka wrote: > > > Perhaps we can somehow poison the object names that are brought local with > > -fwhole-program > > so linking explode, but I am not sure there is way to do so. > > Could emit warning symbols, but, like the others, I don't see why collect2 > can't

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Dave Korn
On 11/06/2010 14:26, Jan Hubicka wrote: > Perhaps we can somehow poison the object names that are brought local with > -fwhole-program > so linking explode, but I am not sure there is way to do so. Could emit warning symbols, but, like the others, I don't see why collect2 can't spot this.

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Manuel López-Ibáñez
On 11 June 2010 15:26, Jan Hubicka wrote: >> Ah, so the problem is the missing -flto in the second compilation >> step? I think this is a bug in the compiler for not reporting this >> somehow. Is there are PR open for this? > > Compiler can not report it because it does not see the other object fi

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Jan Hubicka
> Ah, so the problem is the missing -flto in the second compilation > step? I think this is a bug in the compiler for not reporting this > somehow. Is there are PR open for this? Compiler can not report it because it does not see the other object files. It is really up to user to understand -fwhol

RE: Issue with LTO/-fwhole-program

2010-06-11 Thread Bingfeng Mei
> -Original Message- > From: Manuel López-Ibáñez [mailto:lopeziba...@gmail.com] > Sent: 11 June 2010 14:14 > To: Bingfeng Mei > Cc: Dave Korn; Richard Guenther; gcc@gcc.gnu.org; Jan Hubicka > Subject: Re: Issue with LTO/-fwhole-program > > On 11 June 2010 15

RE: Issue with LTO/-fwhole-program

2010-06-11 Thread Bingfeng Mei
> -Original Message- > From: Richard Guenther [mailto:richard.guent...@gmail.com] > Sent: 11 June 2010 14:08 > To: Bingfeng Mei > Cc: Dave Korn; Manuel López-Ibáñez; gcc@gcc.gnu.org; Jan Hubicka > Subject: Re: Issue with LTO/-fwhole-program > > On Fri, Jun 11, 2

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Manuel López-Ibáñez
On 11 June 2010 15:04, Bingfeng Mei wrote: > Well, mixed LTO/non-LTO is quite useful. For example, we have mixed C/assembly > Application. Gold support for our target is still far away. I found > -fwhole-program > is very important for our size optimization. But if I understand correctly, mixed

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Richard Guenther
>> Sent: 11 June 2010 14:21 >> To: Richard Guenther >> Cc: Manuel López-Ibáñez; Bingfeng Mei; gcc@gcc.gnu.org; Jan Hubicka >> Subject: Re: Issue with LTO/-fwhole-program >> >> On 11/06/2010 13:59, Richard Guenther wrote: >> >> > Well, we can'

RE: Issue with LTO/-fwhole-program

2010-06-11 Thread Bingfeng Mei
rn.cyg...@gmail.com] > Sent: 11 June 2010 14:21 > To: Richard Guenther > Cc: Manuel López-Ibáñez; Bingfeng Mei; gcc@gcc.gnu.org; Jan Hubicka > Subject: Re: Issue with LTO/-fwhole-program > > On 11/06/2010 13:59, Richard Guenther wrote: > > > Well, we can't. We specific

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Richard Guenther
On Fri, Jun 11, 2010 at 3:21 PM, Dave Korn wrote: > On 11/06/2010 13:59, Richard Guenther wrote: > >> Well, we can't.  We specifically support mixed LTO/non LTO objects >> (think of shared libraries for example).  With the linker-plugin and gold >> we can do better, but with just GNU ld and collec

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Dave Korn
On 11/06/2010 13:59, Richard Guenther wrote: > Well, we can't. We specifically support mixed LTO/non LTO objects > (think of shared libraries for example). With the linker-plugin and gold > we can do better, but with just GNU ld and collect2 we can't. Well then shouldn't we warn if -fwhole-pr

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Richard Guenther
On Fri, Jun 11, 2010 at 2:57 PM, Manuel López-Ibáñez wrote: > On 11 June 2010 14:40, Richard Guenther wrote: >> On Fri, Jun 11, 2010 at 2:36 PM, Manuel López-Ibáñez >> wrote: >>> On 11 June 2010 14:23, Richard Guenther wrote: On Fri, Jun 11, 2010 at 2:22 PM, Manuel López-Ibáñez wrote

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Manuel López-Ibáñez
On 11 June 2010 14:40, Richard Guenther wrote: > On Fri, Jun 11, 2010 at 2:36 PM, Manuel López-Ibáñez > wrote: >> On 11 June 2010 14:23, Richard Guenther wrote: >>> On Fri, Jun 11, 2010 at 2:22 PM, Manuel López-Ibáñez >>> wrote: On 11 June 2010 14:07, Richard Guenther wrote: > On Fri,

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Richard Guenther
On Fri, Jun 11, 2010 at 2:36 PM, Manuel López-Ibáñez wrote: > On 11 June 2010 14:23, Richard Guenther wrote: >> On Fri, Jun 11, 2010 at 2:22 PM, Manuel López-Ibáñez >> wrote: >>> On 11 June 2010 14:07, Richard Guenther wrote: On Fri, Jun 11, 2010 at 2:04 PM, Bingfeng Mei wrote: > Hi,

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Manuel López-Ibáñez
On 11 June 2010 14:23, Richard Guenther wrote: > On Fri, Jun 11, 2010 at 2:22 PM, Manuel López-Ibáñez > wrote: >> On 11 June 2010 14:07, Richard Guenther wrote: >>> On Fri, Jun 11, 2010 at 2:04 PM, Bingfeng Mei wrote: Hi, I am still puzzled by the effect of LTO/-fwhole-program. >

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Richard Guenther
On Fri, Jun 11, 2010 at 2:22 PM, Manuel López-Ibáñez wrote: > On 11 June 2010 14:07, Richard Guenther wrote: >> On Fri, Jun 11, 2010 at 2:04 PM, Bingfeng Mei wrote: >>> Hi, >>> >>> I am still puzzled by the effect of LTO/-fwhole-program. >>> For the following simple tests: >>> >>> a.c: >>> >>> #

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Manuel López-Ibáñez
On 11 June 2010 14:07, Richard Guenther wrote: > On Fri, Jun 11, 2010 at 2:04 PM, Bingfeng Mei wrote: >> Hi, >> >> I am still puzzled by the effect of LTO/-fwhole-program. >> For the following simple tests: >> >> a.c: >> >> #include >> int v; >> >> extern void bar(); >> int main() >> { >>  v = 5

Re: Issue with LTO/-fwhole-program

2010-06-11 Thread Richard Guenther
On Fri, Jun 11, 2010 at 2:04 PM, Bingfeng Mei wrote: > Hi, > > I am still puzzled by the effect of LTO/-fwhole-program. > For the following simple tests: > > a.c: > > #include > int v; > > extern void bar(); > int main() > { >  v = 5; >  bar(); > >  printf("v = %d\n", v); >  return 0; > } > > b.c