[llvm] 00ff774 - [CMake] Allow passing extra options to extract_symbols.py.

Simon Tatham via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 15 06:02:18 PST 2021


Author: Simon Tatham
Date: 2021-11-15T14:01:22Z
New Revision: 00ff774fca787af4fecbcab6d7ee5f454127c8a1

URL: https://github.com/llvm/llvm-project/commit/00ff774fca787af4fecbcab6d7ee5f454127c8a1
DIFF: https://github.com/llvm/llvm-project/commit/00ff774fca787af4fecbcab6d7ee5f454127c8a1.diff

LOG: [CMake] Allow passing extra options to extract_symbols.py.

When cross-compiling LLVM in an environment where there //is// an
objdump binary available but it does not understand the target
platform's object file format, extract_symbols.py fails, because its
initial check for tool availability decides that the existence of
objdump at all is good enough to settle on it as the tool of choice.

In such an environment it's useful to work around this by telling
extract_symbols.py to use llvm-readobj instead. The script itself has
an option for that, but its invocation in AddLLVM.cmake wasn't
providing a mechanism to add extra options passed through for the
cmake command line.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D113557

Added: 
    

Modified: 
    llvm/CMakeLists.txt
    llvm/cmake/modules/AddLLVM.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 00fccac4ab17..78c3b4cf1a44 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -984,6 +984,11 @@ endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
 # use export_executable_symbols(target).
 set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
 
+set(LLVM_EXTRACT_SYMBOLS_FLAGS ""
+  CACHE STRING "Additional options to pass to llvm/utils/extract_symbols.py.
+  These cannot override the options set by cmake, but can add extra options
+  such as --tools.")
+
 include(AddLLVM)
 include(TableGen)
 

diff  --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 6e3bfd131064..1d97626d69cc 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1174,7 +1174,7 @@ function(export_executable_symbols target)
       set(mangling itanium)
     endif()
     add_custom_command(OUTPUT ${exported_symbol_file}
-                       COMMAND "${Python3_EXECUTABLE}" ${LLVM_MAIN_SRC_DIR}/utils/extract_symbols.py --mangling=${mangling} ${static_libs} -o ${exported_symbol_file}
+                       COMMAND "${Python3_EXECUTABLE}" ${LLVM_MAIN_SRC_DIR}/utils/extract_symbols.py ${LLVM_EXTRACT_SYMBOLS_FLAGS} --mangling=${mangling} ${static_libs} -o ${exported_symbol_file}
                        WORKING_DIRECTORY ${LLVM_LIBRARY_OUTPUT_INTDIR}
                        DEPENDS ${LLVM_MAIN_SRC_DIR}/utils/extract_symbols.py ${static_libs}
                        VERBATIM


        


More information about the llvm-commits mailing list