From c60f68087b4143b682eeb423d02ffd3c85240259 Mon Sep 17 00:00:00 2001 From: Fernando Date: Sat, 21 Oct 2017 06:26:17 -0700 Subject: [PATCH] Windows Fixes --- CMakeLists.txt | 32 ++++++++++------ include/legacy-util-api.h | 2 + lib/scutil/cpu-stopwatch.c | 4 +- lib/scutil/host-fp-folding.c | 2 +- lib/scutil/lockfile.c | 6 ++- lib/scutil/path-utils.c | 2 + lib/scutil/pgnewfil.c | 11 ++++-- runtime/flang/CMakeLists.txt | 15 ++++++-- runtime/flangrti/CMakeLists.txt | 17 +++++--- runtime/flangrti/cacos.c | 4 ++ runtime/flangrti/casin.c | 4 ++ runtime/flangrti/catan.c | 4 ++ runtime/flangrti/ccosh.c | 4 ++ runtime/flangrti/cdacos.c | 4 ++ runtime/flangrti/cdasin.c | 4 ++ runtime/flangrti/cdatan.c | 4 ++ runtime/flangrti/cdcosh.c | 4 ++ runtime/flangrti/cdsinh.c | 4 ++ runtime/flangrti/cdtan.c | 4 ++ runtime/flangrti/cdtanh.c | 4 ++ runtime/flangrti/csinh.c | 4 ++ runtime/flangrti/ctan.c | 4 ++ runtime/flangrti/ctanh.c | 4 ++ runtime/flangrti/iostdinit.c | 16 +++++--- runtime/flangrti/trace_lin.c | 9 ++++- runtime/flangrti/x86_64-Linux/dumpregs.c | 4 +- runtime/include/mthdecls.h | 49 +++++++----------------- runtime/include/stdioInterf.h | 2 + runtime/ompstub/CMakeLists.txt | 4 ++ tools/flang1/flang1exe/CMakeLists.txt | 6 ++- tools/flang2/flang2exe/CMakeLists.txt | 8 +++- 31 files changed, 168 insertions(+), 77 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d22b2ef62d..0e298e403e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,16 +21,17 @@ cmake_minimum_required(VERSION 2.8) # In order to bootstrap the runtime library we need to skip # CMake's Fortran tests SET(CMAKE_Fortran_COMPILER_WORKS 1) +set(CMAKE_Fortran_PREPROCESS_SOURCE + " -Mpreprocess -E -o ") -if( NOT DEFINED TARGET_ARCHITECTURE ) - execute_process(COMMAND uname -m OUTPUT_STRIP_TRAILING_WHITESPACE - OUTPUT_VARIABLE TARGET_ARCHITECTURE) +# If we are not building as a part of LLVM, build Flang as an +# standalone project, using LLVM as an external library: +if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) + project(Flang) endif() -if( NOT DEFINED TARGET_OS ) - execute_process(COMMAND uname -s OUTPUT_STRIP_TRAILING_WHITESPACE - OUTPUT_VARIABLE TARGET_OS) -endif() +set(TARGET_OS ${CMAKE_HOST_SYSTEM_NAME}) +set(TARGET_ARCHITECTURE ${CMAKE_HOST_SYSTEM_PROCESSOR}) if( ${TARGET_OS} STREQUAL "Linux" ) set(OS "LINUX") @@ -51,16 +52,23 @@ if( ${TARGET_OS} STREQUAL "Linux" ) message("Unsupported architecture: ${TARGET_ARCHITECTURE}" ) return() endif() +elseif(${TARGET_OS} STREQUAL "Windows" ) + set(OS "WINDOWS") + set(OSNAME "Windows") + if( ${TARGET_ARCHITECTURE} STREQUAL "AMD64" ) + set(TARGET_ARCHITECTURE "x86_64") + set(ARCHNAME x86-64) + set(ARCH X86) + set(WRDSZ 64) + else() + message("Unsupported architecture: ${TARGET_ARCHITECTURE}" ) + return() + endif() else() message("Unsupported OS: ${TARGET_OS}" ) return() endif() -# The cmake documentation states that these are set. They are not so we -# set them here -set(CMAKE_HOST_SYSTEM_NAME ${TARGET_OS}) -set(CMAKE_HOST_SYSTEM_PROCESSOR ${TARGET_ARCHITECTURE}) - # If we are not building as a part of LLVM, build Flang as an # standalone project, using LLVM as an external library: if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) diff --git a/include/legacy-util-api.h b/include/legacy-util-api.h index f4fa9a261a2..e30530c5739 100644 --- a/include/legacy-util-api.h +++ b/include/legacy-util-api.h @@ -41,7 +41,9 @@ extern "C" { #include #include #include /* time() */ +#ifndef _WIN32 #include /* getcwd() */ +#endif /* See tmpfile(3). */ FILE *tmpf(char *ignored); diff --git a/lib/scutil/cpu-stopwatch.c b/lib/scutil/cpu-stopwatch.c index b738ee6d7b9..95b6755e605 100644 --- a/lib/scutil/cpu-stopwatch.c +++ b/lib/scutil/cpu-stopwatch.c @@ -57,12 +57,12 @@ getcpu(void) #else #include -#include "scutil.h" +//#include "scutil.h" unsigned long getcpu(void) { - LARGE_INTEGER ticks_per_second = -1; + LARGE_INTEGER ticks_per_second = {-1}; LARGE_INTEGER ticks; unsigned long last = 0; diff --git a/lib/scutil/host-fp-folding.c b/lib/scutil/host-fp-folding.c index 50e48047bdf..cd03bb7b57a 100644 --- a/lib/scutil/host-fp-folding.c +++ b/lib/scutil/host-fp-folding.c @@ -81,7 +81,7 @@ configure_denormals(bool denorms_are_zeros, bool flush_to_zero) fenv_t fenv; if (fegetenv(&fenv) != 0) fprintf(stderr, "fegetenv() failed: %s\n", strerror(errno)); -#ifdef __x86_64__ +#if defined(__x86_64__) && !defined(_WIN32) fenv.__mxcsr &= ~0x0040; if (denorms_are_zeros) fenv.__mxcsr |= 0x0040; diff --git a/lib/scutil/lockfile.c b/lib/scutil/lockfile.c index fea20f16a6f..70dc41d52b4 100644 --- a/lib/scutil/lockfile.c +++ b/lib/scutil/lockfile.c @@ -43,10 +43,11 @@ * Clean up by deleting the uniquely named file we had created earlier. */ -#ifdef _WIN32 +#ifndef _WIN32 #include #else #include + #include #endif #include #include @@ -68,6 +69,9 @@ static char *udir = NULL; */ static long uwaiting; +#ifdef _WIN32 +#define pid_t int +#endif int __pg_make_lock_file(char *dir) { diff --git a/lib/scutil/path-utils.c b/lib/scutil/path-utils.c index ca4c8c72074..cadbdac696c 100644 --- a/lib/scutil/path-utils.c +++ b/lib/scutil/path-utils.c @@ -23,7 +23,9 @@ #include "legacy-util-api.h" #include #include +#ifndef _WIN32 #include /* access() */ +#endif void basenam(const char *orig_path, const char *optional_suffix, char *basename) diff --git a/lib/scutil/pgnewfil.c b/lib/scutil/pgnewfil.c index e198d33ef4e..590c678ed75 100644 --- a/lib/scutil/pgnewfil.c +++ b/lib/scutil/pgnewfil.c @@ -29,9 +29,10 @@ #include #include -#if defined(HOST_WIN) +#if defined(_WIN32) #include #include +#include extern unsigned long getpid(void); #else #include @@ -42,6 +43,10 @@ int pgnewfil_debug = 0; #endif extern size_t strlen(); +#ifndef S_ISDIR +#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) +#endif + /* * copy chars from q to p, terminate string, return end of string */ @@ -307,7 +312,7 @@ pg_makenewfile(char *pfx, char *sfx, int make) if (!make) { break; } else { -#if defined(HOST_WIN) +#if defined(_WIN32) fd = _open(filename, _O_CREAT | _O_BINARY | _O_EXCL | _O_RDWR, _S_IWRITE); #else fd = open(filename, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR); @@ -353,7 +358,7 @@ pg_makenewdir(char *pfx, char *sfx, int make) if (r == -1 && errno == ENOENT) { if (make) { int err; -#if defined(HOST_WIN) || defined(WINNT) || defined(WIN64) +#if defined(_WIN32) || defined(WINNT) || defined(WIN64) err = _mkdir(filename); #else err = mkdir(filename, S_IRWXG | S_IRWXO | S_IXUSR | S_IWUSR | S_IRUSR); diff --git a/runtime/flang/CMakeLists.txt b/runtime/flang/CMakeLists.txt index 2cd90370da0..dc29e565e68 100644 --- a/runtime/flang/CMakeLists.txt +++ b/runtime/flang/CMakeLists.txt @@ -480,7 +480,12 @@ add_flang_library(flang_static ${FTN_SUPPORT} ${SHARED_SOURCES} ) + +if (MSVC) +set_property(TARGET flang_static PROPERTY OUTPUT_NAME flang_static) +else() set_property(TARGET flang_static PROPERTY OUTPUT_NAME flang) +endif() set(SHARED_LIBRARY TRUE) add_flang_library(flang_shared @@ -489,9 +494,12 @@ add_flang_library(flang_shared ${SHARED_SOURCES} ) set_property(TARGET flang_shared PROPERTY OUTPUT_NAME flang) -target_link_libraries(flang_shared ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/libflangrti.so) +target_link_libraries(flang_shared flangrti_shared) # Resolve symbols against libm and librt -target_link_libraries(flang_shared m rt) +target_link_libraries(flang_shared rt) +if (NOT MSVC) +target_link_libraries(flang_shared m) +endif() set(SHARED_LIBRARY FALSE) @@ -523,6 +531,7 @@ set_property( ## CMake does not handle module dependencies between Fortran files, ## we need to help it +if (NOT MSVC) # State the module that the source is producing set_source_files_properties( iso_c_bind.F95 @@ -537,7 +546,7 @@ set_source_files_properties( PROPERTIES OBJECT_DEPENDS ${CMAKE_Fortran_MODULE_DIRECTORY}/iso_c_binding.mod ) - +endif() set_target_properties(flang_static flang_shared PROPERTIES diff --git a/runtime/flangrti/CMakeLists.txt b/runtime/flangrti/CMakeLists.txt index 8688642cf44..0bc427e749b 100644 --- a/runtime/flangrti/CMakeLists.txt +++ b/runtime/flangrti/CMakeLists.txt @@ -179,7 +179,11 @@ add_flang_library(flangrti_static ${PGC_SRC_FILES} ${SHARED_SOURCES} ) -set_property(TARGET flangrti_static PROPERTY OUTPUT_NAME flangrti) +if (MSVC) + set_property(TARGET flangrti_static PROPERTY OUTPUT_NAME flangrti_static) +else() + set_property(TARGET flangrti_static PROPERTY OUTPUT_NAME flangrti) +endif() set(SHARED_LIBRARY TRUE) @@ -189,16 +193,19 @@ add_flang_library(flangrti_shared ) # Resolve symbols against libm -target_link_libraries(flangrti_shared m) + +if (NOT MSVC) +target_link_libraries(flangrti_shared m) +endif() # Import OpenMP -if (NOT DEFINED LIBOMP_EXPORT_DIR) +#if (NOT DEFINED LIBOMP_EXPORT_DIR) find_library( FLANG_LIBOMP - libomp.so + libomp HINTS ${CMAKE_BINARY_DIR}/lib) target_link_libraries(flangrti_shared ${FLANG_LIBOMP}) -endif() +#endif() if( ${TARGET_ARCHITECTURE} STREQUAL "aarch64" ) target_compile_definitions(flangrti_static PRIVATE TARGET_LINUX_ARM) diff --git a/runtime/flangrti/cacos.c b/runtime/flangrti/cacos.c index ce0bb89090d..48a11054d20 100644 --- a/runtime/flangrti/cacos.c +++ b/runtime/flangrti/cacos.c @@ -23,7 +23,11 @@ CMPLXFUNC_C(__mth_i_cacos) { CMPLXARGS_C; + #ifndef _WIN32 complex float f = real + imag * I; + #else + _Fcomplex f = {real, imag}; + #endif f = CACOSF(f); CRETURN_C(f); } diff --git a/runtime/flangrti/casin.c b/runtime/flangrti/casin.c index 35fe17f5c6a..b99a6e38248 100644 --- a/runtime/flangrti/casin.c +++ b/runtime/flangrti/casin.c @@ -23,7 +23,11 @@ CMPLXFUNC_C(__mth_i_casin) { CMPLXARGS_C; + #ifndef _WIN32 complex float f = real + imag * I; + #else + _Fcomplex f = {real, imag}; + #endif f = CASINF(f); CRETURN_C(f); } diff --git a/runtime/flangrti/catan.c b/runtime/flangrti/catan.c index 981447f5b45..17d2ec0ed0e 100644 --- a/runtime/flangrti/catan.c +++ b/runtime/flangrti/catan.c @@ -23,7 +23,11 @@ CMPLXFUNC_C(__mth_i_catan) { CMPLXARGS_C; + #ifndef _WIN32 complex float f = real + imag * I; + #else + _Fcomplex f = {real, imag}; + #endif f = CATANF(f); CRETURN_C(f); } diff --git a/runtime/flangrti/ccosh.c b/runtime/flangrti/ccosh.c index 3f7b93c1d87..efb5f6e67a1 100644 --- a/runtime/flangrti/ccosh.c +++ b/runtime/flangrti/ccosh.c @@ -23,7 +23,11 @@ CMPLXFUNC_C(__mth_i_ccosh) { CMPLXARGS_C; + #ifndef _WIN32 complex float f = real + imag * I; + #else + _Fcomplex f = {real, imag}; + #endif f = CCOSHF(f); CRETURN_C(f); } diff --git a/runtime/flangrti/cdacos.c b/runtime/flangrti/cdacos.c index 797b392ea78..4347b9a16f5 100644 --- a/runtime/flangrti/cdacos.c +++ b/runtime/flangrti/cdacos.c @@ -23,7 +23,11 @@ ZMPLXFUNC_Z(__mth_i_cdacos) { ZMPLXARGS_Z; + #ifndef _WIN32 complex double d = real + imag * I; + #else + _Dcomplex d = {real, imag}; + #endif d = cacos(d); ZRETURN_Z(d); } diff --git a/runtime/flangrti/cdasin.c b/runtime/flangrti/cdasin.c index 0b1ecfb1173..21dfea1f8b8 100644 --- a/runtime/flangrti/cdasin.c +++ b/runtime/flangrti/cdasin.c @@ -23,7 +23,11 @@ ZMPLXFUNC_Z(__mth_i_cdasin) { ZMPLXARGS_Z; + #ifndef _WIN32 complex double d = real + imag * I; + #else + _Dcomplex d = {real, imag}; + #endif d = casin(d); ZRETURN_Z(d); } diff --git a/runtime/flangrti/cdatan.c b/runtime/flangrti/cdatan.c index 624c2cd4c2f..258accf0a34 100644 --- a/runtime/flangrti/cdatan.c +++ b/runtime/flangrti/cdatan.c @@ -23,7 +23,11 @@ ZMPLXFUNC_Z(__mth_i_cdatan) { ZMPLXARGS_Z; + #ifndef _WIN32 complex double d = real + imag * I; + #else + _Dcomplex d = {real, imag}; + #endif d = catan(d); ZRETURN_Z(d); } diff --git a/runtime/flangrti/cdcosh.c b/runtime/flangrti/cdcosh.c index 76c13f5b7ec..1c571c95fee 100644 --- a/runtime/flangrti/cdcosh.c +++ b/runtime/flangrti/cdcosh.c @@ -23,7 +23,11 @@ ZMPLXFUNC_Z(__mth_i_cdcosh) { ZMPLXARGS_Z; + #ifndef _WIN32 complex double d = real + imag * I; + #else + _Dcomplex d = {real, imag}; + #endif d = ccosh(d); ZRETURN_Z(d); } diff --git a/runtime/flangrti/cdsinh.c b/runtime/flangrti/cdsinh.c index 8ed38e12d8e..e3b855aadcd 100644 --- a/runtime/flangrti/cdsinh.c +++ b/runtime/flangrti/cdsinh.c @@ -23,7 +23,11 @@ ZMPLXFUNC_Z(__mth_i_cdsinh) { ZMPLXARGS_Z; + #ifndef _WIN32 complex double d = real + imag * I; + #else + _Dcomplex d = {real, imag}; + #endif d = csinh(d); ZRETURN_Z(d); } diff --git a/runtime/flangrti/cdtan.c b/runtime/flangrti/cdtan.c index 949ac867594..7fd15fe306c 100644 --- a/runtime/flangrti/cdtan.c +++ b/runtime/flangrti/cdtan.c @@ -23,7 +23,11 @@ ZMPLXFUNC_Z(__mth_i_cdtan) { ZMPLXARGS_Z; + #ifndef _WIN32 complex double d = real + imag * I; + #else + _Dcomplex d = {real, imag}; + #endif d = ctan(d); ZRETURN_Z(d); } diff --git a/runtime/flangrti/cdtanh.c b/runtime/flangrti/cdtanh.c index da655c2d03f..3a30f9d8d6a 100644 --- a/runtime/flangrti/cdtanh.c +++ b/runtime/flangrti/cdtanh.c @@ -23,7 +23,11 @@ ZMPLXFUNC_Z(__mth_i_cdtanh) { ZMPLXARGS_Z; + #ifndef _WIN32 complex double d = real + imag * I; + #else + _Dcomplex d = {real, imag}; + #endif d = ctanh(d); ZRETURN_Z(d); } diff --git a/runtime/flangrti/csinh.c b/runtime/flangrti/csinh.c index e0a8ad003fe..cf49a42716c 100644 --- a/runtime/flangrti/csinh.c +++ b/runtime/flangrti/csinh.c @@ -23,7 +23,11 @@ CMPLXFUNC_C(__mth_i_csinh) { CMPLXARGS_C; + #ifndef _WIN32 complex float f = real + imag * I; + #else + _Fcomplex f = {real, imag}; + #endif f = CSINHF(f); CRETURN_C(f); } diff --git a/runtime/flangrti/ctan.c b/runtime/flangrti/ctan.c index f23277944f9..acea489a8f0 100644 --- a/runtime/flangrti/ctan.c +++ b/runtime/flangrti/ctan.c @@ -23,7 +23,11 @@ CMPLXFUNC_C(__mth_i_ctan) { CMPLXARGS_C; + #ifndef _WIN32 complex float f = real + imag * I; + #else + _Fcomplex f = {real, imag}; + #endif f = CTANF(f); CRETURN_C(f); } diff --git a/runtime/flangrti/ctanh.c b/runtime/flangrti/ctanh.c index b2618fbef76..0aee5f808ce 100644 --- a/runtime/flangrti/ctanh.c +++ b/runtime/flangrti/ctanh.c @@ -23,7 +23,11 @@ CMPLXFUNC_C(__mth_i_ctanh) { CMPLXARGS_C; + #ifndef _WIN32 complex float f = real + imag * I; + #else + _Fcomplex f = {real, imag}; + #endif f = CTANHF(f); CRETURN_C(f); } diff --git a/runtime/flangrti/iostdinit.c b/runtime/flangrti/iostdinit.c index c2e5ad1b932..8f2937da770 100644 --- a/runtime/flangrti/iostdinit.c +++ b/runtime/flangrti/iostdinit.c @@ -16,7 +16,7 @@ */ #include -#if !defined(WINNT) && !defined(ST100) +#if !defined(_WIN32) && !defined(ST100) #include #include #endif @@ -160,7 +160,11 @@ __io_ferror(void *p) int __io_getfd(void *fp) { +#ifndef _WIN32 return (((FILE *)fp)->_fileno); +#else + return (_fileno((FILE *)fp)); +#endif } /* is a tty? */ @@ -176,10 +180,10 @@ __io_isatty(int fd) int __io_binary_mode(void *fp) { -#if defined(WINNT) +#if defined(_WIN32_WINNT) #include -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN64) || defined(_WIN32) #define O_BINARY _O_BINARY #endif @@ -203,10 +207,10 @@ __io_binary_mode(void *fp) int __io_setmode_binary(void *fp) { -#if defined(WINNT) +#if defined(_WIN32_WINNT) #include -#if defined(WIN64) || defined(WIN32) +#if defined(_WIN64) || defined(_WIN32) #define O_BINARY _O_BINARY #endif @@ -221,7 +225,7 @@ __io_setmode_binary(void *fp) int __io_ispipe(void *f) { -#if !defined(WINNT) && !defined(ST100) +#if !defined(_WIN32) && !defined(ST100) struct stat st; fstat(fileno((FILE *)f), &st); diff --git a/runtime/flangrti/trace_lin.c b/runtime/flangrti/trace_lin.c index 6974e77fbd3..baaf4e189d0 100644 --- a/runtime/flangrti/trace_lin.c +++ b/runtime/flangrti/trace_lin.c @@ -15,11 +15,16 @@ * */ +#ifndef _WIN32 #include +#ifndef _WIN32 #include #include -#include #include "dumpregs.h" +#else +#include +#endif +#include /* codes and strings for signals */ @@ -191,5 +196,5 @@ __abort_sig_init(void) n++; } } - +#endif diff --git a/runtime/flangrti/x86_64-Linux/dumpregs.c b/runtime/flangrti/x86_64-Linux/dumpregs.c index 1b5e147b329..c4f31ced95f 100644 --- a/runtime/flangrti/x86_64-Linux/dumpregs.c +++ b/runtime/flangrti/x86_64-Linux/dumpregs.c @@ -15,7 +15,7 @@ * */ -#if !defined(TARGET_WIN) +#if !defined(_WIN32) #include #endif #include "stdioInterf.h" @@ -40,7 +40,7 @@ #define RSP 15 #define RIP 16 -#if defined(TARGET_OSX) || defined(TARGET_WIN) +#if defined(TARGET_OSX) || defined(_WIN32) /* no gregs and/or ucontext defined in for OSX or Windows */ void * getRegs(void *u) diff --git a/runtime/include/mthdecls.h b/runtime/include/mthdecls.h index 34e18fc32a0..4b5a901d246 100644 --- a/runtime/include/mthdecls.h +++ b/runtime/include/mthdecls.h @@ -263,7 +263,7 @@ float __builtin_cimagf(float complex); single precision versions of the math.h functions, in which case the single precision versions should be used: */ -#if defined(WIN64) +#if defined(_WIN64) #define ACOSF acos #define ASINF asin @@ -308,13 +308,13 @@ float __builtin_cimagf(float complex); #define BESSEL_Y0 _y0 #define BESSEL_Y1 _y1 #define BESSEL_YN _yn -#define CACOSF cacos -#define CASINF casin -#define CATANF catan -#define CCOSHF ccosh -#define CSINHF csinh -#define CTANHF ctanh -#define CTANF ctan +#define CACOSF cacosf +#define CASINF casinf +#define CATANF catanf +#define CCOSHF ccoshf +#define CSINHF csinhf +#define CTANHF ctanhf +#define CTANF ctanf /* define POWF specially here for win64 until we can leverage * our usual builtin mechanism on that target @@ -326,7 +326,7 @@ float __builtin_cimagf(float complex); #define hypot _hypot #endif -#else /* #if defined (WIN64) */ +#else /* #if defined (_WIN64) */ #define ACOSF acosf #define ASINF asinf #define ATANF atanf @@ -364,7 +364,6 @@ float __builtin_cimagf(float complex); #define COPYSIGNF copysignf #define COPYSIGN copysign -#if !defined(TARGET_WIN) #define CACOSF cacosf #define CASINF casinf #define CATANF catanf @@ -372,17 +371,8 @@ float __builtin_cimagf(float complex); #define CSINHF csinhf #define CTANHF ctanhf #define CTANF ctanf -#else -#define CACOSF cacos -#define CASINF casin -#define CATANF catan -#define CCOSHF ccosh -#define CSINHF csinh -#define CTANHF ctanh -#define CTANF ctan -#endif -#if defined(TARGET_WIN) +#if defined(_WIN32) #define BESSEL_J0F _j0 #define BESSEL_J1F _j1 #define BESSEL_JNF _jn @@ -549,6 +539,7 @@ void __mth_sincos(float, float *, float *); void __mth_dsincos(double, double *, double *); #endif /* ! defined (TARGET_X8664) && ! defined(LINUX8664) */ +#ifndef _WIN32 FLTDECL_C(__mth_i_cabs); CMPLXDECL_C(__mth_i_cacos); CMPLXDECL_C(__mth_i_casin); @@ -586,10 +577,10 @@ ZMPLXDECL_Z(__mth_i_cdsinh); ZMPLXDECL_Z(__mth_i_cdsqrt); ZMPLXDECL_Z(__mth_i_cdtan); ZMPLXDECL_Z(__mth_i_cdtanh); +#endif - -#if defined(TARGET_WIN) +#if defined(_WIN32) /* the following are part of Open Tools 12, we build with Open Tools 10 */ extern double erf(double x); extern float erff(float x); @@ -611,20 +602,6 @@ extern double _jn(int n, double arg); extern double _y0(double arg); extern double _y1(double arg); extern double _yn(int n, double arg); -extern complex float cacosf(complex float); -extern complex double cacos(complex double); -extern complex float casinf(complex float); -extern complex double casin(complex double); -extern complex float catanf(complex float); -extern complex double catan(complex double); -extern complex float ccoshf(complex float); -extern complex double ccosh(complex double); -extern complex float csinhf(complex float); -extern complex double csinh(complex double); -extern complex float ctanhf(complex float); -extern complex double ctanh(complex double); -extern complex float ctanf(complex float); -extern complex double ctan(complex double); #endif /* diff --git a/runtime/include/stdioInterf.h b/runtime/include/stdioInterf.h index cb954b26891..4391ec8668f 100644 --- a/runtime/include/stdioInterf.h +++ b/runtime/include/stdioInterf.h @@ -19,7 +19,9 @@ #include /* TODO: try moving to pgstdio.h */ #include +#ifndef _WIN32 #include +#endif #include /* defines to use real host stdio routines */ diff --git a/runtime/ompstub/CMakeLists.txt b/runtime/ompstub/CMakeLists.txt index a1eebed7811..43f064a31cd 100644 --- a/runtime/ompstub/CMakeLists.txt +++ b/runtime/ompstub/CMakeLists.txt @@ -17,7 +17,11 @@ set(OMPSTUB_SRC init_nomp.c ompstubs.c) add_flang_library(ompstub_static ${OMPSTUB_SRC}) +if (MSVC) +set_property(TARGET ompstub_static PROPERTY OUTPUT_NAME ompstub_static) +else() set_property(TARGET ompstub_static PROPERTY OUTPUT_NAME ompstub) +endif() set(SHARED_LIBRARY TRUE) add_flang_library(ompstub_shared ${OMPSTUB_SRC}) diff --git a/tools/flang1/flang1exe/CMakeLists.txt b/tools/flang1/flang1exe/CMakeLists.txt index fbd057b1a62..f5fcfcd46d6 100644 --- a/tools/flang1/flang1exe/CMakeLists.txt +++ b/tools/flang1/flang1exe/CMakeLists.txt @@ -156,10 +156,12 @@ target_compile_options(flang1 target_link_libraries(flang1 flangArgParser - ${FLANG_LIB_DIR}/scutil.a - -lm + scutil ) +if (NOT MSVC) +target_link_libraries(flang1 m) +endif() # Install flang1 executable install(TARGETS flang1 RUNTIME DESTINATION bin) diff --git a/tools/flang2/flang2exe/CMakeLists.txt b/tools/flang2/flang2exe/CMakeLists.txt index 6242badde6c..d9500a4ab15 100644 --- a/tools/flang2/flang2exe/CMakeLists.txt +++ b/tools/flang2/flang2exe/CMakeLists.txt @@ -125,11 +125,15 @@ target_compile_options(flang2 ${COMPILE_OPTS} ) + target_link_libraries(flang2 flangArgParser - ${FLANG_LIB_DIR}/scutil.a - -lm + scutil ) + +if (NOT MSVC) +target_link_libraries(flang2 m) +endif() add_dependencies(flang2 gen_backend_error_headers # Error message headers