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

Kelvin Li via flang-commits flang-commits at lists.llvm.org
Fri Mar 14 11:54:39 PDT 2025


https://github.com/kkwli created https://github.com/llvm/llvm-project/pull/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.

>From e540c4433be6b2a4ba44020468a4b059aeb34705 Mon Sep 17 00:00:00 2001
From: Kelvin Li <kli at ca.ibm.com>
Date: Fri, 14 Mar 2025 14:38:27 -0400
Subject: [PATCH] [flang][AIX] set the paths for the symbol extracting tool

---
 flang/CMakeLists.txt                    | 16 ++++++++++++++++
 flang/tools/flang-driver/CMakeLists.txt |  1 +
 2 files changed, 17 insertions(+)

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