[llvm-bugs] [Bug 38506] New: After r337339 (addrsig support), clang can emit unnecessary __gxx_personality_v0 references

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 9 13:40:04 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=38506

            Bug ID: 38506
           Summary: After r337339 (addrsig support), clang can emit
                    unnecessary __gxx_personality_v0 references
           Product: new-bugs
           Version: 7.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: dimitry at andric.com
                CC: llvm-bugs at lists.llvm.org

See also https://bugs.freebsd.org/230399

While testing clang 7.0.0 on FreeBSD, we encountered linking errors in various
ports, similar to:

libtool: link: cc -O2 -pipe -O3 -fno-omit-frame-pointer -march=native
-fstack-protector -fexceptions -Wall -Wsign-compare -fstack-protector
-fuse-ld=bfd -o .libs/Gperf-simple Gperf-simple.o 
../src/.libs/libunwind-x86_64.so
/tmp/a/overlay/ports/devel/libunwind/work/libunwind-1.2.1/src/.libs/libunwind.so
../src/.libs/libunwind.so -lgcc_s -llzma -Wl,-rpath -Wl,/usr/local/lib
/usr/lib/libgcc_s.so: undefined reference to `__gxx_personality_v0'
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1

Our libgcc_s.so is actually compiler-rt, with the unwinder from llvm's
libunwind.cpp.

With clang 7.0.0, the assembly output of this file now includes a .addrsig_sym
reference to __gxx_personality_v0:

        .ident  "FreeBSD clang version 7.0.0 (branches/release_70 338892)
(based on LLVM 7.0.0svn)"
        .section        ".note.GNU-stack","", at progbits
        .addrsig
        .addrsig_sym __gxx_personality_v0
        .addrsig_sym
_ZZN9libunwind17LocalAddressSpace18findUnwindSectionsEmRNS_18UnwindInfoSectionsEENUlP12dl_phdr_infomPvE_8__invokeES4_mS5_
        .addrsig_sym _ZN9libunwind17LocalAddressSpace17sThisAddressSpaceE
        .addrsig_sym
_ZN9libunwind13DwarfFDECacheINS_17LocalAddressSpaceEE5_lockE
        .addrsig_sym
_ZN9libunwind13DwarfFDECacheINS_17LocalAddressSpaceEE14_initialBufferE
        .section        .debug_line,"", at progbits
.Lline_table_start0:

This was not the case with clang 6.0.1.  It appears this has started with the
addition of -faddrsig support to the clang frontend, in
<https://reviews.llvm.org/rL337339>.

Minimal test case:

struct a {
  a(int);
};
void f() {
  new a(42);
}

$ clang-r337338 -O2 -S testcase1.cpp -o - | tail -5
        .p2align        2
                                        # -- End function

        .ident  "clang version 7.0.0 (trunk 337338)"
        .section        ".note.GNU-stack","", at progbits

$ clang-r337339 -O2 -S testcase1.cpp -o - | tail -5
        .ident  "clang version 7.0.0 (trunk 337339)"
        .section        ".note.GNU-stack","", at progbits
        .addrsig
        .addrsig_sym __gxx_personality_v0
        .addrsig_sym _Unwind_Resume

Adding -fno-addrsig makes the reference go away:

$ clang-r337339 -O2 -S testcase1.cpp -o - -fno-addrsig | tail -5
        .p2align        2
                                        # -- End function

        .ident  "clang version 7.0.0 (trunk 337339)"
        .section        ".note.GNU-stack","", at progbits

I don't think it's needed to emit this symbol at all?  Specifically in the case
of an unwinder library, it should definitely not have such a reference in
there.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180809/b283c29a/attachment.html>


More information about the llvm-bugs mailing list