Fix the build of Loader/NativeLib test (dotnet/coreclr#22648)
authorSwaroop Sridhar <Swaroop.Sridhar@microsoft.com>
Sun, 17 Feb 2019 21:27:41 +0000 (13:27 -0800)
committerGitHub <noreply@github.com>
Sun, 17 Feb 2019 21:27:41 +0000 (13:27 -0800)
The native test assets were not build correctly on Unix platforms.
The native library exports were generated as private symbols by clang.

This change fixes the export declaration so that the global symbols are
correctly generated for exported symbols.

Fixes dotnet/coreclr#22549

Commit migrated from https://github.com/dotnet/coreclr/commit/390d002ac1ff919fcaae047eb09217ddeac78779

src/coreclr/tests/issues.targets
src/coreclr/tests/src/Loader/NativeLibs/CMakeLists.txt
src/coreclr/tests/src/Loader/NativeLibs/FromNativePaths_lib.cpp
src/coreclr/tests/src/Loader/NativeLibs/FromNativePaths_lib.def [deleted file]

index 5f8e837..20edc17 100644 (file)
         <ExcludeList Include="$(XunitTestBinBase)/JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b37646/*">
             <Issue>Varargs not supported on this platform</Issue>
         </ExcludeList>
-        <ExcludeList Include="$(XunitTestBinBase)/Loader/NativeLibs/FromNativePaths/*">
-            <Issue>Issue building native components for the test.</Issue>
-        </ExcludeList>
         <ExcludeList Include="$(XunitTestBinBase)/JIT/Directed/pinning/object-pin/*">
             <Issue>Issue building native components for the test.</Issue>
         </ExcludeList>
             <Issue>needs triage</Issue>
         </ExcludeList>
         <ExcludeList Include="$(XunitTestBinBase)/Loader/NativeLibs/FromNativePaths/*">
-            <Issue>needs triage</Issue>
+            <Issue>This requires the native assets to be in the test folder, which is currently not the case when building against packages.</Issue>
         </ExcludeList>
         <ExcludeList Include="$(XunitTestBinBase)/Loader/classloader/TypeGeneratorTests/TypeGeneratorTest612/Generated612/*">
             <Issue>needs triage</Issue>
index 125be8f..dffde9a 100644 (file)
@@ -3,7 +3,7 @@ project(FromNativePaths_lib)
 
 set(CMAKE_SHARED_LIBRARY_PREFIX "")
 
-set(SOURCES FromNativePaths_lib.cpp FromNativePaths_lib.def)
+set(SOURCES FromNativePaths_lib.cpp)
 add_library(FromNativePaths_lib SHARED ${SOURCES})
 
 install(TARGETS FromNativePaths_lib DESTINATION Loader/NativeLibs)
index d1f5405..f7eab2d 100644 (file)
@@ -1,7 +1,13 @@
 // Copyright (c) Microsoft. All rights reserved.
 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
 
-extern "C" bool NativeFunc()
+#if defined(__clang__)
+#define EXPORT_API extern "C" __attribute__((visibility("default")))
+#elif defined(_MSC_VER)
+#define EXPORT_API extern "C" __declspec(dllexport)
+#endif 
+
+EXPORT_API bool NativeFunc()
 {
     return true;
 }
diff --git a/src/coreclr/tests/src/Loader/NativeLibs/FromNativePaths_lib.def b/src/coreclr/tests/src/Loader/NativeLibs/FromNativePaths_lib.def
deleted file mode 100644 (file)
index d873fbd..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-EXPORTS
-    NativeFunc
\ No newline at end of file