[Bug lto/93980] New: use of lto breaks -Wl,--exclude-libs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93980 Bug ID: 93980 Summary: use of lto breaks -Wl,--exclude-libs Product: gcc Version: 9.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: sergeev917 at gmail dot com CC: marxin at gcc dot gnu.org Target Milestone: --- Created attachment 47934 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47934&action=edit source files and shell validation script The apparent issue is that with LTO disabled -Wl,--exclude-libs,ALL works as intended, but with -flto -- symbols from linked archives are not hidden anymore. Since this particular issue involves more than one translation unit, I'm not sure about the appropriate submission format. 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 -flto -shared -o libbar.so .bar.o .foo.a readelf --dyn-syms --wide libbar.so | c++filt The last commands produces both bar() and foo() -- that is, foo() is not hidden. Replacing -flto with -fno-lto gives only bar(). -- $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/9.2.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-9.2.0-r4/work/gcc-9.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/9.2.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/9.2.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/9.2.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/9.2.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/include/g++-v9 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/9.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 9.2.0-r4 p5' --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-altivec --disable-fixed-point --enable-targets=all --enable-libgomp --disable-libmudflap --disable-libssp --disable-systemtap --enable-vtable-verify --enable-lto --without-isl --enable-default-pie --enable-default-ssp Thread model: posix gcc version 9.2.0 (Gentoo 9.2.0-r4 p5)
[Bug lto/93980] use of lto breaks -Wl,--exclude-libs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93980 --- Comment #2 from Alexander Sergeyev --- (In reply to Andrew Pinski from comment #1) > Does -fno-use-linker-plugin help? It seems to work with fat lto objects, but I suspect that no actual lto is performed in this case. With -fno-fat-lto-objects -fno-use-linker-plugin: .bar.o: plugin needed to handle lto object .foo.a(.foo.o): plugin needed to handle lto object
[Bug lto/93980] use of lto breaks -Wl,--exclude-libs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93980 --- Comment #5 from Alexander Sergeyev --- (In reply to H.J. Lu from comment #3) > This seems a linker bug. Please open a binutils bug report. The bug report is at https://sourceware.org/bugzilla/show_bug.cgi?id=25618
[Bug lto/93980] use of lto breaks -Wl,--exclude-libs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93980 --- Comment #6 from Alexander Sergeyev --- (In reply to H.J. Lu from comment #4) > This linker patch: Thank you! I've linked the patch to the binutils bug report.
[Bug c++/87513] New: internal compiler error: in write_expression, at cp/mangle.c:3050
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87513 Bug ID: 87513 Summary: internal compiler error: in write_expression, at cp/mangle.c:3050 Product: gcc Version: 8.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sergeev917 at gmail dot com Target Milestone: --- Created attachment 44780 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44780&action=edit preprocessed code sample === compiler and system information === $ g++-8.2.0 -v Using built-in specs. COLLECT_GCC=g++-8.2.0 COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.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/8.2.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/8.2.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/8.2.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/8.2.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/include/g++-v8 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/8.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 8.2.0-r3 p1.4' --disable-esp --enable-libstdcxx-time --disable-libstdcxx-pch --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --with-multilib-list=m64 --disable-altivec --disable-fixed-point --enable-targets=all --enable-libgomp --disable-libmudflap --disable-libssp --disable-libmpx --disable-systemtap --enable-vtable-verify --enable-libvtv --enable-lto --without-isl --enable-libsanitizer --enable-default-pie --enable-default-ssp Thread model: posix gcc version 8.2.0 (Gentoo 8.2.0-r3 p1.4) === the complete command line that triggers the bug, the compiler output === $ g++-8.2.0 -std=c++14 -o /dev/null -c ice_sample_8.2.0.ii In file included from main.cc:2: crow/app.h: In instantiation of 'typename std::result_of)(crow::Router, std::__cxx11::basic_string&&)>::type crow::Crow::route(std::__cxx11::string&&) [with long unsigned int Tag = 0; Middlewares = {}]': main.cc:8:1: required from here crow/app.h:63:14: internal compiler error: in write_expression, at cp/mangle.c:3050 auto route(std::string&& rule) ^ 0x59167a write_expression /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.2.0/gcc/cp/mangle.c:3050 0x65a9af write_expression /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.2.0/gcc/cp/mangle.c:3373 0x65876e write_type /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.2.0/gcc/cp/mangle.c:2352 0x659d1d write_bare_function_type /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.2.0/gcc/cp/mangle.c:2731 0x65d39b write_function_type /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.2.0/gcc/cp/mangle.c:2706 0x658244 write_type /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.2.0/gcc/cp/mangle.c:2214 0x65d58b write_template_args /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.2.0/gcc/cp/mangle.c:2841 0x65d8da write_prefix /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.2.0/gcc/cp/mangle.c:1146 0x6574ba write_nested_name /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.2.0/gcc/cp/mangle.c:1076 0x658680 write_type /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.2.0/gcc/cp/mangle.c:2232 0x659d1d write_bare_function_type /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.2.0/gcc/cp/mangle.c:2731 0x65dcf4 mangle_decl_string /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.2.0/gcc/cp/mangle.c:3795 0x65df28 get_mangled_id /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.2.0/gcc/cp/mangle.c:3817 0x65df28 mangle_decl(tree_node*) /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.2.0/gcc/cp/mangle.c:3855 0xdaaf99 decl_assembler_name(tree_node*) /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.2.0/gcc/tree.c:687 0x7e0fc5 symbol_table::insert_to_assembler_name_hash(symtab_node*, bool) /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.2.0/gcc/symtab.c:174 0x7e1924 symbol_table::symtab_initialize_asm_name_hash() /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.2.0/gcc/symtab.c:266 0x7e19b4 symbol_table::symtab_initialize_asm_name_hash() /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.2.0/gcc/symtab.c:976 0x7e19b4 symtab_node::get_for_asmname(tree_node const*) /var/tmp/portage/sys-devel/gcc-8.2.0-r3/work/gcc-8.2.0/gcc/symtab.c:964 0x7f1660 handle_alias_pairs
[Bug c++/87513] [8/9 Regression] ICE in write_expression, at cp/mangle.c:3050
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87513 --- Comment #3 from Alexander Sergeyev --- Created attachment 44783 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44783&action=edit preprocessed code sample (gcc-7.3.0)
[Bug c++/87513] [8/9 Regression] ICE in write_expression, at cp/mangle.c:3050
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87513 --- Comment #5 from Alexander Sergeyev --- (In reply to Martin Liška from comment #4) > Thanks! No problems. Let me know if I could do anything else.