On Thu, 10 Mar 2011, Rainer Orth wrote: > Richard Guenther <rguent...@suse.de> writes: > > > If I read this patch correctly then > > > > 1) it doesn't change the condition under which lto-plugin/ is built > > (good) > > Right. > > > 2) it makes -fuse-linker-plugin the default for and only for > > known good linkers (GNU binutils >= 2.21) (good) > > Indeed. > > > 3) it makes it impossible to use -fuse-linker-plugin explicitly > > for other linkers or linkers that were not installed during > > configuring gcc (bad - esp. the latter) > > > > can you please try avoiding 3) at this stage? Or is the whole > > point of this patch 3) to be able to fix PR46944? > > That was my goal: the Solaris linker accepts -p <auditlib>, which causes > confusion when it is called with -plugin. > > > Ideally we'd reject broken linkers at runtime, but that would > > require some major collect2 massaging (eventually falling back > > to collect2 or simply reporting an error). > > What about making LTO_PLUGIN 3-valued? > > 2 linker used has full -plugin support, i.e. gld/gold >= 2.21 > 1 linker has some -plugin support, i.e. gold >= 2.20 < 2.21 > 0 linker has no known plugin support, i.e. everything else, in > particular vendor linkers > > We'd default to -fuse-linker-plugin for 2, accept it if given explicitly > for 1, and reject it for 0. > > This would be similar to the first version of my patch, with the > difference that we don't try to determine the level of -plugin support > from trying to run the configured linker with -plugin and check if it > works, but instead hardcode that knowledge. > > > That said, I'm not 100% happy with 3) at this point (though > > 2) is very desirable). > > > > Can we to fix 46944 change the dejagnu require-linker-plugin > > to check if a linker plugin is used by default and not add > > -fuse-linker-plugin? > > That might be involved since it requires parsing gcc -Wl,-debug output. > I suppose the solution outlined above is simpler and thus more robust.
It might be as simple as int res; int main() { int x; asm ("mov res, %0" : x(g)); return x; } which should fail to link with the plugin only (but yes, requies target dependent assembly ...). Or, use -save-temps and check for the existence of the resolution file for int main() {}. It should be named t.res for gcc -o t t.c -flto. Richard.