$OpenBSD: patch-runtime_flang_CMakeLists_txt,v 1.6 2018/09/26 18:31:46 bcallah Exp $

Replace -lrt with -laio_compat
Appease lld
Work around standalone preprocessing of F95 files with C compiler

Index: runtime/flang/CMakeLists.txt
--- runtime/flang/CMakeLists.txt.orig
+++ runtime/flang/CMakeLists.txt
@@ -18,7 +18,7 @@ enable_language(C ASM Fortran) # Enable assembly and F
 
 SET(ASM_OPTIONS "-DLINUX_ELF")
 SET(CMAKE_ASM_FLAGS "${CFLAGS} ${ASM_OPTIONS}" )
-SET(CMAKE_SHARED_LINKER_FLAGS "-no-flang-libs")
+SET(CMAKE_SHARED_LINKER_FLAGS "-no-flang-libs -L/usr/lib")
 
 # We are using Fortran driver to build this library with fresh compiler
 # components, so point its binary directory to the build directory to pick up
@@ -419,7 +419,7 @@ set(I8_FILES_DIR I8_sources)
 # Fortran files with macros as module names need to be preprocessed. 
 add_custom_command(
   OUTPUT "${I8_FILES_DIR}/ieee_arithmetic.F95"
-  COMMAND "${CMAKE_C_COMPILER}" -E 
+  COMMAND "${CMAKE_C_COMPILER}" -E -x c 
   "${CMAKE_CURRENT_SOURCE_DIR}/ieee_arithmetic.F95" -DDESC_I8 
   > "${I8_FILES_DIR}/ieee_arithmetic.F95"
   COMMENT "Preprocessing ieee_arithmetic.F95"
@@ -428,7 +428,7 @@ add_custom_command(
 
 add_custom_command(
   OUTPUT "${I8_FILES_DIR}/ieee_exceptions.F95"
-  COMMAND "${CMAKE_C_COMPILER}" -E 
+  COMMAND "${CMAKE_C_COMPILER}" -E -x c 
   "${CMAKE_CURRENT_SOURCE_DIR}/ieee_exceptions.F95" -DDESC_I8 
   > "${I8_FILES_DIR}/ieee_exceptions.F95"
   COMMENT "Preprocessing ieee_exceptions.F95"
@@ -478,7 +478,7 @@ add_flang_library(flang_shared
 set_property(TARGET flang_shared PROPERTY OUTPUT_NAME flang)
 target_link_libraries(flang_shared ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/libflangrti.so)
 # Resolve symbols against libm and librt
-target_link_libraries(flang_shared m rt)
+target_link_libraries(flang_shared m aio_compat)
 
 set(SHARED_LIBRARY FALSE)
 
