From: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
To: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Cc: gcc-patches@gcc.gnu.org, Paolo Bonzini <bonzini@gnu.org>,
Richard Guenther <rguenther@suse.de>
Subject: Re: [build, lto] Only accept -fuse-linker-plugin if linker supports -plugin (PR lto/46944)
Date: Mon, 14 Feb 2011 19:44:00 -0000 [thread overview]
Message-ID: <20110214193917.GA7519@gmx.de> (raw)
In-Reply-To: <ydd39o082o4.fsf@manam.CeBiTec.Uni-Bielefeld.DE>
Hello Rainer,
Sorry for the delay, I somehow missed this mail.
* Rainer Orth wrote on Mon, Feb 07, 2011 at 01:11:39PM CET:
> This is another instance of PR lto/46944: the dg-require-linker-plugin
> test assumes that the linker in use supports -plugin when one can
> compile a simple test program with -fuse-linker-plugin. Unfortunately,
> this is wrong: while Sun ld doesn't support -plugin, it does have a
> -p <auditlib> option, thus treats -plugin as -p lugin and interprets the
> next arg as linker input file. For 32-bit, this seems to work, for a
> 64-bit link, the linker errors out since it expects 64-bit input files
> while lto-plugin.so is a 32-bit shared object, thus the
> dg-require-linker-plugin concludes that -plugin support is absent.
>
> It always seemed bogus to me to accept/pass on a linker switch without
> checking if the linker in use really supports it, and this failure
> finally prompted me to develop a real check. Obviously, one need not
> only test if the linker accepts -plugin, but also if the plugin passed
> is really used. Otherwise, gcc -fuse-linker-plugin will now error out,
> as well as collect2 -plugin.
>
> I'm uncertain if the configure check below is acceptable, though: I do
> need to build a shared object and cannot use libtool in
> gcc/configure.ac.
You can. Put
LT_OUTPUT
in configure.ac before the code that uses './libtool'.
(It would need to be cleaned up from Makefile.in.)
When using libtool you need to ensure that you get all flags you want to
test past libtool: prepend them with '-Wc,'.
I'm not quite sure which compilers this test needs to work with.
It looks however like your patch will not work on some systems
even with GCC, see below for details.
> Therefore I rely on gcc -shared, which only works in
> stage2 and up, or if gcc is used as the bootstrap compiler.
> Ok for mainline?
I'm afraid not. I only review the build system bits.
> 2011-02-05 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
>
> gcc:
> PR lto/46944
> * configure.ac (ld_plugin): Check for real ld -plugin support
> (HAVE_LD_PLUGIN): Define.
> * configure: Regenerate.
> * config.in: Regenerate.
> * gcc.c (PLUGIN_COND): Only define if HAVE_LD_PLUGIN.
> (PLUGIN_COND_CLOSE): Likewise.
> LINK_PLUGIN_SPEC: Define
> (LINK_COMMAND_SPEC): Use it.
> * collect2.c (main) [!HAVE_LD_PLUGIN]: Error on -plugin.
> --- a/gcc/configure.ac Sat Feb 05 09:17:53 2011 +0100
> +++ b/gcc/configure.ac Sat Feb 05 15:12:39 2011 +0100
> @@ -4771,6 +4771,27 @@
>
> if test x"$enable_plugin" = x"yes"; then
>
> + AC_MSG_CHECKING([for -plugin])
> + ld_plugin=no
> + echo 'int main() {return 0;}' > conftest.c
> + ${CC} ${CFLAGS} -c conftest.c > /dev/null 2>&1
Could add $CPPFLAGS too. I've seen -m32 in there before.
Dropping error output and not showing the commands used in config.log is
fairly ugly for debugging. It is more helpful to use AC_COMPILE_IFELSE
here. Below, it is even more important, as the commands are likely to
fail. The above could simply be
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
[ yep that worked, let's try the rest in here.
...
])
> + # Check if plugin is really used.
> + echo 'int onload () {puts ("yes"); return 0;}' > confplugin.c
> + # This depends on gcc, otherwise would have to use libtool.
> + if ${CC} ${CFLAGS} ${LDFLAGS} -shared -static-libgcc -fPIC \
Likewise for CPPFLAGS.
This will likely fail on MinGW due to the .so name, and anyway when
cross-compiling.
This might fail on Darwin unless you replace -shared with what the other
test nearby does modifying LDFLAGS.
> + -o confplugin.so confplugin.c > /dev/null 2>&1 \
> + && test x$gcc_cv_ld != x \
> + && ld_plugin_out=`$gcc_cv_ld -plugin ./confplugin.so \
> + -o conftest conftest.o -lc 2>/dev/null` \
I don't quite understand how this test is supposed to work in a cross
compile setup. You compile something with $CC and try to load it with
$gcc_cv_ld, but IIUC you are using the test result for the compiler that
you are generating. What am I missing? Or is this test simply
irrelevant in cross compile mode anyway?
> + && test x$ld_plugin_out = xyes; then
> + ld_plugin=yes
> + fi
rm -f confplugin.* conftest.$ac_objext conftest.c
> + if test x$ld_plugin = xyes; then
> + AC_DEFINE(HAVE_LD_PLUGIN, 1,
> + [Define if your linker supports -plugin.])
> + fi
> + AC_MSG_RESULT([$ld_plugin])
> +
> AC_MSG_CHECKING([for exported symbols])
> if test "x$export_sym_check" != x; then
> echo "int main() {return 0;} int foobar() {return 0;}" > conftest.c
> @@ -4834,7 +4855,7 @@
> if test x"$default_plugin" != x"yes"; then
> AC_MSG_ERROR([
> Building GCC with plugin support requires a host that supports
> --fPIC, -shared, -ldl and -rdynamic.])
> +-plugin, -fPIC, -shared, -ldl and -rdynamic.])
> fi
> fi
> fi
next prev parent reply other threads:[~2011-02-14 19:39 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-07 12:11 Rainer Orth
2011-02-14 19:44 ` Ralf Wildenhues [this message]
2011-03-10 11:26 ` Rainer Orth
2011-03-10 11:51 ` Paolo Bonzini
2011-03-10 12:26 ` Richard Guenther
2011-03-10 16:51 ` Rainer Orth
2011-03-10 17:06 ` Richard Guenther
2011-03-10 18:28 ` Rainer Orth
2011-03-11 12:30 ` Richard Guenther
2011-03-11 14:37 ` Rainer Orth
2011-03-11 15:10 ` Richard Guenther
2011-03-11 15:18 ` Rainer Orth
2011-03-11 15:32 ` Richard Guenther
2011-03-11 15:35 ` Rainer Orth
2011-03-14 19:07 ` Rainer Orth
2011-03-15 9:42 ` Richard Guenther
2011-03-16 9:23 ` Rainer Orth
2011-03-16 9:27 ` Paolo Bonzini
2011-03-16 9:43 ` Rainer Orth
2011-03-18 9:27 ` Rainer Orth
2011-03-18 10:09 ` Richard Guenther
2011-03-18 10:16 ` Rainer Orth
2011-03-18 10:19 ` Richard Guenther
2011-03-18 10:23 ` Rainer Orth
2011-03-18 10:34 ` Richard Guenther
2011-03-21 10:18 ` Rainer Orth
2011-03-21 10:27 ` Richard Guenther
2011-03-21 10:27 ` Paolo Bonzini
2011-03-26 3:26 Michael Matz
2011-03-26 11:15 ` Richard Guenther
2011-03-28 10:20 ` Rainer Orth
2011-03-28 10:50 ` Richard Guenther
2011-04-04 16:16 ` Rainer Orth
2011-04-11 13:26 ` Rainer Orth
2011-04-18 18:34 ` Ralf Wildenhues
2011-04-19 17:53 ` Rainer Orth
2011-04-26 16:01 ` Rainer Orth
2011-04-26 22:27 ` Ralf Wildenhues
2011-04-27 14:36 ` Rainer Orth
2011-04-19 12:28 ` Paolo Bonzini
2011-04-19 17:57 ` Rainer Orth
2011-05-30 10:27 ` Rainer Orth
2011-05-30 10:45 ` Richard Guenther
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110214193917.GA7519@gmx.de \
--to=ralf.wildenhues@gmx.de \
--cc=bonzini@gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=rguenther@suse.de \
--cc=ro@CeBiTec.Uni-Bielefeld.DE \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).