Re: gcc-as-needed.diff patch broke mpx support in GCC
That patch could fix the problem:
diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h
index 734310f..f408e5b 100644
--- a/gcc/config/i386/gnu-user64.h
+++ b/gcc/config/i386/gnu-user64.h
@@ -56,6 +56,7 @@ see the files COPYING3 and COPYING.RUNTIME
respectively. If not, see
"%{" SPEC_64 ":-m " GNU_USER_LINK_EMULATION64 "} \
%{" SPEC_32 ":-m " GNU_USER_LINK_EMULATION32 "} \
%{" SPEC_X32 ":-m " GNU_USER_LINK_EMULATIONX32 "} \
+ --as-needed \
%{shared:-shared} \
%{!shared: \
%{!static: \
diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
index dd79ec6..86a2b48 100644
--- a/gcc/config/i386/linux-common.h
+++ b/gcc/config/i386/linux-common.h
@@ -70,7 +70,9 @@ along with GCC; see the file COPYING3. If not see
%{mmpx:%{fcheck-pointer-bounds:\
%{static:--whole-archive -lmpx --no-whole-archive" LIBMPX_LIBS "}\
%{!static:%{static-libmpx:" LD_STATIC_OPTION " --whole-archive}\
- -lmpx %{static-libmpx:--no-whole-archive " LD_DYNAMIC_OPTION \
+ %{!fuse-ld=gold:--push-state} --no-as-needed -lmpx\
+ %{fuse-ld=gold:--as-needed;:--pop-state}
%{static-libmpx:--no-whole-archive "\
+ LD_DYNAMIC_OPTION \
LIBMPX_LIBS "}}}}"
#else
#define LIBMPX_SPEC "\
@@ -84,7 +86,8 @@ along with GCC; see the file COPYING3. If not see
%{mmpx:%{fcheck-pointer-bounds:%{!fno-chkp-use-wrappers:\
%{static:-lmpxwrappers}\
%{!static:%{static-libmpxwrappers:" LD_STATIC_OPTION " --whole-archive}\
- -lmpxwrappers %{static-libmpxwrappers:--no-whole-archive "\
+ %{!fuse-ld=gold:--push-state} --no-as-needed -lmpxwrappers\
+ %{fuse-ld=gold:--as-needed;:--pop-state}
%{static-libmpxwrappers:--no-whole-archive "\
LD_DYNAMIC_OPTION "}}}}}"
#else
#define LIBMPXWRAPPERS_SPEC "\
2016-08-15 17:55 GMT+03:00 Alexander Ivchenko <aivchenk@gmail.com>:
> To: debian-gcc@lists.debian.org
> From: aivchenk@gmail.com
> Subject: gcc-as-needed.diff patch broke mpx support in GCC
>
> Package: gcc-5
> Version: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609
>
> gcc-5 from Ubuntu is configured with MPX support, but it is broken due
> to always-added linker option "-as-needed".
>
> This happens because usual invokation of gcc for mpx (e.g gcc
> -fcheck-pointer-bounds -mmpx hello.c) would implicitely add -lmpx and
> -lmpxwrappers during linking,
> but those libraries are not actually linked:
>
>> ldd a.out
> linux-vdso.so.1 => (0x00007ffe725af000)
> libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3ed2513000)
> /lib64/ld-linux-x86-64.so.2 (0x000055922a9eb000)
> (if we add -Wl,--no-as-needed:
>> ldd a.out
> linux-vdso.so.1 => (0x00007ffe201e5000)
> libmpx.so.0 => /usr/lib/x86_64-linux-gnu/libmpx.so.0
> (0x00007f9e76a76000)
> libmpxwrappers.so.0 =>
> /usr/lib/x86_64-linux-gnu/libmpxwrappers.so.0 (0x00007f9e76873000)
> libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9e764a9000)
> libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
> (0x00007f9e7628c000)
> /lib64/ld-linux-x86-64.so.2 (0x000055f6e450d000))
>
> The fix for that would be to add the same guards for as-needed as for
> sanitizer libraries
Reply to: