diff --git a/GraphBLAS/Config/GB_config.h b/GraphBLAS/Config/GB_config.h index 17787706e..b15c1fbfd 100644 --- a/GraphBLAS/Config/GB_config.h +++ b/GraphBLAS/Config/GB_config.h @@ -15,7 +15,7 @@ // GB_C_COMPILER: the C compiler used to compile GraphBLAS: #ifndef GB_C_COMPILER -#define GB_C_COMPILER "/usr/bin/cc" +#define GB_C_COMPILER "/mingw64/bin/cc.exe" #endif // GB_C_FLAGS: the C compiler flags used to compile GraphBLAS. Used @@ -36,10 +36,10 @@ // GB_LIB_SUFFIX: library suffix (.so for Linux/Unix, .dylib for Mac, etc): #ifndef GB_LIB_SUFFIX -#define GB_LIB_SUFFIX ".so" +#define GB_LIB_SUFFIX ".dll" #endif -// GB_OBJ_SUFFIX: object suffix (.o for Linux/Unix/Mac, .obj for Windows): +// GB_OBJ_SUFFIX: object suffix (.o for Linux/Unix/Mac/MinGW, .obj for MSVC): #ifndef GB_OBJ_SUFFIX #define GB_OBJ_SUFFIX ".o" #endif @@ -57,12 +57,12 @@ // GB_C_LIBRARIES: libraries to link with when using direct compile/link: #ifndef GB_C_LIBRARIES -#define GB_C_LIBRARIES " -lm -ldl /usr/lib/gcc/x86_64-linux-gnu/9/libgomp.so /usr/lib/x86_64-linux-gnu/libpthread.so" +#define GB_C_LIBRARIES " -lgomp -lmingwthrd -lmingwthrd" #endif // GB_CMAKE_LIBRARIES: libraries to link with when using cmake #ifndef GB_CMAKE_LIBRARIES -#define GB_CMAKE_LIBRARIES "m;dl;/usr/lib/gcc/x86_64-linux-gnu/9/libgomp.so;/usr/lib/x86_64-linux-gnu/libpthread.so" +#define GB_CMAKE_LIBRARIES "C:/msys64/mingw64/lib/libgomp.dll.a;C:/msys64/mingw64/lib/libmingwthrd.a;C:/msys64/mingw64/lib/libmingwthrd.a" #endif #endif diff --git a/GraphBLAS/Config/GB_config.h.in b/GraphBLAS/Config/GB_config.h.in index 0968021b3..c72a289d2 100644 --- a/GraphBLAS/Config/GB_config.h.in +++ b/GraphBLAS/Config/GB_config.h.in @@ -39,7 +39,7 @@ #define GB_LIB_SUFFIX "@GB_LIB_SUFFIX@" #endif -// GB_OBJ_SUFFIX: object suffix (.o for Linux/Unix/Mac, .obj for Windows): +// GB_OBJ_SUFFIX: object suffix (.o for Linux/Unix/Mac/MinGW, .obj for MSVC): #ifndef GB_OBJ_SUFFIX #define GB_OBJ_SUFFIX "@GB_OBJ_SUFFIX@" #endif diff --git a/GraphBLAS/Source/GB_jitifyer.c b/GraphBLAS/Source/GB_jitifyer.c index ff292484b..277b82ddc 100644 --- a/GraphBLAS/Source/GB_jitifyer.c +++ b/GraphBLAS/Source/GB_jitifyer.c @@ -37,8 +37,8 @@ static int64_t GB_jit_table_populated = 0 ; static size_t GB_jit_table_allocated = 0 ; static bool GB_jit_use_cmake = - #if GB_WINDOWS - true ; // Windows requires cmake + #if defined (_MSC_VER) + true ; // MSVC requires cmake #else false ; // otherwise, default is to skip cmake and compile directly #endif @@ -2320,8 +2320,9 @@ void GB_jitifyer_direct_compile (char *kernel_name, uint32_t bucket) snprintf (GB_jit_temp, GB_jit_temp_allocated, // compile: - "%s -DGB_JIT_RUNTIME=1 " // compiler command - "%s " // C flags + "sh -c \"" // execute with POSIX shell + "%s " // compiler command + "-DGB_JIT_RUNTIME=1 %s " // C flags "-I%s/src " // include source directory "%s " // openmp include directories "-o %s/c/%02x/%s%s " // *.o output file @@ -2336,8 +2337,8 @@ void GB_jitifyer_direct_compile (char *kernel_name, uint32_t bucket) "-o %s/lib/%02x/%s%s%s " // lib*.so output file "%s/c/%02x/%s%s " // *.o input file "%s " // libraries to link with - "%s" // burble stdout - "%s %s ", // error log file + "%s " // burble stdout + "%s %s\"", // error log file // compile: GB_jit_C_compiler, // C compiler diff --git a/GraphBLAS/cmake_modules/GraphBLAS_JIT_configure.cmake b/GraphBLAS/cmake_modules/GraphBLAS_JIT_configure.cmake index 8b49048c0..7e087b47c 100644 --- a/GraphBLAS/cmake_modules/GraphBLAS_JIT_configure.cmake +++ b/GraphBLAS/cmake_modules/GraphBLAS_JIT_configure.cmake @@ -8,7 +8,13 @@ #------------------------------------------------------------------------------- # construct the JIT compiler/link strings -set ( GB_C_COMPILER "${CMAKE_C_COMPILER}" ) +if ( MINGW ) + execute_process ( COMMAND cygpath -u "${CMAKE_C_COMPILER}" + OUTPUT_VARIABLE C_COMPILER_BINARY OUTPUT_STRIP_TRAILING_WHITESPACE ) +else ( ) + set ( C_COMPILER_BINARY "${CMAKE_C_COMPILER}" ) +endif ( ) +set ( GB_C_COMPILER "${C_COMPILER_BINARY}" ) set ( GB_C_FLAGS "${CMAKE_C_FLAGS}" ) set ( GB_C_LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}" ) set ( GB_LIB_SUFFIX "${CMAKE_SHARED_LIBRARY_SUFFIX}" ) @@ -25,8 +31,8 @@ if ( APPLE ) set ( GB_C_FLAGS "${GB_C_FLAGS} -isysroot ${CMAKE_OSX_SYSROOT} " ) set ( GB_C_LINK_FLAGS "${GB_C_LINK_FLAGS} -dynamiclib " ) set ( GB_OBJ_SUFFIX ".o" ) -elseif ( WIN32 ) - # Windows +elseif ( MSVC ) + # Microsoft compiler set ( GB_OBJ_SUFFIX ".obj" ) else ( ) # Linux / Unix @@ -48,15 +54,30 @@ else ( ) endif ( ) # construct the library list -string ( REPLACE "." "\\." LIBSUFFIX1 ${GB_LIB_SUFFIX} ) -string ( REPLACE "." "\\." LIBSUFFIX2 ${CMAKE_STATIC_LIBRARY_SUFFIX} ) +# This might be something like: +# /usr/lib/libgomp.so;/usr/lib/libpthread.a;m +# convert to -l flags to avoid relocation issues, i.e.: "-lgomp -lpthread -lm" set ( GB_C_LIBRARIES "" ) -foreach ( LIB_NAME ${GB_CMAKE_LIBRARIES} ) - if (( LIB_NAME MATCHES ${LIBSUFFIX1} ) OR ( LIB_NAME MATCHES ${LIBSUFFIX2} )) - string ( APPEND GB_C_LIBRARIES " " ${LIB_NAME} ) - else ( ) - string ( APPEND GB_C_LIBRARIES " -l" ${LIB_NAME} ) +foreach ( _lib ${GB_CMAKE_LIBRARIES} ) + string ( FIND ${_lib} "." _pos REVERSE ) + if ( ${_pos} EQUAL "-1" ) + set ( GB_C_LIBRARIES "${GB_C_LIBRARIES} -l${_lib}" ) + continue () + endif ( ) + set ( _kinds "SHARED" "STATIC" ) + if ( WIN32 ) + list ( PREPEND _kinds "IMPORT" ) endif ( ) + foreach ( _kind IN LISTS _kinds ) + set ( _regex ".*\\/(lib)?([^\\.]*)(${CMAKE_${_kind}_LIBRARY_SUFFIX})" ) + if ( ${_lib} MATCHES ${_regex} ) + string ( REGEX REPLACE ${_regex} "\\2" _libname ${_lib} ) + if ( NOT "${_libname}" STREQUAL "" ) + set ( GB_C_LIBRARIES "${GB_C_LIBRARIES} -l${_libname}" ) + break () + endif ( ) + endif ( ) + endforeach ( ) endforeach ( ) if ( NOT NJIT OR ENABLE_CUDA )