[flang] Disable libc++ assertions in the runtime library
authorShao-Ce SUN <sunshaoce@iscas.ac.cn>
Mon, 13 Feb 2023 09:41:35 +0000 (17:41 +0800)
committerShao-Ce SUN <sunshaoce@iscas.ac.cn>
Tue, 14 Feb 2023 02:18:11 +0000 (10:18 +0800)
Similar to D143168. Solve compiling error caused by D143612.

Error info:
```
flang-new -flang-experimental-exec hello.f90
/usr/bin/ld: /usr/bin/ld: DWARF error: invalid or unhandled FORM value: 0x25
llvm-project/build/lib/libFortranRuntime.a(unit.cpp.o): in function `std::__1::optional<unsigned long>::operator*[abi:v170000]() &':
unit.cpp:(.text._ZNRSt3__18optionalImEdeB7v170000Ev[_ZNRSt3__18optionalImEdeB7v170000Ev]+0x4f): undefined reference to `std::__1::__libcpp_verbose_abort(char const*, ...)'
/usr/bin/ld: llvm-project/build/lib/libFortranRuntime.a(unit.cpp.o): in function `void std::__1::__optional_storage_base<long, false>::__construct[abi:v170000]<unsigned long>(unsigned long&&)':
unit.cpp:(.text._ZNSt3__123__optional_storage_baseIlLb0EE11__constructB7v170000IJmEEEvDpOT_[_ZNSt3__123__optional_storage_baseIlLb0EE11__constructB7v170000IJmEEEvDpOT_]+0x55): undefined reference to `std::__1::__libcpp_verbose_abort(char const*, ...)'
```

Reviewed By: vzakhari

Differential Revision: https://reviews.llvm.org/D143890

flang/runtime/CMakeLists.txt

index e0a8f2c44145fc0887fbb044574ac4f68903cdf9..1e289d35cdfa9fd598c517c6d21c4f6a9e3ff7bd 100644 (file)
@@ -86,9 +86,10 @@ include_directories(AFTER ${CMAKE_CURRENT_BINARY_DIR})
 append(${NO_LTO_FLAGS} CMAKE_C_FLAGS)
 append(${NO_LTO_FLAGS} CMAKE_CXX_FLAGS)
 
-# Disable libstdc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build, to
-# avoid an unwanted dependency on libstdc++.so.
+# Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build,
+# to avoid an unwanted dependency on libstdc++/libc++.so.
 add_definitions(-U_GLIBCXX_ASSERTIONS)
+add_definitions(-U_LIBCPP_ENABLE_ASSERTIONS)
 
 add_subdirectory(FortranMain)