Don't pass --build-id by default.

Rafael EspĂ­ndola via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 2 17:06:26 PDT 2016


> This is going to break a lot of my local rpm packaging scripts, and I suspect the same is true for others. This is not a huge deal, but I wonder if we should emulate GCC is this regard and provide some CMake option to keep the current behavior?

Yes, a cmake option is probably best.

What do you think of the attached patch (still building).

Cheers,
Rafael
-------------- next part --------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f84ae47..fce8229 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -197,6 +197,8 @@ set(GCC_INSTALL_PREFIX "" CACHE PATH "Directory where gcc is installed." )
 set(DEFAULT_SYSROOT "" CACHE PATH
   "Default <path> to all compiler invocations for --sysroot=<path>." )
 
+set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld")
+
 set(CLANG_DEFAULT_CXX_STDLIB "" CACHE STRING
   "Default C++ stdlib to use (empty for architecture default, \"libstdc++\" or \"libc++\"")
 if (NOT(CLANG_DEFAULT_CXX_STDLIB STREQUAL "" OR
diff --git a/include/clang/Config/config.h.cmake b/include/clang/Config/config.h.cmake
index 8917065..09f5e4b 100644
--- a/include/clang/Config/config.h.cmake
+++ b/include/clang/Config/config.h.cmake
@@ -38,4 +38,7 @@
 /* Linker version detected at compile time. */
 #cmakedefine HOST_LINK_VERSION "${HOST_LINK_VERSION}"
 
+/* pass --build-id to ld */
+#cmakedefine ENABLE_LINKER_BUILD_ID
+
 #endif
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 8242b96..eec4174 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -3978,10 +3978,9 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
   if (IsRedhat(Distro) && Distro != RHEL5 && Distro != RHEL6)
     ExtraOpts.push_back("--no-add-needed");
 
-  if ((IsDebian(Distro) && Distro >= DebianSqueeze) || IsOpenSUSE(Distro) ||
-      (IsRedhat(Distro) && Distro != RHEL5) ||
-      (IsUbuntu(Distro) && Distro >= UbuntuKarmic))
-    ExtraOpts.push_back("--build-id");
+#ifdef ENABLE_LINKER_BUILD_ID
+  ExtraOpts.push_back("--build-id");
+#endif
 
   if (IsOpenSUSE(Distro))
     ExtraOpts.push_back("--enable-new-dtags");


More information about the cfe-commits mailing list