[PATCH] D11153: [Compiler-RT] If unwind/c++abi is set, don't include libgcc

Renato Golin renato.golin at linaro.org
Thu Jul 16 01:32:32 PDT 2015


rengolin added a comment.

In http://reviews.llvm.org/D11153#204688, @logan wrote:

> Can't we simply rely on `--rtlib=compiler-rt`?


Specifically about --rtlib=compiler-rt, there are a few choices:

1. Assume RT == unwind + c++abi. This is good for architectures where those libraries work reliably and are always available, either built in with Clang or as a package. Since it's not easy to compile libc++abi, and it requires Clang in the first place, I'd rather not have that until our build system is smart enough to do a two-stage build, like GCC.

2. Assume RT is in a GNU system. This is what we have now, and to make debug, profile and exception code work out-of-the-box, we need the libraries. I have taken the bad choice of including both libgcc libraries.

3. Assume RT is just part of the compiler library. This would force users to include -lgcc_s/-lunwind and/or -lgcc_eh/-lc++abi on every use of --rtlib. Clang includes gcc_s/eh already when rtlib=libgcc (obviously), and so does GCC. If we don't include some unwind/exception libraries with RT, the behaviour would be very different and make build systems a lot more complex.

This change is a preparation for a bigger one. The plan is:

Allow tools to have default libraries on different systems. Something like:

  void GetCompilerLibraries() {
      // pick the defaults
      switch(OS/Env) {
          default:
              llvm_unreachable("must have a default");
          case GNU: // default GNU, --rtlib=libgcc
              RT=libgcc; UNW=libgcc_s; EH=libgcc_eh;
          case GNURT: // GNU with --rtlib=compiler-rt
              RT=compiler-rt; UNW=libgcc_s; EH=libgcc_eh;
          case FreeBSD: // BSD style
              RT=compiler-rt; UNW=libunwind; EH=libc++abi;
          case Darwin: // and so on...
              RT=...
      }
      // override with arguments
      for (lib : libArgs) {
          if (lib == libunwind) UNW=lib;
          else if (lib == libc++abi) EH=lib;
          else if (lib == libgcc_s) UNW=lib;
          else if (lib == libgcc_eh) UNW=lib;
      }
  }

This way you have complete flexibility, and still produce the expected default results on all architectures.

GCC doesn't need that complexity because they're tied up with libgcc and friends.


http://reviews.llvm.org/D11153







More information about the llvm-commits mailing list