[PATCH] D69003: [dsymutil] Add ${system_libs} to target link libraries

Gokturk Yuksek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 5 09:52:23 PST 2019


gokturk added a comment.

In D69003#1721924 <https://reviews.llvm.org/D69003#1721924>, @gokturk wrote:

> In D69003#1721908 <https://reviews.llvm.org/D69003#1721908>, @beanz wrote:
>
> > You don't need to add the library to `dsymutil`. It is not code in `dsymutil` that depends on `libatomic`, it is code in `LLVMSupport` that `dsymutil` is using. By fixing this in `LLVMSupport`, any library linked against `LLVMSupport` will have a linkage to `libatomic` added.
> >
> > Please don't spend 20 hours testing this patch. I'm very pretty sure this isn't the correct fix.
>
>
> dsymutil makes explicit use of libatomic (https://github.com/llvm/llvm-project/blob/release/9.x/llvm/tools/dsymutil/dsymutil.cpp#L542):
>
>       std::atomic_char AllOK(1);
>   ...
>         auto LinkLambda = [&,
>                            OutputFile](std::shared_ptr<raw_fd_ostream> Stream) {
>           AllOK.fetch_and(linkDwarf(*Stream, BinHolder, *Map, *OptionsOrErr));
>           Stream->flush();
>           if (Verify && !NoOutput)
>             AllOK.fetch_and(verify(OutputFile, Map->getTriple().getArchName()));
>         };
>
>
> Doesn't this create a link time dependency on libatomic?


@beanz, the following code snippet:

  #include <atomic>
  
  int main()
  {
  	std::atomic_char AllOK(1);
  	AllOK.fetch_and(0);
  
  	return 0;
  }

fails to compile on RISC-V using gcc 9.2.0 with the following:

  /usr/lib/gcc/riscv64-unknown-linux-gnu/9.2.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /tmp/ccVjOu0P.o: in function `.L0 ':
  AllOK.cpp:(.text+0x38): undefined reference to `__atomic_fetch_and_1'
  collect2: error: ld returned 1 exit status
  make: *** [<builtin>: AllOK] Error 1

The fix is to link against latomic. That leads me to think that dsymutil also requires '-latomic' irrespective of whether it depends on Support or not. Am I missing something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69003





More information about the llvm-commits mailing list