[libcxx-commits] [PATCH] D60794: [libcxx][CMake] Add an option to include -lgcc_s in the linker script

Tom Stellard via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Apr 17 10:28:58 PDT 2019


tstellar added a comment.

In D60794#1469761 <https://reviews.llvm.org/D60794#1469761>, @EricWF wrote:

> I don't think this is correct.
>
> The compiler should be linking gcc unwind for us, and there should be no need for users to link it themselves.


Ok, I wasn't sure the correct place to fix this.  clang does not currently add the gcc unwind library.  I thought clang was assuming that the unwind library would always be specified in the linker script since this is what happens with the LLVM unwinder.

Here is an example to reproduce the problem in clang:

  cat << EOF | ./bin/clang++ -x c++ -fuse-ld=lld -rtlib=compiler-rt -stdlib=libc++ -
  
  #include <iostream>
  int main(int argc, char **argv) {
    std::cout << "Hello World\n";
    return 0;
  }
  EOF
  
  ld.lld: error: undefined symbol: _Unwind_Resume
  >>> referenced by -
  >>>               /tmp/--697774.o:(std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long))
  
  ld.lld: error: undefined symbol: _Unwind_Resume
  >>> referenced by -
  >>>               /tmp/--697774.o:(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char))
  clang-9: error: linker command failed with exit code 1 (use -v to see invocation)



> We only do it in the test suite because we can't drop the C++ standard library without dropping the rest of the link line (At least before `-nostdlibc++` existed).
> 
> Also I don't think a libc++ build is tied to any one particular unwind library?

It can be when the option  LIBCXXABI_USE_LLVM_UNWINDER=ON is used, at least on Linux.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60794/new/

https://reviews.llvm.org/D60794





More information about the libcxx-commits mailing list