Skip to content

Commit 5bc9686

Browse files
committed
Merge branch 'users/meinersbur/flang_runtime' into users/meinersbur/flang_runtime_shared
2 parents 51011af + be9a0a2 commit 5bc9686

File tree

239 files changed

+841
-791
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

239 files changed

+841
-791
lines changed

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ void tools::addOpenMPHostOffloadingArgs(const Compilation &C,
13211321
/// Add Fortran runtime libs
13221322
void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
13231323
llvm::opt::ArgStringList &CmdArgs) {
1324-
// Link flang_rt
1324+
// Link flang_rt.runtime
13251325
// These are handled earlier on Windows by telling the frontend driver to
13261326
// add the correct libraries to link against as dependents in the object
13271327
// file.
@@ -1330,14 +1330,14 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
13301330
F128LibName.consume_front_insensitive("lib");
13311331
if (!F128LibName.empty()) {
13321332
bool AsNeeded = !TC.getTriple().isOSAIX();
1333-
CmdArgs.push_back("-lFortranFloat128Math");
1333+
CmdArgs.push_back("-lflang_rt.quadmath");
13341334
if (AsNeeded)
13351335
addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true);
13361336
CmdArgs.push_back(Args.MakeArgString("-l" + F128LibName));
13371337
if (AsNeeded)
13381338
addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false);
13391339
}
1340-
CmdArgs.push_back("-lflang_rt");
1340+
CmdArgs.push_back("-lflang_rt.runtime");
13411341
addArchSpecificRPath(TC, Args, CmdArgs);
13421342
}
13431343

clang/lib/Driver/ToolChains/Flang.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,26 +367,26 @@ static void processVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args,
367367
case options::OPT__SLASH_MT:
368368
CmdArgs.push_back("-D_MT");
369369
CmdArgs.push_back("--dependent-lib=libcmt");
370-
CmdArgs.push_back("--dependent-lib=flang_rt.static.lib");
370+
CmdArgs.push_back("--dependent-lib=flang_rt.runtime.static.lib");
371371
break;
372372
case options::OPT__SLASH_MTd:
373373
CmdArgs.push_back("-D_MT");
374374
CmdArgs.push_back("-D_DEBUG");
375375
CmdArgs.push_back("--dependent-lib=libcmtd");
376-
CmdArgs.push_back("--dependent-lib=flang_rt.static_dbg.lib");
376+
CmdArgs.push_back("--dependent-lib=flang_rt.runtime.static_dbg.lib");
377377
break;
378378
case options::OPT__SLASH_MD:
379379
CmdArgs.push_back("-D_MT");
380380
CmdArgs.push_back("-D_DLL");
381381
CmdArgs.push_back("--dependent-lib=msvcrt");
382-
CmdArgs.push_back("--dependent-lib=flang_rt.dynamic.lib");
382+
CmdArgs.push_back("--dependent-lib=flang_rt.runtime.dynamic.lib");
383383
break;
384384
case options::OPT__SLASH_MDd:
385385
CmdArgs.push_back("-D_MT");
386386
CmdArgs.push_back("-D_DEBUG");
387387
CmdArgs.push_back("-D_DLL");
388388
CmdArgs.push_back("--dependent-lib=msvcrtd");
389-
CmdArgs.push_back("--dependent-lib=flang_rt.dynamic_dbg.lib");
389+
CmdArgs.push_back("--dependent-lib=flang_rt.runtime.dynamic_dbg.lib");
390390
break;
391391
}
392392
}

flang-rt/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ else ()
198198
endif ()
199199

200200

201-
option(FLANG_RT_ENABLE_CUF "Compile CUDA Fortran runtime sources" OFF)
202-
if (FLANG_RT_ENABLE_CUF)
201+
option(FLANG_RT_INCLUDE_CUF "Build the CUDA Fortran runtime (libflang_rt.cuda.a)" OFF)
202+
if (FLANG_RT_INCLUDE_CUF)
203203
find_package(CUDAToolkit REQUIRED)
204204
endif()
205205

@@ -270,6 +270,10 @@ add_custom_target(flang-rt)
270270

271271
add_subdirectory(lib)
272272

273+
if (LLVM_INCLUDE_EXAMPLES)
274+
add_subdirectory(examples)
275+
endif ()
276+
273277
if (FLANG_RT_INCLUDE_TESTS)
274278
add_subdirectory(unittests)
275279
add_subdirectory(test)

flang-rt/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ CMake itself provide.
151151
GPU accelerators using OpenMP offloading. Only Clang is supported for
152152
`CMAKE_C_COMPILER` and `CMAKE_CXX_COMPILER`.
153153

154-
* `FLANG_RT_ENABLE_CUF` (bool, default: `OFF`)
154+
* `FLANG_RT_INCLUDE_CUF` (bool, default: `OFF`)
155155

156-
Compiles the `libCufRuntime_cuda_<CUDA-version>.a/.so` library. This is
156+
Compiles the `libflang_rt.cuda_<CUDA-version>.a/.so` library. This is
157157
independent of `FLANG_RT_EXPERIMENTAL_OFFLOAD_SUPPORT=CUDA` and only
158158
requires a
159159
[CUDA Toolkit installation](https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html)

flang-rt/cmake/modules/AddFlangRT.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
#===------------------------------------------------------------------------===#
88

9-
# Builds a library with common options for flang-rt.
9+
# Builds a library with common options for Flang-RT.
1010
#
1111
# Usage:
1212
#
@@ -213,11 +213,11 @@ function (add_flangrt_library name)
213213
endif ()
214214

215215
# Flang-RT's public headers
216-
target_include_directories(${tgtname} PRIVATE "${FLANG_RT_SOURCE_DIR}/include")
216+
target_include_directories(${tgtname} PUBLIC "${FLANG_RT_SOURCE_DIR}/include")
217217

218218
# For ISO_Fortran_binding.h to be found by the runtime itself (Accessed as #include "flang/ISO_Fortran_binding.h")
219-
# User applications can use #include <ISO_Fortran_binding.h>
220-
target_include_directories(${tgtname} PRIVATE "${FLANG_SOURCE_DIR}/include")
219+
# User applications can use #include <ISO_Fortran_binding.h>
220+
target_include_directories(${tgtname} PUBLIC "${FLANG_SOURCE_DIR}/include")
221221

222222
# For Flang-RT's configured config.h to be found
223223
target_include_directories(${tgtname} PRIVATE "${FLANG_RT_BINARY_DIR}")

flang-rt/cmake/modules/AddFlangRTOffload.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ macro(enable_cuda_compilation name files)
4040
)
4141
endif()
4242
set_source_files_properties(${files} PROPERTIES COMPILE_OPTIONS
43-
"${CUDA_COMPILE_OPTIONS}"
44-
)
43+
"${CUDA_COMPILE_OPTIONS}")
4544

4645
# Create a .a library consisting of CUDA PTX.
4746
# This is different from a regular static library. The CUDA_PTX_COMPILATION

flang-rt/examples/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#===-- examples/CMakeLists.txt ---------------------------------------------===#
2+
#
3+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
# See https://llvm.org/LICENSE.txt for license information.
5+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
#
7+
#===------------------------------------------------------------------------===#
8+
9+
add_subdirectory(ExternalHelloWorld)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#===-- examples/ExternalHelloWorld/CMakeLists.txt --------------------------===#
2+
#
3+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
# See https://llvm.org/LICENSE.txt for license information.
5+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
#
7+
#===------------------------------------------------------------------------===#
8+
9+
# This test is not run by default as it requires input.
10+
add_llvm_example(external-hello-world
11+
external-hello.cpp
12+
)
13+
14+
target_link_libraries(external-hello-world
15+
PRIVATE
16+
flang_rt.runtime
17+
)

flang/examples/ExternalHelloWorld/external-hello.cpp renamed to flang-rt/examples/ExternalHelloWorld/external-hello.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
//===-- examples/ExternalHelloWorld/external-hello.cpp ----------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
19
#include "flang/Runtime/io-api.h"
210
#include "flang/Runtime/main.h"
311
#include "flang/Runtime/stop.h"

flang-rt/include/flang-rt/CUDA/allocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- include/flang-rt/CUDA/allocator.h -----------------------*- C++ -*-===//
1+
//===-- include/flang-rt/cuda/allocator.h -----------------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

0 commit comments

Comments
 (0)