diff mbox series

PR other/91396 Fix static link error with -fvtable-verify

Message ID CABtf2+S4Tuc=G__EC5-yyF6Drt-SFherjaanOuCYYv8SWv=09Q@mail.gmail.com
State New
Headers show
Series PR other/91396 Fix static link error with -fvtable-verify | expand

Commit Message

Li, Pan2 via Gcc-patches Aug. 12, 2019, 6:51 p.m. UTC
Hi,

This patch is to fix a bug where linking with -fvtable-verify  and
-static causes the linker to complain about multiple definitions of
things in the vtv_end*.o files (once from the .o file and once from
libvtv.a).   (See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91396).
The fix is for the GNU_USER_TARGET_ENDFILE_SPEC to only include the
vtv_end*.o files if we're not doing static linking (and we are using
-fvtable-verify flags).

Tested this fix by verifying that the test case in the bug compiles
both with and without -static, and that there were no new regressions
in the libvtv testsuite.  I'm in the process of doing a full bootstrap
build with this change.   Assuming the bootstrap passes, is this ok to
commit?


ChangeLog entry:

2019-08-12  Caroline Tice  <cmtice@google.com>

        PR other/91396
        * config/gnu-user.h (GNU_USER_TARGET_ENDFILE_SPEC): Only add the
        vtv_end.o or vtv_end_preinit.o files if !static.

Comments

Li, Pan2 via Gcc-patches Aug. 12, 2019, 10:21 p.m. UTC | #1
The bootstrap succeeded.

On Mon, Aug 12, 2019 at 11:51 AM Caroline Tice <cmtice@google.com> wrote:
>
> Hi,
>
> This patch is to fix a bug where linking with -fvtable-verify  and
> -static causes the linker to complain about multiple definitions of
> things in the vtv_end*.o files (once from the .o file and once from
> libvtv.a).   (See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91396).
> The fix is for the GNU_USER_TARGET_ENDFILE_SPEC to only include the
> vtv_end*.o files if we're not doing static linking (and we are using
> -fvtable-verify flags).
>
> Tested this fix by verifying that the test case in the bug compiles
> both with and without -static, and that there were no new regressions
> in the libvtv testsuite.  I'm in the process of doing a full bootstrap
> build with this change.   Assuming the bootstrap passes, is this ok to
> commit?
>
> Index: gcc/config/gnu-user.h
> ===================================================================
> --- gcc/config/gnu-user.h (revision 274317)
> +++ gcc/config/gnu-user.h (working copy)
> @@ -73,9 +73,9 @@
>     GNU userspace "finalizer" file, `crtn.o'.  */
>
>  #define GNU_USER_TARGET_ENDFILE_SPEC \
> -  "%{fvtable-verify=none:%s; \
> +  "%{!static:%{fvtable-verify=none:%s; \
>       fvtable-verify=preinit:vtv_end_preinit.o%s; \
> -     fvtable-verify=std:vtv_end.o%s} \
> +     fvtable-verify=std:vtv_end.o%s}} \
>     %{static:crtend.o%s; \
>       shared|static-pie|" PIE_SPEC ":crtendS.o%s; \
>       :crtend.o%s} " \
>
> ChangeLog entry:
>
> 2019-08-12  Caroline Tice  <cmtice@google.com>
>
>         PR other/91396
>         * config/gnu-user.h (GNU_USER_TARGET_ENDFILE_SPEC): Only add the
>         vtv_end.o or vtv_end_preinit.o files if !static.
Richard Biener Aug. 13, 2019, 7:57 a.m. UTC | #2
On Mon, 12 Aug 2019, Caroline Tice wrote:

> Hi,
> 
> This patch is to fix a bug where linking with -fvtable-verify  and
> -static causes the linker to complain about multiple definitions of
> things in the vtv_end*.o files (once from the .o file and once from
> libvtv.a).   (See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91396).
> The fix is for the GNU_USER_TARGET_ENDFILE_SPEC to only include the
> vtv_end*.o files if we're not doing static linking (and we are using
> -fvtable-verify flags).
> 
> Tested this fix by verifying that the test case in the bug compiles
> both with and without -static, and that there were no new regressions
> in the libvtv testsuite.  I'm in the process of doing a full bootstrap
> build with this change.   Assuming the bootstrap passes, is this ok to
> commit?

OK.

Thanks,
Richard.

> Index: gcc/config/gnu-user.h
> ===================================================================
> --- gcc/config/gnu-user.h (revision 274317)
> +++ gcc/config/gnu-user.h (working copy)
> @@ -73,9 +73,9 @@
>     GNU userspace "finalizer" file, `crtn.o'.  */
> 
>  #define GNU_USER_TARGET_ENDFILE_SPEC \
> -  "%{fvtable-verify=none:%s; \
> +  "%{!static:%{fvtable-verify=none:%s; \
>       fvtable-verify=preinit:vtv_end_preinit.o%s; \
> -     fvtable-verify=std:vtv_end.o%s} \
> +     fvtable-verify=std:vtv_end.o%s}} \
>     %{static:crtend.o%s; \
>       shared|static-pie|" PIE_SPEC ":crtendS.o%s; \
>       :crtend.o%s} " \
> 
> ChangeLog entry:
> 
> 2019-08-12  Caroline Tice  <cmtice@google.com>
> 
>         PR other/91396
>         * config/gnu-user.h (GNU_USER_TARGET_ENDFILE_SPEC): Only add the
>         vtv_end.o or vtv_end_preinit.o files if !static.
>
diff mbox series

Patch

Index: gcc/config/gnu-user.h
===================================================================
--- gcc/config/gnu-user.h (revision 274317)
+++ gcc/config/gnu-user.h (working copy)
@@ -73,9 +73,9 @@ 
    GNU userspace "finalizer" file, `crtn.o'.  */

 #define GNU_USER_TARGET_ENDFILE_SPEC \
-  "%{fvtable-verify=none:%s; \
+  "%{!static:%{fvtable-verify=none:%s; \
      fvtable-verify=preinit:vtv_end_preinit.o%s; \
-     fvtable-verify=std:vtv_end.o%s} \
+     fvtable-verify=std:vtv_end.o%s}} \
    %{static:crtend.o%s; \
      shared|static-pie|" PIE_SPEC ":crtendS.o%s; \
      :crtend.o%s} " \