https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84901

            Bug ID: 84901
           Summary: --dynamic-list=export is ignored in presence of -flto
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: avkhatskevich at gmail dot com
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Created attachment 43677
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43677&action=edit
reproducer

Hello.
In a project, I want to export some symbols with `dynamic-list` ld option and
use lto optimizations, but I face the following behavior:

Compiling without LTO - symbols from `export` are exported (presented in
.dynsym).
Compiling with LTO - nothing is exported.
Compiling with LTO + `-rdynamic` EVERYTHING is exported, but performance
decreased.
Linking with gold - the same result.
Compiling with clang (4.0.1-6) - the same result.

Unexpectedly, `__attribute__((used))` added to symbols I want to export helps,
but it looks like a "crutch".

Here is a gist with a  small reproducer
[https://gist.github.com/Khatskevich/54771081aefbc8420d79fdcfb65d2662](gist) 
(I have also attached as a tar archive)

I believe that it is wrong behavior because `dynamic-list` or `__attr(used)`
helps.

The behavior I expect: symbols passed through `dynamic-list` are exported
without any `__attr(used)`.


P.S. 
1. GCC version 7.2.0
2. At this point, can I somehow pass a list of attributes that I want to
preserve in another way (as a file for example)? I do not want to spoil code
base.
3. I need exported symbols to inceract with them with `ffi` lua module.

Reply via email to