Skip to content

Commit cf6c451

Browse files
authored
[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.
1 parent 6b00ae6 commit cf6c451

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

flang/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ endif()
2525
set(FLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
2626
set(FLANG_RT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../flang-rt")
2727

28+
# Python is needed for symbol extracting tool
29+
set(LLVM_MINIMUM_PYTHON_VERSION 3.8)
30+
find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
31+
COMPONENTS Interpreter)
32+
2833
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE)
2934
message(FATAL_ERROR "In-source builds are not allowed. \
3035
Please create a directory and run cmake from there,\
@@ -81,6 +86,13 @@ if (FLANG_STANDALONE_BUILD)
8186
mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
8287
endif()
8388

89+
# Build with _XOPEN_SOURCE on AIX to avoid errors caused by _ALL_SOURCE.
90+
# We need to enable the large-file API as well.
91+
if (UNIX AND CMAKE_SYSTEM_NAME MATCHES "AIX")
92+
add_compile_definitions(_XOPEN_SOURCE=700)
93+
add_compile_definitions(_LARGE_FILE_API)
94+
endif()
95+
8496
# If the user specifies a relative path to LLVM_DIR, the calls to include
8597
# LLVM modules fail. Append the absolute path to LLVM_DIR instead.
8698
if (LLVM_DIR)
@@ -125,6 +137,10 @@ if (FLANG_STANDALONE_BUILD)
125137
set(USE_NO_MAYBE_UNINITIALIZED 1)
126138
endif()
127139

140+
# The path is needed to locate extract_symbols.py
141+
if (NOT DEFINED LLVM_MAIN_SRC_DIR)
142+
set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
143+
endif()
128144
include(AddLLVM)
129145
include(HandleLLVMOptions)
130146
include(VersionFromVCS)

flang/tools/flang-driver/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ option(FLANG_PLUGIN_SUPPORT "Build Flang with plugin support." ON)
3939

4040
# Enable support for plugins, which need access to symbols from flang
4141
if(FLANG_PLUGIN_SUPPORT)
42+
set(LLVM_LIBRARY_OUTPUT_INTDIR ${LLVM_LIBRARY_DIR})
4243
export_executable_symbols_for_plugins(flang)
4344
endif()
4445

0 commit comments

Comments
 (0)