[flang-commits] [flang] cf6c451 - [flang] set the paths for the symbol extracting tool (#131375)

via flang-commits flang-commits at lists.llvm.org
Fri Mar 21 13:18:19 PDT 2025


Author: Kelvin Li
Date: 2025-03-21T16:18:16-04:00
New Revision: cf6c451a38ce786bbbf225509290c8d7f2695005

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

LOG: [flang] set the paths for the symbol extracting tool (#131375)

This patch is to set the paths for tools used in the
`export_executable_symbols` function in standalone build and set the
necessary macros for compiling the runtime source.

Added: 
    

Modified: 
    flang/CMakeLists.txt
    flang/tools/flang-driver/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt
index 4b703b456cae2..76eb13295eb07 100644
--- a/flang/CMakeLists.txt
+++ b/flang/CMakeLists.txt
@@ -25,6 +25,11 @@ endif()
 set(FLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 set(FLANG_RT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../flang-rt")
 
+# Python is needed for symbol extracting tool
+set(LLVM_MINIMUM_PYTHON_VERSION 3.8)
+find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
+    COMPONENTS Interpreter)
+
 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
   message(FATAL_ERROR "In-source builds are not allowed. \
           Please create a directory and run cmake from there,\
@@ -81,6 +86,13 @@ if (FLANG_STANDALONE_BUILD)
     mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
   endif()
 
+  # Build with _XOPEN_SOURCE on AIX to avoid errors caused by _ALL_SOURCE.
+  # We need to enable the large-file API as well.
+  if (UNIX AND CMAKE_SYSTEM_NAME MATCHES "AIX")
+    add_compile_definitions(_XOPEN_SOURCE=700)
+    add_compile_definitions(_LARGE_FILE_API)
+  endif()
+
   # If the user specifies a relative path to LLVM_DIR, the calls to include
   # LLVM modules fail. Append the absolute path to LLVM_DIR instead.
   if (LLVM_DIR)
@@ -125,6 +137,10 @@ if (FLANG_STANDALONE_BUILD)
     set(USE_NO_MAYBE_UNINITIALIZED 1)
   endif()
 
+  # The path is needed to locate extract_symbols.py
+  if (NOT DEFINED LLVM_MAIN_SRC_DIR)
+    set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
+  endif()
   include(AddLLVM)
   include(HandleLLVMOptions)
   include(VersionFromVCS)

diff  --git a/flang/tools/flang-driver/CMakeLists.txt b/flang/tools/flang-driver/CMakeLists.txt
index 06b61e5951881..b5d6727025121 100644
--- a/flang/tools/flang-driver/CMakeLists.txt
+++ b/flang/tools/flang-driver/CMakeLists.txt
@@ -39,6 +39,7 @@ option(FLANG_PLUGIN_SUPPORT "Build Flang with plugin support." ON)
 
 # Enable support for plugins, which need access to symbols from flang
 if(FLANG_PLUGIN_SUPPORT)
+  set(LLVM_LIBRARY_OUTPUT_INTDIR ${LLVM_LIBRARY_DIR})
   export_executable_symbols_for_plugins(flang)
 endif()
 


        


More information about the flang-commits mailing list