Browse Source

Merge topic 'ispc_window_failures'

bf88a94d88 ISPC: CompilerLauncher tests work properly with x86 builds
8de145cae1 ISPC: DynamicLibrary test now passes on windows.
a83521e082 ISPC: Use the `obj` file extension for objects on windows

Acked-by: Kitware Robot <[email protected]>
Merge-request: !5213
Brad King 5 years ago
parent
commit
907a3de1c4

+ 5 - 1
Modules/CMakeISPCInformation.cmake

@@ -1,7 +1,11 @@
 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
 # file Copyright.txt or https://cmake.org/licensing for details.
 # file Copyright.txt or https://cmake.org/licensing for details.
 
 
-set(CMAKE_ISPC_OUTPUT_EXTENSION .o)
+if(UNIX)
+  set(CMAKE_ISPC_OUTPUT_EXTENSION .o)
+else()
+  set(CMAKE_ISPC_OUTPUT_EXTENSION .obj)
+endif()
 set(CMAKE_INCLUDE_FLAG_ISPC "-I")
 set(CMAKE_INCLUDE_FLAG_ISPC "-I")
 
 
 # Load compiler-specific information.
 # Load compiler-specific information.

+ 3 - 1
Tests/ISPC/DynamicLibrary/CMakeLists.txt

@@ -9,12 +9,14 @@ endif()
 
 
 add_library(ispc_objects1 STATIC extra.ispc extra.cxx)
 add_library(ispc_objects1 STATIC extra.ispc extra.cxx)
 add_library(ispc_objects2 SHARED simple.ispc)
 add_library(ispc_objects2 SHARED simple.ispc)
+target_sources(ispc_objects2 PRIVATE simple.cxx)
 
 
 set_target_properties(ispc_objects1 PROPERTIES POSITION_INDEPENDENT_CODE ON)
 set_target_properties(ispc_objects1 PROPERTIES POSITION_INDEPENDENT_CODE ON)
+
 set_target_properties(ispc_objects1 PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4;avx1-i32x16;avx2-i32x4")
 set_target_properties(ispc_objects1 PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4;avx1-i32x16;avx2-i32x4")
 set_target_properties(ispc_objects2 PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4")
 set_target_properties(ispc_objects2 PROPERTIES ISPC_INSTRUCTION_SETS "sse2-i32x4")
 
 
-target_link_libraries(ispc_objects2 PRIVATE ispc_objects1)
+target_link_libraries(ispc_objects2 PUBLIC ispc_objects1)
 
 
 add_executable(ISPCDynamicLibrary main.cxx)
 add_executable(ISPCDynamicLibrary main.cxx)
 target_link_libraries(ISPCDynamicLibrary PUBLIC ispc_objects2)
 target_link_libraries(ISPCDynamicLibrary PUBLIC ispc_objects2)

+ 7 - 1
Tests/ISPC/DynamicLibrary/extra.cxx

@@ -2,7 +2,13 @@
 
 
 #include "extra.ispc.h"
 #include "extra.ispc.h"
 
 
-int extra()
+#ifdef _WIN32
+#  define EXPORT __declspec(dllexport)
+#else
+#  define EXPORT
+#endif
+
+EXPORT int extra()
 {
 {
   float vin[16], vout[16];
   float vin[16], vout[16];
   for (int i = 0; i < 16; ++i)
   for (int i = 0; i < 16; ++i)

+ 12 - 10
Tests/ISPC/DynamicLibrary/main.cxx

@@ -1,15 +1,17 @@
-#include <stdio.h>
 
 
-#include "simple.ispc.h"
 
 
-int main()
-{
-  float vin[16], vout[16];
-  for (int i = 0; i < 16; ++i)
-    vin[i] = i;
+#ifdef _WIN32
+#  define IMPORT __declspec(dllimport)
+#else
+#  define IMPORT
+#endif
 
 
-  ispc::simple(vin, vout, 16);
+IMPORT int simple();
+int extra();
 
 
-  for (int i = 0; i < 16; ++i)
-    printf("%d: simple(%f) = %f\n", i, vin[i], vout[i]);
+int main()
+{
+  extra();
+  simple();
+  return 0;
 }
 }

+ 0 - 0
Tests/ISPC/DynamicLibrary/shim.cxx


+ 23 - 0
Tests/ISPC/DynamicLibrary/simple.cxx

@@ -0,0 +1,23 @@
+#include <stdio.h>
+
+#include "simple.ispc.h"
+
+#ifdef _WIN32
+#  define EXPORT __declspec(dllexport)
+#else
+#  define EXPORT
+#endif
+
+EXPORT int simple()
+{
+  float vin[16], vout[16];
+  for (int i = 0; i < 16; ++i)
+    vin[i] = i;
+
+  ispc::simple(vin, vout, 16);
+
+  for (int i = 0; i < 16; ++i)
+    printf("%d: extra(%f) = %f\n", i, vin[i], vout[i]);
+
+  return 0;
+}

+ 4 - 0
Tests/RunCMake/CompilerLauncher/ISPC-common.cmake

@@ -1,4 +1,8 @@
 enable_language(ISPC)
 enable_language(ISPC)
 enable_language(CXX)
 enable_language(CXX)
 set(CMAKE_VERBOSE_MAKEFILE TRUE)
 set(CMAKE_VERBOSE_MAKEFILE TRUE)
+
+if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+  set(CMAKE_ISPC_FLAGS "--arch=x86")
+endif()
 add_executable(main main.cxx test.ispc)
 add_executable(main main.cxx test.ispc)