bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug gold/26794] New: use of gcc lto breaks --exclude-libs on gold linke


From: sergeev917 at gmail dot com
Subject: [Bug gold/26794] New: use of gcc lto breaks --exclude-libs on gold linker
Date: Tue, 27 Oct 2020 12:24:56 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=26794

            Bug ID: 26794
           Summary: use of gcc lto breaks --exclude-libs on gold linker
           Product: binutils
           Version: 2.35.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gold
          Assignee: ccoutant at gmail dot com
          Reporter: sergeev917 at gmail dot com
                CC: ian at airs dot com
  Target Milestone: ---

Created attachment 12922
  --> https://sourceware.org/bugzilla/attachment.cgi?id=12922&action=edit
source files with tester shell script

This issue is the same as in [1], but about the gold linker. The bfd linker is
working as expected in 2.35.1, which includes patch from [1].

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=25618

--

The apparent issue is that with LTO disabled -Wl,--exclude-libs,ALL flag works
as intended, but with -flto -- symbols from linked archives are not hidden
anymore.

The issue is easily reproduced with about 10 lines of code with no std libs
involved. The reproducer consists of a static library "foo" and a shared
library "bar" that links with "foo" (and we would like to hide "foo" symbols in
"bar").

foo.h:
#pragma once
__attribute__((visibility("default"))) int foo();

foo.cc:
#include "foo.h"
int foo() { return 100; }

bar.h:
#pragma once
__attribute__((visibility("default"))) int bar();

bar.cc:
#include "bar.h"
#include "foo.h"
int bar() { return foo(); }

Build commands:
g++ -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -flto -c foo.cc -o
.foo.o
ar qc .foo.a .foo.o
g++ -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -flto -c bar.cc -o
.bar.o
g++ -Wl,--exclude-libs,ALL -fuse-ld=gold -flto -shared -o libbar.so .bar.o
.foo.a
readelf --dyn-syms --wide libbar.so | c++filt

The last command produces both bar() and foo() -- that is, foo() is not hidden.
Replacing -flto with -fno-lto gives only bar(), which is the expected result.
The issue is present when using ld.gold (ie -fuse-ld=gold) and not present on
ld.bfd.

--

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-10.2.0-r1/work/gcc-10.2.0/configure
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/10.2.0
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/10.2.0
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/10.2.0/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/10.2.0/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/include/g++-v10
--with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/10.2.0/python
--enable-languages=c,c++,go,fortran --enable-obsolete --enable-secureplt
--disable-werror --with-system-zlib --disable-nls --enable-checking=release
--with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 10.2.0-r1 p2'
--disable-esp --enable-libstdcxx-time --with-build-config=bootstrap-lto
--disable-libstdcxx-pch --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --disable-multilib
--with-multilib-list=m64 --disable-fixed-point --enable-targets=all
--enable-libgomp --disable-libssp --disable-libada --disable-systemtap
--enable-vtable-verify --without-zstd --enable-lto --with-isl
--disable-isl-version-check --enable-default-pie --enable-default-ssp
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (Gentoo 10.2.0-r1 p2) 

$ ld -v
GNU ld (Gentoo 2.35.1 p1) 2.35.1

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]