[flang] Fix Darwin build after 4762c6557d (#84478)
Select POSIX 2008 standard to avoid including Darwin extensions.
Otherwise, Darwin's math.h header defines HUGE, which conflicts
with Flang's HUGE function.
This started happening after 4762c6557d (#82443), that added the
"utility" include, which seems to include "math.h".
This commit is contained in:
@@ -413,6 +413,14 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
|
||||
|
||||
endif()
|
||||
|
||||
# Clang on Darwin enables non-POSIX extensions by default, which allows the
|
||||
# macro HUGE to leak out of <math.h> even when it is never directly included,
|
||||
# conflicting with Flang's HUGE symbols.
|
||||
# Set _POSIX_C_SOURCE to avoid including these extensions.
|
||||
if (APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_POSIX_C_SOURCE=200809")
|
||||
endif()
|
||||
|
||||
list(REMOVE_DUPLICATES CMAKE_CXX_FLAGS)
|
||||
|
||||
# Determine HOST_LINK_VERSION on Darwin.
|
||||
|
||||
@@ -27,10 +27,6 @@
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
// Some environments, viz. clang on Darwin, allow the macro HUGE
|
||||
// to leak out of <math.h> even when it is never directly included.
|
||||
#undef HUGE
|
||||
|
||||
namespace Fortran::evaluate::value {
|
||||
|
||||
// Implements an integer as an assembly of smaller host integer parts
|
||||
|
||||
@@ -18,10 +18,6 @@
|
||||
#include <limits>
|
||||
#include <string>
|
||||
|
||||
// Some environments, viz. clang on Darwin, allow the macro HUGE
|
||||
// to leak out of <math.h> even when it is never directly included.
|
||||
#undef HUGE
|
||||
|
||||
namespace llvm {
|
||||
class raw_ostream;
|
||||
}
|
||||
|
||||
@@ -39,10 +39,6 @@
|
||||
#include <type_traits>
|
||||
#include <variant>
|
||||
|
||||
// Some environments, viz. clang on Darwin, allow the macro HUGE
|
||||
// to leak out of <math.h> even when it is never directly included.
|
||||
#undef HUGE
|
||||
|
||||
namespace Fortran::evaluate {
|
||||
|
||||
// Utilities
|
||||
|
||||
@@ -299,8 +299,8 @@ struct HostRuntimeLibrary<std::complex<HostT>, LibraryVersion::Libm> {
|
||||
/// Define libm extensions
|
||||
/// Bessel functions are defined in POSIX.1-2001.
|
||||
|
||||
// Remove float bessel functions for AIX as they are not supported
|
||||
#ifndef _AIX
|
||||
// Remove float bessel functions for AIX and Darwin as they are not supported
|
||||
#if !defined(_AIX) && !defined(__APPLE__)
|
||||
template <> struct HostRuntimeLibrary<float, LibraryVersion::LibmExtensions> {
|
||||
using F = FuncPointer<float, float>;
|
||||
using FN = FuncPointer<float, int, float>;
|
||||
|
||||
Reference in New Issue
Block a user