build: restrict clang version, prefer lld, enable thinlto

* Restricts clang to at least version 6.0, which gets rid of a couple
  older special cases.

* We now loop through linkers trying to prefer lld where available,
  either using the version provided by the compiler with -fuse-lld or
  explicitly passing the path to the toolchain lld. lld should be faster
  than gold and GNU ld, and also has the advantage of being a known
  quantity within our toolchain.

  This fixes ASAN builds on my Ubuntu 18 machine, where the version of
  gold that ships with the system can't seem to link ASAN executables.

* Switches the LTO build to use ThinLTO, which provides most of the
  performance benefits but at much lower cost.

Change-Id: I09ded0c44c9f7a6839489f0abf5baa4eaf1971f0
Reviewed-on: http://gerrit.cloudera.org:8080/15058
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <adar@cloudera.com>
2 files changed