kwk updated this revision to Diff 387650.
kwk added a comment.

enabled DEFAULT_LINKER_BUILD_ID_STYLE in linux


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113993

Files:
  clang/CMakeLists.txt
  clang/include/clang/Config/config.h.cmake
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Linux.cpp


Index: clang/lib/Driver/ToolChains/Linux.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -245,7 +245,11 @@
   }
 
 #ifdef ENABLE_LINKER_BUILD_ID
-  ExtraOpts.push_back("--build-id");
+  #ifdef ENABLE_LINKER_BUILD_ID_STYLE
+    ExtraOpts.push_back("--build-id=" ENABLE_LINKER_BUILD_ID_STYLE);
+  #else
+    ExtraOpts.push_back("--build-id");
+  #endif
 #endif
 
   if (IsAndroid || Distro.IsOpenSUSE())
Index: clang/lib/Driver/ToolChains/Hurd.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Hurd.cpp
+++ clang/lib/Driver/ToolChains/Hurd.cpp
@@ -82,7 +82,11 @@
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
 
 #ifdef ENABLE_LINKER_BUILD_ID
-  ExtraOpts.push_back("--build-id");
+  #ifdef ENABLE_LINKER_BUILD_ID_STYLE
+    ExtraOpts.push_back("--build-id=" ENABLE_LINKER_BUILD_ID_STYLE);
+  #else
+    ExtraOpts.push_back("--build-id");
+  #endif
 #endif
 
   Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
Index: clang/include/clang/Config/config.h.cmake
===================================================================
--- clang/include/clang/Config/config.h.cmake
+++ clang/include/clang/Config/config.h.cmake
@@ -69,9 +69,12 @@
 /* Linker version detected at compile time. */
 #cmakedefine HOST_LINK_VERSION "${HOST_LINK_VERSION}"
 
-/* pass --build-id to ld */
+/* Pass --build-id or --build-id=<style> to linker (e.g. ld or lld) by default 
*/
 #cmakedefine ENABLE_LINKER_BUILD_ID
 
+/* Set --build-id=<style> */
+#cmakedefine DEFAULT_LINKER_BUILD_ID_STYLE "${DEFAULT_LINKER_BUILD_ID_STYLE}"
+
 /* enable x86 relax relocations by default */
 #cmakedefine01 ENABLE_X86_RELAX_RELOCATIONS
 
Index: clang/CMakeLists.txt
===================================================================
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -219,7 +219,23 @@
 set(DEFAULT_SYSROOT "" CACHE STRING
   "Default <path> to all compiler invocations for --sysroot=<path>." )
 
-set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld")
+set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL
+  "Pass --build-id or --build-id=<style> to linker (e.g. ld or lld). See also 
ENABLE_LINKER_BUILD_ID_STYLE.")
+
+set(DEFAULT_LINKER_BUILD_ID_STYLE "" CACHE STRING
+  "enables ENABLE_LINKER_BUILD_ID (if not already done) and passes the style 
to --build-id=<style>")
+
+if (NOT(DEFAULT_LINKER_BUILD_ID_STYLE STREQUAL ""))
+  if (NOT(ENABLE_LINKER_BUILD_ID))
+    message(WARNING "Turning on ENABLE_LINKER_BUILD_ID because 
DEFAULT_LINKER_BUILD_ID_STYLE style was specified")
+    set(ENABLE_LINKER_BUILD_ID ON)
+  endif()
+  if (NOT("${DEFAULT_LINKER_BUILD_ID_STYLE}" MATCHES 
"^(fast|md5|sha1|uuid|0x[0-9A-Fa-f]+)$"))
+    message(WARNING "Allowed values for DEFAULT_LINKER_BUILD_ID_STYLE are "
+"\"sha1\", \"md5\" or \"uuid\", \"fast\", \"0x<hexstring>\" "
+"but the current value is: ${DEFAULT_LINKER_BUILD_ID_STYLE}")
+  endif()
+endif()  
 
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL
     "enable x86 relax relocations by default")


Index: clang/lib/Driver/ToolChains/Linux.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -245,7 +245,11 @@
   }
 
 #ifdef ENABLE_LINKER_BUILD_ID
-  ExtraOpts.push_back("--build-id");
+  #ifdef ENABLE_LINKER_BUILD_ID_STYLE
+    ExtraOpts.push_back("--build-id=" ENABLE_LINKER_BUILD_ID_STYLE);
+  #else
+    ExtraOpts.push_back("--build-id");
+  #endif
 #endif
 
   if (IsAndroid || Distro.IsOpenSUSE())
Index: clang/lib/Driver/ToolChains/Hurd.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Hurd.cpp
+++ clang/lib/Driver/ToolChains/Hurd.cpp
@@ -82,7 +82,11 @@
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
 
 #ifdef ENABLE_LINKER_BUILD_ID
-  ExtraOpts.push_back("--build-id");
+  #ifdef ENABLE_LINKER_BUILD_ID_STYLE
+    ExtraOpts.push_back("--build-id=" ENABLE_LINKER_BUILD_ID_STYLE);
+  #else
+    ExtraOpts.push_back("--build-id");
+  #endif
 #endif
 
   Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
Index: clang/include/clang/Config/config.h.cmake
===================================================================
--- clang/include/clang/Config/config.h.cmake
+++ clang/include/clang/Config/config.h.cmake
@@ -69,9 +69,12 @@
 /* Linker version detected at compile time. */
 #cmakedefine HOST_LINK_VERSION "${HOST_LINK_VERSION}"
 
-/* pass --build-id to ld */
+/* Pass --build-id or --build-id=<style> to linker (e.g. ld or lld) by default */
 #cmakedefine ENABLE_LINKER_BUILD_ID
 
+/* Set --build-id=<style> */
+#cmakedefine DEFAULT_LINKER_BUILD_ID_STYLE "${DEFAULT_LINKER_BUILD_ID_STYLE}"
+
 /* enable x86 relax relocations by default */
 #cmakedefine01 ENABLE_X86_RELAX_RELOCATIONS
 
Index: clang/CMakeLists.txt
===================================================================
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -219,7 +219,23 @@
 set(DEFAULT_SYSROOT "" CACHE STRING
   "Default <path> to all compiler invocations for --sysroot=<path>." )
 
-set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL "pass --build-id to ld")
+set(ENABLE_LINKER_BUILD_ID OFF CACHE BOOL
+  "Pass --build-id or --build-id=<style> to linker (e.g. ld or lld). See also ENABLE_LINKER_BUILD_ID_STYLE.")
+
+set(DEFAULT_LINKER_BUILD_ID_STYLE "" CACHE STRING
+  "enables ENABLE_LINKER_BUILD_ID (if not already done) and passes the style to --build-id=<style>")
+
+if (NOT(DEFAULT_LINKER_BUILD_ID_STYLE STREQUAL ""))
+  if (NOT(ENABLE_LINKER_BUILD_ID))
+    message(WARNING "Turning on ENABLE_LINKER_BUILD_ID because DEFAULT_LINKER_BUILD_ID_STYLE style was specified")
+    set(ENABLE_LINKER_BUILD_ID ON)
+  endif()
+  if (NOT("${DEFAULT_LINKER_BUILD_ID_STYLE}" MATCHES "^(fast|md5|sha1|uuid|0x[0-9A-Fa-f]+)$"))
+    message(WARNING "Allowed values for DEFAULT_LINKER_BUILD_ID_STYLE are "
+"\"sha1\", \"md5\" or \"uuid\", \"fast\", \"0x<hexstring>\" "
+"but the current value is: ${DEFAULT_LINKER_BUILD_ID_STYLE}")
+  endif()
+endif()  
 
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL
     "enable x86 relax relocations by default")
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to