[PATCH] D63368: [compiler-rt] Respect CMAKE_NM

Shoaib Meenai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 14 21:38:32 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL363483: [compiler-rt] Respect CMAKE_NM (authored by smeenai, committed by ).
Herald added a subscriber: delcypher.

Changed prior to commit:
  https://reviews.llvm.org/D63368?vs=204870&id=204893#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63368

Files:
  compiler-rt/trunk/cmake/Modules/SanitizerUtils.cmake
  compiler-rt/trunk/lib/sanitizer_common/scripts/gen_dynamic_list.py


Index: compiler-rt/trunk/cmake/Modules/SanitizerUtils.cmake
===================================================================
--- compiler-rt/trunk/cmake/Modules/SanitizerUtils.cmake
+++ compiler-rt/trunk/cmake/Modules/SanitizerUtils.cmake
@@ -6,6 +6,12 @@
 set(SANITIZER_LINT_SCRIPT
   ${COMPILER_RT_SOURCE_DIR}/lib/sanitizer_common/scripts/check_lint.sh)
 
+if(CMAKE_NM)
+  set(SANITIZER_NM "${CMAKE_NM}")
+else()
+  set(SANITIZER_NM nm)
+endif()
+
 # Create a target "<name>-<arch>-symbols" that would generate the list of
 # symbols that need to be exported from sanitizer runtime "<name>". Function
 # interceptors are exported automatically, user can also provide files with
@@ -30,7 +36,7 @@
     add_custom_command(OUTPUT ${stamp}
       COMMAND ${PYTHON_EXECUTABLE}
         ${SANITIZER_GEN_DYNAMIC_LIST} ${extra_args} $<TARGET_FILE:${target_name}>
-        -o $<TARGET_FILE:${target_name}>.syms
+        --nm-executable "${SANITIZER_NM}" -o $<TARGET_FILE:${target_name}>.syms
       COMMAND ${CMAKE_COMMAND} -E touch ${stamp}
       DEPENDS ${target_name} ${SANITIZER_GEN_DYNAMIC_LIST} ${ARG_EXTRA}
       WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
@@ -80,7 +86,7 @@
   add_custom_command(OUTPUT ${vers}
     COMMAND ${PYTHON_EXECUTABLE}
       ${SANITIZER_GEN_DYNAMIC_LIST} --version-list ${args}
-      -o ${vers}
+      --nm-executable "${SANITIZER_NM}" -o ${vers}
     DEPENDS ${SANITIZER_GEN_DYNAMIC_LIST} ${ARG_EXTRA} ${ARG_LIBS}
     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
     COMMENT "Generating version list for ${name}"
Index: compiler-rt/trunk/lib/sanitizer_common/scripts/gen_dynamic_list.py
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/scripts/gen_dynamic_list.py
+++ compiler-rt/trunk/lib/sanitizer_common/scripts/gen_dynamic_list.py
@@ -61,9 +61,9 @@
                            'pthread_cond_wait', 'realpath',
                            'sched_getaffinity'])
 
-def get_global_functions(library):
+def get_global_functions(nm_executable, library):
   functions = []
-  nm = os.environ.get('NM', 'nm')
+  nm = os.environ.get('NM', nm_executable)
   nm_proc = subprocess.Popen([nm, library], stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
   nm_out = nm_proc.communicate()[0].decode().split('\n')
@@ -84,6 +84,7 @@
   parser.add_argument('--version-list', action='store_true')
   parser.add_argument('--extra', default=[], action='append')
   parser.add_argument('libraries', default=[], nargs='+')
+  parser.add_argument('--nm-executable', required=True)
   parser.add_argument('-o', '--output', required=True)
   args = parser.parse_args()
 
@@ -91,7 +92,7 @@
 
   all_functions = []
   for library in args.libraries:
-    all_functions.extend(get_global_functions(library))
+    all_functions.extend(get_global_functions(args.nm_executable, library))
   function_set = set(all_functions)
   for func in all_functions:
     # Export new/delete operators.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63368.204893.patch
Type: text/x-patch
Size: 2993 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190615/0d497525/attachment.bin>


More information about the llvm-commits mailing list