Skip to content

Commit 57c3404

Browse files
committed
Module serach paths
1 parent fa6c977 commit 57c3404

File tree

10 files changed

+42
-44
lines changed

10 files changed

+42
-44
lines changed

flang-rt/cmake/modules/AddFlangRT.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ function (add_flangrt_library name)
360360
endif ()
361361

362362
if (ARG_TARGET_PROPERTIES)
363-
message("Setting target properties of ${tgtname}: ${ARG_TARGET_PROPERTIES}" )
364363
set_target_properties(${tgtname} PROPERTIES ${ARG_TARGET_PROPERTIES})
365364
endif ()
366365

flang-rt/lib/runtime/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
2626
check_fortran_source_compiles([[
2727
subroutine test_quadmath
2828
real(16) :: var1
29-
print *, 'Hello'
3029
end
3130
]]
3231
FORTRAN_SUPPORTS_REAL16
@@ -246,7 +245,7 @@ set(gpu_sources
246245

247246
add_compile_options($<$<COMPILE_LANGUAGE:Fortran>:SHELL:-mmlir> $<$<COMPILE_LANGUAGE:Fortran>:-ignore-missing-type-desc>)
248247

249-
# Flang bug: Reformatting of cooked token buffer causes identifier to be split between lines
248+
# Flang bug: Reformating of cooked token buffer causes identifier to be split between lines
250249
add_compile_options($<$<COMPILE_LANGUAGE:Fortran>:SHELL:-Xflang> $<$<COMPILE_LANGUAGE:Fortran>:-fno-reformat>)
251250

252251
#add_compile_options($<$<COMPILE_LANGUAGE:Fortran>:-mllvm=-flang-intrinsics-mode>)
@@ -355,7 +354,7 @@ else()
355354

356355
function (add_win_flangrt_runtime libtype suffix msvc_lib)
357356
set(name "flang_rt.runtime.${suffix}")
358-
message("${name}.intrinsics")
357+
359358
add_flangrt_library(${name}.intrinsics OBJECT
360359
${intrinsics_sources}
361360
)
@@ -397,7 +396,7 @@ else()
397396
# Except for one selected one (the first)
398397
if (_has_main_intrinsics)
399398
set_property(TARGET ${name} ${name}.intrinsics
400-
PROPERTY Fortran_MODULE_DIRECTORY "module.${suffix}"
399+
PROPERTY Fortran_MODULE_DIRECTORY "module.${suffix}"
401400
)
402401
else ()
403402
set(_has_main_intrinsics "YES" PARENT_SCOPE)

flang/test/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,13 @@ endif ()
107107
add_custom_target(flang-test-depends DEPENDS ${FLANG_TEST_DEPENDS})
108108
set_target_properties(flang-test-depends PROPERTIES FOLDER "Flang/Meta")
109109

110-
111110
add_lit_testsuite(check-flang "Running the Flang regression tests"
112111
${CMAKE_CURRENT_BINARY_DIR}
113112
PARAMS ${FLANG_TEST_PARAMS}
114113
DEPENDS ${FLANG_TEST_DEPENDS}
115114
)
116115
set_target_properties(check-flang PROPERTIES FOLDER "Flang/Meta")
117116

118-
#if ("flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES AND NOT FLANG_STANDALONE_BUILD)
119117
# In case of standalone builds.
120118
if (FLANG_STANDALONE_BUILD)
121119
add_lit_testsuites(FLANG ${CMAKE_CURRENT_BINARY_DIR}
@@ -126,7 +124,6 @@ else()
126124
PARAMS ${FLANG_TEST_PARAMS}
127125
DEPENDS ${FLANG_TEST_DEPENDS})
128126
endif()
129-
#endif ()
130127

131128
# To modify the default target triple for flang tests.
132129
if (DEFINED FLANG_TEST_TARGET_TRIPLE)

flang/test/Semantics/test_modfile.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
from pathlib import Path
1919
from difflib import unified_diff
2020

21-
print(sys.argv)
22-
2321
cm.check_args_long(sys.argv)
2422
srcdir = Path(sys.argv[1])
2523
sources = list(glob.iglob(str(srcdir)))
@@ -43,7 +41,6 @@
4341

4442
prev_files = set(os.listdir(tmpdir))
4543
cmd = [flang_fc1, *flang_fc_args, flang_fc1_options, str(src)]
46-
print(' '.join(cmd))
4744
proc = subprocess.check_output(
4845
cmd, stderr=subprocess.PIPE, universal_newlines=True, cwd=tmpdir
4946
)

flang/test/lit.cfg.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@
184184
else:
185185
config.limit_to_features.add("module-independent")
186186

187-
188187
# Determine if OpenMP runtime was built (enable OpenMP tests via REQUIRES in test file)
189188
openmp_flags_substitution = "-fopenmp"
190189
if config.have_openmp_rtl:

flang/tools/bbc/bbc.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,6 @@ int main(int argc, char **argv) {
568568
ProgramName programPrefix;
569569
programPrefix = argv[0] + ": "s;
570570

571-
572571
if (includeDirs.size() == 0) {
573572
includeDirs.push_back(".");
574573
// Default Fortran modules should be installed in finclude/<target-triple> of the resource directory
@@ -577,7 +576,7 @@ int main(int argc, char **argv) {
577576
if (triple.empty())
578577
triple = llvm::sys::getDefaultTargetTriple();
579578

580-
// Driver::GetResourcesPath(StringRef BinaryPath)
579+
581580
// FIXME: Do not modify intrinsicIncludeDirs directly, should be treated as immutable just like argv.
582581
// TODO: Normlize triple directory as clang does; best refactor with ToolChain::getDefaultIntrinsicModulePaths() used by the flang driver.
583582
std::string mainExe = llvm::sys::fs::getMainExecutable(argv[0], nullptr);
@@ -587,15 +586,6 @@ int main(int argc, char **argv) {
587586
llvm::sys::path::append(resourceDir, "finclude", triple);
588587
llvm::errs() << resourceDir << "\n";
589588
intrinsicIncludeDirs.push_back(resourceDir.str().str());
590-
591-
#if 0
592-
intrinsicIncludeDirs.push_back(
593-
llvm::sys::path::parent_path(
594-
llvm::sys::path::parent_path(
595-
llvm::sys::fs::getMainExecutable(argv[0], nullptr)))
596-
.str() +
597-
"/include/flang");
598-
#endif
599589
}
600590

601591
Fortran::parser::Options options;
@@ -664,9 +654,6 @@ int main(int argc, char **argv) {
664654
Fortran::parser::AllCookedSources allCookedSources(allSources);
665655
Fortran::semantics::SemanticsContext semanticsContext{
666656
defaultKinds, options.features, langOpts, allCookedSources};
667-
//std::vector < std::string> intrinsicsSearchPaths;
668-
// intrinsicsSearchPaths.emplace_back("s");
669-
//llvm::append_range(intrinsicsSearchPaths, intrinsicIncludeDirs);
670657
semanticsContext.set_moduleDirectory(moduleDir)
671658
.set_moduleFileSuffix(moduleSuffix)
672659
.set_searchDirectories(includeDirs)

llvm/include/llvm/ADT/SmallVector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ template <typename T> struct CalculateSmallVectorDefaultInlinedElements {
11601160
// happens on a 32-bit host and then fails due to sizeof(T) *increasing* on a
11611161
// 64-bit host, is expected to be very rare.
11621162
static_assert(
1163-
sizeof(T) <= 512,
1163+
sizeof(T) <= 256,
11641164
"You are trying to use a default number of inlined elements for "
11651165
"`SmallVector<T>` but `sizeof(T)` is really big! Please use an "
11661166
"explicit number of inlined elements with `SmallVector<T, N>` to make "

llvm/runtimes/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,10 +525,9 @@ if(build_runtimes)
525525
endforeach()
526526
endif()
527527

528-
# TODO: We need to consider passing it as '-DRUNTIMES_x86_64_LLVM_ENABLE_RUNTIMES'.
528+
# TODO: Also enable Fortran for per-target runtimes
529529
if ("openmp" IN_LIST LLVM_ENABLE_RUNTIMES AND "flang" IN_LIST LLVM_ENABLE_PROJECTS)
530-
#set(LIBOMP_MODULES_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}/flang")
531-
list(APPEND extra_args ENABLE_FORTRAN)
530+
list(APPEND extra_args ENABLE_FORTRAN)
532531
endif()
533532
if("openmp" IN_LIST LLVM_ENABLE_RUNTIMES OR "offload" IN_LIST LLVM_ENABLE_RUNTIMES)
534533
foreach(dep opt llvm-link llvm-extract clang clang-offload-packager clang-nvlink-wrapper)

openmp/runtime/src/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,9 @@ flang_module_fortran_enable()
464464
if (LLVM_TOOL_OPENMP_BUILD AND "flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES)
465465
# flang-rt-mod will be created by runtimes
466466
else ()
467-
if (NOT TARGET flang-rt-mod)
468-
add_custom_target(flang-rt-mod)
469-
endif ()
467+
#if (NOT TARGET flang-rt-mod)
468+
# add_custom_target(flang-rt-mod)
469+
#endif ()
470470
endif ()
471471

472472

@@ -477,9 +477,10 @@ endif ()
477477
omp_lib.F90
478478
)
479479
flang_module_target(libomp-mod)
480+
add_dependencies(libomp-mod flang-rt-mod)
480481

481482
libomp_get_fflags(LIBOMP_CONFIGURED_FFLAGS)
482-
target_compile_options(libomp-mod PRIVATE ${LIBOMP_CONFIGURED_FFLAGS})
483+
target_compile_options(libomp-mod PRIVATE ${LIBOMP_CONFIGURED_FFLAGS})
483484

484485

485486
if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")

runtimes/CMakeLists.txt

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,6 @@ endfunction()
6464

6565

6666

67-
# Determine whether we are in the runtimes/runtimes-bins directory of a
68-
# bootstrapping build.
69-
set(LLVM_TREE_AVAILABLE OFF)
70-
if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSION)
71-
set(LLVM_TREE_AVAILABLE ON)
72-
endif()
73-
74-
7567

7668

7769
find_package(LLVM PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
@@ -106,12 +98,25 @@ include(CheckCCompilerFlag)
10698
include(CheckCXXCompilerFlag)
10799
include(ExtendPath)
108100

101+
102+
# Determine whether we are in the runtimes/runtimes-bins directory of a
103+
# bootstrapping build.
104+
set(LLVM_TREE_AVAILABLE OFF)
105+
if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSION)
106+
set(LLVM_TREE_AVAILABLE ON)
107+
endif()
108+
message("LLVM_TREE_AVAILABLE=${LLVM_TREE_AVAILABLE} LLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_OUTPUT_INTDIR} LLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_RUNTIME_OUTPUT_INTDIR} PACKAGE_VERSION=${PACKAGE_VERSION}")
109+
110+
111+
112+
109113
# CMake omits default compiler include paths, but in runtimes build, we use
110114
# -nostdinc and -nostdinc++ and control include paths manually so this behavior
111115
# is undesirable. Filtering CMAKE_{LANG}_IMPLICIT_INCLUDE_DIRECTORIES to remove
112116
# paths that are inside the build directory disables this behavior.
113117
#
114118
# See https://gitlab.kitware.com/cmake/cmake/-/issues/19227 for further details.
119+
# FIXME: This assumes compiling libc++, but creates problems for every library that uses the C++ standard library
115120

116121
function(filter_prefixed list prefix outvar)
117122
foreach(str ${list})
@@ -342,7 +347,7 @@ macro(flang_module_fortran_enable)
342347
get_clang_resource_dir(RUNTIMES_OUTPUT_RESOURCE_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/..")
343348
get_clang_resource_dir(RUNTIMES_INSTALL_RESOURCE_PATH_DEFAULT)
344349

345-
extend_path(RUNTIMES_OUTPUT_RESOURCE_MOD_DIR "${LIBOMP_OUTPUT_RESOURCE_DIR}" "${toolchain_mod_subdir}")
350+
extend_path(RUNTIMES_OUTPUT_RESOURCE_MOD_DIR "${RUNTIMES_OUTPUT_RESOURCE_DIR}" "${toolchain_mod_subdir}")
346351
else ()
347352
# In a standalone runtimes build, do not write into LLVM_BINARY_DIR. It may be
348353
# read-only and/or shared by multiple runtimes with different build
@@ -354,7 +359,7 @@ macro(flang_module_fortran_enable)
354359
set(RUNTIMES_OUTPUT_RESOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
355360
set(RUNTIMES_INSTALL_RESOURCE_PATH_DEFAULT "lib${LLVM_LIBDIR_SUFFIX}/clang/${LLVM_VERSION_MAJOR}")
356361

357-
extend_path(RUNTIMES_OUTPUT_RESOURCE_MOD_DIR "${LIBOMP_OUTPUT_RESOURCE_DIR}" "finclude")
362+
extend_path(RUNTIMES_OUTPUT_RESOURCE_MOD_DIR "${RUNTIMES_OUTPUT_RESOURCE_DIR}" "finclude")
358363
endif ()
359364
extend_path(RUNTIMES_INSTALL_RESOURCE_MOD_PATH "${RUNTIMES_INSTALL_RESOURCE_PATH}" "${toolchain_mod_subdir}")
360365
else ()
@@ -379,6 +384,7 @@ endmacro ()
379384

380385

381386
function(flang_module_target tgtname)
387+
message("flang_module_target(${tgtname})")
382388
if (NOT RUNTIMES_FLANG_MODULES_ENABLED)
383389
return ()
384390
endif ()
@@ -388,6 +394,20 @@ function(flang_module_target tgtname)
388394
Fortran_MODULE_DIRECTORY "${RUNTIMES_OUTPUT_RESOURCE_MOD_DIR}"
389395
)
390396

397+
message("RUNTIMES_OUTPUT_RESOURCE_MOD_DIR: ${RUNTIMES_OUTPUT_RESOURCE_MOD_DIR}")
398+
target_compile_options(${tgtname} PRIVATE
399+
"$<$<COMPILE_LANGUAGE:Fortran>:SHELL:-fintrinsic-modules-path>"
400+
"$<$<COMPILE_LANGUAGE:Fortran>:${RUNTIMES_OUTPUT_RESOURCE_MOD_DIR}>"
401+
)
402+
403+
set_target_properties(${tgtname}
404+
PROPERTIES
405+
Fortran_MODULE_DIRECTORY "${RUNTIMES_OUTPUT_RESOURCE_MOD_DIR}"
406+
#ARCHIVE_OUTPUT_DIRECTORY "${RUNTIMES_OUTPUT_RESOURCE_LIB_DIR}"
407+
#LIBRARY_OUTPUT_DIRECTORY "${RUNTIMES_OUTPUT_RESOURCE_LIB_DIR}"
408+
)
409+
410+
391411
# TOOD: Install location
392412
endfunction ()
393413

0 commit comments

Comments
 (0)