[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.
This commit is contained in:
Kelvin Li 2025-03-21 16:18:16 -04:00 committed by GitHub
parent 6b00ae6359
commit cf6c451a38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View File

@ -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)

View File

@ -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()