Skip to content

Commit 2e50a1f

Browse files
committed
[Flang] Don't use FortranDecimal for runtime
1 parent 71015c8 commit 2e50a1f

File tree

11 files changed

+18
-119
lines changed

11 files changed

+18
-119
lines changed

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 1 addition & 2 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 FortranRuntime and FortranDecimal
1324+
// Link FortranRuntime
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.
@@ -1338,7 +1338,6 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
13381338
addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false);
13391339
}
13401340
CmdArgs.push_back("-lFortranRuntime");
1341-
CmdArgs.push_back("-lFortranDecimal");
13421341
addArchSpecificRPath(TC, Args, CmdArgs);
13431342
}
13441343

clang/lib/Driver/ToolChains/Flang.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,29 +361,25 @@ static void processVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args,
361361
CmdArgs.push_back("-D_MT");
362362
CmdArgs.push_back("--dependent-lib=libcmt");
363363
CmdArgs.push_back("--dependent-lib=FortranRuntime.static.lib");
364-
CmdArgs.push_back("--dependent-lib=FortranDecimal.static.lib");
365364
break;
366365
case options::OPT__SLASH_MTd:
367366
CmdArgs.push_back("-D_MT");
368367
CmdArgs.push_back("-D_DEBUG");
369368
CmdArgs.push_back("--dependent-lib=libcmtd");
370369
CmdArgs.push_back("--dependent-lib=FortranRuntime.static_dbg.lib");
371-
CmdArgs.push_back("--dependent-lib=FortranDecimal.static_dbg.lib");
372370
break;
373371
case options::OPT__SLASH_MD:
374372
CmdArgs.push_back("-D_MT");
375373
CmdArgs.push_back("-D_DLL");
376374
CmdArgs.push_back("--dependent-lib=msvcrt");
377375
CmdArgs.push_back("--dependent-lib=FortranRuntime.dynamic.lib");
378-
CmdArgs.push_back("--dependent-lib=FortranDecimal.dynamic.lib");
379376
break;
380377
case options::OPT__SLASH_MDd:
381378
CmdArgs.push_back("-D_MT");
382379
CmdArgs.push_back("-D_DEBUG");
383380
CmdArgs.push_back("-D_DLL");
384381
CmdArgs.push_back("--dependent-lib=msvcrtd");
385382
CmdArgs.push_back("--dependent-lib=FortranRuntime.dynamic_dbg.lib");
386-
CmdArgs.push_back("--dependent-lib=FortranDecimal.dynamic_dbg.lib");
387383
break;
388384
}
389385
}

flang/docs/FlangDriver.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,19 +175,18 @@ like this:
175175

176176
```
177177
$ flang -v -o example example.o
178-
"/usr/bin/ld" [...] example.o [...] "-lFortranRuntime" "-lFortranDecimal" [...]
178+
"/usr/bin/ld" [...] example.o [...] "-lFortranRuntime" [...]
179179
```
180180

181181
The automatically added libraries are:
182182

183183
* `FortranRuntime`: Provides most of the Flang runtime library.
184-
* `FortranDecimal`: Provides operations for decimal numbers.
185184

186185
If the code is C/C++ based and invokes Fortran routines, one can either use Clang
187186
or Flang as the linker driver. If Clang is used, it will automatically all
188187
required runtime libraries needed by C++ (e.g., for STL) to the linker invocation.
189-
In this case, one has to explicitly provide the Fortran runtime libraries
190-
`FortranRuntime` and/or `FortranDecimal`. An alternative is to use Flang to link.
188+
In this case, one has to explicitly provide the Fortran runtime library
189+
`FortranRuntime`. An alternative is to use Flang to link.
191190
In this case, it may be required to explicitly supply C++ runtime libraries.
192191

193192
On Darwin, the logical root where the system libraries are located (sysroot)

flang/lib/Decimal/CMakeLists.txt

Lines changed: 9 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,12 @@
1-
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
2-
cmake_minimum_required(VERSION 3.20.0)
3-
4-
project(FortranDecimal C CXX)
5-
6-
set(CMAKE_CXX_STANDARD 17)
7-
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
8-
set(CMAKE_CXX_EXTENSIONS OFF)
9-
10-
set(FLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
11-
12-
set(LLVM_COMMON_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../cmake")
13-
set(LLVM_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../llvm/cmake")
14-
set(CLANG_CMAKE_UTILS "${FLANG_SOURCE_DIR}/../clang/cmake")
15-
16-
# Add path for custom modules
17-
list(INSERT CMAKE_MODULE_PATH 0
18-
"${FLANG_SOURCE_DIR}/cmake"
19-
"${FLANG_SOURCE_DIR}/cmake/modules"
20-
"${LLVM_COMMON_CMAKE_UTILS}"
21-
"${LLVM_COMMON_CMAKE_UTILS}/Modules"
22-
"${LLVM_CMAKE_UTILS}"
23-
"${LLVM_CMAKE_UTILS}/modules"
24-
"${CLANG_CMAKE_UTILS}/modules"
25-
)
26-
27-
include(AddClang)
28-
include(AddLLVM)
29-
include(AddFlang)
30-
include(HandleLLVMOptions)
31-
32-
include(TestBigEndian)
33-
test_big_endian(IS_BIGENDIAN)
34-
if (IS_BIGENDIAN)
35-
add_compile_definitions(FLANG_BIG_ENDIAN=1)
36-
else ()
37-
add_compile_definitions(FLANG_LITTLE_ENDIAN=1)
38-
endif ()
39-
include_directories(BEFORE
40-
${FLANG_SOURCE_DIR}/include)
41-
endif()
42-
43-
check_cxx_compiler_flag(-fno-lto FLANG_RUNTIME_HAS_FNO_LTO_FLAG)
44-
if (FLANG_RUNTIME_HAS_FNO_LTO_FLAG)
45-
append("-fno-lto" CMAKE_CXX_FLAGS)
46-
endif()
47-
48-
# Disable libstdc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build, to
49-
# avoid an unwanted dependency on libstdc++.so.
50-
add_definitions(-U_GLIBCXX_ASSERTIONS)
51-
52-
set(sources
1+
#===-- lib/Decimal/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_flang_library(FortranDecimal
5310
binary-to-decimal.cpp
5411
decimal-to-binary.cpp
5512
)
56-
57-
include(AddFlangOffloadRuntime)
58-
enable_cuda_compilation(FortranDecimal "${sources}")
59-
enable_omp_offload_compilation("${sources}")
60-
61-
add_flang_library(FortranDecimal INSTALL_WITH_TOOLCHAIN ${sources})
62-
63-
if (DEFINED MSVC)
64-
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
65-
add_flang_library(FortranDecimal.static INSTALL_WITH_TOOLCHAIN
66-
binary-to-decimal.cpp
67-
decimal-to-binary.cpp
68-
)
69-
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
70-
add_flang_library(FortranDecimal.dynamic INSTALL_WITH_TOOLCHAIN
71-
binary-to-decimal.cpp
72-
decimal-to-binary.cpp
73-
)
74-
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
75-
add_flang_library(FortranDecimal.static_dbg INSTALL_WITH_TOOLCHAIN
76-
binary-to-decimal.cpp
77-
decimal-to-binary.cpp
78-
)
79-
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebugDLL)
80-
add_flang_library(FortranDecimal.dynamic_dbg INSTALL_WITH_TOOLCHAIN
81-
binary-to-decimal.cpp
82-
decimal-to-binary.cpp
83-
)
84-
add_dependencies(FortranDecimal FortranDecimal.static FortranDecimal.dynamic
85-
FortranDecimal.static_dbg FortranDecimal.dynamic_dbg)
86-
endif()

flang/runtime/CMakeLists.txt

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ add_definitions(-U_LIBCPP_ENABLE_ASSERTIONS)
111111
add_subdirectory(Float128Math)
112112

113113
set(sources
114+
${FLANG_SOURCE_DIR}/lib/Decimal/binary-to-decimal.cpp
115+
${FLANG_SOURCE_DIR}/lib/Decimal/decimal-to-binary.cpp
114116
ISO_Fortran_binding.cpp
115117
allocator-registry.cpp
116118
allocatable.cpp
@@ -270,39 +272,27 @@ endif()
270272
if (NOT DEFINED MSVC)
271273
add_flang_library(FortranRuntime
272274
${sources}
273-
LINK_LIBS
274-
FortranDecimal
275275

276276
INSTALL_WITH_TOOLCHAIN
277277
)
278278
else()
279279
add_flang_library(FortranRuntime
280280
${sources}
281-
LINK_LIBS
282-
FortranDecimal
283281
)
284282
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
285283
add_flang_library(FortranRuntime.static ${sources}
286-
LINK_LIBS
287-
FortranDecimal.static
288284
INSTALL_WITH_TOOLCHAIN)
289285
set_target_properties(FortranRuntime.static PROPERTIES FOLDER "Flang/Runtime Libraries")
290286
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
291287
add_flang_library(FortranRuntime.dynamic ${sources}
292-
LINK_LIBS
293-
FortranDecimal.dynamic
294288
INSTALL_WITH_TOOLCHAIN)
295289
set_target_properties(FortranRuntime.dynamic PROPERTIES FOLDER "Flang/Runtime Libraries")
296290
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebug)
297291
add_flang_library(FortranRuntime.static_dbg ${sources}
298-
LINK_LIBS
299-
FortranDecimal.static_dbg
300292
INSTALL_WITH_TOOLCHAIN)
301293
set_target_properties(FortranRuntime.static_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
302294
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDebugDLL)
303295
add_flang_library(FortranRuntime.dynamic_dbg ${sources}
304-
LINK_LIBS
305-
FortranDecimal.dynamic_dbg
306296
INSTALL_WITH_TOOLCHAIN)
307297
set_target_properties(FortranRuntime.dynamic_dbg PROPERTIES FOLDER "Flang/Runtime Libraries")
308298
add_dependencies(FortranRuntime FortranRuntime.static FortranRuntime.dynamic

flang/test/Driver/linker-flags.f90

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,26 @@
3333
! SOLARIS-F128NONE-NOT: FortranFloat128Math
3434
! UNIX-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
3535
! SOLARIS-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "-z" "ignore" "-lquadmath" "-z" "record"
36-
! UNIX-SAME: "-lFortranRuntime" "-lFortranDecimal" "-lm"
36+
! UNIX-SAME: "-lFortranRuntime" "-lm"
3737
! COMPILER-RT: "{{.*}}{{\\|/}}libclang_rt.builtins.a"
3838

3939
! DARWIN-LABEL: "{{.*}}ld{{(\.exe)?}}"
4040
! DARWIN-SAME: "[[object_file]]"
4141
! DARWIN-F128NONE-NOT: FortranFloat128Math
4242
! DARWIN-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
4343
! DARWIN-SAME: -lFortranRuntime
44-
! DARWIN-SAME: -lFortranDecimal
4544

4645
! HAIKU-LABEL: "{{.*}}ld{{(\.exe)?}}"
4746
! HAIKU-SAME: "[[object_file]]"
4847
! HAIKU-F128NONE-NOT: FortranFloat128Math
4948
! HAIKU-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
50-
! HAIKU-SAME: "-lFortranRuntime" "-lFortranDecimal"
49+
! HAIKU-SAME: "-lFortranRuntime"
5150

5251
! MINGW-LABEL: "{{.*}}ld{{(\.exe)?}}"
5352
! MINGW-SAME: "[[object_file]]"
5453
! MINGW-F128NONE-NOT: FortranFloat128Math
5554
! MINGW-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
5655
! MINGW-SAME: -lFortranRuntime
57-
! MINGW-SAME: -lFortranDecimal
5856

5957
! NOTE: This also matches lld-link (when CLANG_DEFAULT_LINKER=lld) and
6058
! any .exe suffix that is added when resolving to the full path of

flang/test/Driver/msvc-dependent-lib-flags.f90

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,20 @@
88
! MSVC-SAME: -D_MT
99
! MSVC-SAME: --dependent-lib=libcmt
1010
! MSVC-SAME: --dependent-lib=FortranRuntime.static.lib
11-
! MSVC-SAME: --dependent-lib=FortranDecimal.static.lib
1211

1312
! MSVC-DEBUG: -fc1
1413
! MSVC-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
1514
! MSVC-DEBUG-SAME: -D_MT
1615
! MSVC-DEBUG-SAME: -D_DEBUG
1716
! MSVC-DEBUG-SAME: --dependent-lib=libcmtd
1817
! MSVC-DEBUG-SAME: --dependent-lib=FortranRuntime.static_dbg.lib
19-
! MSVC-DEBUG-SAME: --dependent-lib=FortranDecimal.static_dbg.lib
2018

2119
! MSVC-DLL: -fc1
2220
! MSVC-DLL-SAME: --dependent-lib=clang_rt.builtins.lib
2321
! MSVC-DLL-SAME: -D_MT
2422
! MSVC-DLL-SAME: -D_DLL
2523
! MSVC-DLL-SAME: --dependent-lib=msvcrt
2624
! MSVC-DLL-SAME: --dependent-lib=FortranRuntime.dynamic.lib
27-
! MSVC-DLL-SAME: --dependent-lib=FortranDecimal.dynamic.lib
2825

2926
! MSVC-DLL-DEBUG: -fc1
3027
! MSVC-DLL-DEBUG-SAME: --dependent-lib=clang_rt.builtins.lib
@@ -33,4 +30,3 @@
3330
! MSVC-DLL-DEBUG-SAME: -D_DLL
3431
! MSVC-DLL-DEBUG-SAME: --dependent-lib=msvcrtd
3532
! MSVC-DLL-DEBUG-SAME: --dependent-lib=FortranRuntime.dynamic_dbg.lib
36-
! MSVC-DLL-DEBUG-SAME: --dependent-lib=FortranDecimal.dynamic_dbg.lib

flang/test/Driver/nostdlib.f90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,4 @@
2525
! platform individually.
2626

2727
! CHECK-NOT: "-lFortranRuntime"
28-
! CHECK-NOT: "-lFortranDecimal"
2928
! CHECK-NOT: "-lgcc"

flang/test/Runtime/no-cpp-dep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ a C compiler.
66
REQUIRES: c-compiler
77
88
RUN: %if system-aix %{ export OBJECT_MODE=64 %}
9-
RUN: %cc -std=c99 %s -I%include %libruntime %libdecimal -lm \
9+
RUN: %cc -std=c99 %s -I%include %libruntime -lm \
1010
RUN: %if system-aix %{-lpthread %}
1111
RUN: rm a.out
1212
*/

flang/test/lit.cfg.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,10 @@
168168
# we don't have one, we can just disable the test.
169169
if config.cc:
170170
libruntime = os.path.join(config.flang_lib_dir, "libFortranRuntime.a")
171-
libdecimal = os.path.join(config.flang_lib_dir, "libFortranDecimal.a")
172171
include = os.path.join(config.flang_src_dir, "include")
173172

174173
if (
175174
os.path.isfile(libruntime)
176-
and os.path.isfile(libdecimal)
177175
and os.path.isdir(include)
178176
):
179177
config.available_features.add("c-compiler")
@@ -183,7 +181,6 @@
183181
)
184182
)
185183
tools.append(ToolSubst("%libruntime", command=libruntime, unresolved="fatal"))
186-
tools.append(ToolSubst("%libdecimal", command=libdecimal, unresolved="fatal"))
187184
tools.append(ToolSubst("%include", command=include, unresolved="fatal"))
188185

189186
# Add all the tools and their substitutions (if applicable). Use the search paths provided for

lld/COFF/MinGW.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ AutoExporter::AutoExporter(
5151
"libc++",
5252
"libc++abi",
5353
"libFortranRuntime",
54-
"libFortranDecimal",
5554
"libunwind",
5655
"libmsvcrt",
5756
"libucrtbase",

0 commit comments

Comments
 (0)