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.

flang-rt/include/flang-rt/allocator-registry.h renamed to flang-rt/include/flang-rt/runtime/allocator-registry.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
//===-- include/flang-rt/allocator-registry.h -------------------*- C++ -*-===//
1+
//===-- include/flang-rt/runtime/allocator-registry.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.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef FLANG_RT_ALLOCATOR_REGISTRY_H_
10-
#define FLANG_RT_ALLOCATOR_REGISTRY_H_
9+
#ifndef FLANG_RT_RUNTIME_ALLOCATOR_REGISTRY_H_
10+
#define FLANG_RT_RUNTIME_ALLOCATOR_REGISTRY_H_
1111

1212
#include "flang/Common/api-attrs.h"
1313
#include "flang/Runtime/allocator-registry-consts.h"
@@ -55,4 +55,4 @@ RT_OFFLOAD_VAR_GROUP_END
5555

5656
} // namespace Fortran::runtime
5757

58-
#endif // FLANG_RT_ALLOCATOR_REGISTRY_H_
58+
#endif // FLANG_RT_RUNTIME_ALLOCATOR_REGISTRY_H_

flang-rt/include/flang-rt/array-constructor.h renamed to flang-rt/include/flang-rt/runtime/array-constructor.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- include/flang-rt/array-constructor.h --------------------*- C++ -*-===//
1+
//===-- include/flang-rt/runtime/array-constructor.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.
@@ -9,8 +9,8 @@
99
// External APIs to create temporary storage for array constructors when their
1010
// final extents or length parameters cannot be pre-computed.
1111

12-
#ifndef FLANG_RT_ARRAY_CONSTRUCTOR_H_
13-
#define FLANG_RT_ARRAY_CONSTRUCTOR_H_
12+
#ifndef FLANG_RT_RUNTIME_ARRAY_CONSTRUCTOR_H_
13+
#define FLANG_RT_RUNTIME_ARRAY_CONSTRUCTOR_H_
1414

1515
#include "descriptor.h"
1616
#include "flang/Runtime/array-constructor-consts.h"
@@ -54,4 +54,4 @@ static_assert(alignof(Fortran::runtime::ArrayConstructorVector) <=
5454
"MaxArrayConstructorVectorAlignInBytes");
5555

5656
} // namespace Fortran::runtime
57-
#endif // FLANG_RT_ARRAY_CONSTRUCTOR_H_
57+
#endif // FLANG_RT_RUNTIME_ARRAY_CONSTRUCTOR_H_

flang-rt/include/flang-rt/assign-impl.h renamed to flang-rt/include/flang-rt/runtime/assign-impl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
//===-- include/flang-rt/assign-impl.h --------------------------*- C++ -*-===//
1+
//===-- include/flang-rt/runtime/assign-impl.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.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef FLANG_RT_ASSIGN_IMPL_H_
10-
#define FLANG_RT_ASSIGN_IMPL_H_
9+
#ifndef FLANG_RT_RUNTIME_ASSIGN_IMPL_H_
10+
#define FLANG_RT_RUNTIME_ASSIGN_IMPL_H_
1111

1212
#include "flang/Runtime/freestanding-tools.h"
1313

@@ -28,4 +28,4 @@ RT_API_ATTRS void DoFromSourceAssign(Descriptor &, const Descriptor &,
2828
#endif
2929

3030
} // namespace Fortran::runtime
31-
#endif // FLANG_RT_ASSIGN_IMPL_H_
31+
#endif // FLANG_RT_RUNTIME_ASSIGN_IMPL_H_

flang-rt/include/flang-rt/buffer.h renamed to flang-rt/include/flang-rt/runtime/buffer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- include/flang-rt/buffer.h -------------------------------*- C++ -*-===//
1+
//===-- include/flang-rt/runtime/buffer.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.
@@ -8,8 +8,8 @@
88

99
// External file buffering
1010

11-
#ifndef FLANG_RT_BUFFER_H_
12-
#define FLANG_RT_BUFFER_H_
11+
#ifndef FLANG_RT_RUNTIME_BUFFER_H_
12+
#define FLANG_RT_RUNTIME_BUFFER_H_
1313

1414
#include "io-error.h"
1515
#include "memory.h"
@@ -221,4 +221,4 @@ template <typename STORE, std::size_t minBuffer = 65536> class FileFrame {
221221
bool dirty_{false};
222222
};
223223
} // namespace Fortran::runtime::io
224-
#endif // FLANG_RT_BUFFER_H_
224+
#endif // FLANG_RT_RUNTIME_BUFFER_H_

flang-rt/include/flang-rt/connection.h renamed to flang-rt/include/flang-rt/runtime/connection.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- include/flang-rt/connection.h ---------------------------*- C++ -*-===//
1+
//===-- include/flang-rt/runtime/connection.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.
@@ -8,8 +8,8 @@
88

99
// Fortran I/O connection state (abstracted over internal & external units)
1010

11-
#ifndef FLANG_RT_CONNECTION_H_
12-
#define FLANG_RT_CONNECTION_H_
11+
#ifndef FLANG_RT_RUNTIME_CONNECTION_H_
12+
#define FLANG_RT_RUNTIME_CONNECTION_H_
1313

1414
#include "format.h"
1515
#include "flang/Common/optional.h"
@@ -124,4 +124,4 @@ class SavedPosition {
124124
};
125125

126126
} // namespace Fortran::runtime::io
127-
#endif // FLANG_RT_CONNECTION_H_
127+
#endif // FLANG_RT_RUNTIME_CONNECTION_H_

flang-rt/include/flang-rt/derived.h renamed to flang-rt/include/flang-rt/runtime/derived.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- include/flang-rt/derived.h ------------------------------*- C++ -*-===//
1+
//===-- include/flang-rt/runtime/derived.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.
@@ -8,8 +8,8 @@
88

99
// Internal runtime utilities for derived type operations.
1010

11-
#ifndef FLANG_RT_DERIVED_H_
12-
#define FLANG_RT_DERIVED_H_
11+
#ifndef FLANG_RT_RUNTIME_DERIVED_H_
12+
#define FLANG_RT_RUNTIME_DERIVED_H_
1313

1414
#include "flang/Common/api-attrs.h"
1515

@@ -48,4 +48,4 @@ RT_API_ATTRS void Destroy(const Descriptor &, bool finalize,
4848
RT_API_ATTRS bool HasDynamicComponent(const Descriptor &);
4949

5050
} // namespace Fortran::runtime
51-
#endif // FLANG_RT_DERIVED_H_
51+
#endif // FLANG_RT_RUNTIME_DERIVED_H_

flang-rt/include/flang-rt/descriptor.h renamed to flang-rt/include/flang-rt/runtime/descriptor.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
//===-- include/flang-rt/descriptor.h ---------------------------*- C++ -*-===//
1+
//===-- include/flang-rt/runtime/descriptor.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.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef FLANG_RT_DESCRIPTOR_H_
10-
#define FLANG_RT_DESCRIPTOR_H_
9+
#ifndef FLANG_RT_RUNTIME_DESCRIPTOR_H_
10+
#define FLANG_RT_RUNTIME_DESCRIPTOR_H_
1111

1212
// Defines data structures used during execution of a Fortran program
1313
// to implement nontrivial dummy arguments, pointers, allocatables,
@@ -482,4 +482,4 @@ class alignas(Descriptor) StaticDescriptor {
482482
};
483483

484484
} // namespace Fortran::runtime
485-
#endif // FLANG_RT_DESCRIPTOR_H_
485+
#endif // FLANG_RT_RUNTIME_DESCRIPTOR_H_

flang-rt/include/flang-rt/emit-encoded.h renamed to flang-rt/include/flang-rt/runtime/emit-encoded.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- include/flang-rt/emit-encoded.h -------------------------*- C++ -*-===//
1+
//===-- include/flang-rt/runtime/emit-encoded.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.
@@ -8,8 +8,8 @@
88

99
// Templates for emitting CHARACTER values with conversion
1010

11-
#ifndef FLANG_RT_EMIT_ENCODED_H_
12-
#define FLANG_RT_EMIT_ENCODED_H_
11+
#ifndef FLANG_RT_RUNTIME_EMIT_ENCODED_H_
12+
#define FLANG_RT_RUNTIME_EMIT_ENCODED_H_
1313

1414
#include "connection.h"
1515
#include "environment.h"
@@ -114,4 +114,4 @@ RT_API_ATTRS bool EmitRepeated(CONTEXT &to, char ch, std::size_t n) {
114114
}
115115

116116
} // namespace Fortran::runtime::io
117-
#endif // FLANG_RT_EMIT_ENCODED_H_
117+
#endif // FLANG_RT_RUNTIME_EMIT_ENCODED_H_

flang-rt/include/flang-rt/environment.h renamed to flang-rt/include/flang-rt/runtime/environment.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
//===-- include/flang-rt/environment.h --------------------------*- C++ -*-===//
1+
//===-- include/flang-rt/runtime/environment.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.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef FLANG_RT_ENVIRONMENT_H_
10-
#define FLANG_RT_ENVIRONMENT_H_
9+
#ifndef FLANG_RT_RUNTIME_ENVIRONMENT_H_
10+
#define FLANG_RT_RUNTIME_ENVIRONMENT_H_
1111

1212
#include "flang/Common/optional.h"
1313
#include "flang/Decimal/decimal.h"
@@ -67,4 +67,4 @@ RT_OFFLOAD_VAR_GROUP_END
6767

6868
} // namespace Fortran::runtime
6969

70-
#endif // FLANG_RT_ENVIRONMENT_H_
70+
#endif // FLANG_RT_RUNTIME_ENVIRONMENT_H_

0 commit comments

Comments
 (0)