Skip to content

Commit 202d9a7

Browse files
authored
Amd/dev/rlieberm/reland flang rt (llvm#1159)
2 parents ed5d9c3 + 40d6784 commit 202d9a7

File tree

8 files changed

+30
-13
lines changed

8 files changed

+30
-13
lines changed

flang-rt/CMakeLists.txt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -294,14 +294,14 @@ elseif (FLANG_RT_GCC_RESOURCE_DIR)
294294
endif ()
295295

296296
# Check if 128-bit float computations can be done via long double.
297-
check_cxx_source_compiles(
298-
"#include <cfloat>
299-
#if LDBL_MANT_DIG != 113
300-
#error LDBL_MANT_DIG != 113
301-
#endif
302-
int main() { return 0; }
303-
"
304-
HAVE_LDBL_MANT_DIG_113)
297+
#check_cxx_source_compiles(
298+
# "#include <cfloat>
299+
# #if LDBL_MANT_DIG != 113
300+
# #error LDBL_MANT_DIG != 113
301+
# #endif
302+
# int main() { return 0; }
303+
# "
304+
# HAVE_LDBL_MANT_DIG_113)
305305

306306

307307
#####################
@@ -325,7 +325,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED YES)
325325

326326

327327
configure_file(cmake/config.h.cmake.in config.h)
328-
328+
if (FLANG_RT_INCLUDE_QUADMATH_H)
329+
configure_file("cmake/quadmath_wrapper.h.in" "${FLANG_RT_BINARY_DIR}/quadmath_wrapper.h")
330+
endif ()
329331

330332
# The bootstrap build will create a phony target with the same as the top-level
331333
# directory ("flang-rt") and delegate it to the runtimes build dir.

flang-rt/cmake/clang_gcc_root.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int main() { return 0; }

flang-rt/cmake/quadmath_wrapper.h.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*===-- cmake/quadmath_wrapper.h.in ---------------------=-----------*- 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+
9+
#include ${FLANG_RT_INCLUDE_QUADMATH_H}

flang-rt/lib/quadmath/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ target_include_directories(FortranFloat128MathILib INTERFACE
7878

7979
if (FLANG_RUNTIME_F128_MATH_LIB)
8080
if (${FLANG_RUNTIME_F128_MATH_LIB} STREQUAL "libquadmath")
81-
check_include_file(quadmath.h FOUND_QUADMATH_HEADER)
82-
if(FOUND_QUADMATH_HEADER)
81+
if(FLANG_RT_INCLUDE_QUADMATH_H)
8382
add_compile_definitions(HAS_QUADMATHLIB)
8483
else()
8584
message(FATAL_ERROR

flang-rt/lib/quadmath/complex-math.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "flang/Runtime/entry-names.h"
1414

1515
#if HAS_QUADMATHLIB
16-
#include "quadmath.h"
16+
#include "quadmath_wrapper.h"
1717
#define CAbs(x) cabsq(x)
1818
#define CAcos(x) cacosq(x)
1919
#define CAcosh(x) cacoshq(x)

flang-rt/lib/quadmath/math-entries.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ DEFINE_FALLBACK_F128(Yn)
112112

113113
#if HAS_QUADMATHLIB
114114
// Define wrapper callers for libquadmath.
115-
#include "quadmath.h"
115+
#include "quadmath_wrapper.h"
116116
DEFINE_SIMPLE_ALIAS(Abs, fabsq)
117117
DEFINE_SIMPLE_ALIAS(Acos, acosq)
118118
DEFINE_SIMPLE_ALIAS(Acosh, acoshq)

flang/EnableFlangRT

Whitespace-only changes.

flang/runtime/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "XL")
132132
set(NO_RTTI_FLAGS "-qnoeh -qnortti")
133133
endif ()
134134

135+
# When compiling LLVM_ENABLE_RUNTIMES=flang-rt, the build system looks for the
136+
# full path of quadmath.h. In this non-runtimes build, preserve the old behavior
137+
# of just including <quadmath.h>.
138+
set(FLANG_RT_INCLUDE_QUADMATH_H "<quadmath.h>")
139+
configure_file("${FLANG_RT_SOURCE_DIR}/cmake/quadmath_wrapper.h.in" "quadmath_wrapper.h")
140+
135141
configure_file("${FLANG_RT_SOURCE_DIR}/cmake/config.h.cmake.in" config.h)
136142
# include_directories is used here instead of target_include_directories
137143
# because add_flang_library creates multiple objects (STATIC/SHARED, OBJECT)

0 commit comments

Comments
 (0)