From 1c0b32b00f7044568591525e01c6d7abebdc7f64 Mon Sep 17 00:00:00 2001 From: vsadov Date: Thu, 12 Nov 2020 13:26:37 -0800 Subject: [PATCH 01/32] from prototype --- eng/native/build-commons.sh | 16 + eng/native/configurecompiler.cmake | 2 +- .../src/dlls/mscoree/coreclr/CMakeLists.txt | 19 + .../src/libraries-native/CMakeLists.txt | 19 +- src/coreclr/src/vm/corelib.cpp | 2 + src/coreclr/src/vm/dllimport.cpp | 7 +- src/coreclr/src/vm/ecall.cpp | 10 +- src/coreclr/src/vm/ecalllist.h | 7 + src/coreclr/tryrun.cmake | 6 + .../cli/apphost/static/CMakeLists.txt | 4 +- .../Common/src/Interop/Interop.Libraries.cs | 2 +- .../src/Interop/Windows/Interop.Libraries.cs | 2 +- .../entrypoints.c | 42 +++ src/libraries/Native/Unix/CMakeLists.txt | 15 +- .../System.Globalization.Native/entrypoints.c | 1 + .../CMakeLists.txt | 3 +- .../System.IO.Ports.Native/CMakeLists.txt | 21 +- .../Native/Unix/System.Native/CMakeLists.txt | 3 +- .../Native/Unix/System.Native/entrypoints.c | 273 ++++++++++++++ .../Native/Unix/System.Native/pal_log.h | 1 + .../System.Net.Security.Native/CMakeLists.txt | 26 +- .../System.Net.Security.Native/entrypoints.c | 34 ++ .../System.Net.Security.Native/pal_gssapi.h | 1 + .../CMakeLists.txt | 29 +- .../CMakeLists.txt | 66 ++-- .../entrypoints.c | 335 ++++++++++++++++++ src/libraries/Native/Windows/CMakeLists.txt | 8 + .../Windows/clrcompression/CMakeLists.txt | 51 ++- .../tests/ProcessModuleTests.cs | 2 +- .../tests/DefaultECDsaProvider.Unix.cs | 3 +- .../tests/EcDsaOpenSslTests.cs | 3 +- .../tests/HostnameMatchTests.Unix.cs | 10 +- 32 files changed, 921 insertions(+), 102 deletions(-) create mode 100644 src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c create mode 100644 src/libraries/Native/Unix/System.Native/entrypoints.c create mode 100644 src/libraries/Native/Unix/System.Net.Security.Native/entrypoints.c create mode 100644 src/libraries/Native/Unix/System.Security.Cryptography.Native/entrypoints.c diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 0b2caf94c663f2..edb4f07097df2d 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -455,6 +455,22 @@ if [[ "$__PortableBuild" == 0 ]]; then __CommonMSBuildArgs="$__CommonMSBuildArgs /p:PortableBuild=false" fi +if [[ "$__BuildArch" == wasm ]]; then + # nothing to do here + true +elif [[ "$__TargetOS" == iOS ]]; then + # nothing to do here + true +elif [[ "$__TargetOS" == tvOS ]]; then + # nothing to do here + true +elif [[ "$__TargetOS" == Android && -z "$ROOTFS_DIR" ]]; then + # nothing to do here + true +else + __CMakeArgs="-DFEATURE_DISTRO_AGNOSTIC_SSL=$__PortableBuild $__CMakeArgs" +fi + # Configure environment if we are doing a cross compile. if [[ "$__CrossBuild" == 1 ]]; then CROSSCOMPILE=1 diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 7adc24d6acb627..c3d53bb1075903 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -451,7 +451,7 @@ endif(CLR_CMAKE_HOST_UNIX) if (MSVC) # Compile options for targeting windows - add_compile_options($<$:/TP>) # compile all files as C++ + # add_compile_options($<$:/TP>) # compile all files as C++ add_compile_options($<$:/nologo>) # Suppress Startup Banner add_compile_options($<$:/W3>) # set warning level to 3 add_compile_options($<$:/WX>) # treat warnings as errors diff --git a/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt index 7835929afc1c9c..c5633056b05300 100644 --- a/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt @@ -84,6 +84,23 @@ if (CLR_CMAKE_HOST_UNIX) set(LIB_UNWINDER unwinder_wks) endif (CLR_CMAKE_HOST_UNIX) +if(CLR_CMAKE_HOST_WIN32) + set(COMPRESSION_LIB clrcompression-static) +else() + set(COMPRESSION_LIB System.IO.Compression.Native-Static) + + if (CLR_CMAKE_TARGET_BROWSER) + add_definitions(-s USE_ZLIB) + elseif (CLR_CMAKE_TARGET_ANDROID) + # need special case here since we want to link against libz.so but find_package() would resolve libz.a + set(ZLIB_LIBRARIES z) + elseif (CLR_CMAKE_TARGET_SUNOS) + set(ZLIB_LIBRARIES z m) + else () + find_package(ZLIB REQUIRED) + endif () +endif() + # IMPORTANT! Please do not rearrange the order of the libraries. The linker on Linux is # order dependent and changing the order can result in undefined symbols in the shared # library. @@ -108,6 +125,8 @@ set(CORECLR_LIBRARIES utilcode v3binder System.Globalization.Native-Static + ${COMPRESSION_LIB} + ${ZLIB_LIBRARIES} interop ) diff --git a/src/coreclr/src/libraries-native/CMakeLists.txt b/src/coreclr/src/libraries-native/CMakeLists.txt index 65b0d06c29ca83..166ac8fbf83a35 100644 --- a/src/coreclr/src/libraries-native/CMakeLists.txt +++ b/src/coreclr/src/libraries-native/CMakeLists.txt @@ -1,11 +1,22 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) -set(GLOBALIZATION_NATIVE_DIR ${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.Globalization.Native) # Suppress exporting of the PAL APIs add_definitions(-DPALEXPORT=EXTERN_C) -include_directories("${GLOBALIZATION_NATIVE_DIR}") -include_directories("${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/Common") +set(STATIC_LIBS_ONLY 1) -add_subdirectory(${GLOBALIZATION_NATIVE_DIR} System.Globalization.Native) +if(CLR_CMAKE_TARGET_WIN32) + set(GLOBALIZATION_NATIVE_DIR ${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.Globalization.Native) + set(COMPRESSION_NATIVE_DIR ${CLR_REPO_ROOT_DIR}/src/libraries/Native/Windows/clrcompression) + include_directories("${GLOBALIZATION_NATIVE_DIR}") + include_directories("${COMPRESSION_NATIVE_DIR}") + + include_directories("${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/Common") + + add_subdirectory(${COMPRESSION_NATIVE_DIR} clrcompression) + add_subdirectory(${GLOBALIZATION_NATIVE_DIR} System.Globalization.Native) + +else() + add_subdirectory(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix Native.Unix) +endif() diff --git a/src/coreclr/src/vm/corelib.cpp b/src/coreclr/src/vm/corelib.cpp index 4562e2e12ed28d..0632d1f8108a8b 100644 --- a/src/coreclr/src/vm/corelib.cpp +++ b/src/coreclr/src/vm/corelib.cpp @@ -373,6 +373,8 @@ const USHORT c_nCoreLibFieldDescriptions = NumItems(c_rgCoreLibFieldDescriptions // ECalls defined by libraries-native shims EXTERN_C const LPVOID gPalGlobalizationNative[]; +EXTERN_C const LPVOID gEmbedded_Brotli[]; +EXTERN_C const LPVOID gEmbedded_zlib[]; // When compiling crossgen, we only need the target version of the ecall tables #if !defined(CROSSGEN_COMPILE) || defined(CROSSGEN_CORELIB) diff --git a/src/coreclr/src/vm/dllimport.cpp b/src/coreclr/src/vm/dllimport.cpp index d9a003f9ee7120..a6c5bca97f676c 100644 --- a/src/coreclr/src/vm/dllimport.cpp +++ b/src/coreclr/src/vm/dllimport.cpp @@ -4230,7 +4230,11 @@ void NDirect::PopulateNDirectMethodDesc(NDirectMethodDesc* pNMD, PInvokeStaticSi if (callConv == pmCallConvThiscall) ndirectflags |= NDirectMethodDesc::kThisCall; - if (pNMD->GetLoaderModule()->IsSystem() && strcmp(szLibName, "QCall") == 0) + if ((pNMD->GetLoaderModule()->IsSystem() && (strcmp(szLibName, "QCall") == 0)) || + (szLibName != NULL && + (strcmp(szLibName, "libSystem.Globalization.Native") == 0 || + strcmp(szLibName, "libSystem.IO.Compression.Native") == 0 || + strcmp(szLibName, "clrcompression") == 0))) { ndirectflags |= NDirectMethodDesc::kIsQCall; } @@ -6224,7 +6228,6 @@ namespace // this matches exactly the names in Interop.Libraries.cs static const LPCWSTR toRedirect[] = { W("libSystem.Native"), - W("libSystem.IO.Compression.Native"), W("libSystem.Net.Security.Native"), W("libSystem.Security.Cryptography.Native.OpenSsl") }; diff --git a/src/coreclr/src/vm/ecall.cpp b/src/coreclr/src/vm/ecall.cpp index 5daa657f33a4d9..1bfa52005cbe4e 100644 --- a/src/coreclr/src/vm/ecall.cpp +++ b/src/coreclr/src/vm/ecall.cpp @@ -660,7 +660,7 @@ LPVOID ECall::GetQCallImpl(MethodDesc * pMD) if (id == 0) { id = ECall::GetIDForMethod(pMD); - _ASSERTE(id != 0); + _ASSERTE_MSG(id != 0, pMD->m_pszDebugMethodName); // Cache the id ((NDirectMethodDesc *)pMD)->SetECallID(id); @@ -683,9 +683,11 @@ LPVOID ECall::GetQCallImpl(MethodDesc * pMD) // SuppressUnmanagedCodeSecurityAttribute on QCalls suppresses a full demand, but there's still a link demand // for unmanaged code permission. All QCalls should be private or internal and wrapped in a managed method // to suppress this link demand. - CONSISTENCY_CHECK_MSGF(!fPublicOrProtected, - ("%s::%s has to be private or internal.", - pMD->m_pszDebugClassName, pMD->m_pszDebugMethodName)); + + // TODO: HACK HACK HACK uncomment this + //CONSISTENCY_CHECK_MSGF(!fPublicOrProtected, + // ("%s::%s has to be private or internal.", + // pMD->m_pszDebugClassName, pMD->m_pszDebugMethodName)); #endif return cur->m_pImplementation; diff --git a/src/coreclr/src/vm/ecalllist.h b/src/coreclr/src/vm/ecalllist.h index 15468724e0fb9f..1907d8cbacd23a 100644 --- a/src/coreclr/src/vm/ecalllist.h +++ b/src/coreclr/src/vm/ecalllist.h @@ -1116,6 +1116,9 @@ FCClassElement("AssemblyExtensions", "System.Reflection.Metadata", gAssemblyExte FCClassElement("AssemblyLoadContext", "System.Runtime.Loader", gAssemblyLoadContextFuncs) FCClassElement("AssemblyName", "System.Reflection", gAssemblyNameFuncs) +#ifndef CROSSGEN_COMPILE +FCClassElement("Brotli", "", gEmbedded_Brotli) +#endif FCClassElement("Buffer", "System", gBufferFuncs) FCClassElement("CLRConfig", "System", gClrConfig) FCClassElement("CastHelpers", "System.Runtime.CompilerServices", gCastHelpers) @@ -1224,6 +1227,10 @@ FCClassElement("X86Base", "System.Runtime.Intrinsics.X86", gX86BaseFuncs) FCClassElement("XplatEventLogger", "System.Diagnostics.Tracing", gEventLogger) #endif //defined(FEATURE_EVENTSOURCE_XPLAT) +#ifndef CROSSGEN_COMPILE +FCClassElement("zlib", "", gEmbedded_zlib) +#endif + #undef FCFuncElement #undef FCFuncElementSig #undef FCIntrinsic diff --git a/src/coreclr/tryrun.cmake b/src/coreclr/tryrun.cmake index 4b23122b91c2ba..a26794aa8f0c6c 100644 --- a/src/coreclr/tryrun.cmake +++ b/src/coreclr/tryrun.cmake @@ -72,6 +72,7 @@ elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$" OR FREEBSD OR ILLUMOS) set_cache_value(HAS_POSIX_SEMAPHORES_EXITCODE 0) set_cache_value(HAVE_CLOCK_MONOTONIC_COARSE_EXITCODE 0) set_cache_value(HAVE_CLOCK_MONOTONIC_EXITCODE 0) + set_cache_value(HAVE_CLOCK_REALTIME_EXITCODE 0) set_cache_value(HAVE_CLOCK_THREAD_CPUTIME_EXITCODE 0) set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 0) set_cache_value(HAVE_COMPATIBLE_ASIN_EXITCODE 0) @@ -100,16 +101,21 @@ elseif(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$" OR FREEBSD OR ILLUMOS) if(ALPINE_LINUX) + set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP_EXITCODE 1) set_cache_value(SSCANF_CANNOT_HANDLE_MISSING_EXPONENT_EXITCODE 0) set_cache_value(SSCANF_SUPPORT_ll_EXITCODE 1) set_cache_value(UNGETC_NOT_RETURN_EOF_EXITCODE 1) else() + set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP_EXITCODE 0) set_cache_value(SSCANF_CANNOT_HANDLE_MISSING_EXPONENT_EXITCODE 1) set_cache_value(SSCANF_SUPPORT_ll_EXITCODE 0) set_cache_value(UNGETC_NOT_RETURN_EOF_EXITCODE 0) endif() if (FREEBSD) + set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP 1) + set_cache_value(HAVE_CLOCK_MONOTONIC 1) + set_cache_value(HAVE_CLOCK_REALTIME 1) set_cache_value(HAVE_BROKEN_FIFO_KEVENT_EXITCODE 1) set_cache_value(HAVE_PROCFS_MAPS 0) set_cache_value(HAVE_PROCFS_STAT 0) diff --git a/src/installer/corehost/cli/apphost/static/CMakeLists.txt b/src/installer/corehost/cli/apphost/static/CMakeLists.txt index bc91c6fffa0d4c..661a4dc1b36411 100644 --- a/src/installer/corehost/cli/apphost/static/CMakeLists.txt +++ b/src/installer/corehost/cli/apphost/static/CMakeLists.txt @@ -116,6 +116,7 @@ if(CLR_CMAKE_TARGET_WIN32) set(CORECLR_LIBRARIES ${CORECLR_STATIC_LIB_LOCATION}/coreclr_static.lib ${CORECLR_STATIC_LIB_LOCATION}/System.Globalization.Native.lib + ${CORECLR_STATIC_LIB_LOCATION}/libclrcompression.lib kernel32.lib advapi32.lib ole32.lib @@ -131,6 +132,7 @@ else() set(CORECLR_LIBRARIES ${CORECLR_STATIC_LIB_LOCATION}/libcoreclr_static.a ${CORECLR_STATIC_LIB_LOCATION}/libSystem.Globalization.Native.a + ${CORECLR_STATIC_LIB_LOCATION}/libSystem.IO.Compression.Native.a ${CORECLR_STATIC_LIB_LOCATION}/libpalrt.a ${CORECLR_STATIC_LIB_LOCATION}/libcoreclrpal.a ${CORECLR_STATIC_LIB_LOCATION}/libeventprovider.a @@ -186,7 +188,6 @@ if(NOT CLR_CMAKE_TARGET_LINUX) ) else() set(NATIVE_LIBS - ${NATIVE_LIBS_LOCATION}/libSystem.IO.Compression.Native.a ${NATIVE_LIBS_LOCATION}/libSystem.Native.a ${NATIVE_LIBS_LOCATION}/libSystem.Net.Security.Native.a ${NATIVE_LIBS_LOCATION}/libSystem.Security.Cryptography.Native.OpenSsl.a @@ -265,7 +266,6 @@ target_link_libraries(singlefilehost ${ZLIB_LIBRARIES} ${LIBGSS} ${NATIVE_LIBS_EXTRA} - ) if(NOT FEATURE_DISTRO_AGNOSTIC_SSL) diff --git a/src/libraries/Common/src/Interop/Interop.Libraries.cs b/src/libraries/Common/src/Interop/Interop.Libraries.cs index 217852751c32a4..e57d5918ba350d 100644 --- a/src/libraries/Common/src/Interop/Interop.Libraries.cs +++ b/src/libraries/Common/src/Interop/Interop.Libraries.cs @@ -5,6 +5,6 @@ internal static partial class Interop { internal static partial class Libraries { - internal const string GlobalizationNative = "QCall"; + internal const string GlobalizationNative = "libSystem.Globalization.Native"; } } diff --git a/src/libraries/Common/src/Interop/Windows/Interop.Libraries.cs b/src/libraries/Common/src/Interop/Windows/Interop.Libraries.cs index 6b1006caf3932a..4893a2894682de 100644 --- a/src/libraries/Common/src/Interop/Windows/Interop.Libraries.cs +++ b/src/libraries/Common/src/Interop/Windows/Interop.Libraries.cs @@ -31,7 +31,7 @@ internal static partial class Libraries internal const string Wldap32 = "wldap32.dll"; internal const string Ws2_32 = "ws2_32.dll"; internal const string Wtsapi32 = "wtsapi32.dll"; - internal const string CompressionNative = "clrcompression.dll"; + internal const string CompressionNative = "clrcompression"; internal const string MsQuic = "msquic.dll"; internal const string HostPolicy = "hostpolicy.dll"; } diff --git a/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c b/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c new file mode 100644 index 00000000000000..3b96d3856f48de --- /dev/null +++ b/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c @@ -0,0 +1,42 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#include + +// Include System.IO.Compression.Native headers +#include "../zlib/pal_zlib.h" +#include "../brotli/include/brotli/decode.h" +#include "../brotli/include/brotli/encode.h" +#include "../brotli/include/brotli/port.h" +#include "../brotli/include/brotli/types.h" + +#define FCFuncStart(name) EXTERN_C const void* name[]; const void* name[] = { +#define FCFuncEnd() (void*)0x01 /* FCFuncFlag_EndOfArray */ }; + +#define QCFuncElement(name,impl) \ + (void*)0x8 /* FCFuncFlag_QCall */, (void*)(impl), (void*)name, + +FCFuncStart(gEmbedded_Brotli) + QCFuncElement("BrotliDecoderCreateInstance", BrotliDecoderCreateInstance) + QCFuncElement("BrotliDecoderDecompress", BrotliDecoderDecompress) + QCFuncElement("BrotliDecoderDecompressStream", BrotliDecoderDecompressStream) + QCFuncElement("BrotliDecoderDestroyInstance", BrotliDecoderDestroyInstance) + QCFuncElement("BrotliDecoderIsFinished", BrotliDecoderIsFinished) + QCFuncElement("BrotliEncoderCompress", BrotliEncoderCompress) + QCFuncElement("BrotliEncoderCompressStream", BrotliEncoderCompressStream) + QCFuncElement("BrotliEncoderCreateInstance", BrotliEncoderCreateInstance) + QCFuncElement("BrotliEncoderDestroyInstance", BrotliEncoderDestroyInstance) + QCFuncElement("BrotliEncoderHasMoreOutput", BrotliEncoderHasMoreOutput) + QCFuncElement("BrotliEncoderSetParameter", BrotliEncoderSetParameter) +FCFuncEnd() + +FCFuncStart(gEmbedded_zlib) + QCFuncElement("crc32", CompressionNative_Crc32) + QCFuncElement("Deflate", CompressionNative_Deflate) + QCFuncElement("DeflateEnd", CompressionNative_DeflateEnd) + QCFuncElement("DeflateInit2_", CompressionNative_DeflateInit2_) + QCFuncElement("Inflate", CompressionNative_Inflate) + QCFuncElement("InflateEnd", CompressionNative_InflateEnd) + QCFuncElement("InflateInit2_", CompressionNative_InflateInit2_) +FCFuncEnd() + diff --git a/src/libraries/Native/Unix/CMakeLists.txt b/src/libraries/Native/Unix/CMakeLists.txt index 3bc41e406561ac..21a8caa9949c24 100644 --- a/src/libraries/Native/Unix/CMakeLists.txt +++ b/src/libraries/Native/Unix/CMakeLists.txt @@ -54,15 +54,24 @@ if (PRERELEASE) add_compile_options(-Werror) endif() +if(STATIC_LIBS_ONLY) + set(STATIC_LIB_DESTINATION lib) + set(GEN_SHARED_LIB 0) +else() + set(STATIC_LIB_DESTINATION .) + set(GEN_SHARED_LIB 1) +endif() + if(CLR_CMAKE_TARGET_BROWSER) # The emscripten build has additional warnings so -Werror breaks add_compile_options(-Wno-unused-parameter) add_compile_options(-Wno-unused-function) add_compile_options(-Wno-alloca) add_compile_options(-Wno-implicit-int-float-conversion) -else() - set(GEN_SHARED_LIB 1) -endif(CLR_CMAKE_TARGET_BROWSER) + + set(GEN_SHARED_LIB 0) + set(STATIC_LIB_DESTINATION .) +endif() if (CLR_CMAKE_TARGET_ARCH_AMD64) add_definitions(-DTARGET_64BIT=1) diff --git a/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c b/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c index 7a7f5ea037d7e6..c4d60950256799 100644 --- a/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c @@ -23,6 +23,7 @@ typedef uint16_t UChar; #define QCFuncElement(name,impl) \ (void*)0x8 /* FCFuncFlag_QCall */, (void*)(impl), (void*)name, + FCFuncStart(gPalGlobalizationNative) QCFuncElement("ChangeCase", GlobalizationNative_ChangeCase) QCFuncElement("ChangeCaseInvariant", GlobalizationNative_ChangeCaseInvariant) diff --git a/src/libraries/Native/Unix/System.IO.Compression.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.IO.Compression.Native/CMakeLists.txt index dcd1d87963b700..1331b502282ee8 100644 --- a/src/libraries/Native/Unix/System.IO.Compression.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.IO.Compression.Native/CMakeLists.txt @@ -52,6 +52,7 @@ if (NOT CLR_CMAKE_TARGET_BROWSER) ../../AnyOS/brotli/enc/metablock.c ../../AnyOS/brotli/enc/static_dict.c ../../AnyOS/brotli/enc/utf8_util.c + ../../AnyOS/System.IO.Compression.Native/entrypoints.c ) # Disable implicit fallthrough warning for Brotli @@ -78,4 +79,4 @@ add_library(System.IO.Compression.Native-Static set_target_properties(System.IO.Compression.Native-Static PROPERTIES OUTPUT_NAME System.IO.Compression.Native CLEAN_DIRECT_OUTPUT 1) -install (TARGETS System.IO.Compression.Native-Static DESTINATION .) +install (TARGETS System.IO.Compression.Native-Static DESTINATION ${STATIC_LIB_DESTINATION}) diff --git a/src/libraries/Native/Unix/System.IO.Ports.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.IO.Ports.Native/CMakeLists.txt index 1750a07d73c82b..ede448009f2e9e 100644 --- a/src/libraries/Native/Unix/System.IO.Ports.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.IO.Ports.Native/CMakeLists.txt @@ -1,11 +1,13 @@ project(System.IO.Ports.Native C) -add_library(System.IO.Ports.Native - SHARED - pal_termios.c - pal_serial.c - ${VERSION_FILE_PATH} -) +if (GEN_SHARED_LIB) + add_library(System.IO.Ports.Native + SHARED + pal_termios.c + pal_serial.c + ${VERSION_FILE_PATH} + ) +endif() add_library(System.IO.Ports.Native-Static STATIC @@ -15,5 +17,8 @@ add_library(System.IO.Ports.Native-Static set_target_properties(System.IO.Ports.Native-Static PROPERTIES OUTPUT_NAME System.IO.Ports.Native CLEAN_DIRECT_OUTPUT 1) -install_with_stripped_symbols (System.IO.Ports.Native PROGRAMS .) -install (TARGETS System.IO.Ports.Native-Static DESTINATION .) +if (GEN_SHARED_LIB) + install_with_stripped_symbols (System.IO.Ports.Native PROGRAMS .) +endif() + +install (TARGETS System.IO.Ports.Native-Static DESTINATION ${STATIC_LIB_DESTINATION}) diff --git a/src/libraries/Native/Unix/System.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Native/CMakeLists.txt index 517628d8fc3321..f5a925fd46bf86 100644 --- a/src/libraries/Native/Unix/System.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Native/CMakeLists.txt @@ -76,6 +76,7 @@ endif () add_library(System.Native-Static STATIC ${NATIVE_SOURCES} + entrypoints.c ) if (CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) @@ -84,4 +85,4 @@ endif () set_target_properties(System.Native-Static PROPERTIES OUTPUT_NAME System.Native CLEAN_DIRECT_OUTPUT 1) -install (TARGETS System.Native-Static DESTINATION .) +install (TARGETS System.Native-Static DESTINATION ${STATIC_LIB_DESTINATION}) diff --git a/src/libraries/Native/Unix/System.Native/entrypoints.c b/src/libraries/Native/Unix/System.Native/entrypoints.c new file mode 100644 index 00000000000000..7f1e1ccc2b5090 --- /dev/null +++ b/src/libraries/Native/Unix/System.Native/entrypoints.c @@ -0,0 +1,273 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#include + +// Include System.Native headers +#include "pal_console.h" +#include "pal_datetime.h" +#include "pal_errno.h" +#include "pal_interfaceaddresses.h" +#include "pal_io.h" +#include "pal_log.h" +#include "pal_memory.h" +#include "pal_mount.h" +#include "pal_networkchange.h" +#include "pal_networking.h" +#include "pal_networkstatistics.h" +#include "pal_process.h" +#include "pal_random.h" +#include "pal_runtimeextensions.h" +#include "pal_runtimeinformation.h" +#include "pal_searchpath.h" +#include "pal_signal.h" +#include "pal_string.h" +#include "pal_sysctl.h" +#include "pal_tcpstate.h" +#include "pal_threading.h" +#include "pal_time.h" +#include "pal_uid.h" + +#define FCFuncStart(name) EXTERN_C const void* name[]; const void* name[] = { +#define FCFuncEnd() (void*)0x01 /* FCFuncFlag_EndOfArray */ }; + +#define QCFuncElement(name,impl) \ + (void*)0x8 /* FCFuncFlag_QCall */, (void*)(impl), (void*)name, + +FCFuncStart(gEmbedded_Fcntl) + QCFuncElement("FcntlCanGetSetPipeSz", SystemNative_FcntlCanGetSetPipeSz) + QCFuncElement("GetFD", SystemNative_FcntlGetFD) + QCFuncElement("GetIsNonBlocking", SystemNative_FcntlGetIsNonBlocking) + QCFuncElement("GetPipeSz", SystemNative_FcntlGetPipeSz) + QCFuncElement("SetFD", SystemNative_FcntlSetFD) + QCFuncElement("DangerousSetIsNonBlocking", SystemNative_FcntlSetIsNonBlocking) + QCFuncElement("SetIsNonBlocking", SystemNative_FcntlSetIsNonBlocking) + QCFuncElement("SetPipeSz", SystemNative_FcntlSetPipeSz) +FCFuncEnd() + +FCFuncStart(gEmbedded_Sys) + QCFuncElement("Accept", SystemNative_Accept) + QCFuncElement("Access", SystemNative_Access) + QCFuncElement("Bind", SystemNative_Bind) + QCFuncElement("ChDir", SystemNative_ChDir) + QCFuncElement("ChMod", SystemNative_ChMod) + QCFuncElement("Close", SystemNative_Close) + QCFuncElement("CloseDir", SystemNative_CloseDir) + +#if defined(__FreeBSD__) || defined(__linux__) + QCFuncElement("CloseNetworkChangeListenerSocket", SystemNative_CloseNetworkChangeListenerSocket) +#endif + + QCFuncElement("CloseSocketEventPort", SystemNative_CloseSocketEventPort) + QCFuncElement("ConfigureTerminalForChildProcess", SystemNative_ConfigureTerminalForChildProcess) + QCFuncElement("Connect", SystemNative_Connect) + QCFuncElement("ConvertErrorPalToPlatform", SystemNative_ConvertErrorPalToPlatform) + QCFuncElement("ConvertErrorPlatformToPal", SystemNative_ConvertErrorPlatformToPal) + QCFuncElement("CopyFile", SystemNative_CopyFile) + +#if defined(__FreeBSD__) || defined(__linux__) + QCFuncElement("CreateNetworkChangeListenerSocket", SystemNative_CreateNetworkChangeListenerSocket) +#endif + + QCFuncElement("CreateSocketEventBuffer", SystemNative_CreateSocketEventBuffer) + QCFuncElement("CreateSocketEventPort", SystemNative_CreateSocketEventPort) + QCFuncElement("Disconnect", SystemNative_Disconnect) + QCFuncElement("Dup", SystemNative_Dup) + QCFuncElement("EnumerateInterfaceAddresses", SystemNative_EnumerateInterfaceAddresses) + QCFuncElement("FChMod", SystemNative_FChMod) + QCFuncElement("FLock", SystemNative_FLock) + QCFuncElement("ForkAndExecProcess", SystemNative_ForkAndExecProcess) + QCFuncElement("FreeHostEntry", SystemNative_FreeHostEntry) + QCFuncElement("FreeSocketEventBuffer", SystemNative_FreeSocketEventBuffer) + QCFuncElement("FStat", SystemNative_FStat) + QCFuncElement("FSync", SystemNative_FSync) + QCFuncElement("FTruncate", SystemNative_FTruncate) + QCFuncElement("GetAddressFamily", SystemNative_GetAddressFamily) + QCFuncElement("GetAllMountPoints", SystemNative_GetAllMountPoints) + QCFuncElement("GetAtOutOfBandMark", SystemNative_GetAtOutOfBandMark) + QCFuncElement("GetBytesAvailable", SystemNative_GetBytesAvailable) + QCFuncElement("GetControlCharacters", SystemNative_GetControlCharacters) + QCFuncElement("GetControlMessageBufferSize", SystemNative_GetControlMessageBufferSize) + QCFuncElement("GetCpuUtilization", SystemNative_GetCpuUtilization) + QCFuncElement("GetCwd", SystemNative_GetCwd) + QCFuncElement("GetDomainName", SystemNative_GetDomainName) + QCFuncElement("GetDomainSocketSizes", SystemNative_GetDomainSocketSizes) + QCFuncElement("GetEGid", SystemNative_GetEGid) + QCFuncElement("GetEUid", SystemNative_GetEUid) + QCFuncElement("GetFormatInfoForMountPoint", SystemNative_GetFormatInfoForMountPoint) + QCFuncElement("GetGroupList", SystemNative_GetGroupList) + QCFuncElement("GetHostEntryForName", SystemNative_GetHostEntryForName) + QCFuncElement("GetHostName", SystemNative_GetHostName) + QCFuncElement("GetIPSocketAddressSizes", SystemNative_GetIPSocketAddressSizes) + QCFuncElement("GetIPv4Address", SystemNative_GetIPv4Address) + QCFuncElement("GetIPv4MulticastOption", SystemNative_GetIPv4MulticastOption) + QCFuncElement("GetIPv6Address", SystemNative_GetIPv6Address) + QCFuncElement("GetIPv6MulticastOption", SystemNative_GetIPv6MulticastOption) + QCFuncElement("GetLingerOption", SystemNative_GetLingerOption) + QCFuncElement("GetMaximumAddressSize", SystemNative_GetMaximumAddressSize) + QCFuncElement("GetNameInfo", SystemNative_GetNameInfo) + QCFuncElement("GetNetworkInterfaces", SystemNative_GetNetworkInterfaces) + // trimmed + QCFuncElement("GetCryptographicallySecureRandomBytes", SystemNative_GetCryptographicallySecureRandomBytes) + QCFuncElement("GetNonCryptographicallySecureRandomBytes", SystemNative_GetNonCryptographicallySecureRandomBytes) + QCFuncElement("GetOSArchitecture", SystemNative_GetOSArchitecture) + QCFuncElement("GetPeerID", SystemNative_GetPeerID) + QCFuncElement("GetPeerName", SystemNative_GetPeerName) + QCFuncElement("GetPeerUserName", SystemNative_GetPeerUserName) + QCFuncElement("GetPid", SystemNative_GetPid) + QCFuncElement("GetPort", SystemNative_GetPort) + QCFuncElement("GetPriority", SystemNative_GetPriority) + QCFuncElement("GetProcessArchitecture", SystemNative_GetProcessArchitecture) + QCFuncElement("GetPwNamR", SystemNative_GetPwNamR) + QCFuncElement("GetPwUidR", SystemNative_GetPwUidR) + QCFuncElement("GetRawSockOpt", SystemNative_GetRawSockOpt) + QCFuncElement("GetReadDirRBufferSize", SystemNative_GetReadDirRBufferSize) + QCFuncElement("GetSignalForBreak", SystemNative_GetSignalForBreak) + QCFuncElement("GetSocketErrorOption", SystemNative_GetSocketErrorOption) + QCFuncElement("GetSocketType", SystemNative_GetSocketType) + QCFuncElement("GetSockName", SystemNative_GetSockName) + QCFuncElement("GetSockOpt", SystemNative_GetSockOpt) + QCFuncElement("GetSpaceInfoForMountPoint", SystemNative_GetSpaceInfoForMountPoint) + QCFuncElement("GetTimestamp", SystemNative_GetTimestamp) + QCFuncElement("GetUnixNamePrivate", SystemNative_GetUnixName) + QCFuncElement("GetUnixRelease", SystemNative_GetUnixRelease) + QCFuncElement("GetUnixVersion", SystemNative_GetUnixVersion) + QCFuncElement("GetWindowSize", SystemNative_GetWindowSize) + QCFuncElement("InitializeConsoleBeforeRead", SystemNative_InitializeConsoleBeforeRead) + QCFuncElement("InitializeTerminalAndSignalHandling", SystemNative_InitializeTerminalAndSignalHandling) + QCFuncElement("INotifyAddWatch", SystemNative_INotifyAddWatch) + QCFuncElement("INotifyInit", SystemNative_INotifyInit) + QCFuncElement("INotifyRemoveWatch_private", SystemNative_INotifyRemoveWatch) + QCFuncElement("InterfaceNameToIndex", SystemNative_InterfaceNameToIndex) + QCFuncElement("IsATty", SystemNative_IsATty) + QCFuncElement("Kill", SystemNative_Kill) + QCFuncElement("LChflags", SystemNative_LChflags) + QCFuncElement("LChflagsCanSetHiddenFlag", SystemNative_LChflagsCanSetHiddenFlag) + QCFuncElement("Link", SystemNative_Link) + QCFuncElement("Listen", SystemNative_Listen) + QCFuncElement("LockFileRegion", SystemNative_LockFileRegion) + QCFuncElement("LSeek", SystemNative_LSeek) + QCFuncElement("LStat", SystemNative_LStat) + QCFuncElement("MAdvise", SystemNative_MAdvise) + QCFuncElement("MapTcpState", SystemNative_MapTcpState) + QCFuncElement("MemAlloc", SystemNative_MemAlloc) + QCFuncElement("MemFree", SystemNative_MemFree) + QCFuncElement("MemReAlloc", SystemNative_MemReAlloc) + QCFuncElement("MkDir", SystemNative_MkDir) + QCFuncElement("MksTemps", SystemNative_MksTemps) + QCFuncElement("MMap", SystemNative_MMap) + QCFuncElement("MSync", SystemNative_MSync) + QCFuncElement("MUnmap", SystemNative_MUnmap) + QCFuncElement("Open", SystemNative_Open) + QCFuncElement("OpenDir", SystemNative_OpenDir) + //trimmed + QCFuncElement("PathConf", SystemNative_PathConf) + QCFuncElement("Pipe", SystemNative_Pipe) + QCFuncElement("PlatformSupportsDualModeIPv4PacketInfo", SystemNative_PlatformSupportsDualModeIPv4PacketInfo) + QCFuncElement("Poll", SystemNative_Poll) + QCFuncElement("PosixFAdvise", SystemNative_PosixFAdvise) + QCFuncElement("Read", SystemNative_Read) + QCFuncElement("ReadDirR", SystemNative_ReadDirR) + +#if defined(__FreeBSD__) || defined(__linux__) + QCFuncElement("ReadEvents", SystemNative_ReadEvents) +#endif + + QCFuncElement("ReadLink", SystemNative_ReadLink) + QCFuncElement("ReadStdin", SystemNative_ReadStdin) + QCFuncElement("Receive", SystemNative_Receive) + QCFuncElement("ReceiveMessage", SystemNative_ReceiveMessage) + QCFuncElement("RegisterForCtrl", SystemNative_RegisterForCtrl) + QCFuncElement("RegisterForSigChld", SystemNative_RegisterForSigChld) + QCFuncElement("Rename", SystemNative_Rename) + QCFuncElement("RestoreAndHandleCtrl", SystemNative_RestoreAndHandleCtrl) + QCFuncElement("RmDir", SystemNative_RmDir) + +#if HAVE_SCHED_GETAFFINITY + QCFuncElement("SchedGetAffinity", SystemNative_SchedGetAffinity) +#endif + +#if HAVE_SCHED_SETAFFINITY + QCFuncElement("SchedSetAffinity", SystemNative_SchedSetAffinity) +#endif + + QCFuncElement("Send", SystemNative_Send) + QCFuncElement("SendFile", SystemNative_SendFile) + QCFuncElement("SendMessage", SystemNative_SendMessage) + QCFuncElement("SetAddressFamily", SystemNative_SetAddressFamily) + QCFuncElement("SetEUid", SystemNative_SetEUid) + QCFuncElement("SetIPv4Address", SystemNative_SetIPv4Address) + QCFuncElement("SetIPv4MulticastOption", SystemNative_SetIPv4MulticastOption) + QCFuncElement("SetIPv6Address", SystemNative_SetIPv6Address) + QCFuncElement("SetIPv6MulticastOption", SystemNative_SetIPv6MulticastOption) + QCFuncElement("SetKeypadXmit", SystemNative_SetKeypadXmit) + QCFuncElement("SetLingerOption", SystemNative_SetLingerOption) + QCFuncElement("SetPort", SystemNative_SetPort) + QCFuncElement("SetPriority", SystemNative_SetPriority) + QCFuncElement("SetRawSockOpt", SystemNative_SetRawSockOpt) + QCFuncElement("SetReceiveTimeout", SystemNative_SetReceiveTimeout) + QCFuncElement("SetSendTimeout", SystemNative_SetSendTimeout) + QCFuncElement("SetSignalForBreak", SystemNative_SetSignalForBreak) + QCFuncElement("SetSockOpt", SystemNative_SetSockOpt) + QCFuncElement("SetTerminalInvalidationHandler", SystemNative_SetTerminalInvalidationHandler) + QCFuncElement("ShmOpen", SystemNative_ShmOpen) + QCFuncElement("ShmUnlink", SystemNative_ShmUnlink) + QCFuncElement("Shutdown", SystemNative_Shutdown) + QCFuncElement("SNPrintF", SystemNative_SNPrintF) + QCFuncElement("Socket", SystemNative_Socket) + QCFuncElement("Stat", SystemNative_Stat) + QCFuncElement("StdinReady", SystemNative_StdinReady) + QCFuncElement("StrErrorR", SystemNative_StrErrorR) + QCFuncElement("SysConf", SystemNative_SysConf) + QCFuncElement("SysLog", SystemNative_SysLog) + QCFuncElement("TryChangeSocketEventRegistration", SystemNative_TryChangeSocketEventRegistration) + QCFuncElement("TryGetIPPacketInformation", SystemNative_TryGetIPPacketInformation) + QCFuncElement("UninitializeConsoleAfterRead", SystemNative_UninitializeConsoleAfterRead) + QCFuncElement("Unlink", SystemNative_Unlink) + QCFuncElement("UnregisterForCtrl", SystemNative_UnregisterForCtrl) + QCFuncElement("UTimensat", SystemNative_UTimensat) + QCFuncElement("WaitForSocketEvents", SystemNative_WaitForSocketEvents) + QCFuncElement("WaitIdAnyExitedNoHangNoWait", SystemNative_WaitIdAnyExitedNoHangNoWait) + QCFuncElement("WaitPidExitedNoHang", SystemNative_WaitPidExitedNoHang) + QCFuncElement("Write", SystemNative_Write) + + // trimmed + QCFuncElement("GetNodeName", SystemNative_GetNodeName) + // trimmed + QCFuncElement("RealPath", SystemNative_RealPath) + // trimmed + QCFuncElement("GetSid", SystemNative_GetSid) + + // OSX (bsd?) only +#if HAVE_NETINET_TCP_VAR_H + QCFuncElement("GetTcpGlobalStatistics", SystemNative_GetTcpGlobalStatistics) + QCFuncElement("GetIPv4GlobalStatistics", SystemNative_GetIPv4GlobalStatistics) + QCFuncElement("GetUdpGlobalStatistics", SystemNative_GetUdpGlobalStatistics) + QCFuncElement("GetIcmpv4GlobalStatistics", SystemNative_GetIcmpv4GlobalStatistics) + QCFuncElement("GetIcmpv6GlobalStatistics", SystemNative_GetIcmpv6GlobalStatistics) + QCFuncElement("GetEstimatedTcpConnectionCount", SystemNative_GetEstimatedTcpConnectionCount) + QCFuncElement("GetActiveTcpConnectionInfos", SystemNative_GetActiveTcpConnectionInfos) + QCFuncElement("GetEstimatedUdpListenerCount", SystemNative_GetEstimatedUdpListenerCount) + QCFuncElement("GetActiveUdpListeners", SystemNative_GetActiveUdpListeners) + QCFuncElement("GetNativeIPInterfaceStatistics", SystemNative_GetNativeIPInterfaceStatistics) + QCFuncElement("GetNumRoutes", SystemNative_GetNumRoutes) +#endif + + // trimmed + QCFuncElement("Sync", SystemNative_Sync) + + // trimmed + QCFuncElement("GetRLimit", SystemNative_GetRLimit) + + // trimmed + QCFuncElement("SetRLimit", SystemNative_SetRLimit) + + // new + QCFuncElement("GetProcessPath", SystemNative_GetProcessPath) + +#if HAVE_RT_MSGHDR + QCFuncElement("EnumerateGatewayAddressesForInterface", SystemNative_EnumerateGatewayAddressesForInterface) +#endif + +FCFuncEnd() + diff --git a/src/libraries/Native/Unix/System.Native/pal_log.h b/src/libraries/Native/Unix/System.Native/pal_log.h index 1e950cd0260b7d..fd6845fbb83574 100644 --- a/src/libraries/Native/Unix/System.Native/pal_log.h +++ b/src/libraries/Native/Unix/System.Native/pal_log.h @@ -7,3 +7,4 @@ #include "pal_types.h" PALEXPORT void SystemNative_Log(uint8_t* buffer, int32_t length); +PALEXPORT int32_t SystemNative_InitializeTerminalAndSignalHandling(void); diff --git a/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt index 6514f0eac52e76..4d31e5926f0fae 100644 --- a/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt @@ -25,22 +25,28 @@ set(NATIVEGSS_SOURCES pal_gssapi.c ) -add_library(System.Net.Security.Native - SHARED - ${NATIVEGSS_SOURCES} - ${VERSION_FILE_PATH} -) +if (GEN_SHARED_LIB) + add_library(System.Net.Security.Native + SHARED + ${NATIVEGSS_SOURCES} + ${VERSION_FILE_PATH} + ) +endif() add_library(System.Net.Security.Native-Static STATIC ${NATIVEGSS_SOURCES} + entrypoints.c ) set_target_properties(System.Net.Security.Native-Static PROPERTIES OUTPUT_NAME System.Net.Security.Native CLEAN_DIRECT_OUTPUT 1) -target_link_libraries(System.Net.Security.Native - ${LIBGSS} -) +if (GEN_SHARED_LIB) + target_link_libraries(System.Net.Security.Native + ${LIBGSS} + ) + + install_with_stripped_symbols (System.Net.Security.Native PROGRAMS .) +endif() -install_with_stripped_symbols (System.Net.Security.Native PROGRAMS .) -install (TARGETS System.Net.Security.Native-Static DESTINATION .) +install (TARGETS System.Net.Security.Native-Static DESTINATION ${STATIC_LIB_DESTINATION}) diff --git a/src/libraries/Native/Unix/System.Net.Security.Native/entrypoints.c b/src/libraries/Native/Unix/System.Net.Security.Native/entrypoints.c new file mode 100644 index 00000000000000..622181aa930fd7 --- /dev/null +++ b/src/libraries/Native/Unix/System.Net.Security.Native/entrypoints.c @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#include + +// Include System.Net.Security.Native headers +#include "pal_gssapi.h" + +#define FCFuncStart(name) EXTERN_C const void* name[]; const void* name[] = { +#define FCFuncEnd() (void*)0x01 /* FCFuncFlag_EndOfArray */ }; + +#define QCFuncElement(name,impl) \ + (void*)0x8 /* FCFuncFlag_QCall */, (void*)(impl), (void*)name, + +FCFuncStart(gEmbedded_NetSecurityNative) + QCFuncElement("AcceptSecContext", NetSecurityNative_AcceptSecContext) + QCFuncElement("AcquireAcceptorCred", NetSecurityNative_AcquireAcceptorCred) + QCFuncElement("DeleteSecContext", NetSecurityNative_DeleteSecContext) + QCFuncElement("DisplayMajorStatus", NetSecurityNative_DisplayMajorStatus) + QCFuncElement("DisplayMinorStatus", NetSecurityNative_DisplayMinorStatus) + QCFuncElement("GetUser", NetSecurityNative_GetUser) + QCFuncElement("ImportPrincipalName", NetSecurityNative_ImportPrincipalName) + QCFuncElement("ImportUserName", NetSecurityNative_ImportUserName) + QCFuncElement("InitiateCredSpNego", NetSecurityNative_InitiateCredSpNego) + QCFuncElement("InitiateCredWithPassword", NetSecurityNative_InitiateCredWithPassword) + QCFuncElement("InitSecContext", NetSecurityNative_InitSecContext) + QCFuncElement("InitSecContext", NetSecurityNative_InitSecContextEx) + QCFuncElement("IsNtlmInstalled", NetSecurityNative_IsNtlmInstalled) + QCFuncElement("ReleaseCred", NetSecurityNative_ReleaseCred) + QCFuncElement("ReleaseGssBuffer", NetSecurityNative_ReleaseGssBuffer) + QCFuncElement("ReleaseName", NetSecurityNative_ReleaseName) + QCFuncElement("Unwrap", NetSecurityNative_Unwrap) + QCFuncElement("Wrap", NetSecurityNative_Wrap) +FCFuncEnd() diff --git a/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.h b/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.h index cd7ff85cecad95..5c1fe55163ec6c 100644 --- a/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.h +++ b/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.h @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. #pragma once +#include "pal_config.h" #include "pal_compiler.h" #if HAVE_GSSFW_HEADERS || HAVE_HEIMDAL_HEADERS diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple/CMakeLists.txt b/src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple/CMakeLists.txt index 5a424ab6eaf70a..d8e985dcc0fb93 100644 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple/CMakeLists.txt @@ -29,11 +29,13 @@ if (CLR_CMAKE_TARGET_TVOS) add_definitions(-DTARGET_TVOS) endif() -add_library(System.Security.Cryptography.Native.Apple - SHARED - ${NATIVECRYPTO_SOURCES} - ${VERSION_FILE_PATH} -) +if (GEN_SHARED_LIB) + add_library(System.Security.Cryptography.Native.Apple + SHARED + ${NATIVECRYPTO_SOURCES} + ${VERSION_FILE_PATH} + ) +endif() add_library(System.Security.Cryptography.Native.Apple-Static STATIC @@ -42,10 +44,15 @@ add_library(System.Security.Cryptography.Native.Apple-Static set_target_properties(System.Security.Cryptography.Native.Apple-Static PROPERTIES OUTPUT_NAME System.Security.Cryptography.Native.Apple CLEAN_DIRECT_OUTPUT 1) -target_link_libraries(System.Security.Cryptography.Native.Apple - ${COREFOUNDATION_LIBRARY} - ${SECURITY_LIBRARY} -) +if (GEN_SHARED_LIB) + target_link_libraries(System.Security.Cryptography.Native.Apple + ${COREFOUNDATION_LIBRARY} + ${SECURITY_LIBRARY} + ) +endif() + +if (GEN_SHARED_LIB) + install_with_stripped_symbols (System.Security.Cryptography.Native.Apple PROGRAMS .) +endif() -install_with_stripped_symbols (System.Security.Cryptography.Native.Apple PROGRAMS .) -install (TARGETS System.Security.Cryptography.Native.Apple-Static DESTINATION .) +install (TARGETS System.Security.Cryptography.Native.Apple-Static DESTINATION ${STATIC_LIB_DESTINATION}) diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt index e59120b57223ca..505ba5141b6659 100644 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt @@ -84,46 +84,54 @@ endif() add_library(objlib OBJECT ${NATIVECRYPTO_SOURCES} ${VERSION_FILE_PATH}) -add_library(System.Security.Cryptography.Native.OpenSsl - SHARED - $ -) +if (GEN_SHARED_LIB) + add_library(System.Security.Cryptography.Native.OpenSsl + SHARED + $ + ) +endif() add_library(System.Security.Cryptography.Native.OpenSsl-Static STATIC $ + entrypoints.c ) set_target_properties(System.Security.Cryptography.Native.OpenSsl-Static PROPERTIES OUTPUT_NAME System.Security.Cryptography.Native.OpenSsl CLEAN_DIRECT_OUTPUT 1) -if (FEATURE_DISTRO_AGNOSTIC_SSL) - # on macOS the link step fails with undefined symbols, and the script doesn't run. - # if the build succeeds, the script would succeed, except it uses a Linux-only command. - # - # on Linux, the build will succeed with undefined symbols, then the script reports them - # and fails the build for us. - if (NOT APPLE) - add_custom_command(TARGET System.Security.Cryptography.Native.OpenSsl POST_BUILD - COMMENT "Verifying System.Security.Cryptography.Native.OpenSsl.so dependencies" - COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../verify-so.sh - $ - "Verification failed. System.Security.Cryptography.Native.OpenSsl.so has undefined dependencies. These are likely OpenSSL APIs that need to be added to opensslshim.h" - VERBATIM +if (GEN_SHARED_LIB) + if (FEATURE_DISTRO_AGNOSTIC_SSL) + # on macOS the link step fails with undefined symbols, and the script doesn't run. + # if the build succeeds, the script would succeed, except it uses a Linux-only command. + # + # on Linux, the build will succeed with undefined symbols, then the script reports them + # and fails the build for us. + if (NOT APPLE) + add_custom_command(TARGET System.Security.Cryptography.Native.OpenSsl POST_BUILD + COMMENT "Verifying System.Security.Cryptography.Native.OpenSsl.so dependencies" + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../verify-so.sh + $ + "Verification failed. System.Security.Cryptography.Native.OpenSsl.so has undefined dependencies. These are likely OpenSSL APIs that need to be added to opensslshim.h" + VERBATIM + ) + endif() + + # Link with libdl.so to get the dlopen / dlsym / dlclose + target_link_libraries(System.Security.Cryptography.Native.OpenSsl + dl + ) + else() + target_link_libraries(System.Security.Cryptography.Native.OpenSsl + ${OPENSSL_CRYPTO_LIBRARY} + ${OPENSSL_SSL_LIBRARY} ) endif() - - # Link with libdl.so to get the dlopen / dlsym / dlclose - target_link_libraries(System.Security.Cryptography.Native.OpenSsl - dl - ) -else() - target_link_libraries(System.Security.Cryptography.Native.OpenSsl - ${OPENSSL_CRYPTO_LIBRARY} - ${OPENSSL_SSL_LIBRARY} - ) endif() include(configure.cmake) -install_with_stripped_symbols (System.Security.Cryptography.Native.OpenSsl PROGRAMS .) -install (TARGETS System.Security.Cryptography.Native.OpenSsl-Static DESTINATION .) +if (GEN_SHARED_LIB) + install_with_stripped_symbols (System.Security.Cryptography.Native.OpenSsl PROGRAMS .) +endif() + +install (TARGETS System.Security.Cryptography.Native.OpenSsl-Static DESTINATION ${STATIC_LIB_DESTINATION}) diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native/entrypoints.c b/src/libraries/Native/Unix/System.Security.Cryptography.Native/entrypoints.c new file mode 100644 index 00000000000000..e98fd2cb3a21d3 --- /dev/null +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native/entrypoints.c @@ -0,0 +1,335 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#include + +// Include System.Security.Cryptography.Native headers +#include "openssl.h" +#include "pal_asn1.h" +#include "pal_bignum.h" +#include "pal_bio.h" +#include "pal_dsa.h" +#include "pal_ecc_import_export.h" +#include "pal_ecdsa.h" +#include "pal_eckey.h" +#include "pal_err.h" +#include "pal_evp.h" +#include "pal_evp_cipher.h" +#include "pal_evp_pkey.h" +#include "pal_evp_pkey_dsa.h" +#include "pal_evp_pkey_ecdh.h" +#include "pal_evp_pkey_eckey.h" +#include "pal_evp_pkey_rsa.h" +#include "pal_hmac.h" +#include "pal_ocsp.h" +#include "pal_pkcs7.h" +#include "pal_rsa.h" +#include "pal_ssl.h" +#include "pal_x509.h" +#include "pal_x509ext.h" +#include "pal_x509_name.h" +#include "pal_x509_root.h" + +#define FCFuncStart(name) EXTERN_C const void* name[]; const void* name[] = { +#define FCFuncEnd() (void*)0x01 /* FCFuncFlag_EndOfArray */ }; + +#define QCFuncElement(name,impl) \ + (void*)0x8 /* FCFuncFlag_QCall */, (void*)(impl), (void*)name, + +FCFuncStart(gEmbedded_Crypto) + QCFuncElement("Asn1BitStringFree", CryptoNative_Asn1BitStringFree) + QCFuncElement("Asn1ObjectFree", CryptoNative_Asn1ObjectFree) + QCFuncElement("Asn1OctetStringFree", CryptoNative_Asn1OctetStringFree) + QCFuncElement("Asn1OctetStringNew", CryptoNative_Asn1OctetStringNew) + QCFuncElement("Asn1OctetStringSet", CryptoNative_Asn1OctetStringSet) + QCFuncElement("BigNumDestroy", CryptoNative_BigNumDestroy) + QCFuncElement("BigNumFromBinary", CryptoNative_BigNumFromBinary) + QCFuncElement("BigNumToBinary", CryptoNative_BigNumToBinary) + QCFuncElement("BioCtrlPending", CryptoNative_BioCtrlPending) + QCFuncElement("BioDestroy", CryptoNative_BioDestroy) + QCFuncElement("BioGets", CryptoNative_BioGets) + QCFuncElement("BioNewFile", CryptoNative_BioNewFile) + QCFuncElement("BioRead", CryptoNative_BioRead) + QCFuncElement("BioSeek", CryptoNative_BioSeek) + QCFuncElement("CryptoNative_BioTell", CryptoNative_BioTell) + QCFuncElement("BioWrite", CryptoNative_BioWrite) + QCFuncElement("CheckX509Hostname", CryptoNative_CheckX509Hostname) + QCFuncElement("CheckX509IpAddress", CryptoNative_CheckX509IpAddress) + QCFuncElement("CreateMemoryBio", CryptoNative_CreateMemoryBio) + QCFuncElement("D2IPkcs7Bio", CryptoNative_D2IPkcs7Bio) + QCFuncElement("DecodeAsn1BitString", CryptoNative_DecodeAsn1BitString) + QCFuncElement("DecodeExtendedKeyUsage", CryptoNative_DecodeExtendedKeyUsage) + QCFuncElement("CryptoNative_DecodeOcspResponse", CryptoNative_DecodeOcspResponse) + QCFuncElement("DecodePkcs7", CryptoNative_DecodePkcs7) + QCFuncElement("DecodeRsaPublicKey", CryptoNative_DecodeRsaPublicKey) + QCFuncElement("DecodeX509", CryptoNative_DecodeX509) + QCFuncElement("DecodeX509BasicConstraints2Extension", CryptoNative_DecodeX509BasicConstraints2Extension) + QCFuncElement("DecodeX509Crl", CryptoNative_DecodeX509Crl) + QCFuncElement("DsaDestroy", CryptoNative_DsaDestroy) + QCFuncElement("DsaGenerateKey", CryptoNative_DsaGenerateKey) + QCFuncElement("DsaKeyCreateByExplicitParameters", CryptoNative_DsaKeyCreateByExplicitParameters) + QCFuncElement("DsaSign", CryptoNative_DsaSign) + QCFuncElement("DsaSizeP", CryptoNative_DsaSizeP) + QCFuncElement("DsaSizeQ", CryptoNative_DsaSizeQ) + QCFuncElement("DsaSizeSignature", CryptoNative_DsaSizeSignature) + QCFuncElement("DsaUpRef", CryptoNative_DsaUpRef) + QCFuncElement("DsaVerify", CryptoNative_DsaVerify) + QCFuncElement("EcDsaSign", CryptoNative_EcDsaSign) + QCFuncElement("CryptoNative_EcDsaSize", CryptoNative_EcDsaSize) + QCFuncElement("EcDsaVerify", CryptoNative_EcDsaVerify) + QCFuncElement("EcKeyCreateByExplicitParameters", CryptoNative_EcKeyCreateByExplicitParameters) + QCFuncElement("EcKeyCreateByKeyParameters", CryptoNative_EcKeyCreateByKeyParameters) + QCFuncElement("CryptoNative_EcKeyCreateByOid", CryptoNative_EcKeyCreateByOid) + QCFuncElement("EcKeyDestroy", CryptoNative_EcKeyDestroy) + QCFuncElement("EcKeyGenerateKey", CryptoNative_EcKeyGenerateKey) + QCFuncElement("CryptoNative_EcKeyGetCurveName", CryptoNative_EcKeyGetCurveName2) + QCFuncElement("CryptoNative_EcKeyGetSize", CryptoNative_EcKeyGetSize) + QCFuncElement("EcKeyUpRef", CryptoNative_EcKeyUpRef) + QCFuncElement("EncodeAsn1Integer", CryptoNative_EncodeAsn1Integer) + QCFuncElement("EncodeOcspRequest", CryptoNative_EncodeOcspRequest) + QCFuncElement("EncodePkcs7", CryptoNative_EncodePkcs7) + QCFuncElement("EncodeX509", CryptoNative_EncodeX509) + QCFuncElement("EncodeX509SubjectPublicKeyInfo", CryptoNative_EncodeX509SubjectPublicKeyInfo) + QCFuncElement("ErrClearError", CryptoNative_ErrClearError) + QCFuncElement("ErrErrorStringN", CryptoNative_ErrErrorStringN) + QCFuncElement("ErrGetErrorAlloc", CryptoNative_ErrGetErrorAlloc) + QCFuncElement("ErrPeekError", CryptoNative_ErrPeekError) + QCFuncElement("ErrPeekLastError", CryptoNative_ErrPeekLastError) + QCFuncElement("ErrReasonErrorString", CryptoNative_ErrReasonErrorString) + QCFuncElement("EvpAes128Cbc", CryptoNative_EvpAes128Cbc) + QCFuncElement("EvpAes128Ccm", CryptoNative_EvpAes128Ccm) + QCFuncElement("EvpAes128Cfb128", CryptoNative_EvpAes128Cfb128) + QCFuncElement("EvpAes128Cfb8", CryptoNative_EvpAes128Cfb8) + QCFuncElement("EvpAes128Ecb", CryptoNative_EvpAes128Ecb) + QCFuncElement("EvpAes128Gcm", CryptoNative_EvpAes128Gcm) + QCFuncElement("EvpAes192Cbc", CryptoNative_EvpAes192Cbc) + QCFuncElement("EvpAes192Ccm", CryptoNative_EvpAes192Ccm) + QCFuncElement("EvpAes192Cfb128", CryptoNative_EvpAes192Cfb128) + QCFuncElement("EvpAes192Cfb8", CryptoNative_EvpAes192Cfb8) + QCFuncElement("EvpAes192Ecb", CryptoNative_EvpAes192Ecb) + QCFuncElement("EvpAes192Gcm", CryptoNative_EvpAes192Gcm) + QCFuncElement("EvpAes256Cbc", CryptoNative_EvpAes256Cbc) + QCFuncElement("EvpAes256Ccm", CryptoNative_EvpAes256Ccm) + QCFuncElement("EvpAes256Cfb128", CryptoNative_EvpAes256Cfb128) + QCFuncElement("EvpAes256Cfb8", CryptoNative_EvpAes256Cfb8) + QCFuncElement("EvpAes256Ecb", CryptoNative_EvpAes256Ecb) + QCFuncElement("EvpAes256Gcm", CryptoNative_EvpAes256Gcm) + QCFuncElement("EvpCipherCreate", CryptoNative_EvpCipherCreate2) + QCFuncElement("EvpCipherCreatePartial", CryptoNative_EvpCipherCreatePartial) + QCFuncElement("EvpCipherCtxSetPadding", CryptoNative_EvpCipherCtxSetPadding) + QCFuncElement("EvpCipherDestroy", CryptoNative_EvpCipherDestroy) + QCFuncElement("EvpCipherFinalEx", CryptoNative_EvpCipherFinalEx) + QCFuncElement("EvpCipherGetCcmTag", CryptoNative_EvpCipherGetCcmTag) + QCFuncElement("EvpCipherGetGcmTag", CryptoNative_EvpCipherGetGcmTag) + QCFuncElement("EvpCipherReset", CryptoNative_EvpCipherReset) + QCFuncElement("CryptoNative_EvpCipherSetCcmNonceLength", CryptoNative_EvpCipherSetCcmNonceLength) + QCFuncElement("EvpCipherSetCcmTag", CryptoNative_EvpCipherSetCcmTag) + QCFuncElement("CryptoNative_EvpCipherSetGcmNonceLength", CryptoNative_EvpCipherSetGcmNonceLength) + QCFuncElement("EvpCipherSetGcmTag", CryptoNative_EvpCipherSetGcmTag) + QCFuncElement("EvpCipherSetKeyAndIV", CryptoNative_EvpCipherSetKeyAndIV) + QCFuncElement("EvpCipherUpdate", CryptoNative_EvpCipherUpdate) + QCFuncElement("EvpDes3Cbc", CryptoNative_EvpDes3Cbc) + QCFuncElement("EvpDes3Cfb64", CryptoNative_EvpDes3Cfb64) + QCFuncElement("EvpDes3Cfb8", CryptoNative_EvpDes3Cfb8) + QCFuncElement("EvpDes3Ecb", CryptoNative_EvpDes3Ecb) + QCFuncElement("EvpDesCbc", CryptoNative_EvpDesCbc) + QCFuncElement("EvpDesCfb8", CryptoNative_EvpDesCfb8) + QCFuncElement("EvpDesEcb", CryptoNative_EvpDesEcb) + QCFuncElement("EvpDigestCurrent", CryptoNative_EvpDigestCurrent) + QCFuncElement("EvpDigestFinalEx", CryptoNative_EvpDigestFinalEx) + QCFuncElement("EvpDigestOneShot", CryptoNative_EvpDigestOneShot) + QCFuncElement("EvpDigestReset", CryptoNative_EvpDigestReset) + QCFuncElement("EvpDigestUpdate", CryptoNative_EvpDigestUpdate) + QCFuncElement("EvpMd5", CryptoNative_EvpMd5) + QCFuncElement("EvpMdCtxCreate", CryptoNative_EvpMdCtxCreate) + QCFuncElement("EvpMdCtxDestroy", CryptoNative_EvpMdCtxDestroy) + QCFuncElement("EvpMdSize", CryptoNative_EvpMdSize) + QCFuncElement("EvpPkeyCreate", CryptoNative_EvpPkeyCreate) + QCFuncElement("EvpPKeyCtxCreate", CryptoNative_EvpPKeyCtxCreate) + QCFuncElement("EvpPKeyCtxDestroy", CryptoNative_EvpPKeyCtxDestroy) + QCFuncElement("EvpPKeyDeriveSecretAgreement", CryptoNative_EvpPKeyDeriveSecretAgreement) + QCFuncElement("EvpPkeyDestroy", CryptoNative_EvpPkeyDestroy) + QCFuncElement("EvpPkeyGetDsa", CryptoNative_EvpPkeyGetDsa) + QCFuncElement("EvpPkeyGetEcKey", CryptoNative_EvpPkeyGetEcKey) + QCFuncElement("EvpPkeyGetRsa", CryptoNative_EvpPkeyGetRsa) + QCFuncElement("EvpPkeySetDsa", CryptoNative_EvpPkeySetDsa) + QCFuncElement("EvpPkeySetEcKey", CryptoNative_EvpPkeySetEcKey) + QCFuncElement("EvpPkeySetRsa", CryptoNative_EvpPkeySetRsa) + QCFuncElement("EvpRC2Cbc", CryptoNative_EvpRC2Cbc) + QCFuncElement("EvpRC2Ecb", CryptoNative_EvpRC2Ecb) + QCFuncElement("EvpSha1", CryptoNative_EvpSha1) + QCFuncElement("EvpSha256", CryptoNative_EvpSha256) + QCFuncElement("EvpSha384", CryptoNative_EvpSha384) + QCFuncElement("EvpSha512", CryptoNative_EvpSha512) + QCFuncElement("ExtendedKeyUsageDestory", CryptoNative_ExtendedKeyUsageDestory) + QCFuncElement("GetAsn1IntegerDerSize", CryptoNative_GetAsn1IntegerDerSize) + QCFuncElement("GetAsn1StringBytes", CryptoNative_GetAsn1StringBytes) + QCFuncElement("GetBigNumBytes", CryptoNative_GetBigNumBytes) + QCFuncElement("GetDsaParameters", CryptoNative_GetDsaParameters) + QCFuncElement("CryptoNative_GetECCurveParameters", CryptoNative_GetECCurveParameters) + QCFuncElement("CryptoNative_GetECKeyParameters", CryptoNative_GetECKeyParameters) + QCFuncElement("GetMaxMdSize", CryptoNative_GetMaxMdSize) + QCFuncElement("GetMemoryBioSize", CryptoNative_GetMemoryBioSize) + QCFuncElement("CryptoNative_GetObjectDefinitionByName", CryptoNative_GetObjectDefinitionByName) + QCFuncElement("GetOcspRequestDerSize", CryptoNative_GetOcspRequestDerSize) + QCFuncElement("GetPkcs7Certificates", CryptoNative_GetPkcs7Certificates) + QCFuncElement("GetPkcs7DerSize", CryptoNative_GetPkcs7DerSize) + QCFuncElement("CryptoNative_GetRandomBytes", CryptoNative_GetRandomBytes) + QCFuncElement("GetRsaParameters", CryptoNative_GetRsaParameters) + QCFuncElement("GetX509CrlNextUpdate", CryptoNative_GetX509CrlNextUpdate) + QCFuncElement("GetX509DerSize", CryptoNative_GetX509DerSize) + QCFuncElement("GetX509EkuField", CryptoNative_GetX509EkuField) + QCFuncElement("GetX509EkuFieldCount", CryptoNative_GetX509EkuFieldCount) + QCFuncElement("GetX509EvpPublicKey", CryptoNative_GetX509EvpPublicKey) + QCFuncElement("GetX509NameInfo", CryptoNative_GetX509NameInfo) + QCFuncElement("GetX509NameRawBytes", CryptoNative_GetX509NameRawBytes) + QCFuncElement("GetX509NameStackField_private", CryptoNative_GetX509NameStackField) + QCFuncElement("GetX509NameStackFieldCount", CryptoNative_GetX509NameStackFieldCount) + QCFuncElement("GetX509NotAfter", CryptoNative_GetX509NotAfter) + QCFuncElement("GetX509NotBefore", CryptoNative_GetX509NotBefore) + QCFuncElement("GetX509PublicKeyAlgorithm", CryptoNative_GetX509PublicKeyAlgorithm) + QCFuncElement("GetX509PublicKeyBytes", CryptoNative_GetX509PublicKeyBytes) + QCFuncElement("GetX509PublicKeyParameterBytes", CryptoNative_GetX509PublicKeyParameterBytes) + QCFuncElement("GetX509RootStoreFile_private", CryptoNative_GetX509RootStoreFile) + QCFuncElement("GetX509RootStorePath_private", CryptoNative_GetX509RootStorePath) + QCFuncElement("GetX509SignatureAlgorithm", CryptoNative_GetX509SignatureAlgorithm) + QCFuncElement("GetX509StackField", CryptoNative_GetX509StackField) + QCFuncElement("GetX509StackFieldCount", CryptoNative_GetX509StackFieldCount) + QCFuncElement("GetX509SubjectPublicKeyInfoDerSize", CryptoNative_GetX509SubjectPublicKeyInfoDerSize) + QCFuncElement("GetX509Thumbprint", CryptoNative_GetX509Thumbprint) + QCFuncElement("GetX509Version", CryptoNative_GetX509Version) + QCFuncElement("HmacCreate", CryptoNative_HmacCreate) + QCFuncElement("HmacCurrent", CryptoNative_HmacCurrent) + QCFuncElement("HmacDestroy", CryptoNative_HmacDestroy) + QCFuncElement("HmacFinal", CryptoNative_HmacFinal) + QCFuncElement("HmacReset", CryptoNative_HmacReset) + QCFuncElement("HmacUpdate", CryptoNative_HmacUpdate) + QCFuncElement("LookupFriendlyNameByOid", CryptoNative_LookupFriendlyNameByOid) + QCFuncElement("NewX509Stack", CryptoNative_NewX509Stack) + QCFuncElement("ObjNid2Obj", CryptoNative_ObjNid2Obj) + QCFuncElement("ObjObj2Txt", CryptoNative_ObjObj2Txt) + QCFuncElement("ObjSn2Nid", CryptoNative_ObjSn2Nid) + QCFuncElement("ObjTxt2Nid", CryptoNative_ObjTxt2Nid) + QCFuncElement("ObjTxt2Obj", CryptoNative_ObjTxt2Obj) + QCFuncElement("OcspRequestDestroy", CryptoNative_OcspRequestDestroy) + QCFuncElement("OcspResponseDestroy", CryptoNative_OcspResponseDestroy) + QCFuncElement("PemReadBioPkcs7", CryptoNative_PemReadBioPkcs7) + QCFuncElement("PemReadBioX509Crl", CryptoNative_PemReadBioX509Crl) + QCFuncElement("PemReadX509FromBio", CryptoNative_PemReadX509FromBio) + QCFuncElement("PemReadX509FromBioAux", CryptoNative_PemReadX509FromBioAux) + QCFuncElement("PemWriteBioX509Crl", CryptoNative_PemWriteBioX509Crl) + QCFuncElement("Pkcs7CreateCertificateCollection", CryptoNative_Pkcs7CreateCertificateCollection) + QCFuncElement("Pkcs7Destroy", CryptoNative_Pkcs7Destroy) + QCFuncElement("PushX509StackField", CryptoNative_PushX509StackField) + QCFuncElement("ReadX509AsDerFromBio", CryptoNative_ReadX509AsDerFromBio) + QCFuncElement("RecursiveFreeX509Stack", CryptoNative_RecursiveFreeX509Stack) + QCFuncElement("RsaCreate", CryptoNative_RsaCreate) + QCFuncElement("RsaDestroy", CryptoNative_RsaDestroy) + QCFuncElement("RsaGenerateKeyEx", CryptoNative_RsaGenerateKeyEx) + QCFuncElement("RsaPrivateDecrypt", CryptoNative_RsaPrivateDecrypt) + QCFuncElement("RsaPublicEncrypt", CryptoNative_RsaPublicEncrypt) + QCFuncElement("RsaSign", CryptoNative_RsaSign) + QCFuncElement("RsaSignPrimitive", CryptoNative_RsaSignPrimitive) + QCFuncElement("RsaSize", CryptoNative_RsaSize) + QCFuncElement("RsaUpRef", CryptoNative_RsaUpRef) + QCFuncElement("RsaVerificationPrimitive", CryptoNative_RsaVerificationPrimitive) + QCFuncElement("RsaVerify", CryptoNative_RsaVerify) + QCFuncElement("SetRsaParameters", CryptoNative_SetRsaParameters) + QCFuncElement("UpRefEvpPkey", CryptoNative_UpRefEvpPkey) + QCFuncElement("CryptoNative_X509ChainBuildOcspRequest", CryptoNative_X509ChainBuildOcspRequest) + QCFuncElement("CryptoNative_X509ChainGetCachedOcspStatus", CryptoNative_X509ChainGetCachedOcspStatus) + QCFuncElement("CryptoNative_X509ChainNew", CryptoNative_X509ChainNew) + QCFuncElement("CryptoNative_X509ChainVerifyOcsp", CryptoNative_X509ChainVerifyOcsp) + QCFuncElement("X509CheckPurpose", CryptoNative_X509CheckPurpose) + QCFuncElement("X509CrlDestroy", CryptoNative_X509CrlDestroy) + QCFuncElement("X509Destroy", CryptoNative_X509Destroy) + QCFuncElement("X509ExtensionCreateByObj", CryptoNative_X509ExtensionCreateByObj) + QCFuncElement("X509ExtensionDestroy", CryptoNative_X509ExtensionDestroy) + QCFuncElement("X509ExtensionGetCritical", CryptoNative_X509ExtensionGetCritical) + QCFuncElement("X509ExtensionGetData", CryptoNative_X509ExtensionGetData) + QCFuncElement("X509ExtensionGetOid", CryptoNative_X509ExtensionGetOid) + QCFuncElement("CryptoNative_X509FindExtensionData", CryptoNative_X509FindExtensionData) + QCFuncElement("X509GetExt", CryptoNative_X509GetExt) + QCFuncElement("X509GetExtCount", CryptoNative_X509GetExtCount) + QCFuncElement("X509GetIssuerName", CryptoNative_X509GetIssuerName) + QCFuncElement("X509GetSerialNumber_private", CryptoNative_X509GetSerialNumber) + QCFuncElement("X509GetSubjectName", CryptoNative_X509GetSubjectName) + QCFuncElement("X509IssuerNameHash", CryptoNative_X509IssuerNameHash) + QCFuncElement("CryptoNative_X509StackAddDirectoryStore", CryptoNative_X509StackAddDirectoryStore) + QCFuncElement("CryptoNative_X509StackAddMultiple", CryptoNative_X509StackAddMultiple) + QCFuncElement("X509StoreAddCrl", CryptoNative_X509StoreAddCrl) + QCFuncElement("CryptoNative_X509StoreCtxCommitToChain", CryptoNative_X509StoreCtxCommitToChain) + QCFuncElement("X509StoreCtxCreate", CryptoNative_X509StoreCtxCreate) + QCFuncElement("X509StoreCtxDestroy", CryptoNative_X509StoreCtxDestroy) + QCFuncElement("X509StoreCtxGetChain", CryptoNative_X509StoreCtxGetChain) + QCFuncElement("X509StoreCtxGetCurrentCert", CryptoNative_X509StoreCtxGetCurrentCert) + QCFuncElement("X509StoreCtxGetError", CryptoNative_X509StoreCtxGetError) + QCFuncElement("X509StoreCtxGetErrorDepth", CryptoNative_X509StoreCtxGetErrorDepth) + QCFuncElement("X509StoreCtxGetSharedUntrusted_private", CryptoNative_X509StoreCtxGetSharedUntrusted) + QCFuncElement("X509StoreCtxInit", CryptoNative_X509StoreCtxInit) + QCFuncElement("CryptoNative_X509StoreCtxRebuildChain", CryptoNative_X509StoreCtxRebuildChain) + QCFuncElement("CryptoNative_X509StoreCtxReset", CryptoNative_X509StoreCtxReset) + QCFuncElement("CryptoNative_X509StoreCtxResetForSignatureError", CryptoNative_X509StoreCtxResetForSignatureError) + QCFuncElement("X509StoreCtxSetVerifyCallback", CryptoNative_X509StoreCtxSetVerifyCallback) + QCFuncElement("X509StoreDestory", CryptoNative_X509StoreDestory) + QCFuncElement("CryptoNative_X509StoreSetRevocationFlag", CryptoNative_X509StoreSetRevocationFlag) + QCFuncElement("CryptoNative_X509StoreSetVerifyTime", CryptoNative_X509StoreSetVerifyTime) + QCFuncElement("X509UpRef", CryptoNative_X509UpRef) + QCFuncElement("X509V3ExtPrint", CryptoNative_X509V3ExtPrint) + QCFuncElement("CryptoNative_X509VerifyCert", CryptoNative_X509VerifyCert) + QCFuncElement("X509VerifyCertErrorString", CryptoNative_X509VerifyCertErrorString) +FCFuncEnd() + +FCFuncStart(gEmbedded_CryptoInitializer) + QCFuncElement("EnsureOpenSslInitialized", CryptoNative_EnsureOpenSslInitialized) +FCFuncEnd() + +FCFuncStart(gEmbedded_OpenSsl) + // trimmed + QCFuncElement("OpenSslGetProtocolSupport", CryptoNative_OpenSslGetProtocolSupport) + QCFuncElement("OpenSslVersionNumber", CryptoNative_OpenSslVersionNumber) +FCFuncEnd() + +FCFuncStart(gEmbedded_Ssl) + QCFuncElement("BioWrite", CryptoNative_BioWrite) + QCFuncElement("EnsureLibSslInitialized", CryptoNative_EnsureLibSslInitialized) + QCFuncElement("GetOpenSslCipherSuiteName", CryptoNative_GetOpenSslCipherSuiteName) + QCFuncElement("IsSslRenegotiatePending", CryptoNative_IsSslRenegotiatePending) + QCFuncElement("IsSslStateOK", CryptoNative_IsSslStateOK) + QCFuncElement("SetCiphers", CryptoNative_SetCiphers) + QCFuncElement("SetEncryptionPolicy", CryptoNative_SetEncryptionPolicy) + QCFuncElement("SetProtocolOptions", CryptoNative_SetProtocolOptions) + QCFuncElement("SslAddExtraChainCert", CryptoNative_SslAddExtraChainCert) + QCFuncElement("SslCreate", CryptoNative_SslCreate) + QCFuncElement("SslCtxCheckPrivateKey", CryptoNative_SslCtxCheckPrivateKey) + QCFuncElement("SslCtxCreate", CryptoNative_SslCtxCreate) + QCFuncElement("SslCtxDestroy", CryptoNative_SslCtxDestroy) + QCFuncElement("SslCtxSetAlpnProtos", CryptoNative_SslCtxSetAlpnProtos) + QCFuncElement("SslCtxSetAlpnSelectCb", CryptoNative_SslCtxSetAlpnSelectCb) + QCFuncElement("SslCtxSetQuietShutdown", CryptoNative_SslCtxSetQuietShutdown) + QCFuncElement("SslCtxSetVerify", CryptoNative_SslCtxSetVerify) + QCFuncElement("SslCtxUseCertificate", CryptoNative_SslCtxUseCertificate) + QCFuncElement("SslCtxUsePrivateKey", CryptoNative_SslCtxUsePrivateKey) + QCFuncElement("SslDestroy", CryptoNative_SslDestroy) + QCFuncElement("SslDoHandshake", CryptoNative_SslDoHandshake) + QCFuncElement("SslGetAlpnSelected", CryptoNative_SslGet0AlpnSelected) + QCFuncElement("SslGetClientCAList_private", CryptoNative_SslGetClientCAList) + QCFuncElement("SslGetCurrentCipherId", CryptoNative_SslGetCurrentCipherId) + QCFuncElement("SslGetError", CryptoNative_SslGetError) + QCFuncElement("SslGetFinished", CryptoNative_SslGetFinished) + QCFuncElement("SslGetPeerCertChain", CryptoNative_SslGetPeerCertChain) + QCFuncElement("SslGetPeerCertificate", CryptoNative_SslGetPeerCertificate) + QCFuncElement("SslGetPeerFinished", CryptoNative_SslGetPeerFinished) + QCFuncElement("SslGetVersion", CryptoNative_SslGetVersion) + QCFuncElement("SslRead", CryptoNative_SslRead) + QCFuncElement("SslSessionReused", CryptoNative_SslSessionReused) + QCFuncElement("SslSetAcceptState", CryptoNative_SslSetAcceptState) + QCFuncElement("SslSetBio", CryptoNative_SslSetBio) + QCFuncElement("SslSetConnectState", CryptoNative_SslSetConnectState) + QCFuncElement("SslSetQuietShutdown", CryptoNative_SslSetQuietShutdown) + QCFuncElement("SslSetTlsExtHostName", CryptoNative_SslSetTlsExtHostName) + QCFuncElement("SslShutdown", CryptoNative_SslShutdown) + QCFuncElement("SslV2_3Method", CryptoNative_SslV2_3Method) + QCFuncElement("SslWrite", CryptoNative_SslWrite) + QCFuncElement("Tls13SupportedImpl", CryptoNative_Tls13Supported) +FCFuncEnd() diff --git a/src/libraries/Native/Windows/CMakeLists.txt b/src/libraries/Native/Windows/CMakeLists.txt index 6343b3f5f20bff..1f5380173f40d0 100644 --- a/src/libraries/Native/Windows/CMakeLists.txt +++ b/src/libraries/Native/Windows/CMakeLists.txt @@ -23,6 +23,14 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") message(FATAL_ERROR "Binary directory isn't being correctly set before calling Cmake. Tree must be built in separate directory from source.") endif() +if(STATIC_LIBS_ONLY) + set(GEN_SHARED_LIB 0) + set(STATIC_LIB_DESTINATION lib) +else() + set(GEN_SHARED_LIB 1) + set(STATIC_LIB_DESTINATION .) +endif() + project(CoreFX) # The following options are set by the razzle build diff --git a/src/libraries/Native/Windows/clrcompression/CMakeLists.txt b/src/libraries/Native/Windows/clrcompression/CMakeLists.txt index 5ac67d5edbe574..9566e381d88ec1 100644 --- a/src/libraries/Native/Windows/clrcompression/CMakeLists.txt +++ b/src/libraries/Native/Windows/clrcompression/CMakeLists.txt @@ -5,7 +5,10 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") endif() set(CMAKE_INCLUDE_CURRENT_DIR ON) -include (GenerateExportHeader) + +if (GEN_SHARED_LIB) + include (GenerateExportHeader) +endif() if($ENV{__BuildArch} STREQUAL x86 OR $ENV{__BuildArch} STREQUAL x64) set(NATIVECOMPRESSION_SOURCES @@ -71,18 +74,21 @@ set (NATIVECOMPRESSION_SOURCES ../../AnyOS/brotli/enc/metablock.c ../../AnyOS/brotli/enc/static_dict.c ../../AnyOS/brotli/enc/utf8_util.c - clrcompression.def + ../../AnyOS/System.IO.Compression.Native/entrypoints.c ) #Include Brotli include files include_directories("../../AnyOS/brotli/include") -add_library(clrcompression - SHARED - ${NATIVECOMPRESSION_SOURCES} - # This will add versioning to the library - ${CMAKE_REPO_ROOT}/artifacts/obj/NativeVersion.rc -) +if (GEN_SHARED_LIB) + add_library(clrcompression + SHARED + ${NATIVECOMPRESSION_SOURCES} + clrcompression.def + # This will add versioning to the library + ${CMAKE_REPO_ROOT}/artifacts/obj/NativeVersion.rc + ) +endif() add_library(clrcompression-static STATIC @@ -93,21 +99,28 @@ SET_TARGET_PROPERTIES(clrcompression-static PROPERTIES PREFIX "") SET_TARGET_PROPERTIES(clrcompression-static PROPERTIES OUTPUT_NAME libclrcompression) # Allow specification of arguments that should be passed to the linker -SET_TARGET_PROPERTIES(clrcompression PROPERTIES LINK_OPTIONS "${__LinkArgs};${__SharedLinkArgs}") +if (GEN_SHARED_LIB) + SET_TARGET_PROPERTIES(clrcompression PROPERTIES LINK_OPTIONS "${__LinkArgs};${__SharedLinkArgs}") +endif() SET_TARGET_PROPERTIES(clrcompression-static PROPERTIES STATIC_LIBRARY_OPTIONS "${__LinkArgs}") # Allow specification of libraries that should be linked against -target_link_libraries(clrcompression ${__LinkLibraries}) +if (GEN_SHARED_LIB) + target_link_libraries(clrcompression ${__LinkLibraries}) +endif() target_link_libraries(clrcompression-static ${__LinkLibraries}) -GENERATE_EXPORT_HEADER( clrcompression - BASE_NAME clrcompression - EXPORT_MACRO_NAME clrcompression_EXPORT - EXPORT_FILE_NAME clrcompression_Export.h - STATIC_DEFINE clrcompression_BUILT_AS_STATIC -) +if (GEN_SHARED_LIB) + GENERATE_EXPORT_HEADER( clrcompression + BASE_NAME clrcompression + EXPORT_MACRO_NAME clrcompression_EXPORT + EXPORT_FILE_NAME clrcompression_Export.h + STATIC_DEFINE clrcompression_BUILT_AS_STATIC + ) + + install (TARGETS clrcompression DESTINATION .) + install (FILES $ DESTINATION .) +endif() -install (TARGETS clrcompression DESTINATION .) -install (TARGETS clrcompression-static DESTINATION .) -install (FILES $ DESTINATION .) +install (TARGETS clrcompression-static DESTINATION ${STATIC_LIB_DESTINATION}) diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.cs index 2a7d67888c3291..53497b6b75c2ec 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.cs @@ -41,7 +41,7 @@ public void TestModulesContainsUnixNativeLibs() { ProcessModuleCollection modules = Process.GetCurrentProcess().Modules; Assert.Contains(modules.Cast(), m => m.FileName.Contains("libcoreclr")); - Assert.Contains(modules.Cast(), m => m.FileName.Contains("System.Native")); + // Assert.Contains(modules.Cast(), m => m.FileName.Contains("System.Native")); } [Fact] diff --git a/src/libraries/System.Security.Cryptography.Algorithms/tests/DefaultECDsaProvider.Unix.cs b/src/libraries/System.Security.Cryptography.Algorithms/tests/DefaultECDsaProvider.Unix.cs index 53e9198720360b..bdd7d6c1d48b9c 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/tests/DefaultECDsaProvider.Unix.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/tests/DefaultECDsaProvider.Unix.cs @@ -57,7 +57,8 @@ internal static partial class Interop internal static partial class Crypto { [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyCreateByOid")] - internal static extern System.IntPtr EcKeyCreateByOid(string oid); + private static extern System.IntPtr CryptoNative_EcKeyCreateByOid(string oid); + internal static System.IntPtr EcKeyCreateByOid(string oid) => CryptoNative_EcKeyCreateByOid(oid); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyDestroy")] internal static extern void EcKeyDestroy(System.IntPtr r); diff --git a/src/libraries/System.Security.Cryptography.OpenSsl/tests/EcDsaOpenSslTests.cs b/src/libraries/System.Security.Cryptography.OpenSsl/tests/EcDsaOpenSslTests.cs index 800362ef1840de..aa69fd106ee9ac 100644 --- a/src/libraries/System.Security.Cryptography.OpenSsl/tests/EcDsaOpenSslTests.cs +++ b/src/libraries/System.Security.Cryptography.OpenSsl/tests/EcDsaOpenSslTests.cs @@ -305,7 +305,8 @@ internal static partial class Interop internal static class Crypto { [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyCreateByOid")] - internal static extern IntPtr EcKeyCreateByOid(string oid); + private static extern IntPtr CryptoNative_EcKeyCreateByOid(string oid); + internal static IntPtr EcKeyCreateByOid(string oid) => CryptoNative_EcKeyCreateByOid(oid); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyGenerateKey")] internal static extern int EcKeyGenerateKey(IntPtr ecKey); diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/tests/HostnameMatchTests.Unix.cs b/src/libraries/System.Security.Cryptography.X509Certificates/tests/HostnameMatchTests.Unix.cs index a83611cee154c2..32adec1d4c57e0 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/tests/HostnameMatchTests.Unix.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/tests/HostnameMatchTests.Unix.cs @@ -181,13 +181,19 @@ private static string FixCase(string input, bool flatten) private static bool CheckHostname(X509Certificate2 cert, string targetName) { - int value = CheckX509Hostname(cert.Handle, targetName, targetName.Length); + int value = Interop.Crypto.CheckX509Hostname(cert.Handle, targetName, targetName.Length); GC.KeepAlive(cert); Assert.InRange(value, 0, 1); return value != 0; } + } +} +internal static partial class Interop +{ + internal static partial class Crypto + { [DllImport(Interop.Libraries.CryptoNative, EntryPoint = "CryptoNative_CheckX509Hostname")] - private static extern int CheckX509Hostname(IntPtr x509, string hostname, int cchHostname); + internal static extern int CheckX509Hostname(System.IntPtr x509, string hostname, int cchHostname); } } From 4adfaa6b3ef5192caf28179aaf695f72569a3189 Mon Sep 17 00:00:00 2001 From: vsadov Date: Thu, 12 Nov 2020 14:39:58 -0800 Subject: [PATCH 02/32] fix OSX --- src/coreclr/tryrun.cmake | 2 ++ .../cli/apphost/static/CMakeLists.txt | 22 ++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/coreclr/tryrun.cmake b/src/coreclr/tryrun.cmake index a26794aa8f0c6c..2cfd798c5d7c10 100644 --- a/src/coreclr/tryrun.cmake +++ b/src/coreclr/tryrun.cmake @@ -31,6 +31,7 @@ if(DARWIN) set_cache_value(HAVE_BROKEN_FIFO_SELECT_EXITCODE 1) set_cache_value(HAVE_CLOCK_MONOTONIC_COARSE_EXITCODE 1) set_cache_value(HAVE_CLOCK_MONOTONIC_EXITCODE 0) + set_cache_value(HAVE_CLOCK_REALTIME_EXITCODE 0) set_cache_value(HAVE_CLOCK_THREAD_CPUTIME_EXITCODE 0) set_cache_value(HAVE_CLOCK_GETTIME_NSEC_NP_EXITCODE 0) set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 0) @@ -63,6 +64,7 @@ if(DARWIN) set_cache_value(SSCANF_CANNOT_HANDLE_MISSING_EXPONENT_EXITCODE 1) set_cache_value(SSCANF_SUPPORT_ll_EXITCODE 0) set_cache_value(UNGETC_NOT_RETURN_EOF_EXITCODE 1) + set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP_EXITCODE 0) else() message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only arm64 or x64 is supported for OSX cross build!") endif() diff --git a/src/installer/corehost/cli/apphost/static/CMakeLists.txt b/src/installer/corehost/cli/apphost/static/CMakeLists.txt index 661a4dc1b36411..dbef445c6bda86 100644 --- a/src/installer/corehost/cli/apphost/static/CMakeLists.txt +++ b/src/installer/corehost/cli/apphost/static/CMakeLists.txt @@ -138,6 +138,18 @@ else() ${CORECLR_STATIC_LIB_LOCATION}/libeventprovider.a ${CORECLR_STATIC_LIB_LOCATION}/libnativeresourcestring.a ) + + # additional requirements for System.IO.Compression.Native + if (CLR_CMAKE_TARGET_BROWSER) + add_definitions(-s USE_ZLIB) + elseif (CLR_CMAKE_TARGET_ANDROID) + # need special case here since we want to link against libz.so but find_package() would resolve libz.a + set(ZLIB_LIBRARIES z) + elseif (CLR_CMAKE_TARGET_SUNOS) + set(ZLIB_LIBRARIES z m) + else () + find_package(ZLIB REQUIRED) + endif () endif() if(CLR_CMAKE_TARGET_OSX) @@ -193,16 +205,6 @@ else() ${NATIVE_LIBS_LOCATION}/libSystem.Security.Cryptography.Native.OpenSsl.a ) - find_package(ZLIB REQUIRED) - - # Additional requirements for System.System.IO.Compression.Native - # - # if (CLR_CMAKE_TARGET_SUNOS) - # set(ZLIB_LIBRARIES z m) - # elseif (CLR_CMAKE_TARGET_UNIX) - # find_package(ZLIB REQUIRED) - # endif () - # Additional requirements for System.Net.Security.Native if (HAVE_GSSFW_HEADERS) find_library(LIBGSS NAMES GSS) From 0facc65d6bf7cd6ae269ff8db08861b0b5c5202e Mon Sep 17 00:00:00 2001 From: vsadov Date: Mon, 16 Nov 2020 10:57:36 -0800 Subject: [PATCH 03/32] fix for Android --- eng/native/build-commons.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index edb4f07097df2d..7b604d319a083b 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -464,7 +464,7 @@ elif [[ "$__TargetOS" == iOS ]]; then elif [[ "$__TargetOS" == tvOS ]]; then # nothing to do here true -elif [[ "$__TargetOS" == Android && -z "$ROOTFS_DIR" ]]; then +elif [[ "$__TargetOS" == Android ]]; then # nothing to do here true else From a2ab07cd69840f09065e8802d5866f2867ea5b3f Mon Sep 17 00:00:00 2001 From: vsadov Date: Tue, 17 Nov 2020 13:37:01 -0800 Subject: [PATCH 04/32] treat "libSystem.Globalization.Native" as QCall in mono too (for now). --- src/mono/mono/metadata/native-library.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/metadata/native-library.c b/src/mono/mono/metadata/native-library.c index 2176315c667692..cc0c191415bdc3 100644 --- a/src/mono/mono/metadata/native-library.c +++ b/src/mono/mono/metadata/native-library.c @@ -1323,7 +1323,7 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou /* If qcalls are disabled, we fall back to the normal pinvoke code for them */ #ifndef DISABLE_QCALLS - if (strcmp (new_scope, "QCall") == 0) { + if (strcmp (new_scope, "QCall") == 0 || strcmp(new_scope, "libSystem.Globalization.Native") == 0) { piinfo->addr = mono_lookup_pinvoke_qcall_internal (method, status_out); if (!piinfo->addr) { mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_DLLIMPORT, From 2b2f800a704e80778bf09fa14264fdd71edb6c59 Mon Sep 17 00:00:00 2001 From: vsadov Date: Thu, 19 Nov 2020 12:37:27 -0800 Subject: [PATCH 05/32] fix for wasm --- src/mono/wasm/wasm.proj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/wasm.proj b/src/mono/wasm/wasm.proj index 035c141f75b941..896fefde24d7e0 100644 --- a/src/mono/wasm/wasm.proj +++ b/src/mono/wasm/wasm.proj @@ -35,7 +35,7 @@ - + From 8c4e51485eb72d484a6b208481bf1ef830b3620c Mon Sep 17 00:00:00 2001 From: vsadov Date: Thu, 19 Nov 2020 19:59:23 -0800 Subject: [PATCH 06/32] current --- .../src/dlls/mscoree/unixinterface.cpp | 12 ++++ src/coreclr/src/inc/pinvokeoverride.h | 26 +++++++ src/coreclr/src/inc/pinvokeoverrideimpl.h | 12 ++++ src/coreclr/src/vm/CMakeLists.txt | 2 + src/coreclr/src/vm/corelib.cpp | 5 -- src/coreclr/src/vm/dllimport.cpp | 16 +++-- src/coreclr/src/vm/ecalllist.h | 10 --- src/coreclr/src/vm/pinvokeoverride.cpp | 24 +++++++ src/coreclr/src/vm/pinvokeoverrideimpl.cpp | 32 +++++++++ .../entrypoints.c | 67 ++++++++++++------- .../System.Globalization.Native/entrypoints.c | 62 +++++++++++++++++ 11 files changed, 222 insertions(+), 46 deletions(-) create mode 100644 src/coreclr/src/inc/pinvokeoverride.h create mode 100644 src/coreclr/src/inc/pinvokeoverrideimpl.h create mode 100644 src/coreclr/src/vm/pinvokeoverride.cpp create mode 100644 src/coreclr/src/vm/pinvokeoverrideimpl.cpp diff --git a/src/coreclr/src/dlls/mscoree/unixinterface.cpp b/src/coreclr/src/dlls/mscoree/unixinterface.cpp index fd8cf506b23442..3214d7bbae32e9 100644 --- a/src/coreclr/src/dlls/mscoree/unixinterface.cpp +++ b/src/coreclr/src/dlls/mscoree/unixinterface.cpp @@ -18,6 +18,10 @@ #include "../../vm/gdbjithelpers.h" #endif // FEATURE_GDBJIT #include "bundle.h" +#include "pinvokeoverride.h" + +// TODO: WIP, this is for testing, will remove later. +#include "pinvokeoverrideimpl.h" #define ASSERTE_ALL_BUILDS(expr) _ASSERTE_ALL_BUILDS(__FILE__, (expr)) @@ -211,6 +215,14 @@ int coreclr_initialize( g_hostpolicy_embedded = hostPolicyEmbedded; + // TODO: WIP, fetch this from args similar to Bundle/bundleProbe + // + // if (overider != nullptr) + // { + // PInvokeOverride::SetPInvokeOverride(overrider); + // } + PInvokeOverride::SetPInvokeOverride(SuperHost::ResolveDllImport); + ReleaseHolder host; hr = CorHost2::CreateObject(IID_ICLRRuntimeHost4, (void**)&host); diff --git a/src/coreclr/src/inc/pinvokeoverride.h b/src/coreclr/src/inc/pinvokeoverride.h new file mode 100644 index 00000000000000..d3faa36212604a --- /dev/null +++ b/src/coreclr/src/inc/pinvokeoverride.h @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +/***************************************************************************** + ** ** + ** pinvokeoverride.h - PInvoke binding override ** + ** ** + *****************************************************************************/ + +#ifndef _PINVOKEOVERRIDE_H_ +#define _PINVOKEOVERRIDE_H_ + +typedef const void* (__stdcall PInvokeOverrideFn)(const char* libraryName, const char* entrypointName); + +class PInvokeOverride +{ +private: + static PInvokeOverrideFn* s_overrideImpl; + +public: + static void SetPInvokeOverride(PInvokeOverrideFn* overrideImpl); + static const void* TryGetMethodImpl(const char* libraryName, const char* entrypointName); +}; + +#endif // _PINVOKEOVERRIDE_H_ +// EOF ======================================================================= diff --git a/src/coreclr/src/inc/pinvokeoverrideimpl.h b/src/coreclr/src/inc/pinvokeoverrideimpl.h new file mode 100644 index 00000000000000..fb0ad51304e0a6 --- /dev/null +++ b/src/coreclr/src/inc/pinvokeoverrideimpl.h @@ -0,0 +1,12 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// + +// +// REVIEW: THE IMPLEMENTATION FOR THE OVERRIDER WILL BE MOVED TO HOST +// + +namespace SuperHost +{ + const void* ResolveDllImport(const char* libraryName, const char* entrypointName); +} diff --git a/src/coreclr/src/vm/CMakeLists.txt b/src/coreclr/src/vm/CMakeLists.txt index 42da88eb4088eb..6b83423be7b15c 100644 --- a/src/coreclr/src/vm/CMakeLists.txt +++ b/src/coreclr/src/vm/CMakeLists.txt @@ -102,6 +102,8 @@ set(VM_SOURCES_DAC_AND_WKS_COMMON perfmap.cpp perfinfo.cpp pgo.cpp + pinvokeoverride.cpp + pinvokeoverrideimpl.cpp precode.cpp prestub.cpp profilerdiagnosticprotocolhelper.cpp diff --git a/src/coreclr/src/vm/corelib.cpp b/src/coreclr/src/vm/corelib.cpp index 0632d1f8108a8b..aaf9bc9d10dcab 100644 --- a/src/coreclr/src/vm/corelib.cpp +++ b/src/coreclr/src/vm/corelib.cpp @@ -371,11 +371,6 @@ const USHORT c_nCoreLibFieldDescriptions = NumItems(c_rgCoreLibFieldDescriptions // ECalls // -// ECalls defined by libraries-native shims -EXTERN_C const LPVOID gPalGlobalizationNative[]; -EXTERN_C const LPVOID gEmbedded_Brotli[]; -EXTERN_C const LPVOID gEmbedded_zlib[]; - // When compiling crossgen, we only need the target version of the ecall tables #if !defined(CROSSGEN_COMPILE) || defined(CROSSGEN_CORELIB) diff --git a/src/coreclr/src/vm/dllimport.cpp b/src/coreclr/src/vm/dllimport.cpp index a6c5bca97f676c..5f66d0b6e8dae5 100644 --- a/src/coreclr/src/vm/dllimport.cpp +++ b/src/coreclr/src/vm/dllimport.cpp @@ -34,6 +34,7 @@ #include "strongnameholders.h" #include "ecall.h" #include "fieldmarshaler.h" +#include "pinvokeoverride.h" #include #include "../md/compiler/custattr.h" @@ -4230,11 +4231,7 @@ void NDirect::PopulateNDirectMethodDesc(NDirectMethodDesc* pNMD, PInvokeStaticSi if (callConv == pmCallConvThiscall) ndirectflags |= NDirectMethodDesc::kThisCall; - if ((pNMD->GetLoaderModule()->IsSystem() && (strcmp(szLibName, "QCall") == 0)) || - (szLibName != NULL && - (strcmp(szLibName, "libSystem.Globalization.Native") == 0 || - strcmp(szLibName, "libSystem.IO.Compression.Native") == 0 || - strcmp(szLibName, "clrcompression") == 0))) + if (pNMD->GetLoaderModule()->IsSystem() && (strcmp(szLibName, "QCall") == 0)) { ndirectflags |= NDirectMethodDesc::kIsQCall; } @@ -6512,6 +6509,15 @@ VOID NDirect::NDirectLink(NDirectMethodDesc *pMD) // Loading unmanaged dlls can trigger dllmains which certainly count as code execution! pMD->EnsureActive(); + { + LPVOID pvTarget = (LPVOID)PInvokeOverride::TryGetMethodImpl(pMD->GetLibNameRaw(), pMD->GetEntrypointName()); + if (pvTarget != NULL) + { + pMD->SetNDirectTarget(pvTarget); + return; + } + } + LoadLibErrorTracker errorTracker; BOOL fSuccess = FALSE; diff --git a/src/coreclr/src/vm/ecalllist.h b/src/coreclr/src/vm/ecalllist.h index 1907d8cbacd23a..3602c0297b02c2 100644 --- a/src/coreclr/src/vm/ecalllist.h +++ b/src/coreclr/src/vm/ecalllist.h @@ -1116,9 +1116,6 @@ FCClassElement("AssemblyExtensions", "System.Reflection.Metadata", gAssemblyExte FCClassElement("AssemblyLoadContext", "System.Runtime.Loader", gAssemblyLoadContextFuncs) FCClassElement("AssemblyName", "System.Reflection", gAssemblyNameFuncs) -#ifndef CROSSGEN_COMPILE -FCClassElement("Brotli", "", gEmbedded_Brotli) -#endif FCClassElement("Buffer", "System", gBufferFuncs) FCClassElement("CLRConfig", "System", gClrConfig) FCClassElement("CastHelpers", "System.Runtime.CompilerServices", gCastHelpers) @@ -1142,9 +1139,6 @@ FCClassElement("FileLoadException", "System.IO", gFileLoadExceptionFuncs) FCClassElement("GC", "System", gGCInterfaceFuncs) FCClassElement("GCHandle", "System.Runtime.InteropServices", gGCHandleFuncs) FCClassElement("GCSettings", "System.Runtime", gGCSettingsFuncs) -#ifndef CROSSGEN_COMPILE -FCClassElement("Globalization", "", gPalGlobalizationNative) -#endif #ifdef FEATURE_COMINTEROP FCClassElement("IEnumerable", "System.Collections", gStdMngIEnumerableFuncs) FCClassElement("IEnumerator", "System.Collections", gStdMngIEnumeratorFuncs) @@ -1227,10 +1221,6 @@ FCClassElement("X86Base", "System.Runtime.Intrinsics.X86", gX86BaseFuncs) FCClassElement("XplatEventLogger", "System.Diagnostics.Tracing", gEventLogger) #endif //defined(FEATURE_EVENTSOURCE_XPLAT) -#ifndef CROSSGEN_COMPILE -FCClassElement("zlib", "", gEmbedded_zlib) -#endif - #undef FCFuncElement #undef FCFuncElementSig #undef FCIntrinsic diff --git a/src/coreclr/src/vm/pinvokeoverride.cpp b/src/coreclr/src/vm/pinvokeoverride.cpp new file mode 100644 index 00000000000000..f5c0099bdbef86 --- /dev/null +++ b/src/coreclr/src/vm/pinvokeoverride.cpp @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +//***************************************************************************** +// pinvokeoverride.cpp +// +// Helpers to implement PInvoke overriding +// +//***************************************************************************** + +#include "pinvokeoverride.h" + +PInvokeOverrideFn* PInvokeOverride::s_overrideImpl = nullptr; + +void PInvokeOverride::SetPInvokeOverride(PInvokeOverrideFn* overrideImpl) +{ + s_overrideImpl = overrideImpl; +} + +const void* PInvokeOverride::TryGetMethodImpl(const char* libraryName, const char* entrypointName) +{ + return s_overrideImpl ? + s_overrideImpl(libraryName, entrypointName) : + nullptr; +} diff --git a/src/coreclr/src/vm/pinvokeoverrideimpl.cpp b/src/coreclr/src/vm/pinvokeoverrideimpl.cpp new file mode 100644 index 00000000000000..091b07b1c0023c --- /dev/null +++ b/src/coreclr/src/vm/pinvokeoverrideimpl.cpp @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// + +// +// REVIEW: THE IMPLEMENTATION FOR THE OVERRIDER WILL BE MOVED TO HOST +// + +#include "common.h" +#include "pinvokeoverrideimpl.h" + +extern "C" const void* GlobalizationResolveDllImport(const char* name); +extern "C" const void* CompressionResolveDllImport(const char* name); + +const void* SuperHost::ResolveDllImport(const char* libraryName, const char* entrypointName) +{ + if (strcmp(libraryName, "libSystem.Globalization.Native") == 0) + { + return GlobalizationResolveDllImport(entrypointName); + } + +#if defined(_WIN32) + if (strcmp(libraryName, "clrcompression") == 0) +#else + if (strcmp(libraryName, "libSystem.IO.Compression.Native") == 0) +#endif + { + return CompressionResolveDllImport(entrypointName); + } + + return nullptr; +} diff --git a/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c b/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c index 3b96d3856f48de..363f2a5073c629 100644 --- a/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c +++ b/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#include #include // Include System.IO.Compression.Native headers @@ -10,33 +11,47 @@ #include "../brotli/include/brotli/port.h" #include "../brotli/include/brotli/types.h" -#define FCFuncStart(name) EXTERN_C const void* name[]; const void* name[] = { -#define FCFuncEnd() (void*)0x01 /* FCFuncFlag_EndOfArray */ }; +#ifndef lengthof +#define lengthof(rg) (sizeof(rg)/sizeof(rg[0])) +#endif -#define QCFuncElement(name,impl) \ - (void*)0x8 /* FCFuncFlag_QCall */, (void*)(impl), (void*)name, +typedef struct +{ + const char* name; + const void* method; +} Entry; -FCFuncStart(gEmbedded_Brotli) - QCFuncElement("BrotliDecoderCreateInstance", BrotliDecoderCreateInstance) - QCFuncElement("BrotliDecoderDecompress", BrotliDecoderDecompress) - QCFuncElement("BrotliDecoderDecompressStream", BrotliDecoderDecompressStream) - QCFuncElement("BrotliDecoderDestroyInstance", BrotliDecoderDestroyInstance) - QCFuncElement("BrotliDecoderIsFinished", BrotliDecoderIsFinished) - QCFuncElement("BrotliEncoderCompress", BrotliEncoderCompress) - QCFuncElement("BrotliEncoderCompressStream", BrotliEncoderCompressStream) - QCFuncElement("BrotliEncoderCreateInstance", BrotliEncoderCreateInstance) - QCFuncElement("BrotliEncoderDestroyInstance", BrotliEncoderDestroyInstance) - QCFuncElement("BrotliEncoderHasMoreOutput", BrotliEncoderHasMoreOutput) - QCFuncElement("BrotliEncoderSetParameter", BrotliEncoderSetParameter) -FCFuncEnd() +static Entry s_compressionNative[] = +{ + {"BrotliDecoderCreateInstance", BrotliDecoderCreateInstance}, + {"BrotliDecoderDecompress", BrotliDecoderDecompress}, + {"BrotliDecoderDecompressStream", BrotliDecoderDecompressStream}, + {"BrotliDecoderDestroyInstance", BrotliDecoderDestroyInstance}, + {"BrotliDecoderIsFinished", BrotliDecoderIsFinished}, + {"BrotliEncoderCompress", BrotliEncoderCompress}, + {"BrotliEncoderCompressStream", BrotliEncoderCompressStream}, + {"BrotliEncoderCreateInstance", BrotliEncoderCreateInstance}, + {"BrotliEncoderDestroyInstance", BrotliEncoderDestroyInstance}, + {"BrotliEncoderHasMoreOutput", BrotliEncoderHasMoreOutput}, + {"BrotliEncoderSetParameter", BrotliEncoderSetParameter}, + {"CompressionNative_Crc32", CompressionNative_Crc32}, + {"CompressionNative_Deflate", CompressionNative_Deflate}, + {"CompressionNative_DeflateEnd", CompressionNative_DeflateEnd}, + {"CompressionNative_DeflateInit2_", CompressionNative_DeflateInit2_}, + {"CompressionNative_Inflate", CompressionNative_Inflate}, + {"CompressionNative_InflateEnd", CompressionNative_InflateEnd}, + {"CompressionNative_InflateInit2_", CompressionNative_InflateInit2_}, +}; -FCFuncStart(gEmbedded_zlib) - QCFuncElement("crc32", CompressionNative_Crc32) - QCFuncElement("Deflate", CompressionNative_Deflate) - QCFuncElement("DeflateEnd", CompressionNative_DeflateEnd) - QCFuncElement("DeflateInit2_", CompressionNative_DeflateInit2_) - QCFuncElement("Inflate", CompressionNative_Inflate) - QCFuncElement("InflateEnd", CompressionNative_InflateEnd) - QCFuncElement("InflateInit2_", CompressionNative_InflateInit2_) -FCFuncEnd() +extern const void* CompressionResolveDllImport(const char* name) +{ + for (int i = 0; i < lengthof(s_compressionNative); i++) + { + if (strcmp(name, s_compressionNative[i].name) == 0) + { + return s_compressionNative[i].method; + } + } + return NULL; +} diff --git a/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c b/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c index c4d60950256799..d8b16ed3fc717c 100644 --- a/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. #include +#include typedef uint16_t UChar; @@ -60,3 +61,64 @@ FCFuncStart(gPalGlobalizationNative) QCFuncElement("ToAscii", GlobalizationNative_ToAscii) QCFuncElement("ToUnicode", GlobalizationNative_ToUnicode) FCFuncEnd() + +#ifndef lengthof +#define lengthof(rg) (sizeof(rg)/sizeof(rg[0])) +#endif + +typedef struct +{ + const char* name; + const void* method; +} Entry; + +static Entry s_globalizationNative[] = +{ + {"GlobalizationNative_ChangeCase", GlobalizationNative_ChangeCase}, + {"GlobalizationNative_ChangeCaseInvariant", GlobalizationNative_ChangeCaseInvariant}, + {"GlobalizationNative_ChangeCaseTurkish", GlobalizationNative_ChangeCaseTurkish}, + {"GlobalizationNative_CloseSortHandle", GlobalizationNative_CloseSortHandle}, + {"GlobalizationNative_CompareString", GlobalizationNative_CompareString}, + {"GlobalizationNative_EndsWith", GlobalizationNative_EndsWith}, + {"GlobalizationNative_EnumCalendarInfo", GlobalizationNative_EnumCalendarInfo}, + {"GlobalizationNative_GetCalendarInfo", GlobalizationNative_GetCalendarInfo}, + {"GlobalizationNative_GetCalendars", GlobalizationNative_GetCalendars}, + {"GlobalizationNative_GetDefaultLocaleName", GlobalizationNative_GetDefaultLocaleName}, + {"GlobalizationNative_GetICUVersion", GlobalizationNative_GetICUVersion}, + {"GlobalizationNative_GetJapaneseEraStartDate", GlobalizationNative_GetJapaneseEraStartDate}, + {"GlobalizationNative_GetLatestJapaneseEra", GlobalizationNative_GetLatestJapaneseEra}, + {"GlobalizationNative_GetLocaleInfoGroupingSizes", GlobalizationNative_GetLocaleInfoGroupingSizes}, + {"GlobalizationNative_GetLocaleInfoInt", GlobalizationNative_GetLocaleInfoInt}, + {"GlobalizationNative_GetLocaleInfoString", GlobalizationNative_GetLocaleInfoString}, + {"GlobalizationNative_GetLocaleName", GlobalizationNative_GetLocaleName}, + {"GlobalizationNative_GetLocales", GlobalizationNative_GetLocales}, + {"GlobalizationNative_GetLocaleTimeFormat", GlobalizationNative_GetLocaleTimeFormat}, + {"GlobalizationNative_GetSortHandle", GlobalizationNative_GetSortHandle}, + {"GlobalizationNative_GetSortKey", GlobalizationNative_GetSortKey}, + {"GlobalizationNative_GetSortVersion", GlobalizationNative_GetSortVersion}, + {"GlobalizationNative_GetTimeZoneDisplayName", GlobalizationNative_GetTimeZoneDisplayName}, + {"GlobalizationNative_IndexOf", GlobalizationNative_IndexOf}, + {"GlobalizationNative_InitICUFunctions", GlobalizationNative_InitICUFunctions}, + {"GlobalizationNative_InitOrdinalCasingPage", GlobalizationNative_InitOrdinalCasingPage}, + {"GlobalizationNative_IsNormalized", GlobalizationNative_IsNormalized}, + {"GlobalizationNative_IsPredefinedLocale", GlobalizationNative_IsPredefinedLocale}, + {"GlobalizationNative_LastIndexOf", GlobalizationNative_LastIndexOf}, + {"GlobalizationNative_LoadICU", GlobalizationNative_LoadICU}, + {"GlobalizationNative_NormalizeString", GlobalizationNative_NormalizeString}, + {"GlobalizationNative_StartsWith", GlobalizationNative_StartsWith}, + {"GlobalizationNative_ToAscii", GlobalizationNative_ToAscii}, + {"GlobalizationNative_ToUnicode", GlobalizationNative_ToUnicode}, +}; + +extern "C" const void* GlobalizationResolveDllImport(const char* name) +{ + for (int i = 0; i < lengthof(s_globalizationNative); i++) + { + if (strcmp(name, s_globalizationNative[i].name) == 0) + { + return s_globalizationNative[i].method; + } + } + + return NULL; +} From 6e584b475fc2b5577fa7ef11adc4ac2f04922556 Mon Sep 17 00:00:00 2001 From: vsadov Date: Thu, 19 Nov 2020 20:42:44 -0800 Subject: [PATCH 07/32] remove no longer needed hacks --- src/coreclr/src/vm/ecall.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/coreclr/src/vm/ecall.cpp b/src/coreclr/src/vm/ecall.cpp index 1bfa52005cbe4e..5daa657f33a4d9 100644 --- a/src/coreclr/src/vm/ecall.cpp +++ b/src/coreclr/src/vm/ecall.cpp @@ -660,7 +660,7 @@ LPVOID ECall::GetQCallImpl(MethodDesc * pMD) if (id == 0) { id = ECall::GetIDForMethod(pMD); - _ASSERTE_MSG(id != 0, pMD->m_pszDebugMethodName); + _ASSERTE(id != 0); // Cache the id ((NDirectMethodDesc *)pMD)->SetECallID(id); @@ -683,11 +683,9 @@ LPVOID ECall::GetQCallImpl(MethodDesc * pMD) // SuppressUnmanagedCodeSecurityAttribute on QCalls suppresses a full demand, but there's still a link demand // for unmanaged code permission. All QCalls should be private or internal and wrapped in a managed method // to suppress this link demand. - - // TODO: HACK HACK HACK uncomment this - //CONSISTENCY_CHECK_MSGF(!fPublicOrProtected, - // ("%s::%s has to be private or internal.", - // pMD->m_pszDebugClassName, pMD->m_pszDebugMethodName)); + CONSISTENCY_CHECK_MSGF(!fPublicOrProtected, + ("%s::%s has to be private or internal.", + pMD->m_pszDebugClassName, pMD->m_pszDebugMethodName)); #endif return cur->m_pImplementation; From ba7146451dbe02af9034513330b58ef2057cd224 Mon Sep 17 00:00:00 2001 From: vsadov Date: Thu, 19 Nov 2020 21:19:54 -0800 Subject: [PATCH 08/32] Undo confusing changes for now --- .../Native/Unix/System.Native/CMakeLists.txt | 1 - .../Native/Unix/System.Native/entrypoints.c | 273 -------------- .../Native/Unix/System.Native/pal_log.h | 1 - .../System.Net.Security.Native/CMakeLists.txt | 1 - .../System.Net.Security.Native/entrypoints.c | 34 -- .../CMakeLists.txt | 1 - .../entrypoints.c | 335 ------------------ .../tests/ProcessModuleTests.cs | 2 +- .../tests/DefaultECDsaProvider.Unix.cs | 3 +- .../tests/EcDsaOpenSslTests.cs | 3 +- .../tests/HostnameMatchTests.Unix.cs | 10 +- 11 files changed, 5 insertions(+), 659 deletions(-) delete mode 100644 src/libraries/Native/Unix/System.Native/entrypoints.c delete mode 100644 src/libraries/Native/Unix/System.Net.Security.Native/entrypoints.c delete mode 100644 src/libraries/Native/Unix/System.Security.Cryptography.Native/entrypoints.c diff --git a/src/libraries/Native/Unix/System.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Native/CMakeLists.txt index f5a925fd46bf86..7e4ee517c78f36 100644 --- a/src/libraries/Native/Unix/System.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Native/CMakeLists.txt @@ -76,7 +76,6 @@ endif () add_library(System.Native-Static STATIC ${NATIVE_SOURCES} - entrypoints.c ) if (CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) diff --git a/src/libraries/Native/Unix/System.Native/entrypoints.c b/src/libraries/Native/Unix/System.Native/entrypoints.c deleted file mode 100644 index 7f1e1ccc2b5090..00000000000000 --- a/src/libraries/Native/Unix/System.Native/entrypoints.c +++ /dev/null @@ -1,273 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -#include - -// Include System.Native headers -#include "pal_console.h" -#include "pal_datetime.h" -#include "pal_errno.h" -#include "pal_interfaceaddresses.h" -#include "pal_io.h" -#include "pal_log.h" -#include "pal_memory.h" -#include "pal_mount.h" -#include "pal_networkchange.h" -#include "pal_networking.h" -#include "pal_networkstatistics.h" -#include "pal_process.h" -#include "pal_random.h" -#include "pal_runtimeextensions.h" -#include "pal_runtimeinformation.h" -#include "pal_searchpath.h" -#include "pal_signal.h" -#include "pal_string.h" -#include "pal_sysctl.h" -#include "pal_tcpstate.h" -#include "pal_threading.h" -#include "pal_time.h" -#include "pal_uid.h" - -#define FCFuncStart(name) EXTERN_C const void* name[]; const void* name[] = { -#define FCFuncEnd() (void*)0x01 /* FCFuncFlag_EndOfArray */ }; - -#define QCFuncElement(name,impl) \ - (void*)0x8 /* FCFuncFlag_QCall */, (void*)(impl), (void*)name, - -FCFuncStart(gEmbedded_Fcntl) - QCFuncElement("FcntlCanGetSetPipeSz", SystemNative_FcntlCanGetSetPipeSz) - QCFuncElement("GetFD", SystemNative_FcntlGetFD) - QCFuncElement("GetIsNonBlocking", SystemNative_FcntlGetIsNonBlocking) - QCFuncElement("GetPipeSz", SystemNative_FcntlGetPipeSz) - QCFuncElement("SetFD", SystemNative_FcntlSetFD) - QCFuncElement("DangerousSetIsNonBlocking", SystemNative_FcntlSetIsNonBlocking) - QCFuncElement("SetIsNonBlocking", SystemNative_FcntlSetIsNonBlocking) - QCFuncElement("SetPipeSz", SystemNative_FcntlSetPipeSz) -FCFuncEnd() - -FCFuncStart(gEmbedded_Sys) - QCFuncElement("Accept", SystemNative_Accept) - QCFuncElement("Access", SystemNative_Access) - QCFuncElement("Bind", SystemNative_Bind) - QCFuncElement("ChDir", SystemNative_ChDir) - QCFuncElement("ChMod", SystemNative_ChMod) - QCFuncElement("Close", SystemNative_Close) - QCFuncElement("CloseDir", SystemNative_CloseDir) - -#if defined(__FreeBSD__) || defined(__linux__) - QCFuncElement("CloseNetworkChangeListenerSocket", SystemNative_CloseNetworkChangeListenerSocket) -#endif - - QCFuncElement("CloseSocketEventPort", SystemNative_CloseSocketEventPort) - QCFuncElement("ConfigureTerminalForChildProcess", SystemNative_ConfigureTerminalForChildProcess) - QCFuncElement("Connect", SystemNative_Connect) - QCFuncElement("ConvertErrorPalToPlatform", SystemNative_ConvertErrorPalToPlatform) - QCFuncElement("ConvertErrorPlatformToPal", SystemNative_ConvertErrorPlatformToPal) - QCFuncElement("CopyFile", SystemNative_CopyFile) - -#if defined(__FreeBSD__) || defined(__linux__) - QCFuncElement("CreateNetworkChangeListenerSocket", SystemNative_CreateNetworkChangeListenerSocket) -#endif - - QCFuncElement("CreateSocketEventBuffer", SystemNative_CreateSocketEventBuffer) - QCFuncElement("CreateSocketEventPort", SystemNative_CreateSocketEventPort) - QCFuncElement("Disconnect", SystemNative_Disconnect) - QCFuncElement("Dup", SystemNative_Dup) - QCFuncElement("EnumerateInterfaceAddresses", SystemNative_EnumerateInterfaceAddresses) - QCFuncElement("FChMod", SystemNative_FChMod) - QCFuncElement("FLock", SystemNative_FLock) - QCFuncElement("ForkAndExecProcess", SystemNative_ForkAndExecProcess) - QCFuncElement("FreeHostEntry", SystemNative_FreeHostEntry) - QCFuncElement("FreeSocketEventBuffer", SystemNative_FreeSocketEventBuffer) - QCFuncElement("FStat", SystemNative_FStat) - QCFuncElement("FSync", SystemNative_FSync) - QCFuncElement("FTruncate", SystemNative_FTruncate) - QCFuncElement("GetAddressFamily", SystemNative_GetAddressFamily) - QCFuncElement("GetAllMountPoints", SystemNative_GetAllMountPoints) - QCFuncElement("GetAtOutOfBandMark", SystemNative_GetAtOutOfBandMark) - QCFuncElement("GetBytesAvailable", SystemNative_GetBytesAvailable) - QCFuncElement("GetControlCharacters", SystemNative_GetControlCharacters) - QCFuncElement("GetControlMessageBufferSize", SystemNative_GetControlMessageBufferSize) - QCFuncElement("GetCpuUtilization", SystemNative_GetCpuUtilization) - QCFuncElement("GetCwd", SystemNative_GetCwd) - QCFuncElement("GetDomainName", SystemNative_GetDomainName) - QCFuncElement("GetDomainSocketSizes", SystemNative_GetDomainSocketSizes) - QCFuncElement("GetEGid", SystemNative_GetEGid) - QCFuncElement("GetEUid", SystemNative_GetEUid) - QCFuncElement("GetFormatInfoForMountPoint", SystemNative_GetFormatInfoForMountPoint) - QCFuncElement("GetGroupList", SystemNative_GetGroupList) - QCFuncElement("GetHostEntryForName", SystemNative_GetHostEntryForName) - QCFuncElement("GetHostName", SystemNative_GetHostName) - QCFuncElement("GetIPSocketAddressSizes", SystemNative_GetIPSocketAddressSizes) - QCFuncElement("GetIPv4Address", SystemNative_GetIPv4Address) - QCFuncElement("GetIPv4MulticastOption", SystemNative_GetIPv4MulticastOption) - QCFuncElement("GetIPv6Address", SystemNative_GetIPv6Address) - QCFuncElement("GetIPv6MulticastOption", SystemNative_GetIPv6MulticastOption) - QCFuncElement("GetLingerOption", SystemNative_GetLingerOption) - QCFuncElement("GetMaximumAddressSize", SystemNative_GetMaximumAddressSize) - QCFuncElement("GetNameInfo", SystemNative_GetNameInfo) - QCFuncElement("GetNetworkInterfaces", SystemNative_GetNetworkInterfaces) - // trimmed - QCFuncElement("GetCryptographicallySecureRandomBytes", SystemNative_GetCryptographicallySecureRandomBytes) - QCFuncElement("GetNonCryptographicallySecureRandomBytes", SystemNative_GetNonCryptographicallySecureRandomBytes) - QCFuncElement("GetOSArchitecture", SystemNative_GetOSArchitecture) - QCFuncElement("GetPeerID", SystemNative_GetPeerID) - QCFuncElement("GetPeerName", SystemNative_GetPeerName) - QCFuncElement("GetPeerUserName", SystemNative_GetPeerUserName) - QCFuncElement("GetPid", SystemNative_GetPid) - QCFuncElement("GetPort", SystemNative_GetPort) - QCFuncElement("GetPriority", SystemNative_GetPriority) - QCFuncElement("GetProcessArchitecture", SystemNative_GetProcessArchitecture) - QCFuncElement("GetPwNamR", SystemNative_GetPwNamR) - QCFuncElement("GetPwUidR", SystemNative_GetPwUidR) - QCFuncElement("GetRawSockOpt", SystemNative_GetRawSockOpt) - QCFuncElement("GetReadDirRBufferSize", SystemNative_GetReadDirRBufferSize) - QCFuncElement("GetSignalForBreak", SystemNative_GetSignalForBreak) - QCFuncElement("GetSocketErrorOption", SystemNative_GetSocketErrorOption) - QCFuncElement("GetSocketType", SystemNative_GetSocketType) - QCFuncElement("GetSockName", SystemNative_GetSockName) - QCFuncElement("GetSockOpt", SystemNative_GetSockOpt) - QCFuncElement("GetSpaceInfoForMountPoint", SystemNative_GetSpaceInfoForMountPoint) - QCFuncElement("GetTimestamp", SystemNative_GetTimestamp) - QCFuncElement("GetUnixNamePrivate", SystemNative_GetUnixName) - QCFuncElement("GetUnixRelease", SystemNative_GetUnixRelease) - QCFuncElement("GetUnixVersion", SystemNative_GetUnixVersion) - QCFuncElement("GetWindowSize", SystemNative_GetWindowSize) - QCFuncElement("InitializeConsoleBeforeRead", SystemNative_InitializeConsoleBeforeRead) - QCFuncElement("InitializeTerminalAndSignalHandling", SystemNative_InitializeTerminalAndSignalHandling) - QCFuncElement("INotifyAddWatch", SystemNative_INotifyAddWatch) - QCFuncElement("INotifyInit", SystemNative_INotifyInit) - QCFuncElement("INotifyRemoveWatch_private", SystemNative_INotifyRemoveWatch) - QCFuncElement("InterfaceNameToIndex", SystemNative_InterfaceNameToIndex) - QCFuncElement("IsATty", SystemNative_IsATty) - QCFuncElement("Kill", SystemNative_Kill) - QCFuncElement("LChflags", SystemNative_LChflags) - QCFuncElement("LChflagsCanSetHiddenFlag", SystemNative_LChflagsCanSetHiddenFlag) - QCFuncElement("Link", SystemNative_Link) - QCFuncElement("Listen", SystemNative_Listen) - QCFuncElement("LockFileRegion", SystemNative_LockFileRegion) - QCFuncElement("LSeek", SystemNative_LSeek) - QCFuncElement("LStat", SystemNative_LStat) - QCFuncElement("MAdvise", SystemNative_MAdvise) - QCFuncElement("MapTcpState", SystemNative_MapTcpState) - QCFuncElement("MemAlloc", SystemNative_MemAlloc) - QCFuncElement("MemFree", SystemNative_MemFree) - QCFuncElement("MemReAlloc", SystemNative_MemReAlloc) - QCFuncElement("MkDir", SystemNative_MkDir) - QCFuncElement("MksTemps", SystemNative_MksTemps) - QCFuncElement("MMap", SystemNative_MMap) - QCFuncElement("MSync", SystemNative_MSync) - QCFuncElement("MUnmap", SystemNative_MUnmap) - QCFuncElement("Open", SystemNative_Open) - QCFuncElement("OpenDir", SystemNative_OpenDir) - //trimmed - QCFuncElement("PathConf", SystemNative_PathConf) - QCFuncElement("Pipe", SystemNative_Pipe) - QCFuncElement("PlatformSupportsDualModeIPv4PacketInfo", SystemNative_PlatformSupportsDualModeIPv4PacketInfo) - QCFuncElement("Poll", SystemNative_Poll) - QCFuncElement("PosixFAdvise", SystemNative_PosixFAdvise) - QCFuncElement("Read", SystemNative_Read) - QCFuncElement("ReadDirR", SystemNative_ReadDirR) - -#if defined(__FreeBSD__) || defined(__linux__) - QCFuncElement("ReadEvents", SystemNative_ReadEvents) -#endif - - QCFuncElement("ReadLink", SystemNative_ReadLink) - QCFuncElement("ReadStdin", SystemNative_ReadStdin) - QCFuncElement("Receive", SystemNative_Receive) - QCFuncElement("ReceiveMessage", SystemNative_ReceiveMessage) - QCFuncElement("RegisterForCtrl", SystemNative_RegisterForCtrl) - QCFuncElement("RegisterForSigChld", SystemNative_RegisterForSigChld) - QCFuncElement("Rename", SystemNative_Rename) - QCFuncElement("RestoreAndHandleCtrl", SystemNative_RestoreAndHandleCtrl) - QCFuncElement("RmDir", SystemNative_RmDir) - -#if HAVE_SCHED_GETAFFINITY - QCFuncElement("SchedGetAffinity", SystemNative_SchedGetAffinity) -#endif - -#if HAVE_SCHED_SETAFFINITY - QCFuncElement("SchedSetAffinity", SystemNative_SchedSetAffinity) -#endif - - QCFuncElement("Send", SystemNative_Send) - QCFuncElement("SendFile", SystemNative_SendFile) - QCFuncElement("SendMessage", SystemNative_SendMessage) - QCFuncElement("SetAddressFamily", SystemNative_SetAddressFamily) - QCFuncElement("SetEUid", SystemNative_SetEUid) - QCFuncElement("SetIPv4Address", SystemNative_SetIPv4Address) - QCFuncElement("SetIPv4MulticastOption", SystemNative_SetIPv4MulticastOption) - QCFuncElement("SetIPv6Address", SystemNative_SetIPv6Address) - QCFuncElement("SetIPv6MulticastOption", SystemNative_SetIPv6MulticastOption) - QCFuncElement("SetKeypadXmit", SystemNative_SetKeypadXmit) - QCFuncElement("SetLingerOption", SystemNative_SetLingerOption) - QCFuncElement("SetPort", SystemNative_SetPort) - QCFuncElement("SetPriority", SystemNative_SetPriority) - QCFuncElement("SetRawSockOpt", SystemNative_SetRawSockOpt) - QCFuncElement("SetReceiveTimeout", SystemNative_SetReceiveTimeout) - QCFuncElement("SetSendTimeout", SystemNative_SetSendTimeout) - QCFuncElement("SetSignalForBreak", SystemNative_SetSignalForBreak) - QCFuncElement("SetSockOpt", SystemNative_SetSockOpt) - QCFuncElement("SetTerminalInvalidationHandler", SystemNative_SetTerminalInvalidationHandler) - QCFuncElement("ShmOpen", SystemNative_ShmOpen) - QCFuncElement("ShmUnlink", SystemNative_ShmUnlink) - QCFuncElement("Shutdown", SystemNative_Shutdown) - QCFuncElement("SNPrintF", SystemNative_SNPrintF) - QCFuncElement("Socket", SystemNative_Socket) - QCFuncElement("Stat", SystemNative_Stat) - QCFuncElement("StdinReady", SystemNative_StdinReady) - QCFuncElement("StrErrorR", SystemNative_StrErrorR) - QCFuncElement("SysConf", SystemNative_SysConf) - QCFuncElement("SysLog", SystemNative_SysLog) - QCFuncElement("TryChangeSocketEventRegistration", SystemNative_TryChangeSocketEventRegistration) - QCFuncElement("TryGetIPPacketInformation", SystemNative_TryGetIPPacketInformation) - QCFuncElement("UninitializeConsoleAfterRead", SystemNative_UninitializeConsoleAfterRead) - QCFuncElement("Unlink", SystemNative_Unlink) - QCFuncElement("UnregisterForCtrl", SystemNative_UnregisterForCtrl) - QCFuncElement("UTimensat", SystemNative_UTimensat) - QCFuncElement("WaitForSocketEvents", SystemNative_WaitForSocketEvents) - QCFuncElement("WaitIdAnyExitedNoHangNoWait", SystemNative_WaitIdAnyExitedNoHangNoWait) - QCFuncElement("WaitPidExitedNoHang", SystemNative_WaitPidExitedNoHang) - QCFuncElement("Write", SystemNative_Write) - - // trimmed - QCFuncElement("GetNodeName", SystemNative_GetNodeName) - // trimmed - QCFuncElement("RealPath", SystemNative_RealPath) - // trimmed - QCFuncElement("GetSid", SystemNative_GetSid) - - // OSX (bsd?) only -#if HAVE_NETINET_TCP_VAR_H - QCFuncElement("GetTcpGlobalStatistics", SystemNative_GetTcpGlobalStatistics) - QCFuncElement("GetIPv4GlobalStatistics", SystemNative_GetIPv4GlobalStatistics) - QCFuncElement("GetUdpGlobalStatistics", SystemNative_GetUdpGlobalStatistics) - QCFuncElement("GetIcmpv4GlobalStatistics", SystemNative_GetIcmpv4GlobalStatistics) - QCFuncElement("GetIcmpv6GlobalStatistics", SystemNative_GetIcmpv6GlobalStatistics) - QCFuncElement("GetEstimatedTcpConnectionCount", SystemNative_GetEstimatedTcpConnectionCount) - QCFuncElement("GetActiveTcpConnectionInfos", SystemNative_GetActiveTcpConnectionInfos) - QCFuncElement("GetEstimatedUdpListenerCount", SystemNative_GetEstimatedUdpListenerCount) - QCFuncElement("GetActiveUdpListeners", SystemNative_GetActiveUdpListeners) - QCFuncElement("GetNativeIPInterfaceStatistics", SystemNative_GetNativeIPInterfaceStatistics) - QCFuncElement("GetNumRoutes", SystemNative_GetNumRoutes) -#endif - - // trimmed - QCFuncElement("Sync", SystemNative_Sync) - - // trimmed - QCFuncElement("GetRLimit", SystemNative_GetRLimit) - - // trimmed - QCFuncElement("SetRLimit", SystemNative_SetRLimit) - - // new - QCFuncElement("GetProcessPath", SystemNative_GetProcessPath) - -#if HAVE_RT_MSGHDR - QCFuncElement("EnumerateGatewayAddressesForInterface", SystemNative_EnumerateGatewayAddressesForInterface) -#endif - -FCFuncEnd() - diff --git a/src/libraries/Native/Unix/System.Native/pal_log.h b/src/libraries/Native/Unix/System.Native/pal_log.h index fd6845fbb83574..1e950cd0260b7d 100644 --- a/src/libraries/Native/Unix/System.Native/pal_log.h +++ b/src/libraries/Native/Unix/System.Native/pal_log.h @@ -7,4 +7,3 @@ #include "pal_types.h" PALEXPORT void SystemNative_Log(uint8_t* buffer, int32_t length); -PALEXPORT int32_t SystemNative_InitializeTerminalAndSignalHandling(void); diff --git a/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt index 4d31e5926f0fae..60a2f67b135d81 100644 --- a/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt @@ -36,7 +36,6 @@ endif() add_library(System.Net.Security.Native-Static STATIC ${NATIVEGSS_SOURCES} - entrypoints.c ) set_target_properties(System.Net.Security.Native-Static PROPERTIES OUTPUT_NAME System.Net.Security.Native CLEAN_DIRECT_OUTPUT 1) diff --git a/src/libraries/Native/Unix/System.Net.Security.Native/entrypoints.c b/src/libraries/Native/Unix/System.Net.Security.Native/entrypoints.c deleted file mode 100644 index 622181aa930fd7..00000000000000 --- a/src/libraries/Native/Unix/System.Net.Security.Native/entrypoints.c +++ /dev/null @@ -1,34 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -#include - -// Include System.Net.Security.Native headers -#include "pal_gssapi.h" - -#define FCFuncStart(name) EXTERN_C const void* name[]; const void* name[] = { -#define FCFuncEnd() (void*)0x01 /* FCFuncFlag_EndOfArray */ }; - -#define QCFuncElement(name,impl) \ - (void*)0x8 /* FCFuncFlag_QCall */, (void*)(impl), (void*)name, - -FCFuncStart(gEmbedded_NetSecurityNative) - QCFuncElement("AcceptSecContext", NetSecurityNative_AcceptSecContext) - QCFuncElement("AcquireAcceptorCred", NetSecurityNative_AcquireAcceptorCred) - QCFuncElement("DeleteSecContext", NetSecurityNative_DeleteSecContext) - QCFuncElement("DisplayMajorStatus", NetSecurityNative_DisplayMajorStatus) - QCFuncElement("DisplayMinorStatus", NetSecurityNative_DisplayMinorStatus) - QCFuncElement("GetUser", NetSecurityNative_GetUser) - QCFuncElement("ImportPrincipalName", NetSecurityNative_ImportPrincipalName) - QCFuncElement("ImportUserName", NetSecurityNative_ImportUserName) - QCFuncElement("InitiateCredSpNego", NetSecurityNative_InitiateCredSpNego) - QCFuncElement("InitiateCredWithPassword", NetSecurityNative_InitiateCredWithPassword) - QCFuncElement("InitSecContext", NetSecurityNative_InitSecContext) - QCFuncElement("InitSecContext", NetSecurityNative_InitSecContextEx) - QCFuncElement("IsNtlmInstalled", NetSecurityNative_IsNtlmInstalled) - QCFuncElement("ReleaseCred", NetSecurityNative_ReleaseCred) - QCFuncElement("ReleaseGssBuffer", NetSecurityNative_ReleaseGssBuffer) - QCFuncElement("ReleaseName", NetSecurityNative_ReleaseName) - QCFuncElement("Unwrap", NetSecurityNative_Unwrap) - QCFuncElement("Wrap", NetSecurityNative_Wrap) -FCFuncEnd() diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt index 505ba5141b6659..aaf1fa7e5b2d96 100644 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt @@ -94,7 +94,6 @@ endif() add_library(System.Security.Cryptography.Native.OpenSsl-Static STATIC $ - entrypoints.c ) set_target_properties(System.Security.Cryptography.Native.OpenSsl-Static PROPERTIES OUTPUT_NAME System.Security.Cryptography.Native.OpenSsl CLEAN_DIRECT_OUTPUT 1) diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native/entrypoints.c b/src/libraries/Native/Unix/System.Security.Cryptography.Native/entrypoints.c deleted file mode 100644 index e98fd2cb3a21d3..00000000000000 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native/entrypoints.c +++ /dev/null @@ -1,335 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -#include - -// Include System.Security.Cryptography.Native headers -#include "openssl.h" -#include "pal_asn1.h" -#include "pal_bignum.h" -#include "pal_bio.h" -#include "pal_dsa.h" -#include "pal_ecc_import_export.h" -#include "pal_ecdsa.h" -#include "pal_eckey.h" -#include "pal_err.h" -#include "pal_evp.h" -#include "pal_evp_cipher.h" -#include "pal_evp_pkey.h" -#include "pal_evp_pkey_dsa.h" -#include "pal_evp_pkey_ecdh.h" -#include "pal_evp_pkey_eckey.h" -#include "pal_evp_pkey_rsa.h" -#include "pal_hmac.h" -#include "pal_ocsp.h" -#include "pal_pkcs7.h" -#include "pal_rsa.h" -#include "pal_ssl.h" -#include "pal_x509.h" -#include "pal_x509ext.h" -#include "pal_x509_name.h" -#include "pal_x509_root.h" - -#define FCFuncStart(name) EXTERN_C const void* name[]; const void* name[] = { -#define FCFuncEnd() (void*)0x01 /* FCFuncFlag_EndOfArray */ }; - -#define QCFuncElement(name,impl) \ - (void*)0x8 /* FCFuncFlag_QCall */, (void*)(impl), (void*)name, - -FCFuncStart(gEmbedded_Crypto) - QCFuncElement("Asn1BitStringFree", CryptoNative_Asn1BitStringFree) - QCFuncElement("Asn1ObjectFree", CryptoNative_Asn1ObjectFree) - QCFuncElement("Asn1OctetStringFree", CryptoNative_Asn1OctetStringFree) - QCFuncElement("Asn1OctetStringNew", CryptoNative_Asn1OctetStringNew) - QCFuncElement("Asn1OctetStringSet", CryptoNative_Asn1OctetStringSet) - QCFuncElement("BigNumDestroy", CryptoNative_BigNumDestroy) - QCFuncElement("BigNumFromBinary", CryptoNative_BigNumFromBinary) - QCFuncElement("BigNumToBinary", CryptoNative_BigNumToBinary) - QCFuncElement("BioCtrlPending", CryptoNative_BioCtrlPending) - QCFuncElement("BioDestroy", CryptoNative_BioDestroy) - QCFuncElement("BioGets", CryptoNative_BioGets) - QCFuncElement("BioNewFile", CryptoNative_BioNewFile) - QCFuncElement("BioRead", CryptoNative_BioRead) - QCFuncElement("BioSeek", CryptoNative_BioSeek) - QCFuncElement("CryptoNative_BioTell", CryptoNative_BioTell) - QCFuncElement("BioWrite", CryptoNative_BioWrite) - QCFuncElement("CheckX509Hostname", CryptoNative_CheckX509Hostname) - QCFuncElement("CheckX509IpAddress", CryptoNative_CheckX509IpAddress) - QCFuncElement("CreateMemoryBio", CryptoNative_CreateMemoryBio) - QCFuncElement("D2IPkcs7Bio", CryptoNative_D2IPkcs7Bio) - QCFuncElement("DecodeAsn1BitString", CryptoNative_DecodeAsn1BitString) - QCFuncElement("DecodeExtendedKeyUsage", CryptoNative_DecodeExtendedKeyUsage) - QCFuncElement("CryptoNative_DecodeOcspResponse", CryptoNative_DecodeOcspResponse) - QCFuncElement("DecodePkcs7", CryptoNative_DecodePkcs7) - QCFuncElement("DecodeRsaPublicKey", CryptoNative_DecodeRsaPublicKey) - QCFuncElement("DecodeX509", CryptoNative_DecodeX509) - QCFuncElement("DecodeX509BasicConstraints2Extension", CryptoNative_DecodeX509BasicConstraints2Extension) - QCFuncElement("DecodeX509Crl", CryptoNative_DecodeX509Crl) - QCFuncElement("DsaDestroy", CryptoNative_DsaDestroy) - QCFuncElement("DsaGenerateKey", CryptoNative_DsaGenerateKey) - QCFuncElement("DsaKeyCreateByExplicitParameters", CryptoNative_DsaKeyCreateByExplicitParameters) - QCFuncElement("DsaSign", CryptoNative_DsaSign) - QCFuncElement("DsaSizeP", CryptoNative_DsaSizeP) - QCFuncElement("DsaSizeQ", CryptoNative_DsaSizeQ) - QCFuncElement("DsaSizeSignature", CryptoNative_DsaSizeSignature) - QCFuncElement("DsaUpRef", CryptoNative_DsaUpRef) - QCFuncElement("DsaVerify", CryptoNative_DsaVerify) - QCFuncElement("EcDsaSign", CryptoNative_EcDsaSign) - QCFuncElement("CryptoNative_EcDsaSize", CryptoNative_EcDsaSize) - QCFuncElement("EcDsaVerify", CryptoNative_EcDsaVerify) - QCFuncElement("EcKeyCreateByExplicitParameters", CryptoNative_EcKeyCreateByExplicitParameters) - QCFuncElement("EcKeyCreateByKeyParameters", CryptoNative_EcKeyCreateByKeyParameters) - QCFuncElement("CryptoNative_EcKeyCreateByOid", CryptoNative_EcKeyCreateByOid) - QCFuncElement("EcKeyDestroy", CryptoNative_EcKeyDestroy) - QCFuncElement("EcKeyGenerateKey", CryptoNative_EcKeyGenerateKey) - QCFuncElement("CryptoNative_EcKeyGetCurveName", CryptoNative_EcKeyGetCurveName2) - QCFuncElement("CryptoNative_EcKeyGetSize", CryptoNative_EcKeyGetSize) - QCFuncElement("EcKeyUpRef", CryptoNative_EcKeyUpRef) - QCFuncElement("EncodeAsn1Integer", CryptoNative_EncodeAsn1Integer) - QCFuncElement("EncodeOcspRequest", CryptoNative_EncodeOcspRequest) - QCFuncElement("EncodePkcs7", CryptoNative_EncodePkcs7) - QCFuncElement("EncodeX509", CryptoNative_EncodeX509) - QCFuncElement("EncodeX509SubjectPublicKeyInfo", CryptoNative_EncodeX509SubjectPublicKeyInfo) - QCFuncElement("ErrClearError", CryptoNative_ErrClearError) - QCFuncElement("ErrErrorStringN", CryptoNative_ErrErrorStringN) - QCFuncElement("ErrGetErrorAlloc", CryptoNative_ErrGetErrorAlloc) - QCFuncElement("ErrPeekError", CryptoNative_ErrPeekError) - QCFuncElement("ErrPeekLastError", CryptoNative_ErrPeekLastError) - QCFuncElement("ErrReasonErrorString", CryptoNative_ErrReasonErrorString) - QCFuncElement("EvpAes128Cbc", CryptoNative_EvpAes128Cbc) - QCFuncElement("EvpAes128Ccm", CryptoNative_EvpAes128Ccm) - QCFuncElement("EvpAes128Cfb128", CryptoNative_EvpAes128Cfb128) - QCFuncElement("EvpAes128Cfb8", CryptoNative_EvpAes128Cfb8) - QCFuncElement("EvpAes128Ecb", CryptoNative_EvpAes128Ecb) - QCFuncElement("EvpAes128Gcm", CryptoNative_EvpAes128Gcm) - QCFuncElement("EvpAes192Cbc", CryptoNative_EvpAes192Cbc) - QCFuncElement("EvpAes192Ccm", CryptoNative_EvpAes192Ccm) - QCFuncElement("EvpAes192Cfb128", CryptoNative_EvpAes192Cfb128) - QCFuncElement("EvpAes192Cfb8", CryptoNative_EvpAes192Cfb8) - QCFuncElement("EvpAes192Ecb", CryptoNative_EvpAes192Ecb) - QCFuncElement("EvpAes192Gcm", CryptoNative_EvpAes192Gcm) - QCFuncElement("EvpAes256Cbc", CryptoNative_EvpAes256Cbc) - QCFuncElement("EvpAes256Ccm", CryptoNative_EvpAes256Ccm) - QCFuncElement("EvpAes256Cfb128", CryptoNative_EvpAes256Cfb128) - QCFuncElement("EvpAes256Cfb8", CryptoNative_EvpAes256Cfb8) - QCFuncElement("EvpAes256Ecb", CryptoNative_EvpAes256Ecb) - QCFuncElement("EvpAes256Gcm", CryptoNative_EvpAes256Gcm) - QCFuncElement("EvpCipherCreate", CryptoNative_EvpCipherCreate2) - QCFuncElement("EvpCipherCreatePartial", CryptoNative_EvpCipherCreatePartial) - QCFuncElement("EvpCipherCtxSetPadding", CryptoNative_EvpCipherCtxSetPadding) - QCFuncElement("EvpCipherDestroy", CryptoNative_EvpCipherDestroy) - QCFuncElement("EvpCipherFinalEx", CryptoNative_EvpCipherFinalEx) - QCFuncElement("EvpCipherGetCcmTag", CryptoNative_EvpCipherGetCcmTag) - QCFuncElement("EvpCipherGetGcmTag", CryptoNative_EvpCipherGetGcmTag) - QCFuncElement("EvpCipherReset", CryptoNative_EvpCipherReset) - QCFuncElement("CryptoNative_EvpCipherSetCcmNonceLength", CryptoNative_EvpCipherSetCcmNonceLength) - QCFuncElement("EvpCipherSetCcmTag", CryptoNative_EvpCipherSetCcmTag) - QCFuncElement("CryptoNative_EvpCipherSetGcmNonceLength", CryptoNative_EvpCipherSetGcmNonceLength) - QCFuncElement("EvpCipherSetGcmTag", CryptoNative_EvpCipherSetGcmTag) - QCFuncElement("EvpCipherSetKeyAndIV", CryptoNative_EvpCipherSetKeyAndIV) - QCFuncElement("EvpCipherUpdate", CryptoNative_EvpCipherUpdate) - QCFuncElement("EvpDes3Cbc", CryptoNative_EvpDes3Cbc) - QCFuncElement("EvpDes3Cfb64", CryptoNative_EvpDes3Cfb64) - QCFuncElement("EvpDes3Cfb8", CryptoNative_EvpDes3Cfb8) - QCFuncElement("EvpDes3Ecb", CryptoNative_EvpDes3Ecb) - QCFuncElement("EvpDesCbc", CryptoNative_EvpDesCbc) - QCFuncElement("EvpDesCfb8", CryptoNative_EvpDesCfb8) - QCFuncElement("EvpDesEcb", CryptoNative_EvpDesEcb) - QCFuncElement("EvpDigestCurrent", CryptoNative_EvpDigestCurrent) - QCFuncElement("EvpDigestFinalEx", CryptoNative_EvpDigestFinalEx) - QCFuncElement("EvpDigestOneShot", CryptoNative_EvpDigestOneShot) - QCFuncElement("EvpDigestReset", CryptoNative_EvpDigestReset) - QCFuncElement("EvpDigestUpdate", CryptoNative_EvpDigestUpdate) - QCFuncElement("EvpMd5", CryptoNative_EvpMd5) - QCFuncElement("EvpMdCtxCreate", CryptoNative_EvpMdCtxCreate) - QCFuncElement("EvpMdCtxDestroy", CryptoNative_EvpMdCtxDestroy) - QCFuncElement("EvpMdSize", CryptoNative_EvpMdSize) - QCFuncElement("EvpPkeyCreate", CryptoNative_EvpPkeyCreate) - QCFuncElement("EvpPKeyCtxCreate", CryptoNative_EvpPKeyCtxCreate) - QCFuncElement("EvpPKeyCtxDestroy", CryptoNative_EvpPKeyCtxDestroy) - QCFuncElement("EvpPKeyDeriveSecretAgreement", CryptoNative_EvpPKeyDeriveSecretAgreement) - QCFuncElement("EvpPkeyDestroy", CryptoNative_EvpPkeyDestroy) - QCFuncElement("EvpPkeyGetDsa", CryptoNative_EvpPkeyGetDsa) - QCFuncElement("EvpPkeyGetEcKey", CryptoNative_EvpPkeyGetEcKey) - QCFuncElement("EvpPkeyGetRsa", CryptoNative_EvpPkeyGetRsa) - QCFuncElement("EvpPkeySetDsa", CryptoNative_EvpPkeySetDsa) - QCFuncElement("EvpPkeySetEcKey", CryptoNative_EvpPkeySetEcKey) - QCFuncElement("EvpPkeySetRsa", CryptoNative_EvpPkeySetRsa) - QCFuncElement("EvpRC2Cbc", CryptoNative_EvpRC2Cbc) - QCFuncElement("EvpRC2Ecb", CryptoNative_EvpRC2Ecb) - QCFuncElement("EvpSha1", CryptoNative_EvpSha1) - QCFuncElement("EvpSha256", CryptoNative_EvpSha256) - QCFuncElement("EvpSha384", CryptoNative_EvpSha384) - QCFuncElement("EvpSha512", CryptoNative_EvpSha512) - QCFuncElement("ExtendedKeyUsageDestory", CryptoNative_ExtendedKeyUsageDestory) - QCFuncElement("GetAsn1IntegerDerSize", CryptoNative_GetAsn1IntegerDerSize) - QCFuncElement("GetAsn1StringBytes", CryptoNative_GetAsn1StringBytes) - QCFuncElement("GetBigNumBytes", CryptoNative_GetBigNumBytes) - QCFuncElement("GetDsaParameters", CryptoNative_GetDsaParameters) - QCFuncElement("CryptoNative_GetECCurveParameters", CryptoNative_GetECCurveParameters) - QCFuncElement("CryptoNative_GetECKeyParameters", CryptoNative_GetECKeyParameters) - QCFuncElement("GetMaxMdSize", CryptoNative_GetMaxMdSize) - QCFuncElement("GetMemoryBioSize", CryptoNative_GetMemoryBioSize) - QCFuncElement("CryptoNative_GetObjectDefinitionByName", CryptoNative_GetObjectDefinitionByName) - QCFuncElement("GetOcspRequestDerSize", CryptoNative_GetOcspRequestDerSize) - QCFuncElement("GetPkcs7Certificates", CryptoNative_GetPkcs7Certificates) - QCFuncElement("GetPkcs7DerSize", CryptoNative_GetPkcs7DerSize) - QCFuncElement("CryptoNative_GetRandomBytes", CryptoNative_GetRandomBytes) - QCFuncElement("GetRsaParameters", CryptoNative_GetRsaParameters) - QCFuncElement("GetX509CrlNextUpdate", CryptoNative_GetX509CrlNextUpdate) - QCFuncElement("GetX509DerSize", CryptoNative_GetX509DerSize) - QCFuncElement("GetX509EkuField", CryptoNative_GetX509EkuField) - QCFuncElement("GetX509EkuFieldCount", CryptoNative_GetX509EkuFieldCount) - QCFuncElement("GetX509EvpPublicKey", CryptoNative_GetX509EvpPublicKey) - QCFuncElement("GetX509NameInfo", CryptoNative_GetX509NameInfo) - QCFuncElement("GetX509NameRawBytes", CryptoNative_GetX509NameRawBytes) - QCFuncElement("GetX509NameStackField_private", CryptoNative_GetX509NameStackField) - QCFuncElement("GetX509NameStackFieldCount", CryptoNative_GetX509NameStackFieldCount) - QCFuncElement("GetX509NotAfter", CryptoNative_GetX509NotAfter) - QCFuncElement("GetX509NotBefore", CryptoNative_GetX509NotBefore) - QCFuncElement("GetX509PublicKeyAlgorithm", CryptoNative_GetX509PublicKeyAlgorithm) - QCFuncElement("GetX509PublicKeyBytes", CryptoNative_GetX509PublicKeyBytes) - QCFuncElement("GetX509PublicKeyParameterBytes", CryptoNative_GetX509PublicKeyParameterBytes) - QCFuncElement("GetX509RootStoreFile_private", CryptoNative_GetX509RootStoreFile) - QCFuncElement("GetX509RootStorePath_private", CryptoNative_GetX509RootStorePath) - QCFuncElement("GetX509SignatureAlgorithm", CryptoNative_GetX509SignatureAlgorithm) - QCFuncElement("GetX509StackField", CryptoNative_GetX509StackField) - QCFuncElement("GetX509StackFieldCount", CryptoNative_GetX509StackFieldCount) - QCFuncElement("GetX509SubjectPublicKeyInfoDerSize", CryptoNative_GetX509SubjectPublicKeyInfoDerSize) - QCFuncElement("GetX509Thumbprint", CryptoNative_GetX509Thumbprint) - QCFuncElement("GetX509Version", CryptoNative_GetX509Version) - QCFuncElement("HmacCreate", CryptoNative_HmacCreate) - QCFuncElement("HmacCurrent", CryptoNative_HmacCurrent) - QCFuncElement("HmacDestroy", CryptoNative_HmacDestroy) - QCFuncElement("HmacFinal", CryptoNative_HmacFinal) - QCFuncElement("HmacReset", CryptoNative_HmacReset) - QCFuncElement("HmacUpdate", CryptoNative_HmacUpdate) - QCFuncElement("LookupFriendlyNameByOid", CryptoNative_LookupFriendlyNameByOid) - QCFuncElement("NewX509Stack", CryptoNative_NewX509Stack) - QCFuncElement("ObjNid2Obj", CryptoNative_ObjNid2Obj) - QCFuncElement("ObjObj2Txt", CryptoNative_ObjObj2Txt) - QCFuncElement("ObjSn2Nid", CryptoNative_ObjSn2Nid) - QCFuncElement("ObjTxt2Nid", CryptoNative_ObjTxt2Nid) - QCFuncElement("ObjTxt2Obj", CryptoNative_ObjTxt2Obj) - QCFuncElement("OcspRequestDestroy", CryptoNative_OcspRequestDestroy) - QCFuncElement("OcspResponseDestroy", CryptoNative_OcspResponseDestroy) - QCFuncElement("PemReadBioPkcs7", CryptoNative_PemReadBioPkcs7) - QCFuncElement("PemReadBioX509Crl", CryptoNative_PemReadBioX509Crl) - QCFuncElement("PemReadX509FromBio", CryptoNative_PemReadX509FromBio) - QCFuncElement("PemReadX509FromBioAux", CryptoNative_PemReadX509FromBioAux) - QCFuncElement("PemWriteBioX509Crl", CryptoNative_PemWriteBioX509Crl) - QCFuncElement("Pkcs7CreateCertificateCollection", CryptoNative_Pkcs7CreateCertificateCollection) - QCFuncElement("Pkcs7Destroy", CryptoNative_Pkcs7Destroy) - QCFuncElement("PushX509StackField", CryptoNative_PushX509StackField) - QCFuncElement("ReadX509AsDerFromBio", CryptoNative_ReadX509AsDerFromBio) - QCFuncElement("RecursiveFreeX509Stack", CryptoNative_RecursiveFreeX509Stack) - QCFuncElement("RsaCreate", CryptoNative_RsaCreate) - QCFuncElement("RsaDestroy", CryptoNative_RsaDestroy) - QCFuncElement("RsaGenerateKeyEx", CryptoNative_RsaGenerateKeyEx) - QCFuncElement("RsaPrivateDecrypt", CryptoNative_RsaPrivateDecrypt) - QCFuncElement("RsaPublicEncrypt", CryptoNative_RsaPublicEncrypt) - QCFuncElement("RsaSign", CryptoNative_RsaSign) - QCFuncElement("RsaSignPrimitive", CryptoNative_RsaSignPrimitive) - QCFuncElement("RsaSize", CryptoNative_RsaSize) - QCFuncElement("RsaUpRef", CryptoNative_RsaUpRef) - QCFuncElement("RsaVerificationPrimitive", CryptoNative_RsaVerificationPrimitive) - QCFuncElement("RsaVerify", CryptoNative_RsaVerify) - QCFuncElement("SetRsaParameters", CryptoNative_SetRsaParameters) - QCFuncElement("UpRefEvpPkey", CryptoNative_UpRefEvpPkey) - QCFuncElement("CryptoNative_X509ChainBuildOcspRequest", CryptoNative_X509ChainBuildOcspRequest) - QCFuncElement("CryptoNative_X509ChainGetCachedOcspStatus", CryptoNative_X509ChainGetCachedOcspStatus) - QCFuncElement("CryptoNative_X509ChainNew", CryptoNative_X509ChainNew) - QCFuncElement("CryptoNative_X509ChainVerifyOcsp", CryptoNative_X509ChainVerifyOcsp) - QCFuncElement("X509CheckPurpose", CryptoNative_X509CheckPurpose) - QCFuncElement("X509CrlDestroy", CryptoNative_X509CrlDestroy) - QCFuncElement("X509Destroy", CryptoNative_X509Destroy) - QCFuncElement("X509ExtensionCreateByObj", CryptoNative_X509ExtensionCreateByObj) - QCFuncElement("X509ExtensionDestroy", CryptoNative_X509ExtensionDestroy) - QCFuncElement("X509ExtensionGetCritical", CryptoNative_X509ExtensionGetCritical) - QCFuncElement("X509ExtensionGetData", CryptoNative_X509ExtensionGetData) - QCFuncElement("X509ExtensionGetOid", CryptoNative_X509ExtensionGetOid) - QCFuncElement("CryptoNative_X509FindExtensionData", CryptoNative_X509FindExtensionData) - QCFuncElement("X509GetExt", CryptoNative_X509GetExt) - QCFuncElement("X509GetExtCount", CryptoNative_X509GetExtCount) - QCFuncElement("X509GetIssuerName", CryptoNative_X509GetIssuerName) - QCFuncElement("X509GetSerialNumber_private", CryptoNative_X509GetSerialNumber) - QCFuncElement("X509GetSubjectName", CryptoNative_X509GetSubjectName) - QCFuncElement("X509IssuerNameHash", CryptoNative_X509IssuerNameHash) - QCFuncElement("CryptoNative_X509StackAddDirectoryStore", CryptoNative_X509StackAddDirectoryStore) - QCFuncElement("CryptoNative_X509StackAddMultiple", CryptoNative_X509StackAddMultiple) - QCFuncElement("X509StoreAddCrl", CryptoNative_X509StoreAddCrl) - QCFuncElement("CryptoNative_X509StoreCtxCommitToChain", CryptoNative_X509StoreCtxCommitToChain) - QCFuncElement("X509StoreCtxCreate", CryptoNative_X509StoreCtxCreate) - QCFuncElement("X509StoreCtxDestroy", CryptoNative_X509StoreCtxDestroy) - QCFuncElement("X509StoreCtxGetChain", CryptoNative_X509StoreCtxGetChain) - QCFuncElement("X509StoreCtxGetCurrentCert", CryptoNative_X509StoreCtxGetCurrentCert) - QCFuncElement("X509StoreCtxGetError", CryptoNative_X509StoreCtxGetError) - QCFuncElement("X509StoreCtxGetErrorDepth", CryptoNative_X509StoreCtxGetErrorDepth) - QCFuncElement("X509StoreCtxGetSharedUntrusted_private", CryptoNative_X509StoreCtxGetSharedUntrusted) - QCFuncElement("X509StoreCtxInit", CryptoNative_X509StoreCtxInit) - QCFuncElement("CryptoNative_X509StoreCtxRebuildChain", CryptoNative_X509StoreCtxRebuildChain) - QCFuncElement("CryptoNative_X509StoreCtxReset", CryptoNative_X509StoreCtxReset) - QCFuncElement("CryptoNative_X509StoreCtxResetForSignatureError", CryptoNative_X509StoreCtxResetForSignatureError) - QCFuncElement("X509StoreCtxSetVerifyCallback", CryptoNative_X509StoreCtxSetVerifyCallback) - QCFuncElement("X509StoreDestory", CryptoNative_X509StoreDestory) - QCFuncElement("CryptoNative_X509StoreSetRevocationFlag", CryptoNative_X509StoreSetRevocationFlag) - QCFuncElement("CryptoNative_X509StoreSetVerifyTime", CryptoNative_X509StoreSetVerifyTime) - QCFuncElement("X509UpRef", CryptoNative_X509UpRef) - QCFuncElement("X509V3ExtPrint", CryptoNative_X509V3ExtPrint) - QCFuncElement("CryptoNative_X509VerifyCert", CryptoNative_X509VerifyCert) - QCFuncElement("X509VerifyCertErrorString", CryptoNative_X509VerifyCertErrorString) -FCFuncEnd() - -FCFuncStart(gEmbedded_CryptoInitializer) - QCFuncElement("EnsureOpenSslInitialized", CryptoNative_EnsureOpenSslInitialized) -FCFuncEnd() - -FCFuncStart(gEmbedded_OpenSsl) - // trimmed - QCFuncElement("OpenSslGetProtocolSupport", CryptoNative_OpenSslGetProtocolSupport) - QCFuncElement("OpenSslVersionNumber", CryptoNative_OpenSslVersionNumber) -FCFuncEnd() - -FCFuncStart(gEmbedded_Ssl) - QCFuncElement("BioWrite", CryptoNative_BioWrite) - QCFuncElement("EnsureLibSslInitialized", CryptoNative_EnsureLibSslInitialized) - QCFuncElement("GetOpenSslCipherSuiteName", CryptoNative_GetOpenSslCipherSuiteName) - QCFuncElement("IsSslRenegotiatePending", CryptoNative_IsSslRenegotiatePending) - QCFuncElement("IsSslStateOK", CryptoNative_IsSslStateOK) - QCFuncElement("SetCiphers", CryptoNative_SetCiphers) - QCFuncElement("SetEncryptionPolicy", CryptoNative_SetEncryptionPolicy) - QCFuncElement("SetProtocolOptions", CryptoNative_SetProtocolOptions) - QCFuncElement("SslAddExtraChainCert", CryptoNative_SslAddExtraChainCert) - QCFuncElement("SslCreate", CryptoNative_SslCreate) - QCFuncElement("SslCtxCheckPrivateKey", CryptoNative_SslCtxCheckPrivateKey) - QCFuncElement("SslCtxCreate", CryptoNative_SslCtxCreate) - QCFuncElement("SslCtxDestroy", CryptoNative_SslCtxDestroy) - QCFuncElement("SslCtxSetAlpnProtos", CryptoNative_SslCtxSetAlpnProtos) - QCFuncElement("SslCtxSetAlpnSelectCb", CryptoNative_SslCtxSetAlpnSelectCb) - QCFuncElement("SslCtxSetQuietShutdown", CryptoNative_SslCtxSetQuietShutdown) - QCFuncElement("SslCtxSetVerify", CryptoNative_SslCtxSetVerify) - QCFuncElement("SslCtxUseCertificate", CryptoNative_SslCtxUseCertificate) - QCFuncElement("SslCtxUsePrivateKey", CryptoNative_SslCtxUsePrivateKey) - QCFuncElement("SslDestroy", CryptoNative_SslDestroy) - QCFuncElement("SslDoHandshake", CryptoNative_SslDoHandshake) - QCFuncElement("SslGetAlpnSelected", CryptoNative_SslGet0AlpnSelected) - QCFuncElement("SslGetClientCAList_private", CryptoNative_SslGetClientCAList) - QCFuncElement("SslGetCurrentCipherId", CryptoNative_SslGetCurrentCipherId) - QCFuncElement("SslGetError", CryptoNative_SslGetError) - QCFuncElement("SslGetFinished", CryptoNative_SslGetFinished) - QCFuncElement("SslGetPeerCertChain", CryptoNative_SslGetPeerCertChain) - QCFuncElement("SslGetPeerCertificate", CryptoNative_SslGetPeerCertificate) - QCFuncElement("SslGetPeerFinished", CryptoNative_SslGetPeerFinished) - QCFuncElement("SslGetVersion", CryptoNative_SslGetVersion) - QCFuncElement("SslRead", CryptoNative_SslRead) - QCFuncElement("SslSessionReused", CryptoNative_SslSessionReused) - QCFuncElement("SslSetAcceptState", CryptoNative_SslSetAcceptState) - QCFuncElement("SslSetBio", CryptoNative_SslSetBio) - QCFuncElement("SslSetConnectState", CryptoNative_SslSetConnectState) - QCFuncElement("SslSetQuietShutdown", CryptoNative_SslSetQuietShutdown) - QCFuncElement("SslSetTlsExtHostName", CryptoNative_SslSetTlsExtHostName) - QCFuncElement("SslShutdown", CryptoNative_SslShutdown) - QCFuncElement("SslV2_3Method", CryptoNative_SslV2_3Method) - QCFuncElement("SslWrite", CryptoNative_SslWrite) - QCFuncElement("Tls13SupportedImpl", CryptoNative_Tls13Supported) -FCFuncEnd() diff --git a/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.cs b/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.cs index 53497b6b75c2ec..2a7d67888c3291 100644 --- a/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.cs +++ b/src/libraries/System.Diagnostics.Process/tests/ProcessModuleTests.cs @@ -41,7 +41,7 @@ public void TestModulesContainsUnixNativeLibs() { ProcessModuleCollection modules = Process.GetCurrentProcess().Modules; Assert.Contains(modules.Cast(), m => m.FileName.Contains("libcoreclr")); - // Assert.Contains(modules.Cast(), m => m.FileName.Contains("System.Native")); + Assert.Contains(modules.Cast(), m => m.FileName.Contains("System.Native")); } [Fact] diff --git a/src/libraries/System.Security.Cryptography.Algorithms/tests/DefaultECDsaProvider.Unix.cs b/src/libraries/System.Security.Cryptography.Algorithms/tests/DefaultECDsaProvider.Unix.cs index bdd7d6c1d48b9c..53e9198720360b 100644 --- a/src/libraries/System.Security.Cryptography.Algorithms/tests/DefaultECDsaProvider.Unix.cs +++ b/src/libraries/System.Security.Cryptography.Algorithms/tests/DefaultECDsaProvider.Unix.cs @@ -57,8 +57,7 @@ internal static partial class Interop internal static partial class Crypto { [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyCreateByOid")] - private static extern System.IntPtr CryptoNative_EcKeyCreateByOid(string oid); - internal static System.IntPtr EcKeyCreateByOid(string oid) => CryptoNative_EcKeyCreateByOid(oid); + internal static extern System.IntPtr EcKeyCreateByOid(string oid); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyDestroy")] internal static extern void EcKeyDestroy(System.IntPtr r); diff --git a/src/libraries/System.Security.Cryptography.OpenSsl/tests/EcDsaOpenSslTests.cs b/src/libraries/System.Security.Cryptography.OpenSsl/tests/EcDsaOpenSslTests.cs index aa69fd106ee9ac..800362ef1840de 100644 --- a/src/libraries/System.Security.Cryptography.OpenSsl/tests/EcDsaOpenSslTests.cs +++ b/src/libraries/System.Security.Cryptography.OpenSsl/tests/EcDsaOpenSslTests.cs @@ -305,8 +305,7 @@ internal static partial class Interop internal static class Crypto { [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyCreateByOid")] - private static extern IntPtr CryptoNative_EcKeyCreateByOid(string oid); - internal static IntPtr EcKeyCreateByOid(string oid) => CryptoNative_EcKeyCreateByOid(oid); + internal static extern IntPtr EcKeyCreateByOid(string oid); [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcKeyGenerateKey")] internal static extern int EcKeyGenerateKey(IntPtr ecKey); diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/tests/HostnameMatchTests.Unix.cs b/src/libraries/System.Security.Cryptography.X509Certificates/tests/HostnameMatchTests.Unix.cs index 32adec1d4c57e0..a83611cee154c2 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/tests/HostnameMatchTests.Unix.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/tests/HostnameMatchTests.Unix.cs @@ -181,19 +181,13 @@ private static string FixCase(string input, bool flatten) private static bool CheckHostname(X509Certificate2 cert, string targetName) { - int value = Interop.Crypto.CheckX509Hostname(cert.Handle, targetName, targetName.Length); + int value = CheckX509Hostname(cert.Handle, targetName, targetName.Length); GC.KeepAlive(cert); Assert.InRange(value, 0, 1); return value != 0; } - } -} -internal static partial class Interop -{ - internal static partial class Crypto - { [DllImport(Interop.Libraries.CryptoNative, EntryPoint = "CryptoNative_CheckX509Hostname")] - internal static extern int CheckX509Hostname(System.IntPtr x509, string hostname, int cchHostname); + private static extern int CheckX509Hostname(IntPtr x509, string hostname, int cchHostname); } } From 4563d69e28843dfdde2248326015ba3f7e8557c1 Mon Sep 17 00:00:00 2001 From: vsadov Date: Fri, 20 Nov 2020 13:13:19 -0800 Subject: [PATCH 09/32] fix pedantic errors on GCC --- src/coreclr/src/inc/pinvokeoverride.h | 2 +- .../entrypoints.c | 42 ++++++----- .../System.Globalization.Native/entrypoints.c | 74 ++++++++++--------- 3 files changed, 61 insertions(+), 57 deletions(-) diff --git a/src/coreclr/src/inc/pinvokeoverride.h b/src/coreclr/src/inc/pinvokeoverride.h index d3faa36212604a..5ce137460a3fb9 100644 --- a/src/coreclr/src/inc/pinvokeoverride.h +++ b/src/coreclr/src/inc/pinvokeoverride.h @@ -10,7 +10,7 @@ #ifndef _PINVOKEOVERRIDE_H_ #define _PINVOKEOVERRIDE_H_ -typedef const void* (__stdcall PInvokeOverrideFn)(const char* libraryName, const char* entrypointName); +typedef const void* (PInvokeOverrideFn)(const char* libraryName, const char* entrypointName); class PInvokeOverride { diff --git a/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c b/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c index 363f2a5073c629..951e7a87702cea 100644 --- a/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c +++ b/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c @@ -12,7 +12,7 @@ #include "../brotli/include/brotli/types.h" #ifndef lengthof -#define lengthof(rg) (sizeof(rg)/sizeof(rg[0])) +#define lengthof(rg) (int)(sizeof(rg)/sizeof(rg[0])) #endif typedef struct @@ -23,27 +23,29 @@ typedef struct static Entry s_compressionNative[] = { - {"BrotliDecoderCreateInstance", BrotliDecoderCreateInstance}, - {"BrotliDecoderDecompress", BrotliDecoderDecompress}, - {"BrotliDecoderDecompressStream", BrotliDecoderDecompressStream}, - {"BrotliDecoderDestroyInstance", BrotliDecoderDestroyInstance}, - {"BrotliDecoderIsFinished", BrotliDecoderIsFinished}, - {"BrotliEncoderCompress", BrotliEncoderCompress}, - {"BrotliEncoderCompressStream", BrotliEncoderCompressStream}, - {"BrotliEncoderCreateInstance", BrotliEncoderCreateInstance}, - {"BrotliEncoderDestroyInstance", BrotliEncoderDestroyInstance}, - {"BrotliEncoderHasMoreOutput", BrotliEncoderHasMoreOutput}, - {"BrotliEncoderSetParameter", BrotliEncoderSetParameter}, - {"CompressionNative_Crc32", CompressionNative_Crc32}, - {"CompressionNative_Deflate", CompressionNative_Deflate}, - {"CompressionNative_DeflateEnd", CompressionNative_DeflateEnd}, - {"CompressionNative_DeflateInit2_", CompressionNative_DeflateInit2_}, - {"CompressionNative_Inflate", CompressionNative_Inflate}, - {"CompressionNative_InflateEnd", CompressionNative_InflateEnd}, - {"CompressionNative_InflateInit2_", CompressionNative_InflateInit2_}, + {"BrotliDecoderCreateInstance", (void*)BrotliDecoderCreateInstance}, + {"BrotliDecoderDecompress", (void*)BrotliDecoderDecompress}, + {"BrotliDecoderDecompressStream", (void*)BrotliDecoderDecompressStream}, + {"BrotliDecoderDestroyInstance", (void*)BrotliDecoderDestroyInstance}, + {"BrotliDecoderIsFinished", (void*)BrotliDecoderIsFinished}, + {"BrotliEncoderCompress", (void*)BrotliEncoderCompress}, + {"BrotliEncoderCompressStream", (void*)BrotliEncoderCompressStream}, + {"BrotliEncoderCreateInstance", (void*)BrotliEncoderCreateInstance}, + {"BrotliEncoderDestroyInstance", (void*)BrotliEncoderDestroyInstance}, + {"BrotliEncoderHasMoreOutput", (void*)BrotliEncoderHasMoreOutput}, + {"BrotliEncoderSetParameter", (void*)BrotliEncoderSetParameter}, + {"CompressionNative_Crc32", (void*)CompressionNative_Crc32}, + {"CompressionNative_Deflate", (void*)CompressionNative_Deflate}, + {"CompressionNative_DeflateEnd", (void*)CompressionNative_DeflateEnd}, + {"CompressionNative_DeflateInit2_", (void*)CompressionNative_DeflateInit2_}, + {"CompressionNative_Inflate", (void*)CompressionNative_Inflate}, + {"CompressionNative_InflateEnd", (void*)CompressionNative_InflateEnd}, + {"CompressionNative_InflateInit2_", (void*)CompressionNative_InflateInit2_}, }; -extern const void* CompressionResolveDllImport(const char* name) +EXTERN_C const void* CompressionResolveDllImport(const char* name); + +EXTERN_C const void* CompressionResolveDllImport(const char* name) { for (int i = 0; i < lengthof(s_compressionNative); i++) { diff --git a/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c b/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c index d8b16ed3fc717c..c8434cdb0d325b 100644 --- a/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c @@ -63,7 +63,7 @@ FCFuncStart(gPalGlobalizationNative) FCFuncEnd() #ifndef lengthof -#define lengthof(rg) (sizeof(rg)/sizeof(rg[0])) +#define lengthof(rg) (int)(sizeof(rg)/sizeof(rg[0])) #endif typedef struct @@ -74,43 +74,45 @@ typedef struct static Entry s_globalizationNative[] = { - {"GlobalizationNative_ChangeCase", GlobalizationNative_ChangeCase}, - {"GlobalizationNative_ChangeCaseInvariant", GlobalizationNative_ChangeCaseInvariant}, - {"GlobalizationNative_ChangeCaseTurkish", GlobalizationNative_ChangeCaseTurkish}, - {"GlobalizationNative_CloseSortHandle", GlobalizationNative_CloseSortHandle}, - {"GlobalizationNative_CompareString", GlobalizationNative_CompareString}, - {"GlobalizationNative_EndsWith", GlobalizationNative_EndsWith}, - {"GlobalizationNative_EnumCalendarInfo", GlobalizationNative_EnumCalendarInfo}, - {"GlobalizationNative_GetCalendarInfo", GlobalizationNative_GetCalendarInfo}, - {"GlobalizationNative_GetCalendars", GlobalizationNative_GetCalendars}, - {"GlobalizationNative_GetDefaultLocaleName", GlobalizationNative_GetDefaultLocaleName}, - {"GlobalizationNative_GetICUVersion", GlobalizationNative_GetICUVersion}, - {"GlobalizationNative_GetJapaneseEraStartDate", GlobalizationNative_GetJapaneseEraStartDate}, - {"GlobalizationNative_GetLatestJapaneseEra", GlobalizationNative_GetLatestJapaneseEra}, - {"GlobalizationNative_GetLocaleInfoGroupingSizes", GlobalizationNative_GetLocaleInfoGroupingSizes}, - {"GlobalizationNative_GetLocaleInfoInt", GlobalizationNative_GetLocaleInfoInt}, - {"GlobalizationNative_GetLocaleInfoString", GlobalizationNative_GetLocaleInfoString}, - {"GlobalizationNative_GetLocaleName", GlobalizationNative_GetLocaleName}, - {"GlobalizationNative_GetLocales", GlobalizationNative_GetLocales}, - {"GlobalizationNative_GetLocaleTimeFormat", GlobalizationNative_GetLocaleTimeFormat}, - {"GlobalizationNative_GetSortHandle", GlobalizationNative_GetSortHandle}, - {"GlobalizationNative_GetSortKey", GlobalizationNative_GetSortKey}, - {"GlobalizationNative_GetSortVersion", GlobalizationNative_GetSortVersion}, - {"GlobalizationNative_GetTimeZoneDisplayName", GlobalizationNative_GetTimeZoneDisplayName}, - {"GlobalizationNative_IndexOf", GlobalizationNative_IndexOf}, - {"GlobalizationNative_InitICUFunctions", GlobalizationNative_InitICUFunctions}, - {"GlobalizationNative_InitOrdinalCasingPage", GlobalizationNative_InitOrdinalCasingPage}, - {"GlobalizationNative_IsNormalized", GlobalizationNative_IsNormalized}, - {"GlobalizationNative_IsPredefinedLocale", GlobalizationNative_IsPredefinedLocale}, - {"GlobalizationNative_LastIndexOf", GlobalizationNative_LastIndexOf}, - {"GlobalizationNative_LoadICU", GlobalizationNative_LoadICU}, - {"GlobalizationNative_NormalizeString", GlobalizationNative_NormalizeString}, - {"GlobalizationNative_StartsWith", GlobalizationNative_StartsWith}, - {"GlobalizationNative_ToAscii", GlobalizationNative_ToAscii}, - {"GlobalizationNative_ToUnicode", GlobalizationNative_ToUnicode}, + {"GlobalizationNative_ChangeCase", (void*)GlobalizationNative_ChangeCase}, + {"GlobalizationNative_ChangeCaseInvariant", (void*)GlobalizationNative_ChangeCaseInvariant}, + {"GlobalizationNative_ChangeCaseTurkish", (void*)GlobalizationNative_ChangeCaseTurkish}, + {"GlobalizationNative_CloseSortHandle", (void*)GlobalizationNative_CloseSortHandle}, + {"GlobalizationNative_CompareString", (void*)GlobalizationNative_CompareString}, + {"GlobalizationNative_EndsWith", (void*)GlobalizationNative_EndsWith}, + {"GlobalizationNative_EnumCalendarInfo", (void*)GlobalizationNative_EnumCalendarInfo}, + {"GlobalizationNative_GetCalendarInfo", (void*)GlobalizationNative_GetCalendarInfo}, + {"GlobalizationNative_GetCalendars", (void*)GlobalizationNative_GetCalendars}, + {"GlobalizationNative_GetDefaultLocaleName", (void*)GlobalizationNative_GetDefaultLocaleName}, + {"GlobalizationNative_GetICUVersion", (void*)GlobalizationNative_GetICUVersion}, + {"GlobalizationNative_GetJapaneseEraStartDate", (void*)GlobalizationNative_GetJapaneseEraStartDate}, + {"GlobalizationNative_GetLatestJapaneseEra", (void*)GlobalizationNative_GetLatestJapaneseEra}, + {"GlobalizationNative_GetLocaleInfoGroupingSizes", (void*)GlobalizationNative_GetLocaleInfoGroupingSizes}, + {"GlobalizationNative_GetLocaleInfoInt", (void*)GlobalizationNative_GetLocaleInfoInt}, + {"GlobalizationNative_GetLocaleInfoString", (void*)GlobalizationNative_GetLocaleInfoString}, + {"GlobalizationNative_GetLocaleName", (void*)GlobalizationNative_GetLocaleName}, + {"GlobalizationNative_GetLocales", (void*)GlobalizationNative_GetLocales}, + {"GlobalizationNative_GetLocaleTimeFormat", (void*)GlobalizationNative_GetLocaleTimeFormat}, + {"GlobalizationNative_GetSortHandle", (void*)GlobalizationNative_GetSortHandle}, + {"GlobalizationNative_GetSortKey", (void*)GlobalizationNative_GetSortKey}, + {"GlobalizationNative_GetSortVersion", (void*)GlobalizationNative_GetSortVersion}, + {"GlobalizationNative_GetTimeZoneDisplayName", (void*)GlobalizationNative_GetTimeZoneDisplayName}, + {"GlobalizationNative_IndexOf", (void*)GlobalizationNative_IndexOf}, + {"GlobalizationNative_InitICUFunctions", (void*)GlobalizationNative_InitICUFunctions}, + {"GlobalizationNative_InitOrdinalCasingPage", (void*)GlobalizationNative_InitOrdinalCasingPage}, + {"GlobalizationNative_IsNormalized", (void*)GlobalizationNative_IsNormalized}, + {"GlobalizationNative_IsPredefinedLocale", (void*)GlobalizationNative_IsPredefinedLocale}, + {"GlobalizationNative_LastIndexOf", (void*)GlobalizationNative_LastIndexOf}, + {"GlobalizationNative_LoadICU", (void*)GlobalizationNative_LoadICU}, + {"GlobalizationNative_NormalizeString", (void*)GlobalizationNative_NormalizeString}, + {"GlobalizationNative_StartsWith", (void*)GlobalizationNative_StartsWith}, + {"GlobalizationNative_ToAscii", (void*)GlobalizationNative_ToAscii}, + {"GlobalizationNative_ToUnicode", (void*)GlobalizationNative_ToUnicode}, }; -extern "C" const void* GlobalizationResolveDllImport(const char* name) +EXTERN_C const void* GlobalizationResolveDllImport(const char* name); + +EXTERN_C const void* GlobalizationResolveDllImport(const char* name) { for (int i = 0; i < lengthof(s_globalizationNative); i++) { From 51281d695edaf734a3129f02f037b2437662378f Mon Sep 17 00:00:00 2001 From: vsadov Date: Fri, 20 Nov 2020 16:37:11 -0800 Subject: [PATCH 10/32] delete gPalGlobalizationNative --- .../System.Globalization.Native/entrypoints.c | 44 ------------------- src/mono/mono/metadata/native-library-qcall.c | 11 ++++- src/mono/mono/metadata/qcall-def.h | 2 +- 3 files changed, 10 insertions(+), 47 deletions(-) diff --git a/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c b/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c index c8434cdb0d325b..6bdabaf45bec82 100644 --- a/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c @@ -18,50 +18,6 @@ typedef uint16_t UChar; #include "pal_normalization.h" #include "pal_timeZoneInfo.h" -#define FCFuncStart(name) EXTERN_C const void* name[]; const void* name[] = { -#define FCFuncEnd() (void*)0x01 /* FCFuncFlag_EndOfArray */ }; - -#define QCFuncElement(name,impl) \ - (void*)0x8 /* FCFuncFlag_QCall */, (void*)(impl), (void*)name, - - -FCFuncStart(gPalGlobalizationNative) - QCFuncElement("ChangeCase", GlobalizationNative_ChangeCase) - QCFuncElement("ChangeCaseInvariant", GlobalizationNative_ChangeCaseInvariant) - QCFuncElement("ChangeCaseTurkish", GlobalizationNative_ChangeCaseTurkish) - QCFuncElement("CloseSortHandle", GlobalizationNative_CloseSortHandle) - QCFuncElement("CompareString", GlobalizationNative_CompareString) - QCFuncElement("EndsWith", GlobalizationNative_EndsWith) - QCFuncElement("EnumCalendarInfo", GlobalizationNative_EnumCalendarInfo) - QCFuncElement("GetCalendarInfo", GlobalizationNative_GetCalendarInfo) - QCFuncElement("GetCalendars", GlobalizationNative_GetCalendars) - QCFuncElement("GetDefaultLocaleName", GlobalizationNative_GetDefaultLocaleName) - QCFuncElement("GetICUVersion", GlobalizationNative_GetICUVersion) - QCFuncElement("GetJapaneseEraStartDate", GlobalizationNative_GetJapaneseEraStartDate) - QCFuncElement("GetLatestJapaneseEra", GlobalizationNative_GetLatestJapaneseEra) - QCFuncElement("GetLocaleInfoGroupingSizes", GlobalizationNative_GetLocaleInfoGroupingSizes) - QCFuncElement("GetLocaleInfoInt", GlobalizationNative_GetLocaleInfoInt) - QCFuncElement("GetLocaleInfoString", GlobalizationNative_GetLocaleInfoString) - QCFuncElement("GetLocaleName", GlobalizationNative_GetLocaleName) - QCFuncElement("GetLocales", GlobalizationNative_GetLocales) - QCFuncElement("GetLocaleTimeFormat", GlobalizationNative_GetLocaleTimeFormat) - QCFuncElement("GetSortHandle", GlobalizationNative_GetSortHandle) - QCFuncElement("GetSortKey", GlobalizationNative_GetSortKey) - QCFuncElement("GetSortVersion", GlobalizationNative_GetSortVersion) - QCFuncElement("GetTimeZoneDisplayName", GlobalizationNative_GetTimeZoneDisplayName) - QCFuncElement("IndexOf", GlobalizationNative_IndexOf) - QCFuncElement("InitICUFunctions", GlobalizationNative_InitICUFunctions) - QCFuncElement("InitOrdinalCasingPage", GlobalizationNative_InitOrdinalCasingPage) - QCFuncElement("IsNormalized", GlobalizationNative_IsNormalized) - QCFuncElement("IsPredefinedLocale", GlobalizationNative_IsPredefinedLocale) - QCFuncElement("LastIndexOf", GlobalizationNative_LastIndexOf) - QCFuncElement("LoadICU", GlobalizationNative_LoadICU) - QCFuncElement("NormalizeString", GlobalizationNative_NormalizeString) - QCFuncElement("StartsWith", GlobalizationNative_StartsWith) - QCFuncElement("ToAscii", GlobalizationNative_ToAscii) - QCFuncElement("ToUnicode", GlobalizationNative_ToUnicode) -FCFuncEnd() - #ifndef lengthof #define lengthof(rg) (int)(sizeof(rg)/sizeof(rg[0])) #endif diff --git a/src/mono/mono/metadata/native-library-qcall.c b/src/mono/mono/metadata/native-library-qcall.c index c4e1defc01dbc4..a69bc0c3a3d595 100644 --- a/src/mono/mono/metadata/native-library-qcall.c +++ b/src/mono/mono/metadata/native-library-qcall.c @@ -12,7 +12,7 @@ #include "mono/utils/mono-path.h" #include "mono/metadata/native-library.h" -extern const void* gPalGlobalizationNative[]; +extern const void* GlobalizationResolveDllImport(const char* name); enum { func_flag_end_of_array = 0x01, @@ -22,7 +22,7 @@ enum { }; #if defined(NO_GLOBALIZATION_SHIM) || !defined(ENABLE_NETCORE) -const void* gPalGlobalizationNative[] = { (void*)func_flag_end_of_array }; +const void* GlobalizationResolveDllImport(const char* name) { return NULL; } #endif static const MonoQCallDef c_qcalls[] = @@ -108,6 +108,13 @@ find_index_for_method (MonoMethod *method, const void **impls) gpointer mono_lookup_pinvoke_qcall_internal (MonoMethod *method, MonoLookupPInvokeStatus *status_out) { + const char *method_name = method->name; + const void *method_impl = GlobalizationResolveDllImport(method_name); + if (method_impl != NULL) + { + return (gpointer)method_impl; + } + int pos_class = find_impls_index_for_class (method); if (pos_class < 0) { mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_QCALL, diff --git a/src/mono/mono/metadata/qcall-def.h b/src/mono/mono/metadata/qcall-def.h index 1e83108fa7b1b6..7341edddef2929 100644 --- a/src/mono/mono/metadata/qcall-def.h +++ b/src/mono/mono/metadata/qcall-def.h @@ -12,4 +12,4 @@ * have to end with a func_flag_end_of_array (0x01) entry. **/ -FCClassElement("Globalization", "", gPalGlobalizationNative) +FCClassElement("", "", NULL) From 25369f4e2fd1e7a2538efbc47d5e0e355ce4de80 Mon Sep 17 00:00:00 2001 From: vsadov Date: Fri, 20 Nov 2020 17:38:54 -0800 Subject: [PATCH 11/32] pass overrider from the host --- .../src/dlls/mscoree/unixinterface.cpp | 28 +++++++++---- src/coreclr/src/inc/pinvokeoverride.h | 6 ++- src/coreclr/src/inc/pinvokeoverrideimpl.h | 3 +- src/coreclr/src/vm/pinvokeoverrideimpl.cpp | 5 ++- .../cli/apphost/static/CMakeLists.txt | 1 + .../corehost/cli/hostpolicy/coreclr.cpp | 1 + .../corehost/cli/hostpolicy/coreclr.h | 1 + .../cli/hostpolicy/hostpolicy_context.cpp | 42 +++++++++++++++++++ 8 files changed, 76 insertions(+), 11 deletions(-) diff --git a/src/coreclr/src/dlls/mscoree/unixinterface.cpp b/src/coreclr/src/dlls/mscoree/unixinterface.cpp index 3214d7bbae32e9..49c46108fef827 100644 --- a/src/coreclr/src/dlls/mscoree/unixinterface.cpp +++ b/src/coreclr/src/dlls/mscoree/unixinterface.cpp @@ -124,6 +124,7 @@ static void ConvertConfigPropertiesToUnicode( LPCWSTR** propertyKeysWRef, LPCWSTR** propertyValuesWRef, BundleProbe** bundleProbe, + PInvokeOverrideFn** pinvokeOverride, bool* hostPolicyEmbedded) { LPCWSTR* propertyKeysW = new (nothrow) LPCWSTR[propertyCount]; @@ -143,6 +144,12 @@ static void ConvertConfigPropertiesToUnicode( // is passed in as the value of "BUNDLE_PROBE" property (encoded as a string). *bundleProbe = (BundleProbe*)_wcstoui64(propertyValuesW[propertyIndex], nullptr, 0); } + else if (strcmp(propertyKeys[propertyIndex], "PINVOKE_OVERRIDE") == 0) + { + // If host provides a PInvoke override (typically in a single-file bundle), + // the override callback is passed in as the value of "PINVOKE_OVERRIDE" property (encoded as a string). + *pinvokeOverride = (PInvokeOverrideFn*)_wcstoui64(propertyValuesW[propertyIndex], nullptr, 0); + } else if (strcmp(propertyKeys[propertyIndex], "HOSTPOLICY_EMBEDDED") == 0) { // The HOSTPOLICY_EMBEDDED property indicates if the executable has hostpolicy statically linked in @@ -191,6 +198,7 @@ int coreclr_initialize( LPCWSTR* propertyValuesW; BundleProbe* bundleProbe = nullptr; bool hostPolicyEmbedded = false; + PInvokeOverrideFn* pinvokeOverride = nullptr; ConvertConfigPropertiesToUnicode( propertyKeys, @@ -199,6 +207,7 @@ int coreclr_initialize( &propertyKeysW, &propertyValuesW, &bundleProbe, + &pinvokeOverride, &hostPolicyEmbedded); #ifdef TARGET_UNIX @@ -215,13 +224,18 @@ int coreclr_initialize( g_hostpolicy_embedded = hostPolicyEmbedded; - // TODO: WIP, fetch this from args similar to Bundle/bundleProbe - // - // if (overider != nullptr) - // { - // PInvokeOverride::SetPInvokeOverride(overrider); - // } - PInvokeOverride::SetPInvokeOverride(SuperHost::ResolveDllImport); + if (pinvokeOverride != nullptr) + { + PInvokeOverride::SetPInvokeOverride(pinvokeOverride); + } + else + { + // + // REVIEW: THIS IS A TEST-ONLY IMPLEMENTATION AND WILL BE REMOVED. + // THE ACTUAL IMPLEMENTATION IS PROVIDED BY THE HOST + // + // PInvokeOverride::SetPInvokeOverride(SuperHost::ResolveDllImport); + } ReleaseHolder host; diff --git a/src/coreclr/src/inc/pinvokeoverride.h b/src/coreclr/src/inc/pinvokeoverride.h index 5ce137460a3fb9..2d493582e2a3dc 100644 --- a/src/coreclr/src/inc/pinvokeoverride.h +++ b/src/coreclr/src/inc/pinvokeoverride.h @@ -10,7 +10,11 @@ #ifndef _PINVOKEOVERRIDE_H_ #define _PINVOKEOVERRIDE_H_ -typedef const void* (PInvokeOverrideFn)(const char* libraryName, const char* entrypointName); +#ifndef _MSC_VER +#define __stdcall +#endif + +typedef const void* (__stdcall PInvokeOverrideFn)(const char* libraryName, const char* entrypointName); class PInvokeOverride { diff --git a/src/coreclr/src/inc/pinvokeoverrideimpl.h b/src/coreclr/src/inc/pinvokeoverrideimpl.h index fb0ad51304e0a6..0ce41295fbee63 100644 --- a/src/coreclr/src/inc/pinvokeoverrideimpl.h +++ b/src/coreclr/src/inc/pinvokeoverrideimpl.h @@ -3,7 +3,8 @@ // // -// REVIEW: THE IMPLEMENTATION FOR THE OVERRIDER WILL BE MOVED TO HOST +// REVIEW: THIS IS A TEST-ONLY IMPLEMENTATION AND WILL BE REMOVED. +// THE ACTUAL IMPLEMENTATION IS PROVIDED BY THE HOST // namespace SuperHost diff --git a/src/coreclr/src/vm/pinvokeoverrideimpl.cpp b/src/coreclr/src/vm/pinvokeoverrideimpl.cpp index 091b07b1c0023c..bcefd1bf45345b 100644 --- a/src/coreclr/src/vm/pinvokeoverrideimpl.cpp +++ b/src/coreclr/src/vm/pinvokeoverrideimpl.cpp @@ -3,7 +3,8 @@ // // -// REVIEW: THE IMPLEMENTATION FOR THE OVERRIDER WILL BE MOVED TO HOST +// REVIEW: THIS IS A TEST-ONLY IMPLEMENTATION AND WILL BE REMOVED. +// THE ACTUAL IMPLEMENTATION IS PROVIDED BY THE HOST // #include "common.h" @@ -12,7 +13,7 @@ extern "C" const void* GlobalizationResolveDllImport(const char* name); extern "C" const void* CompressionResolveDllImport(const char* name); -const void* SuperHost::ResolveDllImport(const char* libraryName, const char* entrypointName) +const void* __stdcall SuperHost::ResolveDllImport(const char* libraryName, const char* entrypointName) { if (strcmp(libraryName, "libSystem.Globalization.Native") == 0) { diff --git a/src/installer/corehost/cli/apphost/static/CMakeLists.txt b/src/installer/corehost/cli/apphost/static/CMakeLists.txt index dbef445c6bda86..5f3d8b63fc0e2e 100644 --- a/src/installer/corehost/cli/apphost/static/CMakeLists.txt +++ b/src/installer/corehost/cli/apphost/static/CMakeLists.txt @@ -35,6 +35,7 @@ add_definitions(-D_NO_ASYNCRTIMP) add_definitions(-D_NO_PPLXIMP) add_definitions(-DEXPORT_SHARED_API=1) add_definitions(-DHOSTPOLICY_EMBEDDED) +add_definitions(-DNATIVE_LIBS_EMBEDDED) include(../../fxr/files.cmake) diff --git a/src/installer/corehost/cli/hostpolicy/coreclr.cpp b/src/installer/corehost/cli/hostpolicy/coreclr.cpp index d9564ac8fa6768..52611d45416e3f 100644 --- a/src/installer/corehost/cli/hostpolicy/coreclr.cpp +++ b/src/installer/corehost/cli/hostpolicy/coreclr.cpp @@ -148,6 +148,7 @@ namespace _X("APP_NI_PATHS"), _X("RUNTIME_IDENTIFIER"), _X("BUNDLE_PROBE"), + _X("PINVOKE_OVERRIDE"), _X("HOSTPOLICY_EMBEDDED") }; diff --git a/src/installer/corehost/cli/hostpolicy/coreclr.h b/src/installer/corehost/cli/hostpolicy/coreclr.h index c086ba56e10b2d..fa74d638b809fa 100644 --- a/src/installer/corehost/cli/hostpolicy/coreclr.h +++ b/src/installer/corehost/cli/hostpolicy/coreclr.h @@ -66,6 +66,7 @@ enum class common_property AppNIPaths, RuntimeIdentifier, BundleProbe, + PInvokeOverride, HostPolicyEmbedded, // Sentinel value - new values should be defined above Last diff --git a/src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp b/src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp index 48d7cd335dd918..6619be4fede460 100644 --- a/src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp +++ b/src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp @@ -42,6 +42,32 @@ namespace return bundle::runner_t::app()->probe(file_path, offset, size); } + +#if defined(NATIVE_LIBS_EMBEDDED) + extern "C" const void* GlobalizationResolveDllImport(const char* name); + extern "C" const void* CompressionResolveDllImport(const char* name); + + // pinvoke_override: + // Check if given function belongs to one of statically linked libraries and return a pointer if found. + const void* STDMETHODCALLTYPE pinvoke_override(const char* libraryName, const char* entrypointName) + { + if (strcmp(libraryName, "libSystem.Globalization.Native") == 0) + { + return GlobalizationResolveDllImport(entrypointName); + } + +#if defined(_WIN32) + if (strcmp(libraryName, "clrcompression") == 0) +#else + if (strcmp(libraryName, "libSystem.IO.Compression.Native") == 0) +#endif + { + return CompressionResolveDllImport(entrypointName); + } + + return nullptr; + } +#endif } int hostpolicy_context_t::initialize(hostpolicy_init_t &hostpolicy_init, const arguments_t &args, bool enable_breadcrumbs) @@ -241,6 +267,22 @@ int hostpolicy_context_t::initialize(hostpolicy_init_t &hostpolicy_init, const a } } +#if defined(NATIVE_LIBS_EMBEDDED) + // PInvoke Override + if (bundle::info_t::is_single_file_bundle()) + { + // Encode the pinvoke_override function pointer as a string, and pass it to the runtime. + pal::stringstream_t ptr_stream; + ptr_stream << "0x" << std::hex << (size_t)(&pinvoke_override); + + if (!coreclr_properties.add(common_property::PInvokeOverride, ptr_stream.str().c_str())) + { + log_duplicate_property_error(coreclr_property_bag_t::common_property_to_string(common_property::StartUpHooks)); + return StatusCode::LibHostDuplicateProperty; + } + } +#endif + #if defined(HOSTPOLICY_EMBEDDED) if (!coreclr_properties.add(common_property::HostPolicyEmbedded, _X("true"))) { From e6fca939022a36c9f2b34fcfcce51795b1e1d356 Mon Sep 17 00:00:00 2001 From: vsadov Date: Sat, 21 Nov 2020 12:17:52 -0800 Subject: [PATCH 12/32] default override --- src/coreclr/src/dlls/mscoree/unixinterface.cpp | 8 +------- src/coreclr/src/inc/pinvokeoverrideimpl.h | 7 +------ src/coreclr/src/vm/pinvokeoverrideimpl.cpp | 15 ++++++++------- src/mono/mono/metadata/native-library-qcall.c | 5 ++--- src/mono/mono/metadata/native-library.c | 2 +- src/mono/mono/metadata/native-library.h | 2 +- 6 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/coreclr/src/dlls/mscoree/unixinterface.cpp b/src/coreclr/src/dlls/mscoree/unixinterface.cpp index 49c46108fef827..f6d49396e9ac17 100644 --- a/src/coreclr/src/dlls/mscoree/unixinterface.cpp +++ b/src/coreclr/src/dlls/mscoree/unixinterface.cpp @@ -19,8 +19,6 @@ #endif // FEATURE_GDBJIT #include "bundle.h" #include "pinvokeoverride.h" - -// TODO: WIP, this is for testing, will remove later. #include "pinvokeoverrideimpl.h" #define ASSERTE_ALL_BUILDS(expr) _ASSERTE_ALL_BUILDS(__FILE__, (expr)) @@ -230,11 +228,7 @@ int coreclr_initialize( } else { - // - // REVIEW: THIS IS A TEST-ONLY IMPLEMENTATION AND WILL BE REMOVED. - // THE ACTUAL IMPLEMENTATION IS PROVIDED BY THE HOST - // - // PInvokeOverride::SetPInvokeOverride(SuperHost::ResolveDllImport); + PInvokeOverride::SetPInvokeOverride(DefaultPInvokeOverride::ResolveDllImport); } ReleaseHolder host; diff --git a/src/coreclr/src/inc/pinvokeoverrideimpl.h b/src/coreclr/src/inc/pinvokeoverrideimpl.h index 0ce41295fbee63..f008d490c91d82 100644 --- a/src/coreclr/src/inc/pinvokeoverrideimpl.h +++ b/src/coreclr/src/inc/pinvokeoverrideimpl.h @@ -2,12 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // -// -// REVIEW: THIS IS A TEST-ONLY IMPLEMENTATION AND WILL BE REMOVED. -// THE ACTUAL IMPLEMENTATION IS PROVIDED BY THE HOST -// - -namespace SuperHost +namespace DefaultPInvokeOverride { const void* ResolveDllImport(const char* libraryName, const char* entrypointName); } diff --git a/src/coreclr/src/vm/pinvokeoverrideimpl.cpp b/src/coreclr/src/vm/pinvokeoverrideimpl.cpp index bcefd1bf45345b..210e19b7b47770 100644 --- a/src/coreclr/src/vm/pinvokeoverrideimpl.cpp +++ b/src/coreclr/src/vm/pinvokeoverrideimpl.cpp @@ -2,31 +2,32 @@ // The .NET Foundation licenses this file to you under the MIT license. // -// -// REVIEW: THIS IS A TEST-ONLY IMPLEMENTATION AND WILL BE REMOVED. -// THE ACTUAL IMPLEMENTATION IS PROVIDED BY THE HOST -// - #include "common.h" #include "pinvokeoverrideimpl.h" extern "C" const void* GlobalizationResolveDllImport(const char* name); extern "C" const void* CompressionResolveDllImport(const char* name); -const void* __stdcall SuperHost::ResolveDllImport(const char* libraryName, const char* entrypointName) +const void* __stdcall DefaultPInvokeOverride::ResolveDllImport(const char* libraryName, const char* entrypointName) { if (strcmp(libraryName, "libSystem.Globalization.Native") == 0) { return GlobalizationResolveDllImport(entrypointName); } + + // + // REVIEW: HANDLING IMPORTS OTHER THAN "libSystem.Globalization.Native" + // IS TEST-ONLY AND WILL BE REMOVED. + // + #if defined(_WIN32) if (strcmp(libraryName, "clrcompression") == 0) #else if (strcmp(libraryName, "libSystem.IO.Compression.Native") == 0) #endif { - return CompressionResolveDllImport(entrypointName); + // return CompressionResolveDllImport(entrypointName); } return nullptr; diff --git a/src/mono/mono/metadata/native-library-qcall.c b/src/mono/mono/metadata/native-library-qcall.c index a69bc0c3a3d595..cc3f74c7d3e099 100644 --- a/src/mono/mono/metadata/native-library-qcall.c +++ b/src/mono/mono/metadata/native-library-qcall.c @@ -106,10 +106,9 @@ find_index_for_method (MonoMethod *method, const void **impls) } gpointer -mono_lookup_pinvoke_qcall_internal (MonoMethod *method, MonoLookupPInvokeStatus *status_out) +mono_lookup_pinvoke_qcall_internal (MonoMethod *method, const char* dllentry, MonoLookupPInvokeStatus *status_out) { - const char *method_name = method->name; - const void *method_impl = GlobalizationResolveDllImport(method_name); + const void *method_impl = GlobalizationResolveDllImport(dllentry); if (method_impl != NULL) { return (gpointer)method_impl; diff --git a/src/mono/mono/metadata/native-library.c b/src/mono/mono/metadata/native-library.c index cc0c191415bdc3..52940133b6cb58 100644 --- a/src/mono/mono/metadata/native-library.c +++ b/src/mono/mono/metadata/native-library.c @@ -1324,7 +1324,7 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou /* If qcalls are disabled, we fall back to the normal pinvoke code for them */ #ifndef DISABLE_QCALLS if (strcmp (new_scope, "QCall") == 0 || strcmp(new_scope, "libSystem.Globalization.Native") == 0) { - piinfo->addr = mono_lookup_pinvoke_qcall_internal (method, status_out); + piinfo->addr = mono_lookup_pinvoke_qcall_internal (method, new_import, status_out); if (!piinfo->addr) { mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_DLLIMPORT, "Unable to find qcall for '%s'.", diff --git a/src/mono/mono/metadata/native-library.h b/src/mono/mono/metadata/native-library.h index a5b556b80dac5b..038e59bcacf369 100644 --- a/src/mono/mono/metadata/native-library.h +++ b/src/mono/mono/metadata/native-library.h @@ -29,7 +29,7 @@ typedef struct MonoLookupPInvokeStatus { } MonoLookupPInvokeStatus; gpointer -mono_lookup_pinvoke_qcall_internal (MonoMethod *method, MonoLookupPInvokeStatus *error); +mono_lookup_pinvoke_qcall_internal (MonoMethod *method, const char* dllentry, MonoLookupPInvokeStatus *error); typedef struct MonoQCallDef { From c11612f503450e6f85c9082072d9f1f17c2253d2 Mon Sep 17 00:00:00 2001 From: vsadov Date: Mon, 23 Nov 2020 15:57:49 -0800 Subject: [PATCH 13/32] default PInvoke override runs after optional host-provided overrider. --- .../src/dlls/mscoree/unixinterface.cpp | 5 --- src/coreclr/src/inc/pinvokeoverride.h | 3 ++ src/coreclr/src/inc/pinvokeoverrideimpl.h | 8 ----- src/coreclr/src/vm/CMakeLists.txt | 1 - src/coreclr/src/vm/pinvokeoverride.cpp | 27 +++++++++++++-- src/coreclr/src/vm/pinvokeoverrideimpl.cpp | 34 ------------------- 6 files changed, 27 insertions(+), 51 deletions(-) delete mode 100644 src/coreclr/src/inc/pinvokeoverrideimpl.h delete mode 100644 src/coreclr/src/vm/pinvokeoverrideimpl.cpp diff --git a/src/coreclr/src/dlls/mscoree/unixinterface.cpp b/src/coreclr/src/dlls/mscoree/unixinterface.cpp index f6d49396e9ac17..dbefb048902492 100644 --- a/src/coreclr/src/dlls/mscoree/unixinterface.cpp +++ b/src/coreclr/src/dlls/mscoree/unixinterface.cpp @@ -19,7 +19,6 @@ #endif // FEATURE_GDBJIT #include "bundle.h" #include "pinvokeoverride.h" -#include "pinvokeoverrideimpl.h" #define ASSERTE_ALL_BUILDS(expr) _ASSERTE_ALL_BUILDS(__FILE__, (expr)) @@ -226,10 +225,6 @@ int coreclr_initialize( { PInvokeOverride::SetPInvokeOverride(pinvokeOverride); } - else - { - PInvokeOverride::SetPInvokeOverride(DefaultPInvokeOverride::ResolveDllImport); - } ReleaseHolder host; diff --git a/src/coreclr/src/inc/pinvokeoverride.h b/src/coreclr/src/inc/pinvokeoverride.h index 2d493582e2a3dc..a427a6c754b88e 100644 --- a/src/coreclr/src/inc/pinvokeoverride.h +++ b/src/coreclr/src/inc/pinvokeoverride.h @@ -24,6 +24,9 @@ class PInvokeOverride public: static void SetPInvokeOverride(PInvokeOverrideFn* overrideImpl); static const void* TryGetMethodImpl(const char* libraryName, const char* entrypointName); + +private: + static const void* DefaultResolveDllImport(const char* libraryName, const char* entrypointName); }; #endif // _PINVOKEOVERRIDE_H_ diff --git a/src/coreclr/src/inc/pinvokeoverrideimpl.h b/src/coreclr/src/inc/pinvokeoverrideimpl.h deleted file mode 100644 index f008d490c91d82..00000000000000 --- a/src/coreclr/src/inc/pinvokeoverrideimpl.h +++ /dev/null @@ -1,8 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// - -namespace DefaultPInvokeOverride -{ - const void* ResolveDllImport(const char* libraryName, const char* entrypointName); -} diff --git a/src/coreclr/src/vm/CMakeLists.txt b/src/coreclr/src/vm/CMakeLists.txt index 6b83423be7b15c..3f2600a40689f7 100644 --- a/src/coreclr/src/vm/CMakeLists.txt +++ b/src/coreclr/src/vm/CMakeLists.txt @@ -103,7 +103,6 @@ set(VM_SOURCES_DAC_AND_WKS_COMMON perfinfo.cpp pgo.cpp pinvokeoverride.cpp - pinvokeoverrideimpl.cpp precode.cpp prestub.cpp profilerdiagnosticprotocolhelper.cpp diff --git a/src/coreclr/src/vm/pinvokeoverride.cpp b/src/coreclr/src/vm/pinvokeoverride.cpp index f5c0099bdbef86..6d096941b9ee5a 100644 --- a/src/coreclr/src/vm/pinvokeoverride.cpp +++ b/src/coreclr/src/vm/pinvokeoverride.cpp @@ -7,8 +7,11 @@ // //***************************************************************************** +#include "common.h" #include "pinvokeoverride.h" +extern "C" const void* GlobalizationResolveDllImport(const char* name); + PInvokeOverrideFn* PInvokeOverride::s_overrideImpl = nullptr; void PInvokeOverride::SetPInvokeOverride(PInvokeOverrideFn* overrideImpl) @@ -18,7 +21,25 @@ void PInvokeOverride::SetPInvokeOverride(PInvokeOverrideFn* overrideImpl) const void* PInvokeOverride::TryGetMethodImpl(const char* libraryName, const char* entrypointName) { - return s_overrideImpl ? - s_overrideImpl(libraryName, entrypointName) : - nullptr; + if (s_overrideImpl != nullptr) + { + const void* result = s_overrideImpl(libraryName, entrypointName); + if (result != nullptr) + { + return result; + } + } + + return DefaultResolveDllImport(libraryName, entrypointName); +} + +// here we handle PInvokes whose implementation is always statically linked (even in .so/.dll case) +const void* PInvokeOverride::DefaultResolveDllImport(const char* libraryName, const char* entrypointName) +{ + if (strcmp(libraryName, "libSystem.Globalization.Native") == 0) + { + return GlobalizationResolveDllImport(entrypointName); + } + + return nullptr; } diff --git a/src/coreclr/src/vm/pinvokeoverrideimpl.cpp b/src/coreclr/src/vm/pinvokeoverrideimpl.cpp deleted file mode 100644 index 210e19b7b47770..00000000000000 --- a/src/coreclr/src/vm/pinvokeoverrideimpl.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// - -#include "common.h" -#include "pinvokeoverrideimpl.h" - -extern "C" const void* GlobalizationResolveDllImport(const char* name); -extern "C" const void* CompressionResolveDllImport(const char* name); - -const void* __stdcall DefaultPInvokeOverride::ResolveDllImport(const char* libraryName, const char* entrypointName) -{ - if (strcmp(libraryName, "libSystem.Globalization.Native") == 0) - { - return GlobalizationResolveDllImport(entrypointName); - } - - - // - // REVIEW: HANDLING IMPORTS OTHER THAN "libSystem.Globalization.Native" - // IS TEST-ONLY AND WILL BE REMOVED. - // - -#if defined(_WIN32) - if (strcmp(libraryName, "clrcompression") == 0) -#else - if (strcmp(libraryName, "libSystem.IO.Compression.Native") == 0) -#endif - { - // return CompressionResolveDllImport(entrypointName); - } - - return nullptr; -} From d3f4abec1a1ecccf6bc1673674b16c333b8cb38c Mon Sep 17 00:00:00 2001 From: vsadov Date: Tue, 24 Nov 2020 17:18:03 -0800 Subject: [PATCH 14/32] Some PR feedback (mostly related to code, not the CMake stuff). --- eng/native/configurecompiler.cmake | 1 - .../src/dlls/mscoree/coreclr/CMakeLists.txt | 19 ---- src/coreclr/src/inc/bundle.h | 5 +- src/coreclr/src/inc/cor.h | 1 - src/coreclr/src/inc/corpriv.h | 1 - src/coreclr/src/inc/pinvokeoverride.h | 15 +-- src/coreclr/src/vm/dllimport.cpp | 2 +- src/coreclr/src/vm/pinvokeoverride.cpp | 27 ++--- .../corehost/cli/hostpolicy/coreclr.cpp | 4 +- .../corehost/cli/hostpolicy/coreclr.h | 2 +- .../cli/hostpolicy/hostpolicy_context.cpp | 5 - .../entrypoints.c | 48 ++++----- .../System.Globalization.Native/entrypoints.c | 78 ++++++++------- .../System.Net.Security.Native/pal_gssapi.h | 98 +++++++++---------- src/mono/mono/metadata/native-library-qcall.c | 14 +-- src/mono/mono/metadata/native-library.c | 18 +++- src/mono/mono/metadata/native-library.h | 2 +- 17 files changed, 156 insertions(+), 184 deletions(-) diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index c3d53bb1075903..4daa6feaf531ac 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -451,7 +451,6 @@ endif(CLR_CMAKE_HOST_UNIX) if (MSVC) # Compile options for targeting windows - # add_compile_options($<$:/TP>) # compile all files as C++ add_compile_options($<$:/nologo>) # Suppress Startup Banner add_compile_options($<$:/W3>) # set warning level to 3 add_compile_options($<$:/WX>) # treat warnings as errors diff --git a/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt index c5633056b05300..7835929afc1c9c 100644 --- a/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/src/dlls/mscoree/coreclr/CMakeLists.txt @@ -84,23 +84,6 @@ if (CLR_CMAKE_HOST_UNIX) set(LIB_UNWINDER unwinder_wks) endif (CLR_CMAKE_HOST_UNIX) -if(CLR_CMAKE_HOST_WIN32) - set(COMPRESSION_LIB clrcompression-static) -else() - set(COMPRESSION_LIB System.IO.Compression.Native-Static) - - if (CLR_CMAKE_TARGET_BROWSER) - add_definitions(-s USE_ZLIB) - elseif (CLR_CMAKE_TARGET_ANDROID) - # need special case here since we want to link against libz.so but find_package() would resolve libz.a - set(ZLIB_LIBRARIES z) - elseif (CLR_CMAKE_TARGET_SUNOS) - set(ZLIB_LIBRARIES z m) - else () - find_package(ZLIB REQUIRED) - endif () -endif() - # IMPORTANT! Please do not rearrange the order of the libraries. The linker on Linux is # order dependent and changing the order can result in undefined symbols in the shared # library. @@ -125,8 +108,6 @@ set(CORECLR_LIBRARIES utilcode v3binder System.Globalization.Native-Static - ${COMPRESSION_LIB} - ${ZLIB_LIBRARIES} interop ) diff --git a/src/coreclr/src/inc/bundle.h b/src/coreclr/src/inc/bundle.h index e6c7a0a1dd18f4..f3355901024489 100644 --- a/src/coreclr/src/inc/bundle.h +++ b/src/coreclr/src/inc/bundle.h @@ -3,7 +3,7 @@ /***************************************************************************** ** ** - ** bundle.h - Information about applications bundled as a single-file ** + ** bundle.h - Information about applications bundled as a single-file ** ** ** *****************************************************************************/ @@ -34,7 +34,7 @@ struct BundleFileLocation bool IsValid() const { LIMITED_METHOD_CONTRACT; return Offset != 0; } }; -typedef bool(__stdcall BundleProbe)(LPCSTR, INT64*, INT64*); +typedef bool(BundleProbe)(LPCSTR, INT64*, INT64*); class Bundle { @@ -59,4 +59,3 @@ class Bundle }; #endif // _BUNDLE_H_ -// EOF ======================================================================= diff --git a/src/coreclr/src/inc/cor.h b/src/coreclr/src/inc/cor.h index 7b9bf9c4ff1726..9101bcdbd45055 100644 --- a/src/coreclr/src/inc/cor.h +++ b/src/coreclr/src/inc/cor.h @@ -2388,4 +2388,3 @@ inline ULONG CorSigUncompressPointer( // return number of bytes of that compre #endif // __cplusplus #endif // _COR_H_ -// EOF ======================================================================= diff --git a/src/coreclr/src/inc/corpriv.h b/src/coreclr/src/inc/corpriv.h index 003386c4d17758..49056335cc7639 100644 --- a/src/coreclr/src/inc/corpriv.h +++ b/src/coreclr/src/inc/corpriv.h @@ -383,5 +383,4 @@ struct CORCOMPILE_DEPENDENCY; typedef GUID CORCOMPILE_NGEN_SIGNATURE; #endif // _CORPRIV_H_ -// EOF ======================================================================= diff --git a/src/coreclr/src/inc/pinvokeoverride.h b/src/coreclr/src/inc/pinvokeoverride.h index a427a6c754b88e..3f7215e5294840 100644 --- a/src/coreclr/src/inc/pinvokeoverride.h +++ b/src/coreclr/src/inc/pinvokeoverride.h @@ -10,24 +10,13 @@ #ifndef _PINVOKEOVERRIDE_H_ #define _PINVOKEOVERRIDE_H_ -#ifndef _MSC_VER -#define __stdcall -#endif - -typedef const void* (__stdcall PInvokeOverrideFn)(const char* libraryName, const char* entrypointName); +typedef const void* (PInvokeOverrideFn)(const char* libraryName, const char* entrypointName); class PInvokeOverride { -private: - static PInvokeOverrideFn* s_overrideImpl; - public: static void SetPInvokeOverride(PInvokeOverrideFn* overrideImpl); - static const void* TryGetMethodImpl(const char* libraryName, const char* entrypointName); - -private: - static const void* DefaultResolveDllImport(const char* libraryName, const char* entrypointName); + static const void* GetMethodImpl(const char* libraryName, const char* entrypointName); }; #endif // _PINVOKEOVERRIDE_H_ -// EOF ======================================================================= diff --git a/src/coreclr/src/vm/dllimport.cpp b/src/coreclr/src/vm/dllimport.cpp index 5f66d0b6e8dae5..4cae3832604f3b 100644 --- a/src/coreclr/src/vm/dllimport.cpp +++ b/src/coreclr/src/vm/dllimport.cpp @@ -6510,7 +6510,7 @@ VOID NDirect::NDirectLink(NDirectMethodDesc *pMD) pMD->EnsureActive(); { - LPVOID pvTarget = (LPVOID)PInvokeOverride::TryGetMethodImpl(pMD->GetLibNameRaw(), pMD->GetEntrypointName()); + LPVOID pvTarget = (LPVOID)PInvokeOverride::GetMethodImpl(pMD->GetLibNameRaw(), pMD->GetEntrypointName()); if (pvTarget != NULL) { pMD->SetNDirectTarget(pvTarget); diff --git a/src/coreclr/src/vm/pinvokeoverride.cpp b/src/coreclr/src/vm/pinvokeoverride.cpp index 6d096941b9ee5a..07af650e3aa926 100644 --- a/src/coreclr/src/vm/pinvokeoverride.cpp +++ b/src/coreclr/src/vm/pinvokeoverride.cpp @@ -12,34 +12,35 @@ extern "C" const void* GlobalizationResolveDllImport(const char* name); -PInvokeOverrideFn* PInvokeOverride::s_overrideImpl = nullptr; +static PInvokeOverrideFn* s_overrideImpl = nullptr; + +// here we handle PInvokes whose implementation is always statically linked (even in .so/.dll case) +static const void* DefaultResolveDllImport(const char* libraryName, const char* entrypointName) +{ + if (strcmp(libraryName, "libSystem.Globalization.Native") == 0) + { + return GlobalizationResolveDllImport(entrypointName); + } + + return nullptr; +} void PInvokeOverride::SetPInvokeOverride(PInvokeOverrideFn* overrideImpl) { s_overrideImpl = overrideImpl; } -const void* PInvokeOverride::TryGetMethodImpl(const char* libraryName, const char* entrypointName) +const void* PInvokeOverride::GetMethodImpl(const char* libraryName, const char* entrypointName) { if (s_overrideImpl != nullptr) { const void* result = s_overrideImpl(libraryName, entrypointName); if (result != nullptr) { + LOG((LF_INTEROP, LL_INFO1000, "PInvoke overriden for: lib: %s, entry: %s \n", libraryName, entrypointName)); return result; } } return DefaultResolveDllImport(libraryName, entrypointName); } - -// here we handle PInvokes whose implementation is always statically linked (even in .so/.dll case) -const void* PInvokeOverride::DefaultResolveDllImport(const char* libraryName, const char* entrypointName) -{ - if (strcmp(libraryName, "libSystem.Globalization.Native") == 0) - { - return GlobalizationResolveDllImport(entrypointName); - } - - return nullptr; -} diff --git a/src/installer/corehost/cli/hostpolicy/coreclr.cpp b/src/installer/corehost/cli/hostpolicy/coreclr.cpp index 52611d45416e3f..0046d66d474f76 100644 --- a/src/installer/corehost/cli/hostpolicy/coreclr.cpp +++ b/src/installer/corehost/cli/hostpolicy/coreclr.cpp @@ -148,8 +148,8 @@ namespace _X("APP_NI_PATHS"), _X("RUNTIME_IDENTIFIER"), _X("BUNDLE_PROBE"), - _X("PINVOKE_OVERRIDE"), - _X("HOSTPOLICY_EMBEDDED") + _X("HOSTPOLICY_EMBEDDED"), + _X("PINVOKE_OVERRIDE") }; static_assert((sizeof(PropertyNameMapping) / sizeof(*PropertyNameMapping)) == static_cast(common_property::Last), "Invalid property count"); diff --git a/src/installer/corehost/cli/hostpolicy/coreclr.h b/src/installer/corehost/cli/hostpolicy/coreclr.h index fa74d638b809fa..72b6742956a40e 100644 --- a/src/installer/corehost/cli/hostpolicy/coreclr.h +++ b/src/installer/corehost/cli/hostpolicy/coreclr.h @@ -66,8 +66,8 @@ enum class common_property AppNIPaths, RuntimeIdentifier, BundleProbe, - PInvokeOverride, HostPolicyEmbedded, + PInvokeOverride, // Sentinel value - new values should be defined above Last }; diff --git a/src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp b/src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp index 6619be4fede460..4d886583275366 100644 --- a/src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp +++ b/src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp @@ -51,11 +51,6 @@ namespace // Check if given function belongs to one of statically linked libraries and return a pointer if found. const void* STDMETHODCALLTYPE pinvoke_override(const char* libraryName, const char* entrypointName) { - if (strcmp(libraryName, "libSystem.Globalization.Native") == 0) - { - return GlobalizationResolveDllImport(entrypointName); - } - #if defined(_WIN32) if (strcmp(libraryName, "clrcompression") == 0) #else diff --git a/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c b/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c index 951e7a87702cea..f5973cb94fc4d0 100644 --- a/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c +++ b/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c @@ -1,8 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#include #include +#include // Include System.IO.Compression.Native headers #include "../zlib/pal_zlib.h" @@ -12,7 +12,7 @@ #include "../brotli/include/brotli/types.h" #ifndef lengthof -#define lengthof(rg) (int)(sizeof(rg)/sizeof(rg[0])) +#define lengthof(rg) (sizeof(rg)/sizeof(rg[0])) #endif typedef struct @@ -21,33 +21,37 @@ typedef struct const void* method; } Entry; -static Entry s_compressionNative[] = +// expands to: {"impl", (void*)impl}, +#define OverrideEntry(impl) \ + {#impl, (void*)impl}, + +static const Entry s_compressionNative[] = { - {"BrotliDecoderCreateInstance", (void*)BrotliDecoderCreateInstance}, - {"BrotliDecoderDecompress", (void*)BrotliDecoderDecompress}, - {"BrotliDecoderDecompressStream", (void*)BrotliDecoderDecompressStream}, - {"BrotliDecoderDestroyInstance", (void*)BrotliDecoderDestroyInstance}, - {"BrotliDecoderIsFinished", (void*)BrotliDecoderIsFinished}, - {"BrotliEncoderCompress", (void*)BrotliEncoderCompress}, - {"BrotliEncoderCompressStream", (void*)BrotliEncoderCompressStream}, - {"BrotliEncoderCreateInstance", (void*)BrotliEncoderCreateInstance}, - {"BrotliEncoderDestroyInstance", (void*)BrotliEncoderDestroyInstance}, - {"BrotliEncoderHasMoreOutput", (void*)BrotliEncoderHasMoreOutput}, - {"BrotliEncoderSetParameter", (void*)BrotliEncoderSetParameter}, - {"CompressionNative_Crc32", (void*)CompressionNative_Crc32}, - {"CompressionNative_Deflate", (void*)CompressionNative_Deflate}, - {"CompressionNative_DeflateEnd", (void*)CompressionNative_DeflateEnd}, - {"CompressionNative_DeflateInit2_", (void*)CompressionNative_DeflateInit2_}, - {"CompressionNative_Inflate", (void*)CompressionNative_Inflate}, - {"CompressionNative_InflateEnd", (void*)CompressionNative_InflateEnd}, - {"CompressionNative_InflateInit2_", (void*)CompressionNative_InflateInit2_}, + OverrideEntry(BrotliDecoderCreateInstance) + OverrideEntry(BrotliDecoderDecompress) + OverrideEntry(BrotliDecoderDecompressStream) + OverrideEntry(BrotliDecoderDestroyInstance) + OverrideEntry(BrotliDecoderIsFinished) + OverrideEntry(BrotliEncoderCompress) + OverrideEntry(BrotliEncoderCompressStream) + OverrideEntry(BrotliEncoderCreateInstance) + OverrideEntry(BrotliEncoderDestroyInstance) + OverrideEntry(BrotliEncoderHasMoreOutput) + OverrideEntry(BrotliEncoderSetParameter) + OverrideEntry(CompressionNative_Crc32) + OverrideEntry(CompressionNative_Deflate) + OverrideEntry(CompressionNative_DeflateEnd) + OverrideEntry(CompressionNative_DeflateInit2_) + OverrideEntry(CompressionNative_Inflate) + OverrideEntry(CompressionNative_InflateEnd) + OverrideEntry(CompressionNative_InflateInit2_) }; EXTERN_C const void* CompressionResolveDllImport(const char* name); EXTERN_C const void* CompressionResolveDllImport(const char* name) { - for (int i = 0; i < lengthof(s_compressionNative); i++) + for (size_t i = 0; i < lengthof(s_compressionNative); i++) { if (strcmp(name, s_compressionNative[i].name) == 0) { diff --git a/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c b/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c index 6bdabaf45bec82..07bee5d40697d1 100644 --- a/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c @@ -19,7 +19,7 @@ typedef uint16_t UChar; #include "pal_timeZoneInfo.h" #ifndef lengthof -#define lengthof(rg) (int)(sizeof(rg)/sizeof(rg[0])) +#define lengthof(rg) (sizeof(rg)/sizeof(rg[0])) #endif typedef struct @@ -28,49 +28,53 @@ typedef struct const void* method; } Entry; -static Entry s_globalizationNative[] = +// expands to: {"impl", (void*)impl}, +#define OverrideEntry(impl) \ + {#impl, (void*)impl}, + +static const Entry s_globalizationNative[] = { - {"GlobalizationNative_ChangeCase", (void*)GlobalizationNative_ChangeCase}, - {"GlobalizationNative_ChangeCaseInvariant", (void*)GlobalizationNative_ChangeCaseInvariant}, - {"GlobalizationNative_ChangeCaseTurkish", (void*)GlobalizationNative_ChangeCaseTurkish}, - {"GlobalizationNative_CloseSortHandle", (void*)GlobalizationNative_CloseSortHandle}, - {"GlobalizationNative_CompareString", (void*)GlobalizationNative_CompareString}, - {"GlobalizationNative_EndsWith", (void*)GlobalizationNative_EndsWith}, - {"GlobalizationNative_EnumCalendarInfo", (void*)GlobalizationNative_EnumCalendarInfo}, - {"GlobalizationNative_GetCalendarInfo", (void*)GlobalizationNative_GetCalendarInfo}, - {"GlobalizationNative_GetCalendars", (void*)GlobalizationNative_GetCalendars}, - {"GlobalizationNative_GetDefaultLocaleName", (void*)GlobalizationNative_GetDefaultLocaleName}, - {"GlobalizationNative_GetICUVersion", (void*)GlobalizationNative_GetICUVersion}, - {"GlobalizationNative_GetJapaneseEraStartDate", (void*)GlobalizationNative_GetJapaneseEraStartDate}, - {"GlobalizationNative_GetLatestJapaneseEra", (void*)GlobalizationNative_GetLatestJapaneseEra}, - {"GlobalizationNative_GetLocaleInfoGroupingSizes", (void*)GlobalizationNative_GetLocaleInfoGroupingSizes}, - {"GlobalizationNative_GetLocaleInfoInt", (void*)GlobalizationNative_GetLocaleInfoInt}, - {"GlobalizationNative_GetLocaleInfoString", (void*)GlobalizationNative_GetLocaleInfoString}, - {"GlobalizationNative_GetLocaleName", (void*)GlobalizationNative_GetLocaleName}, - {"GlobalizationNative_GetLocales", (void*)GlobalizationNative_GetLocales}, - {"GlobalizationNative_GetLocaleTimeFormat", (void*)GlobalizationNative_GetLocaleTimeFormat}, - {"GlobalizationNative_GetSortHandle", (void*)GlobalizationNative_GetSortHandle}, - {"GlobalizationNative_GetSortKey", (void*)GlobalizationNative_GetSortKey}, - {"GlobalizationNative_GetSortVersion", (void*)GlobalizationNative_GetSortVersion}, - {"GlobalizationNative_GetTimeZoneDisplayName", (void*)GlobalizationNative_GetTimeZoneDisplayName}, - {"GlobalizationNative_IndexOf", (void*)GlobalizationNative_IndexOf}, - {"GlobalizationNative_InitICUFunctions", (void*)GlobalizationNative_InitICUFunctions}, - {"GlobalizationNative_InitOrdinalCasingPage", (void*)GlobalizationNative_InitOrdinalCasingPage}, - {"GlobalizationNative_IsNormalized", (void*)GlobalizationNative_IsNormalized}, - {"GlobalizationNative_IsPredefinedLocale", (void*)GlobalizationNative_IsPredefinedLocale}, - {"GlobalizationNative_LastIndexOf", (void*)GlobalizationNative_LastIndexOf}, - {"GlobalizationNative_LoadICU", (void*)GlobalizationNative_LoadICU}, - {"GlobalizationNative_NormalizeString", (void*)GlobalizationNative_NormalizeString}, - {"GlobalizationNative_StartsWith", (void*)GlobalizationNative_StartsWith}, - {"GlobalizationNative_ToAscii", (void*)GlobalizationNative_ToAscii}, - {"GlobalizationNative_ToUnicode", (void*)GlobalizationNative_ToUnicode}, + OverrideEntry(GlobalizationNative_ChangeCase) + OverrideEntry(GlobalizationNative_ChangeCaseInvariant) + OverrideEntry(GlobalizationNative_ChangeCaseTurkish) + OverrideEntry(GlobalizationNative_CloseSortHandle) + OverrideEntry(GlobalizationNative_CompareString) + OverrideEntry(GlobalizationNative_EndsWith) + OverrideEntry(GlobalizationNative_EnumCalendarInfo) + OverrideEntry(GlobalizationNative_GetCalendarInfo) + OverrideEntry(GlobalizationNative_GetCalendars) + OverrideEntry(GlobalizationNative_GetDefaultLocaleName) + OverrideEntry(GlobalizationNative_GetICUVersion) + OverrideEntry(GlobalizationNative_GetJapaneseEraStartDate) + OverrideEntry(GlobalizationNative_GetLatestJapaneseEra) + OverrideEntry(GlobalizationNative_GetLocaleInfoGroupingSizes) + OverrideEntry(GlobalizationNative_GetLocaleInfoInt) + OverrideEntry(GlobalizationNative_GetLocaleInfoString) + OverrideEntry(GlobalizationNative_GetLocaleName) + OverrideEntry(GlobalizationNative_GetLocales) + OverrideEntry(GlobalizationNative_GetLocaleTimeFormat) + OverrideEntry(GlobalizationNative_GetSortHandle) + OverrideEntry(GlobalizationNative_GetSortKey) + OverrideEntry(GlobalizationNative_GetSortVersion) + OverrideEntry(GlobalizationNative_GetTimeZoneDisplayName) + OverrideEntry(GlobalizationNative_IndexOf) + OverrideEntry(GlobalizationNative_InitICUFunctions) + OverrideEntry(GlobalizationNative_InitOrdinalCasingPage) + OverrideEntry(GlobalizationNative_IsNormalized) + OverrideEntry(GlobalizationNative_IsPredefinedLocale) + OverrideEntry(GlobalizationNative_LastIndexOf) + OverrideEntry(GlobalizationNative_LoadICU) + OverrideEntry(GlobalizationNative_NormalizeString) + OverrideEntry(GlobalizationNative_StartsWith) + OverrideEntry(GlobalizationNative_ToAscii) + OverrideEntry(GlobalizationNative_ToUnicode) }; EXTERN_C const void* GlobalizationResolveDllImport(const char* name); EXTERN_C const void* GlobalizationResolveDllImport(const char* name) { - for (int i = 0; i < lengthof(s_globalizationNative); i++) + for (size_t i = 0; i < lengthof(s_globalizationNative); i++) { if (strcmp(name, s_globalizationNative[i].name) == 0) { diff --git a/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.h b/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.h index 5c1fe55163ec6c..4e94de546e4d8f 100644 --- a/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.h +++ b/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.h @@ -80,9 +80,9 @@ NetSecurityNative_ImportUserName(uint32_t* minorStatus, char* inputName, uint32_ Shims the gss_import_name method with nametype = GSS_C_NT_USER_NAME. */ PALEXPORT uint32_t NetSecurityNative_ImportPrincipalName(uint32_t* minorStatus, - char* inputName, - uint32_t inputNameLen, - GssName** outputName); + char* inputName, + uint32_t inputNameLen, + GssName** outputName); /* Shims the gss_release_name method. @@ -109,42 +109,42 @@ PALEXPORT uint32_t NetSecurityNative_ReleaseCred(uint32_t* minorStatus, GssCredI Shims the gss_init_sec_context method with SPNEGO oids. */ PALEXPORT uint32_t NetSecurityNative_InitSecContext(uint32_t* minorStatus, - GssCredId* claimantCredHandle, - GssCtxId** contextHandle, - uint32_t isNtlm, - GssName* targetName, - uint32_t reqFlags, - uint8_t* inputBytes, - uint32_t inputLength, - PAL_GssBuffer* outBuffer, - uint32_t* retFlags, - int32_t* isNtlmUsed); + GssCredId* claimantCredHandle, + GssCtxId** contextHandle, + uint32_t isNtlm, + GssName* targetName, + uint32_t reqFlags, + uint8_t* inputBytes, + uint32_t inputLength, + PAL_GssBuffer* outBuffer, + uint32_t* retFlags, + int32_t* isNtlmUsed); PALEXPORT uint32_t NetSecurityNative_InitSecContextEx(uint32_t* minorStatus, - GssCredId* claimantCredHandle, - GssCtxId** contextHandle, - uint32_t isNtlm, - void* cbt, - int32_t cbtSize, - GssName* targetName, - uint32_t reqFlags, - uint8_t* inputBytes, - uint32_t inputLength, - PAL_GssBuffer* outBuffer, - uint32_t* retFlags, - int32_t* isNtlmUsed); + GssCredId* claimantCredHandle, + GssCtxId** contextHandle, + uint32_t isNtlm, + void* cbt, + int32_t cbtSize, + GssName* targetName, + uint32_t reqFlags, + uint8_t* inputBytes, + uint32_t inputLength, + PAL_GssBuffer* outBuffer, + uint32_t* retFlags, + int32_t* isNtlmUsed); /* Shims the gss_accept_sec_context method. */ PALEXPORT uint32_t NetSecurityNative_AcceptSecContext(uint32_t* minorStatus, - GssCredId* acceptorCredHandle, - GssCtxId** contextHandle, - uint8_t* inputBytes, - uint32_t inputLength, - PAL_GssBuffer* outBuffer, - uint32_t* retFlags, - int32_t* isNtlmUsed); + GssCredId* acceptorCredHandle, + GssCtxId** contextHandle, + uint8_t* inputBytes, + uint32_t inputLength, + PAL_GssBuffer* outBuffer, + uint32_t* retFlags, + int32_t* isNtlmUsed); /* @@ -156,31 +156,31 @@ PALEXPORT uint32_t NetSecurityNative_DeleteSecContext(uint32_t* minorStatus, Gss Shims the gss_wrap method. */ PALEXPORT uint32_t NetSecurityNative_Wrap(uint32_t* minorStatus, - GssCtxId* contextHandle, - int32_t isEncrypt, - uint8_t* inputBytes, - int32_t count, - PAL_GssBuffer* outBuffer); + GssCtxId* contextHandle, + int32_t isEncrypt, + uint8_t* inputBytes, + int32_t count, + PAL_GssBuffer* outBuffer); /* Shims the gss_unwrap method. */ PALEXPORT uint32_t NetSecurityNative_Unwrap(uint32_t* minorStatus, - GssCtxId* contextHandle, - uint8_t* inputBytes, - int32_t offset, - int32_t count, - PAL_GssBuffer* outBuffer); + GssCtxId* contextHandle, + uint8_t* inputBytes, + int32_t offset, + int32_t count, + PAL_GssBuffer* outBuffer); /* Shims the gss_acquire_cred_with_password method with GSS_C_INITIATE. */ PALEXPORT uint32_t NetSecurityNative_InitiateCredWithPassword(uint32_t* minorStatus, - int32_t isNtlm, - GssName* desiredName, - char* password, - uint32_t passwdLen, - GssCredId** outputCredHandle); + int32_t isNtlm, + GssName* desiredName, + char* password, + uint32_t passwdLen, + GssCredId** outputCredHandle); /* Shims the gss_indicate_mechs method to detect if NTLM mech is installed. @@ -191,5 +191,5 @@ PALEXPORT uint32_t NetSecurityNative_IsNtlmInstalled(void); Shims gss_inquire_context and gss_display_name to get the remote user principal name. */ PALEXPORT uint32_t NetSecurityNative_GetUser(uint32_t* minorStatus, - GssCtxId* contextHandle, - PAL_GssBuffer* outBuffer); + GssCtxId* contextHandle, + PAL_GssBuffer* outBuffer); diff --git a/src/mono/mono/metadata/native-library-qcall.c b/src/mono/mono/metadata/native-library-qcall.c index cc3f74c7d3e099..232b2df120b793 100644 --- a/src/mono/mono/metadata/native-library-qcall.c +++ b/src/mono/mono/metadata/native-library-qcall.c @@ -12,8 +12,6 @@ #include "mono/utils/mono-path.h" #include "mono/metadata/native-library.h" -extern const void* GlobalizationResolveDllImport(const char* name); - enum { func_flag_end_of_array = 0x01, func_flag_has_signature = 0x02, @@ -21,10 +19,6 @@ enum { func_flag_qcall = 0x08, // QCall - mscorlib.dll to mscorwks.dll transition implemented as PInvoke }; -#if defined(NO_GLOBALIZATION_SHIM) || !defined(ENABLE_NETCORE) -const void* GlobalizationResolveDllImport(const char* name) { return NULL; } -#endif - static const MonoQCallDef c_qcalls[] = { #ifndef DISABLE_QCALLS @@ -106,14 +100,8 @@ find_index_for_method (MonoMethod *method, const void **impls) } gpointer -mono_lookup_pinvoke_qcall_internal (MonoMethod *method, const char* dllentry, MonoLookupPInvokeStatus *status_out) +mono_lookup_pinvoke_qcall_internal (MonoMethod *method, MonoLookupPInvokeStatus *status_out) { - const void *method_impl = GlobalizationResolveDllImport(dllentry); - if (method_impl != NULL) - { - return (gpointer)method_impl; - } - int pos_class = find_impls_index_for_class (method); if (pos_class < 0) { mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_QCALL, diff --git a/src/mono/mono/metadata/native-library.c b/src/mono/mono/metadata/native-library.c index 52940133b6cb58..94c9e3416b225d 100644 --- a/src/mono/mono/metadata/native-library.c +++ b/src/mono/mono/metadata/native-library.c @@ -49,6 +49,10 @@ static GHashTable *native_library_module_map; static GHashTable *native_library_module_blocklist; #endif +#if defined(ENABLE_NETCORE) && !defined(NO_GLOBALIZATION_SHIM) +extern const void* GlobalizationResolveDllImport(const char* name); +#endif + #ifndef DISABLE_DLLMAP static MonoDllMap *global_dll_map; #endif @@ -1323,8 +1327,8 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou /* If qcalls are disabled, we fall back to the normal pinvoke code for them */ #ifndef DISABLE_QCALLS - if (strcmp (new_scope, "QCall") == 0 || strcmp(new_scope, "libSystem.Globalization.Native") == 0) { - piinfo->addr = mono_lookup_pinvoke_qcall_internal (method, new_import, status_out); + if (strcmp (new_scope, "QCall") == 0) { + piinfo->addr = mono_lookup_pinvoke_qcall_internal (method, status_out); if (!piinfo->addr) { mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_DLLIMPORT, "Unable to find qcall for '%s'.", @@ -1336,6 +1340,16 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou } #endif +#if defined(ENABLE_NETCORE) && !defined(NO_GLOBALIZATION_SHIM) + if (strcmp(new_scope, "libSystem.Globalization.Native") == 0) { + const void* method_impl = GlobalizationResolveDllImport(new_import); + if (method_impl) + { + return (gpointer)method_impl; + } + } +#endif + #ifdef ENABLE_NETCORE #ifndef HOST_WIN32 retry_with_libcoreclr: diff --git a/src/mono/mono/metadata/native-library.h b/src/mono/mono/metadata/native-library.h index 038e59bcacf369..a5b556b80dac5b 100644 --- a/src/mono/mono/metadata/native-library.h +++ b/src/mono/mono/metadata/native-library.h @@ -29,7 +29,7 @@ typedef struct MonoLookupPInvokeStatus { } MonoLookupPInvokeStatus; gpointer -mono_lookup_pinvoke_qcall_internal (MonoMethod *method, const char* dllentry, MonoLookupPInvokeStatus *error); +mono_lookup_pinvoke_qcall_internal (MonoMethod *method, MonoLookupPInvokeStatus *error); typedef struct MonoQCallDef { From 79453c72ea171a8061a2e0277bfc6c7696fd64b3 Mon Sep 17 00:00:00 2001 From: vsadov Date: Mon, 30 Nov 2020 16:01:03 -0800 Subject: [PATCH 15/32] more coding PR feedback --- src/coreclr/src/CMakeLists.txt | 1 + src/coreclr/src/dlls/mscoree/unixinterface.cpp | 6 +++--- src/coreclr/src/hosts/inc/coreclrhost.h | 9 +++++++++ src/coreclr/src/inc/bundle.h | 7 +++---- src/coreclr/src/inc/pinvokeoverride.h | 2 +- src/coreclr/src/vm/bundle.cpp | 2 +- .../corehost/cli/hostpolicy/hostpolicy_context.cpp | 1 - 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/coreclr/src/CMakeLists.txt b/src/coreclr/src/CMakeLists.txt index 5f74a587d8496b..9285c57a3bbe07 100644 --- a/src/coreclr/src/CMakeLists.txt +++ b/src/coreclr/src/CMakeLists.txt @@ -7,6 +7,7 @@ include_directories("classlibnative/bcltype") include_directories("classlibnative/cryptography") include_directories("classlibnative/inc") include_directories("${GENERATED_INCLUDE_DIR}") +include_directories("hosts/inc") if(CLR_CMAKE_TARGET_WIN32 AND FEATURE_EVENT_TRACE) include_directories("${GENERATED_INCLUDE_DIR}/etw") diff --git a/src/coreclr/src/dlls/mscoree/unixinterface.cpp b/src/coreclr/src/dlls/mscoree/unixinterface.cpp index dbefb048902492..73ed20afeb93bf 100644 --- a/src/coreclr/src/dlls/mscoree/unixinterface.cpp +++ b/src/coreclr/src/dlls/mscoree/unixinterface.cpp @@ -120,7 +120,7 @@ static void ConvertConfigPropertiesToUnicode( int propertyCount, LPCWSTR** propertyKeysWRef, LPCWSTR** propertyValuesWRef, - BundleProbe** bundleProbe, + BundleProbeFn** bundleProbe, PInvokeOverrideFn** pinvokeOverride, bool* hostPolicyEmbedded) { @@ -139,7 +139,7 @@ static void ConvertConfigPropertiesToUnicode( { // If this application is a single-file bundle, the bundle-probe callback // is passed in as the value of "BUNDLE_PROBE" property (encoded as a string). - *bundleProbe = (BundleProbe*)_wcstoui64(propertyValuesW[propertyIndex], nullptr, 0); + *bundleProbe = (BundleProbeFn*)_wcstoui64(propertyValuesW[propertyIndex], nullptr, 0); } else if (strcmp(propertyKeys[propertyIndex], "PINVOKE_OVERRIDE") == 0) { @@ -193,7 +193,7 @@ int coreclr_initialize( LPCWSTR* propertyKeysW; LPCWSTR* propertyValuesW; - BundleProbe* bundleProbe = nullptr; + BundleProbeFn* bundleProbe = nullptr; bool hostPolicyEmbedded = false; PInvokeOverrideFn* pinvokeOverride = nullptr; diff --git a/src/coreclr/src/hosts/inc/coreclrhost.h b/src/coreclr/src/hosts/inc/coreclrhost.h index 4cb04b95693d71..327879e2934a88 100644 --- a/src/coreclr/src/hosts/inc/coreclrhost.h +++ b/src/coreclr/src/hosts/inc/coreclrhost.h @@ -14,6 +14,8 @@ #define CORECLR_CALLING_CONVENTION #endif +#include + // For each hosting API, we define a function prototype and a function pointer // The prototype is useful for implicit linking against the dynamic coreclr // library and the pointer for explicit dynamic loading (dlopen, LoadLibrary) @@ -121,4 +123,11 @@ CORECLR_HOSTING_API(coreclr_execute_assembly, #undef CORECLR_HOSTING_API +// +// Callback types used by the hosts +// +typedef bool(BundleProbeFn)(const char* path, int64_t* offset, int64_t* size); +typedef const void* (PInvokeOverrideFn)(const char* libraryName, const char* entrypointName); + + #endif // __CORECLR_HOST_H__ diff --git a/src/coreclr/src/inc/bundle.h b/src/coreclr/src/inc/bundle.h index f3355901024489..ab3ece2d7f5cce 100644 --- a/src/coreclr/src/inc/bundle.h +++ b/src/coreclr/src/inc/bundle.h @@ -11,6 +11,7 @@ #define _BUNDLE_H_ #include +#include "coreclrhost.h" class Bundle; @@ -34,12 +35,10 @@ struct BundleFileLocation bool IsValid() const { LIMITED_METHOD_CONTRACT; return Offset != 0; } }; -typedef bool(BundleProbe)(LPCSTR, INT64*, INT64*); - class Bundle { public: - Bundle(LPCSTR bundlePath, BundleProbe *probe); + Bundle(LPCSTR bundlePath, BundleProbeFn *probe); BundleFileLocation Probe(const SString& path, bool pathIsBundleRelative = false) const; const SString &Path() const { LIMITED_METHOD_CONTRACT; return m_path; } @@ -52,7 +51,7 @@ class Bundle private: SString m_path; // The path to single-file executable - BundleProbe *m_probe; + BundleProbeFn *m_probe; SString m_basePath; // The prefix to denote a path within the bundle COUNT_T m_basePathLength; diff --git a/src/coreclr/src/inc/pinvokeoverride.h b/src/coreclr/src/inc/pinvokeoverride.h index 3f7215e5294840..525f976b3deaef 100644 --- a/src/coreclr/src/inc/pinvokeoverride.h +++ b/src/coreclr/src/inc/pinvokeoverride.h @@ -10,7 +10,7 @@ #ifndef _PINVOKEOVERRIDE_H_ #define _PINVOKEOVERRIDE_H_ -typedef const void* (PInvokeOverrideFn)(const char* libraryName, const char* entrypointName); +#include "coreclrhost.h" class PInvokeOverride { diff --git a/src/coreclr/src/vm/bundle.cpp b/src/coreclr/src/vm/bundle.cpp index 373ab591b432d6..64994aae222b7a 100644 --- a/src/coreclr/src/vm/bundle.cpp +++ b/src/coreclr/src/vm/bundle.cpp @@ -30,7 +30,7 @@ const SString &BundleFileLocation::Path() const return Bundle::AppBundle->Path(); } -Bundle::Bundle(LPCSTR bundlePath, BundleProbe *probe) +Bundle::Bundle(LPCSTR bundlePath, BundleProbeFn *probe) { STANDARD_VM_CONTRACT; diff --git a/src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp b/src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp index 4d886583275366..c804ef062731a6 100644 --- a/src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp +++ b/src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp @@ -44,7 +44,6 @@ namespace } #if defined(NATIVE_LIBS_EMBEDDED) - extern "C" const void* GlobalizationResolveDllImport(const char* name); extern "C" const void* CompressionResolveDllImport(const char* name); // pinvoke_override: From becda0e291dfaebb421044952dba2a79828ef2d4 Mon Sep 17 00:00:00 2001 From: vsadov Date: Mon, 30 Nov 2020 18:32:48 -0800 Subject: [PATCH 16/32] Deleted "libraries-native" folder. --- src/coreclr/CMakeLists.txt | 8 ++++++- .../src/libraries-native/CMakeLists.txt | 22 ------------------- src/libraries/Native/Unix/CMakeLists.txt | 3 +++ src/libraries/Native/Windows/CMakeLists.txt | 8 +++++++ 4 files changed, 18 insertions(+), 23 deletions(-) delete mode 100644 src/coreclr/src/libraries-native/CMakeLists.txt diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index ddd5734ce92ed0..b7cb9e93e69c19 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -52,7 +52,13 @@ include(pgosupport.cmake) # Include libraries native shims #------------------------------- if(NOT CLR_CROSS_COMPONENTS_BUILD AND CLR_CMAKE_BUILD_SUBSET_RUNTIME) - add_subdirectory(src/libraries-native) + set(STATIC_LIBS_ONLY 1) + + if(CLR_CMAKE_TARGET_WIN32) + add_subdirectory(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Windows Native.Windows) + else() + add_subdirectory(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix Native.Unix) + endif() endif(NOT CLR_CROSS_COMPONENTS_BUILD AND CLR_CMAKE_BUILD_SUBSET_RUNTIME) #----------------------------------------- diff --git a/src/coreclr/src/libraries-native/CMakeLists.txt b/src/coreclr/src/libraries-native/CMakeLists.txt deleted file mode 100644 index 166ac8fbf83a35..00000000000000 --- a/src/coreclr/src/libraries-native/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -# Suppress exporting of the PAL APIs -add_definitions(-DPALEXPORT=EXTERN_C) - -set(STATIC_LIBS_ONLY 1) - -if(CLR_CMAKE_TARGET_WIN32) - set(GLOBALIZATION_NATIVE_DIR ${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.Globalization.Native) - set(COMPRESSION_NATIVE_DIR ${CLR_REPO_ROOT_DIR}/src/libraries/Native/Windows/clrcompression) - - include_directories("${GLOBALIZATION_NATIVE_DIR}") - include_directories("${COMPRESSION_NATIVE_DIR}") - - include_directories("${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/Common") - - add_subdirectory(${COMPRESSION_NATIVE_DIR} clrcompression) - add_subdirectory(${GLOBALIZATION_NATIVE_DIR} System.Globalization.Native) - -else() - add_subdirectory(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix Native.Unix) -endif() diff --git a/src/libraries/Native/Unix/CMakeLists.txt b/src/libraries/Native/Unix/CMakeLists.txt index 21a8caa9949c24..ebc9ff30e9ea82 100644 --- a/src/libraries/Native/Unix/CMakeLists.txt +++ b/src/libraries/Native/Unix/CMakeLists.txt @@ -55,6 +55,9 @@ if (PRERELEASE) endif() if(STATIC_LIBS_ONLY) + # Suppress exporting of the PAL APIs + add_definitions(-DPALEXPORT=EXTERN_C) + set(STATIC_LIB_DESTINATION lib) set(GEN_SHARED_LIB 0) else() diff --git a/src/libraries/Native/Windows/CMakeLists.txt b/src/libraries/Native/Windows/CMakeLists.txt index 1f5380173f40d0..1f3ac2bd8ecccf 100644 --- a/src/libraries/Native/Windows/CMakeLists.txt +++ b/src/libraries/Native/Windows/CMakeLists.txt @@ -24,6 +24,9 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") endif() if(STATIC_LIBS_ONLY) + # Suppress exporting of the PAL APIs + add_definitions(-DPALEXPORT=EXTERN_C) + set(GEN_SHARED_LIB 0) set(STATIC_LIB_DESTINATION lib) else() @@ -121,4 +124,9 @@ endif () # as other asserts should still be included. add_compile_definitions($<$:NDEBUG>) +# we only need to build System.Globalization.Native when building static libs. +if(STATIC_LIBS_ONLY) + add_subdirectory(../Unix/System.Globalization.Native System.Globalization.Native) +endif() + add_subdirectory(clrcompression) From 932b5fe9009fb3cec53105c3174d6da30ed082d0 Mon Sep 17 00:00:00 2001 From: vsadov Date: Wed, 2 Dec 2020 08:00:29 -0800 Subject: [PATCH 17/32] unifying tryrun.cmake into 1 common file --- eng/native/gen-buildsys.sh | 4 +-- {src/coreclr => eng/native}/tryrun.cmake | 0 src/coreclr/build-runtime.sh | 4 +-- src/installer/corehost/build.sh | 2 +- src/installer/corehost/tryrun.cmake | 28 ---------------- src/libraries/Native/Unix/tryrun.cmake | 42 ------------------------ src/libraries/Native/build-native.sh | 2 +- src/tests/build.sh | 3 +- 8 files changed, 6 insertions(+), 79 deletions(-) rename {src/coreclr => eng/native}/tryrun.cmake (100%) delete mode 100644 src/installer/corehost/tryrun.cmake delete mode 100644 src/libraries/Native/Unix/tryrun.cmake diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index 6ecc2d8954cdef..2831ddd062c2ef 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -73,9 +73,7 @@ if [[ "$CROSSCOMPILE" == "1" ]]; then TARGET_BUILD_ARCH="$build_arch" export TARGET_BUILD_ARCH - if [[ -n "$tryrun_dir" ]]; then - cmake_extra_defines="$cmake_extra_defines -C $tryrun_dir/tryrun.cmake" - fi + cmake_extra_defines="$cmake_extra_defines -C $scriptroot/tryrun.cmake" if [[ "$platform" == "Darwin" ]]; then cmake_extra_defines="$cmake_extra_defines -DCMAKE_SYSTEM_NAME=Darwin" diff --git a/src/coreclr/tryrun.cmake b/eng/native/tryrun.cmake similarity index 100% rename from src/coreclr/tryrun.cmake rename to eng/native/tryrun.cmake diff --git a/src/coreclr/build-runtime.sh b/src/coreclr/build-runtime.sh index 91c0b445c75650..f87d4ea643bcc4 100755 --- a/src/coreclr/build-runtime.sh +++ b/src/coreclr/build-runtime.sh @@ -99,7 +99,7 @@ build_cross_architecture_components() export __CMakeBinDir CROSSCOMPILE __CMakeArgs="-DCLR_CMAKE_TARGET_ARCH=$__BuildArch -DCLR_CROSS_COMPONENTS_BUILD=1 $__CMakeArgs" - build_native "$__TargetOS" "$__CrossArch" "$__ProjectRoot" "$__ProjectRoot" "$intermediatesForBuild" "$__CMakeArgs" "cross-architecture components" + build_native "$__TargetOS" "$__CrossArch" "$__ProjectRoot" "$__RepoRootDir/eng/native" "$intermediatesForBuild" "$__CMakeArgs" "cross-architecture components" CROSSCOMPILE=1 export CROSSCOMPILE @@ -257,7 +257,7 @@ fi if [[ "$__SkipNative" == 1 ]]; then echo "Skipping CoreCLR component build." else - build_native "$__TargetOS" "$__BuildArch" "$__ProjectRoot" "$__ProjectRoot" "$__IntermediatesDir" "$__CMakeArgs" "CoreCLR component" + build_native "$__TargetOS" "$__BuildArch" "$__ProjectRoot" "$__RepoRootDir/eng/native" "$__IntermediatesDir" "$__CMakeArgs" "CoreCLR component" # Build cross-architecture components if [[ "$__SkipCrossArchNative" != 1 ]]; then diff --git a/src/installer/corehost/build.sh b/src/installer/corehost/build.sh index 976675398e8743..60cc5ed4511b23 100755 --- a/src/installer/corehost/build.sh +++ b/src/installer/corehost/build.sh @@ -116,4 +116,4 @@ setup_dirs check_prereqs # Build the installer native components. -build_native "$__TargetOS" "$__BuildArch" "$__scriptpath" "$__scriptpath" "$__IntermediatesDir" "$__CMakeArgs" "installer component" +build_native "$__TargetOS" "$__BuildArch" "$__scriptpath" "$__RepoRootDir/eng/native" "$__IntermediatesDir" "$__CMakeArgs" "installer component" diff --git a/src/installer/corehost/tryrun.cmake b/src/installer/corehost/tryrun.cmake deleted file mode 100644 index eba94aea7cb74b..00000000000000 --- a/src/installer/corehost/tryrun.cmake +++ /dev/null @@ -1,28 +0,0 @@ -set(CROSS_ROOTFS $ENV{ROOTFS_DIR}) -set(TARGET_ARCH_NAME $ENV{TARGET_BUILD_ARCH}) - -macro(set_cache_value) - set(${ARGV0} ${ARGV1} CACHE STRING "Result from TRY_RUN" FORCE) - set(${ARGV0}__TRYRUN_OUTPUT "dummy output" CACHE STRING "Output from TRY_RUN" FORCE) -endmacro() - -if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv7-alpine-linux-musleabihf OR - EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf OR - EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/aarch64-alpine-linux-musl) - - set(ALPINE_LINUX 1) -elseif(EXISTS ${CROSS_ROOTFS}/bin/freebsd-version) - set(FREEBSD 1) - set(CMAKE_SYSTEM_NAME FreeBSD) - set(CLR_CMAKE_TARGET_OS FreeBSD) -elseif(EXISTS ${CROSS_ROOTFS}/usr/platform/i86pc) - set(ILLUMOS 1) -endif() - -if(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$" OR FREEBSD OR ILLUMOS) - if(ILLUMOS) - set_cache_value(COMPILER_SUPPORTS_W_CLASS_MEMACCESS 0) - endif() -else() - message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only armel, arm, arm64 and x86 are supported!") -endif() diff --git a/src/libraries/Native/Unix/tryrun.cmake b/src/libraries/Native/Unix/tryrun.cmake deleted file mode 100644 index adb186203324b1..00000000000000 --- a/src/libraries/Native/Unix/tryrun.cmake +++ /dev/null @@ -1,42 +0,0 @@ -set(TARGET_ARCH_NAME $ENV{TARGET_BUILD_ARCH}) -set(CROSS_ROOTFS $ENV{ROOTFS_DIR}) - -macro(set_cache_value) - set(${ARGV0} ${ARGV1} CACHE STRING "Result from TRY_RUN" FORCE) - set(${ARGV0}__TRYRUN_OUTPUT "dummy output" CACHE STRING "Output from TRY_RUN" FORCE) -endmacro() - -if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv7-alpine-linux-musleabihf OR - EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf OR - EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/aarch64-alpine-linux-musl) - - set(ALPINE_LINUX 1) -elseif(EXISTS ${CROSS_ROOTFS}/bin/freebsd-version) - set(FREEBSD 1) - set(CMAKE_SYSTEM_NAME FreeBSD) - set(CLR_CMAKE_TARGET_OS FreeBSD) -elseif(EXISTS ${CROSS_ROOTFS}/usr/platform/i86pc) - set(ILLUMOS 1) - set(CLR_CMAKE_TARGET_OS SunOS) -endif() - -if(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$" OR FREEBSD OR ILLUMOS) - set_cache_value(HAVE_CLOCK_MONOTONIC_EXITCODE 0) - set_cache_value(HAVE_CLOCK_REALTIME_EXITCODE 0) - - if(ALPINE_LINUX) - set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP_EXITCODE 1) - else() - set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP_EXITCODE 0) - endif() - - if(FREEBSD) - set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP 1) - set_cache_value(HAVE_CLOCK_MONOTONIC 1) - set_cache_value(HAVE_CLOCK_REALTIME 1) - elseif(ILLUMOS) - set_cache_value(HAVE_SET_MAX_VARIABLE 1) - endif() -else() - message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only armel, arm, arm64 and x86 are supported!") -endif() diff --git a/src/libraries/Native/build-native.sh b/src/libraries/Native/build-native.sh index 2aaa9fe4831f98..3149f9d461cd73 100755 --- a/src/libraries/Native/build-native.sh +++ b/src/libraries/Native/build-native.sh @@ -157,4 +157,4 @@ setup_dirs check_prereqs # Build the corefx native components. -build_native "$__TargetOS" "$__BuildArch" "$__nativeroot" "$__nativeroot" "$__IntermediatesDir" "$__CMakeArgs" "native libraries component" +build_native "$__TargetOS" "$__BuildArch" "$__nativeroot" "$__RepoRootDir/eng/native" "$__IntermediatesDir" "$__CMakeArgs" "native libraries component" diff --git a/src/tests/build.sh b/src/tests/build.sh index a1efe50cc009eb..fa08b582365f2f 100755 --- a/src/tests/build.sh +++ b/src/tests/build.sh @@ -279,7 +279,7 @@ build_Tests() fi if [[ "$__SkipNative" != 1 && "$__TargetOS" != "Browser" && "$__TargetOS" != "Android" ]]; then - build_native "$__TargetOS" "$__BuildArch" "$__TestDir" "$__TryRunDir" "$__NativeTestIntermediatesDir" "CoreCLR test component" + build_native "$__TargetOS" "$__BuildArch" "$__TestDir" "$__RepoRootDir/eng/native" "$__NativeTestIntermediatesDir" "CoreCLR test component" if [[ "$?" -ne 0 ]]; then echo "${__ErrMsgPrefix}${__MsgPrefix}Error: native test build failed. Refer to the build log files for details (above)" @@ -605,7 +605,6 @@ __OSPlatformConfig="$__TargetOS.$__BuildArch.$__BuildType" __BinDir="$__RootBinDir/bin/coreclr/$__OSPlatformConfig" __PackagesBinDir="$__BinDir/.nuget" __TestDir="$__RepoRootDir/src/tests" -__TryRunDir="$__RepoRootDir/src/coreclr" __TestWorkingDir="$__RootBinDir/tests/coreclr/$__OSPlatformConfig" __IntermediatesDir="$__RootBinDir/obj/coreclr/$__OSPlatformConfig" __TestIntermediatesDir="$__RootBinDir/tests/coreclr/obj/$__OSPlatformConfig" From 3f5cea98eb62cbb0999b93266c78af114c3b9970 Mon Sep 17 00:00:00 2001 From: vsadov Date: Wed, 2 Dec 2020 16:04:05 -0800 Subject: [PATCH 18/32] factor out adding lib-specific dependencies into one place (per native library) --- .../cli/apphost/static/CMakeLists.txt | 87 ++++--------------- .../CMakeLists.txt | 14 ++- .../extra_libs.cmake | 13 +++ .../Native/Unix/System.Native/CMakeLists.txt | 23 ++--- .../Unix/System.Native/extra_libs.cmake | 17 ++++ .../System.Net.Security.Native/CMakeLists.txt | 22 +---- .../extra_libs.cmake | 21 +++++ .../CMakeLists.txt | 44 ++-------- .../extra_libs.cmake | 43 +++++++++ 9 files changed, 131 insertions(+), 153 deletions(-) create mode 100644 src/libraries/Native/Unix/System.IO.Compression.Native/extra_libs.cmake create mode 100644 src/libraries/Native/Unix/System.Native/extra_libs.cmake create mode 100644 src/libraries/Native/Unix/System.Net.Security.Native/extra_libs.cmake create mode 100644 src/libraries/Native/Unix/System.Security.Cryptography.Native/extra_libs.cmake diff --git a/src/installer/corehost/cli/apphost/static/CMakeLists.txt b/src/installer/corehost/cli/apphost/static/CMakeLists.txt index 5f3d8b63fc0e2e..ced89a63215df1 100644 --- a/src/installer/corehost/cli/apphost/static/CMakeLists.txt +++ b/src/installer/corehost/cli/apphost/static/CMakeLists.txt @@ -107,6 +107,8 @@ if (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_AR target_link_libraries(singlefilehost Advapi32.lib shell32.lib) endif() +set(NATIVE_LIBS_EXTRA) + # Path like: artifacts/bin/coreclr/windows.x64.Release/lib or # /root/runtime/artifacts/transport/coreclr/lib set(CORECLR_STATIC_LIB_LOCATION "${CORECLR_ARTIFACTS}/lib") @@ -141,16 +143,7 @@ else() ) # additional requirements for System.IO.Compression.Native - if (CLR_CMAKE_TARGET_BROWSER) - add_definitions(-s USE_ZLIB) - elseif (CLR_CMAKE_TARGET_ANDROID) - # need special case here since we want to link against libz.so but find_package() would resolve libz.a - set(ZLIB_LIBRARIES z) - elseif (CLR_CMAKE_TARGET_SUNOS) - set(ZLIB_LIBRARIES z m) - else () - find_package(ZLIB REQUIRED) - endif () + include(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.IO.Compression.Native/extra_libs.cmake) endif() if(CLR_CMAKE_TARGET_OSX) @@ -194,68 +187,27 @@ endif() set(NATIVE_LIBS_LOCATION "${NATIVE_LIBS_ARTIFACTS}") message ("Looking for native libs at location: '${NATIVE_LIBS_LOCATION}'.") -if(NOT CLR_CMAKE_TARGET_LINUX) - set(NATIVE_LIBS - # Native libs linked into singlefilehost is supported only on Linux for now. - # if/when BSD and OSX are supported too, consider the commented code sections below. - ) -else() +# These native libs are linked into singlefilehost only on Linux (for now). +if(CLR_CMAKE_TARGET_LINUX) set(NATIVE_LIBS ${NATIVE_LIBS_LOCATION}/libSystem.Native.a ${NATIVE_LIBS_LOCATION}/libSystem.Net.Security.Native.a ${NATIVE_LIBS_LOCATION}/libSystem.Security.Cryptography.Native.OpenSsl.a ) - # Additional requirements for System.Net.Security.Native - if (HAVE_GSSFW_HEADERS) - find_library(LIBGSS NAMES GSS) - if(LIBGSS STREQUAL LIBGSS-NOTFOUND) - message(FATAL_ERROR "Cannot find GSS.Framework and System.Net.Security.Native cannot build without it. Try installing GSS.Framework (or the appropriate package for your platform)") - endif() - elseif(HAVE_HEIMDAL_HEADERS) - find_library(LIBGSS NAMES gssapi) - if(LIBGSS STREQUAL LIBGSS-NOTFOUND) - message(FATAL_ERROR "Cannot find libgssapi and System.Net.Security.Native cannot build without it. Try installing heimdal (or the appropriate package for your platform)") - endif() - else() - find_library(LIBGSS NAMES gssapi_krb5) - if(LIBGSS STREQUAL LIBGSS-NOTFOUND) - message(FATAL_ERROR "Cannot find libgssapi_krb5 and System.Net.Security.Native cannot build without it. Try installing libkrb5-dev (or the appropriate package for your platform)") - endif() - endif() - # Additional requirements for System.Native - if (CLR_CMAKE_TARGET_LINUX AND NOT CLR_CMAKE_TARGET_ANDROID) - set(NATIVE_LIBS_EXTRA - rt - ) - # elseif (CLR_CMAKE_TARGET_FREEBSD) - # set(NATIVE_LIBS_EXTRA - # pthread - # ) - # find_library(INOTIFY_LIBRARY inotify HINTS /usr/local/lib) - # if(NOT (INOTIFY_LIBRARY STREQUAL INOTIFY_LIBRARY-NOTFOUND)) - # LIST(APPEND NATIVE_LIBS_EXTRA - # ${INOTIFY_LIBRARY} - # ) - # endif () - # elseif (CLR_CMAKE_TARGET_SUNOS) - # set(NATIVE_LIBS_EXTRA - # socket - # ) - endif () - + include(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.Native/extra_libs.cmake) + # Additional requirements for System.Net.Security.Native + include(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.Net.Security.Native/extra_libs.cmake) # Additional requirements for System.Security.Cryptography.Native.OpenSsl - if(NOT FEATURE_DISTRO_AGNOSTIC_SSL) - find_package(OpenSSL) - endif() + include(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.Security.Cryptography.Native/extra_libs.cmake) +endif() - if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS) - # These options are used to force every object to be included even if it's unused. - set(START_WHOLE_ARCHIVE -Wl,--whole-archive) - set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive) - endif(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS) -endif(NOT CLR_CMAKE_TARGET_LINUX) +if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS) + # These options are used to force every object to be included even if it's unused. + set(START_WHOLE_ARCHIVE -Wl,--whole-archive) + set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive) +endif(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS) set_property(TARGET singlefilehost PROPERTY ENABLE_EXPORTS 1) @@ -266,14 +218,5 @@ target_link_libraries(singlefilehost ${NATIVE_LIBS} ${END_WHOLE_ARCHIVE} - ${ZLIB_LIBRARIES} - ${LIBGSS} ${NATIVE_LIBS_EXTRA} ) - -if(NOT FEATURE_DISTRO_AGNOSTIC_SSL) - target_link_libraries(singlefilehost - ${OPENSSL_CRYPTO_LIBRARY} - ${OPENSSL_SSL_LIBRARY} - ) -endif() diff --git a/src/libraries/Native/Unix/System.IO.Compression.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.IO.Compression.Native/CMakeLists.txt index 1331b502282ee8..cf2a68144ddc74 100644 --- a/src/libraries/Native/Unix/System.IO.Compression.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.IO.Compression.Native/CMakeLists.txt @@ -2,14 +2,10 @@ project(System.IO.Compression.Native C) if (CLR_CMAKE_TARGET_BROWSER) add_definitions(-s USE_ZLIB) -elseif (CLR_CMAKE_TARGET_ANDROID) - # need special case here since we want to link against libz.so but find_package() would resolve libz.a - set(ZLIB_LIBRARIES z) -elseif (CLR_CMAKE_TARGET_SUNOS) - set(ZLIB_LIBRARIES z m) -else () - find_package(ZLIB REQUIRED) -endif () +endif() + +set(NATIVE_LIBS_EXTRA) +include(${CMAKE_CURRENT_LIST_DIR}/extra_libs.cmake) set(NATIVECOMPRESSION_SOURCES ../../AnyOS/zlib/pal_zlib.c @@ -67,7 +63,7 @@ if (GEN_SHARED_LIB) ) target_link_libraries(System.IO.Compression.Native - ${ZLIB_LIBRARIES} + ${NATIVE_LIBS_EXTRA} ) install_with_stripped_symbols (System.IO.Compression.Native PROGRAMS .) endif () diff --git a/src/libraries/Native/Unix/System.IO.Compression.Native/extra_libs.cmake b/src/libraries/Native/Unix/System.IO.Compression.Native/extra_libs.cmake new file mode 100644 index 00000000000000..bbd3518078ddd5 --- /dev/null +++ b/src/libraries/Native/Unix/System.IO.Compression.Native/extra_libs.cmake @@ -0,0 +1,13 @@ + +if (CLR_CMAKE_TARGET_BROWSER) + # nothing special to link +elseif (CLR_CMAKE_TARGET_ANDROID) + # need special case here since we want to link against libz.so but find_package() would resolve libz.a + set(ZLIB_LIBRARIES z) +elseif (CLR_CMAKE_TARGET_SUNOS) + set(ZLIB_LIBRARIES z m) +else () + find_package(ZLIB REQUIRED) +endif () + +list(APPEND NATIVE_LIBS_EXTRA ${ZLIB_LIBRARIES}) diff --git a/src/libraries/Native/Unix/System.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Native/CMakeLists.txt index 7e4ee517c78f36..743b1dcaedb76d 100644 --- a/src/libraries/Native/Unix/System.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Native/CMakeLists.txt @@ -53,23 +53,20 @@ elseif (CLR_CMAKE_TARGET_FREEBSD) endif () endif () +set(NATIVE_LIBS_EXTRA) +include(${CMAKE_CURRENT_LIST_DIR}/extra_libs.cmake) + if (GEN_SHARED_LIB) add_library(System.Native SHARED ${NATIVE_SOURCES} ${VERSION_FILE_PATH} ) - if (CLR_CMAKE_TARGET_LINUX AND NOT CLR_CMAKE_TARGET_ANDROID) - target_link_libraries(System.Native rt) - elseif (CLR_CMAKE_TARGET_FREEBSD) - target_link_libraries(System.Native pthread) - if (HAVE_INOTIFY) - find_library(INOTIFY_LIBRARY inotify HINTS /usr/local/lib) - target_link_libraries(System.Native ${INOTIFY_LIBRARY}) - endif () - elseif (CLR_CMAKE_TARGET_SUNOS) - target_link_libraries(System.Native socket) - endif () + + target_link_libraries(System.Native + ${NATIVE_LIBS_EXTRA} + ) + install_with_stripped_symbols (System.Native PROGRAMS .) endif () @@ -78,10 +75,6 @@ add_library(System.Native-Static ${NATIVE_SOURCES} ) -if (CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) - target_link_libraries(System.Native "-framework Foundation") -endif () - set_target_properties(System.Native-Static PROPERTIES OUTPUT_NAME System.Native CLEAN_DIRECT_OUTPUT 1) install (TARGETS System.Native-Static DESTINATION ${STATIC_LIB_DESTINATION}) diff --git a/src/libraries/Native/Unix/System.Native/extra_libs.cmake b/src/libraries/Native/Unix/System.Native/extra_libs.cmake new file mode 100644 index 00000000000000..0e86942bb4f12f --- /dev/null +++ b/src/libraries/Native/Unix/System.Native/extra_libs.cmake @@ -0,0 +1,17 @@ + + +if (CLR_CMAKE_TARGET_LINUX AND NOT CLR_CMAKE_TARGET_ANDROID) + list(APPEND NATIVE_LIBS_EXTRA rt) +elseif (CLR_CMAKE_TARGET_FREEBSD) + list(APPEND NATIVE_LIBS_EXTRA pthread) + if (HAVE_INOTIFY) + find_library(INOTIFY_LIBRARY inotify HINTS /usr/local/lib) + list(APPEND NATIVE_LIBS_EXTRA ${INOTIFY_LIBRARY}) + endif () +elseif (CLR_CMAKE_TARGET_SUNOS) + list(APPEND NATIVE_LIBS_EXTRA socket) +endif () + +if (CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + list(APPEND NATIVE_LIBS_EXTRA "-framework Foundation") +endif () diff --git a/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt index 60a2f67b135d81..cea72770a63d1c 100644 --- a/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt @@ -2,24 +2,8 @@ project(System.Net.Security.Native C) add_compile_options(-Wno-incompatible-pointer-types-discards-qualifiers) -if (HAVE_GSSFW_HEADERS) - find_library(LIBGSS NAMES GSS) - if(LIBGSS STREQUAL LIBGSS-NOTFOUND) - message(FATAL_ERROR "Cannot find GSS.Framework and System.Net.Security.Native cannot build without it. Try installing GSS.Framework (or the appropriate package for your platform)") - endif() -elseif(HAVE_HEIMDAL_HEADERS) - find_library(LIBGSS NAMES gssapi) - if(LIBGSS STREQUAL LIBGSS-NOTFOUND) - message(FATAL_ERROR "Cannot find libgssapi and System.Net.Security.Native cannot build without it. Try installing heimdal (or the appropriate package for your platform)") - endif() -elseif(HeimdalGssApi) - message(FATAL_ERROR "HeimdalGssApi option was set but gssapi headers could not be found and System.Net.Security.Native cannot build without the headers. Try installing heimdal (or the appropriate package for your platform)") -else() - find_library(LIBGSS NAMES gssapi_krb5) - if(LIBGSS STREQUAL LIBGSS-NOTFOUND) - message(FATAL_ERROR "Cannot find libgssapi_krb5 and System.Net.Security.Native cannot build without it. Try installing libkrb5-dev (or the appropriate package for your platform)") - endif() -endif() +set(NATIVE_LIBS_EXTRA) +include(${CMAKE_CURRENT_LIST_DIR}/extra_libs.cmake) set(NATIVEGSS_SOURCES pal_gssapi.c @@ -42,7 +26,7 @@ set_target_properties(System.Net.Security.Native-Static PROPERTIES OUTPUT_NAME S if (GEN_SHARED_LIB) target_link_libraries(System.Net.Security.Native - ${LIBGSS} + ${NATIVE_LIBS_EXTRA} ) install_with_stripped_symbols (System.Net.Security.Native PROGRAMS .) diff --git a/src/libraries/Native/Unix/System.Net.Security.Native/extra_libs.cmake b/src/libraries/Native/Unix/System.Net.Security.Native/extra_libs.cmake new file mode 100644 index 00000000000000..a2c51653736170 --- /dev/null +++ b/src/libraries/Native/Unix/System.Net.Security.Native/extra_libs.cmake @@ -0,0 +1,21 @@ + +if (HAVE_GSSFW_HEADERS) + find_library(LIBGSS NAMES GSS) + if(LIBGSS STREQUAL LIBGSS-NOTFOUND) + message(FATAL_ERROR "Cannot find GSS.Framework and System.Net.Security.Native cannot build without it. Try installing GSS.Framework (or the appropriate package for your platform)") + endif() +elseif(HAVE_HEIMDAL_HEADERS) + find_library(LIBGSS NAMES gssapi) + if(LIBGSS STREQUAL LIBGSS-NOTFOUND) + message(FATAL_ERROR "Cannot find libgssapi and System.Net.Security.Native cannot build without it. Try installing heimdal (or the appropriate package for your platform)") + endif() +elseif(HeimdalGssApi) + message(FATAL_ERROR "HeimdalGssApi option was set but gssapi headers could not be found and System.Net.Security.Native cannot build without the headers. Try installing heimdal (or the appropriate package for your platform)") +else() + find_library(LIBGSS NAMES gssapi_krb5) + if(LIBGSS STREQUAL LIBGSS-NOTFOUND) + message(FATAL_ERROR "Cannot find libgssapi_krb5 and System.Net.Security.Native cannot build without it. Try installing libkrb5-dev (or the appropriate package for your platform)") + endif() +endif() + +list(APPEND NATIVE_LIBS_EXTRA ${LIBGSS}) diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt index aaf1fa7e5b2d96..c752f08918442c 100644 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt @@ -8,34 +8,8 @@ add_compile_options(-Wno-used-but-marked-unused) add_definitions(-DOPENSSL_API_COMPAT=0x10100000L) -if(CMAKE_STATIC_LIB_LINK) - set(CMAKE_FIND_LIBRARY_SUFFIXES .a) -endif(CMAKE_STATIC_LIB_LINK) - -if(CLR_CMAKE_TARGET_ANDROID AND NOT CROSS_ROOTFS) - # TEMP: consume OpenSSL dependencies from external sources via env. variables - set(OPENSSL_FOUND 1) - set(OPENSSL_INCLUDE_DIR $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/include) - if(CLR_CMAKE_TARGET_ARCH_ARM64) - set(OPENSSL_CRYPTO_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/crypto/libs/android.arm64-v8a/libcrypto.so) - set(OPENSSL_SSL_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/libs/android.arm64-v8a/libssl.so) - elseif(CLR_CMAKE_TARGET_ARCH_ARM) - set(OPENSSL_CRYPTO_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/crypto/libs/android.armeabi-v7a/libcrypto.so) - set(OPENSSL_SSL_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/libs/android.armeabi-v7a/libssl.so) - elseif(CLR_CMAKE_TARGET_ARCH_I386) - set(OPENSSL_CRYPTO_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/crypto/libs/android.x86/libcrypto.so) - set(OPENSSL_SSL_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/libs/android.x86/libssl.so) - else() - set(OPENSSL_CRYPTO_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/crypto/libs/android.x86_64/libcrypto.so) - set(OPENSSL_SSL_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/libs/android.x86_64/libssl.so) - endif() -else() - find_package(OpenSSL) -endif() - -if(NOT OPENSSL_FOUND) - message(FATAL_ERROR "!!! Cannot find libssl and System.Security.Cryptography.Native cannot build without it. Try installing libssl-dev (on Linux, but this may vary by distro) or openssl (on macOS) !!!. See the requirements document for your specific operating system: https://github.com/dotnet/runtime/tree/master/docs/workflow/requirements.") -endif(NOT OPENSSL_FOUND) +set(NATIVE_LIBS_EXTRA) +include(${CMAKE_CURRENT_LIST_DIR}/extra_libs.cmake) include_directories(${OPENSSL_INCLUDE_DIR}) @@ -114,17 +88,11 @@ if (GEN_SHARED_LIB) VERBATIM ) endif() - - # Link with libdl.so to get the dlopen / dlsym / dlclose - target_link_libraries(System.Security.Cryptography.Native.OpenSsl - dl - ) - else() - target_link_libraries(System.Security.Cryptography.Native.OpenSsl - ${OPENSSL_CRYPTO_LIBRARY} - ${OPENSSL_SSL_LIBRARY} - ) endif() + + target_link_libraries(System.Security.Cryptography.Native.OpenSsl + ${NATIVE_LIBS_EXTRA} + ) endif() include(configure.cmake) diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native/extra_libs.cmake b/src/libraries/Native/Unix/System.Security.Cryptography.Native/extra_libs.cmake new file mode 100644 index 00000000000000..330a616c846804 --- /dev/null +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native/extra_libs.cmake @@ -0,0 +1,43 @@ + + +if(CMAKE_STATIC_LIB_LINK) + set(CMAKE_FIND_LIBRARY_SUFFIXES .a) +endif(CMAKE_STATIC_LIB_LINK) + +if(CLR_CMAKE_TARGET_ANDROID AND NOT CROSS_ROOTFS) + # TEMP: consume OpenSSL dependencies from external sources via env. variables + set(OPENSSL_FOUND 1) + set(OPENSSL_INCLUDE_DIR $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/include) + if(CLR_CMAKE_TARGET_ARCH_ARM64) + set(OPENSSL_CRYPTO_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/crypto/libs/android.arm64-v8a/libcrypto.so) + set(OPENSSL_SSL_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/libs/android.arm64-v8a/libssl.so) + elseif(CLR_CMAKE_TARGET_ARCH_ARM) + set(OPENSSL_CRYPTO_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/crypto/libs/android.armeabi-v7a/libcrypto.so) + set(OPENSSL_SSL_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/libs/android.armeabi-v7a/libssl.so) + elseif(CLR_CMAKE_TARGET_ARCH_I386) + set(OPENSSL_CRYPTO_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/crypto/libs/android.x86/libcrypto.so) + set(OPENSSL_SSL_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/libs/android.x86/libssl.so) + else() + set(OPENSSL_CRYPTO_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/crypto/libs/android.x86_64/libcrypto.so) + set(OPENSSL_SSL_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/libs/android.x86_64/libssl.so) + endif() +else() + find_package(OpenSSL) +endif() + +if(NOT OPENSSL_FOUND) + message(FATAL_ERROR "!!! Cannot find libssl and System.Security.Cryptography.Native cannot build without it. Try installing libssl-dev (on Linux, but this may vary by distro) or openssl (on macOS) !!!. See the requirements document for your specific operating system: https://github.com/dotnet/runtime/tree/master/docs/workflow/requirements.") +endif(NOT OPENSSL_FOUND) + + +if (FEATURE_DISTRO_AGNOSTIC_SSL) + # Link with libdl.so to get the dlopen / dlsym / dlclose + list(APPEND NATIVE_LIBS_EXTRA + dl + ) +else() + list(APPEND NATIVE_LIBS_EXTRA + ${OPENSSL_CRYPTO_LIBRARY} + ${OPENSSL_SSL_LIBRARY} + ) +endif() From 8d2b6b96198b7681dbc14f65fd554945e15c3344 Mon Sep 17 00:00:00 2001 From: vsadov Date: Thu, 3 Dec 2020 10:58:41 -0800 Subject: [PATCH 19/32] cleanup: entirely remove tryrun.cmake propagation in eng, gen-buildsys, build-commons, and build scripts --- eng/native/build-commons.sh | 9 ++++----- eng/native/gen-buildsys.sh | 16 +++++++--------- src/coreclr/build-runtime.sh | 4 ++-- src/installer/corehost/build.sh | 2 +- src/libraries/Native/build-native.sh | 2 +- src/tests/build.sh | 2 +- 6 files changed, 16 insertions(+), 19 deletions(-) diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 7b604d319a083b..e77d219ce0caf1 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -71,10 +71,9 @@ build_native() targetOS="$1" platformArch="$2" cmakeDir="$3" - tryrunDir="$4" - intermediatesDir="$5" - cmakeArgs="$6" - message="$7" + intermediatesDir="$4" + cmakeArgs="$5" + message="$6" # All set to commence the build echo "Commencing build of \"$message\" for $__TargetOS.$__BuildArch.$__BuildType in $intermediatesDir" @@ -146,7 +145,7 @@ EOF scan_build=scan-build fi - nextCommand="\"$__RepoRootDir/eng/native/gen-buildsys.sh\" \"$cmakeDir\" \"$tryrunDir\" \"$intermediatesDir\" $platformArch $__Compiler \"$__CompilerMajorVersion\" \"$__CompilerMinorVersion\" $__BuildType \"$generator\" $scan_build $cmakeArgs" + nextCommand="\"$__RepoRootDir/eng/native/gen-buildsys.sh\" \"$cmakeDir\" \"$intermediatesDir\" $platformArch $__Compiler \"$__CompilerMajorVersion\" \"$__CompilerMinorVersion\" $__BuildType \"$generator\" $scan_build $cmakeArgs" echo "Invoking $nextCommand" eval $nextCommand diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index 2831ddd062c2ef..5588b509e4334b 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -7,10 +7,9 @@ scriptroot="$( cd -P "$( dirname "$0" )" && pwd )" if [[ "$#" -lt 4 ]]; then echo "Usage..." - echo "gen-buildsys.sh [build flavor] [ninja] [scan-build] [cmakeargs]" + echo "gen-buildsys.sh [build flavor] [ninja] [scan-build] [cmakeargs]" echo "Specify the path to the top level CMake file." echo "Specify the path that the build system files are generated in." - echo "Specify the path to the directory with tryrun.cmake file." echo "Specify the target architecture." echo "Specify the name of compiler (clang or gcc)." echo "Specify the major version of compiler." @@ -22,11 +21,10 @@ if [[ "$#" -lt 4 ]]; then exit 1 fi -tryrun_dir="$2" -build_arch="$4" -compiler="$5" -majorVersion="$6" -minorVersion="$7" +build_arch="$3" +compiler="$4" +majorVersion="$5" +minorVersion="$6" source "$scriptroot/init-compiler.sh" "$build_arch" "$compiler" "$majorVersion" "$minorVersion" @@ -42,7 +40,7 @@ scan_build=OFF generator="Unix Makefiles" __UnprocessedCMakeArgs="" -for i in "${@:8}"; do +for i in "${@:7}"; do upperI="$(echo "$i" | awk '{print toupper($0)}')" case "$upperI" in # Possible build types are DEBUG, CHECKED, RELEASE, RELWITHDEBINFO. @@ -97,7 +95,7 @@ if [[ "$build_arch" == "wasm" ]]; then fi # We have to be able to build with CMake 3.6.2, so we can't use the -S or -B options -pushd "$3" +pushd "$2" # Include CMAKE_USER_MAKE_RULES_OVERRIDE as uninitialized since it will hold its value in the CMake cache otherwise can cause issues when branch switching $cmake_command \ diff --git a/src/coreclr/build-runtime.sh b/src/coreclr/build-runtime.sh index f87d4ea643bcc4..f8129a719a3064 100755 --- a/src/coreclr/build-runtime.sh +++ b/src/coreclr/build-runtime.sh @@ -99,7 +99,7 @@ build_cross_architecture_components() export __CMakeBinDir CROSSCOMPILE __CMakeArgs="-DCLR_CMAKE_TARGET_ARCH=$__BuildArch -DCLR_CROSS_COMPONENTS_BUILD=1 $__CMakeArgs" - build_native "$__TargetOS" "$__CrossArch" "$__ProjectRoot" "$__RepoRootDir/eng/native" "$intermediatesForBuild" "$__CMakeArgs" "cross-architecture components" + build_native "$__TargetOS" "$__CrossArch" "$__ProjectRoot" "$intermediatesForBuild" "$__CMakeArgs" "cross-architecture components" CROSSCOMPILE=1 export CROSSCOMPILE @@ -257,7 +257,7 @@ fi if [[ "$__SkipNative" == 1 ]]; then echo "Skipping CoreCLR component build." else - build_native "$__TargetOS" "$__BuildArch" "$__ProjectRoot" "$__RepoRootDir/eng/native" "$__IntermediatesDir" "$__CMakeArgs" "CoreCLR component" + build_native "$__TargetOS" "$__BuildArch" "$__ProjectRoot" "$__IntermediatesDir" "$__CMakeArgs" "CoreCLR component" # Build cross-architecture components if [[ "$__SkipCrossArchNative" != 1 ]]; then diff --git a/src/installer/corehost/build.sh b/src/installer/corehost/build.sh index 60cc5ed4511b23..d807a9cde0a721 100755 --- a/src/installer/corehost/build.sh +++ b/src/installer/corehost/build.sh @@ -116,4 +116,4 @@ setup_dirs check_prereqs # Build the installer native components. -build_native "$__TargetOS" "$__BuildArch" "$__scriptpath" "$__RepoRootDir/eng/native" "$__IntermediatesDir" "$__CMakeArgs" "installer component" +build_native "$__TargetOS" "$__BuildArch" "$__scriptpath" "$__IntermediatesDir" "$__CMakeArgs" "installer component" diff --git a/src/libraries/Native/build-native.sh b/src/libraries/Native/build-native.sh index 3149f9d461cd73..0dc7c80d674fab 100755 --- a/src/libraries/Native/build-native.sh +++ b/src/libraries/Native/build-native.sh @@ -157,4 +157,4 @@ setup_dirs check_prereqs # Build the corefx native components. -build_native "$__TargetOS" "$__BuildArch" "$__nativeroot" "$__RepoRootDir/eng/native" "$__IntermediatesDir" "$__CMakeArgs" "native libraries component" +build_native "$__TargetOS" "$__BuildArch" "$__nativeroot" "$__IntermediatesDir" "$__CMakeArgs" "native libraries component" diff --git a/src/tests/build.sh b/src/tests/build.sh index fa08b582365f2f..0955a4adbe4072 100755 --- a/src/tests/build.sh +++ b/src/tests/build.sh @@ -279,7 +279,7 @@ build_Tests() fi if [[ "$__SkipNative" != 1 && "$__TargetOS" != "Browser" && "$__TargetOS" != "Android" ]]; then - build_native "$__TargetOS" "$__BuildArch" "$__TestDir" "$__RepoRootDir/eng/native" "$__NativeTestIntermediatesDir" "CoreCLR test component" + build_native "$__TargetOS" "$__BuildArch" "$__TestDir" "$__NativeTestIntermediatesDir" "CoreCLR test component" if [[ "$?" -ne 0 ]]; then echo "${__ErrMsgPrefix}${__MsgPrefix}Error: native test build failed. Refer to the build log files for details (above)" From 9b7476fe4926212d954c4058c7243209f2a73531 Mon Sep 17 00:00:00 2001 From: vsadov Date: Thu, 3 Dec 2020 11:01:04 -0800 Subject: [PATCH 20/32] remove "clrcompression.dll" and "libSystem.IO.Compression.Native.dylib" from single-file host packaging --- .../pkg/sfx/Microsoft.NETCore.App/Directory.Build.props | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props b/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props index 7d742fd131116e..036716cf0a7f9f 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props @@ -15,14 +15,12 @@ - - From 8a02254d71333a83f3d8f672287dd4b60f8d4e85 Mon Sep 17 00:00:00 2001 From: vsadov Date: Thu, 3 Dec 2020 11:19:27 -0800 Subject: [PATCH 21/32] mono: refactor Globalization lookup into `default_resolve_dllimport`. --- src/mono/mono/metadata/native-library.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/mono/mono/metadata/native-library.c b/src/mono/mono/metadata/native-library.c index 94c9e3416b225d..16ff1fd5230638 100644 --- a/src/mono/mono/metadata/native-library.c +++ b/src/mono/mono/metadata/native-library.c @@ -1260,6 +1260,20 @@ legacy_lookup_native_library (MonoImage *image, const char *scope) #endif // ENABLE_NETCORE +#if defined(ENABLE_NETCORE) && !defined(NO_GLOBALIZATION_SHIM) +static gpointer +default_resolve_dllimport(const char* dll, const char* func) +{ + if (strcmp(dll, "libSystem.Globalization.Native") == 0) { + const void* method_impl = GlobalizationResolveDllImport(func); + if (method_impl) + return (gpointer)method_impl; + } + + return NULL; +} +#endif + gpointer lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_out) { @@ -1341,13 +1355,9 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou #endif #if defined(ENABLE_NETCORE) && !defined(NO_GLOBALIZATION_SHIM) - if (strcmp(new_scope, "libSystem.Globalization.Native") == 0) { - const void* method_impl = GlobalizationResolveDllImport(new_import); - if (method_impl) - { - return (gpointer)method_impl; - } - } + gpointer default_override = default_resolve_dllimport(new_scope, new_import); + if (default_override) + return default_override; #endif #ifdef ENABLE_NETCORE From f22e9fde51e7ed154290d179e2334e5266803d45 Mon Sep 17 00:00:00 2001 From: vsadov Date: Thu, 3 Dec 2020 12:19:00 -0800 Subject: [PATCH 22/32] set FEATURE_DISTRO_AGNOSTIC_SSL according to __PortableBuild --- eng/native/build-commons.sh | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index e77d219ce0caf1..7bf00e02c69b85 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -454,21 +454,7 @@ if [[ "$__PortableBuild" == 0 ]]; then __CommonMSBuildArgs="$__CommonMSBuildArgs /p:PortableBuild=false" fi -if [[ "$__BuildArch" == wasm ]]; then - # nothing to do here - true -elif [[ "$__TargetOS" == iOS ]]; then - # nothing to do here - true -elif [[ "$__TargetOS" == tvOS ]]; then - # nothing to do here - true -elif [[ "$__TargetOS" == Android ]]; then - # nothing to do here - true -else - __CMakeArgs="-DFEATURE_DISTRO_AGNOSTIC_SSL=$__PortableBuild $__CMakeArgs" -fi +__CMakeArgs="-DFEATURE_DISTRO_AGNOSTIC_SSL=$__PortableBuild $__CMakeArgs" # Configure environment if we are doing a cross compile. if [[ "$__CrossBuild" == 1 ]]; then From e539a1ad47e386709650830a7986d945efe43849 Mon Sep 17 00:00:00 2001 From: vsadov Date: Thu, 3 Dec 2020 15:19:11 -0800 Subject: [PATCH 23/32] CORECLR_CALLING_CONVENTION for the host callback types --- src/coreclr/src/hosts/inc/coreclrhost.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coreclr/src/hosts/inc/coreclrhost.h b/src/coreclr/src/hosts/inc/coreclrhost.h index 327879e2934a88..f1d6c005a32f62 100644 --- a/src/coreclr/src/hosts/inc/coreclrhost.h +++ b/src/coreclr/src/hosts/inc/coreclrhost.h @@ -126,8 +126,8 @@ CORECLR_HOSTING_API(coreclr_execute_assembly, // // Callback types used by the hosts // -typedef bool(BundleProbeFn)(const char* path, int64_t* offset, int64_t* size); -typedef const void* (PInvokeOverrideFn)(const char* libraryName, const char* entrypointName); +typedef bool(CORECLR_CALLING_CONVENTION BundleProbeFn)(const char* path, int64_t* offset, int64_t* size); +typedef const void* (CORECLR_CALLING_CONVENTION PInvokeOverrideFn)(const char* libraryName, const char* entrypointName); #endif // __CORECLR_HOST_H__ From 06dad0020d0c8d7387ee115a255314fefc4261ae Mon Sep 17 00:00:00 2001 From: vsadov Date: Thu, 3 Dec 2020 15:48:06 -0800 Subject: [PATCH 24/32] revert change in pal_gssapi.h --- .../System.Net.Security.Native/pal_gssapi.h | 99 +++++++++---------- 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.h b/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.h index 4e94de546e4d8f..cd7ff85cecad95 100644 --- a/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.h +++ b/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.h @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. #pragma once -#include "pal_config.h" #include "pal_compiler.h" #if HAVE_GSSFW_HEADERS || HAVE_HEIMDAL_HEADERS @@ -80,9 +79,9 @@ NetSecurityNative_ImportUserName(uint32_t* minorStatus, char* inputName, uint32_ Shims the gss_import_name method with nametype = GSS_C_NT_USER_NAME. */ PALEXPORT uint32_t NetSecurityNative_ImportPrincipalName(uint32_t* minorStatus, - char* inputName, - uint32_t inputNameLen, - GssName** outputName); + char* inputName, + uint32_t inputNameLen, + GssName** outputName); /* Shims the gss_release_name method. @@ -109,42 +108,42 @@ PALEXPORT uint32_t NetSecurityNative_ReleaseCred(uint32_t* minorStatus, GssCredI Shims the gss_init_sec_context method with SPNEGO oids. */ PALEXPORT uint32_t NetSecurityNative_InitSecContext(uint32_t* minorStatus, - GssCredId* claimantCredHandle, - GssCtxId** contextHandle, - uint32_t isNtlm, - GssName* targetName, - uint32_t reqFlags, - uint8_t* inputBytes, - uint32_t inputLength, - PAL_GssBuffer* outBuffer, - uint32_t* retFlags, - int32_t* isNtlmUsed); + GssCredId* claimantCredHandle, + GssCtxId** contextHandle, + uint32_t isNtlm, + GssName* targetName, + uint32_t reqFlags, + uint8_t* inputBytes, + uint32_t inputLength, + PAL_GssBuffer* outBuffer, + uint32_t* retFlags, + int32_t* isNtlmUsed); PALEXPORT uint32_t NetSecurityNative_InitSecContextEx(uint32_t* minorStatus, - GssCredId* claimantCredHandle, - GssCtxId** contextHandle, - uint32_t isNtlm, - void* cbt, - int32_t cbtSize, - GssName* targetName, - uint32_t reqFlags, - uint8_t* inputBytes, - uint32_t inputLength, - PAL_GssBuffer* outBuffer, - uint32_t* retFlags, - int32_t* isNtlmUsed); + GssCredId* claimantCredHandle, + GssCtxId** contextHandle, + uint32_t isNtlm, + void* cbt, + int32_t cbtSize, + GssName* targetName, + uint32_t reqFlags, + uint8_t* inputBytes, + uint32_t inputLength, + PAL_GssBuffer* outBuffer, + uint32_t* retFlags, + int32_t* isNtlmUsed); /* Shims the gss_accept_sec_context method. */ PALEXPORT uint32_t NetSecurityNative_AcceptSecContext(uint32_t* minorStatus, - GssCredId* acceptorCredHandle, - GssCtxId** contextHandle, - uint8_t* inputBytes, - uint32_t inputLength, - PAL_GssBuffer* outBuffer, - uint32_t* retFlags, - int32_t* isNtlmUsed); + GssCredId* acceptorCredHandle, + GssCtxId** contextHandle, + uint8_t* inputBytes, + uint32_t inputLength, + PAL_GssBuffer* outBuffer, + uint32_t* retFlags, + int32_t* isNtlmUsed); /* @@ -156,31 +155,31 @@ PALEXPORT uint32_t NetSecurityNative_DeleteSecContext(uint32_t* minorStatus, Gss Shims the gss_wrap method. */ PALEXPORT uint32_t NetSecurityNative_Wrap(uint32_t* minorStatus, - GssCtxId* contextHandle, - int32_t isEncrypt, - uint8_t* inputBytes, - int32_t count, - PAL_GssBuffer* outBuffer); + GssCtxId* contextHandle, + int32_t isEncrypt, + uint8_t* inputBytes, + int32_t count, + PAL_GssBuffer* outBuffer); /* Shims the gss_unwrap method. */ PALEXPORT uint32_t NetSecurityNative_Unwrap(uint32_t* minorStatus, - GssCtxId* contextHandle, - uint8_t* inputBytes, - int32_t offset, - int32_t count, - PAL_GssBuffer* outBuffer); + GssCtxId* contextHandle, + uint8_t* inputBytes, + int32_t offset, + int32_t count, + PAL_GssBuffer* outBuffer); /* Shims the gss_acquire_cred_with_password method with GSS_C_INITIATE. */ PALEXPORT uint32_t NetSecurityNative_InitiateCredWithPassword(uint32_t* minorStatus, - int32_t isNtlm, - GssName* desiredName, - char* password, - uint32_t passwdLen, - GssCredId** outputCredHandle); + int32_t isNtlm, + GssName* desiredName, + char* password, + uint32_t passwdLen, + GssCredId** outputCredHandle); /* Shims the gss_indicate_mechs method to detect if NTLM mech is installed. @@ -191,5 +190,5 @@ PALEXPORT uint32_t NetSecurityNative_IsNtlmInstalled(void); Shims gss_inquire_context and gss_display_name to get the remote user principal name. */ PALEXPORT uint32_t NetSecurityNative_GetUser(uint32_t* minorStatus, - GssCtxId* contextHandle, - PAL_GssBuffer* outBuffer); + GssCtxId* contextHandle, + PAL_GssBuffer* outBuffer); From ac026bafa35b6cc5dbf1a841dd0a5cdfc93ef32a Mon Sep 17 00:00:00 2001 From: vsadov Date: Thu, 3 Dec 2020 16:01:04 -0800 Subject: [PATCH 25/32] keep the #include "pal_config.h" --- .../Native/Unix/System.Net.Security.Native/pal_gssapi.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.h b/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.h index cd7ff85cecad95..5c1fe55163ec6c 100644 --- a/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.h +++ b/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.h @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. #pragma once +#include "pal_config.h" #include "pal_compiler.h" #if HAVE_GSSFW_HEADERS || HAVE_HEIMDAL_HEADERS From eb62c4a8aa6c6609a27904ed9d0ef5f29ccd9526 Mon Sep 17 00:00:00 2001 From: vsadov Date: Thu, 3 Dec 2020 21:43:26 -0800 Subject: [PATCH 26/32] refactor common parts of entrypoints.c into entrypoints.h --- .../entrypoints.c | 27 ++------------- src/libraries/Native/AnyOS/entrypoints.h | 34 +++++++++++++++++++ .../System.Globalization.Native/entrypoints.c | 27 ++------------- 3 files changed, 39 insertions(+), 49 deletions(-) create mode 100644 src/libraries/Native/AnyOS/entrypoints.h diff --git a/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c b/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c index f5973cb94fc4d0..f438261e070e3e 100644 --- a/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c +++ b/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c @@ -1,8 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#include -#include +#include "../../AnyOS/entrypoints.h" // Include System.IO.Compression.Native headers #include "../zlib/pal_zlib.h" @@ -11,19 +10,7 @@ #include "../brotli/include/brotli/port.h" #include "../brotli/include/brotli/types.h" -#ifndef lengthof -#define lengthof(rg) (sizeof(rg)/sizeof(rg[0])) -#endif - -typedef struct -{ - const char* name; - const void* method; -} Entry; - -// expands to: {"impl", (void*)impl}, -#define OverrideEntry(impl) \ - {#impl, (void*)impl}, +#include "../../AnyOS/entrypoints.h" static const Entry s_compressionNative[] = { @@ -51,13 +38,5 @@ EXTERN_C const void* CompressionResolveDllImport(const char* name); EXTERN_C const void* CompressionResolveDllImport(const char* name) { - for (size_t i = 0; i < lengthof(s_compressionNative); i++) - { - if (strcmp(name, s_compressionNative[i].name) == 0) - { - return s_compressionNative[i].method; - } - } - - return NULL; + return ResolveDllImport(s_compressionNative, lengthof(s_compressionNative), name); } diff --git a/src/libraries/Native/AnyOS/entrypoints.h b/src/libraries/Native/AnyOS/entrypoints.h new file mode 100644 index 00000000000000..aa29bd4a2c80c4 --- /dev/null +++ b/src/libraries/Native/AnyOS/entrypoints.h @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#pragma once + +#include +#include + +#ifndef lengthof +#define lengthof(rg) (sizeof(rg)/sizeof(rg[0])) +#endif + +typedef struct +{ + const char* name; + const void* method; +} Entry; + +// expands to: {"impl", (void*)impl}, +#define OverrideEntry(impl) \ + {#impl, (void*)impl}, + +static const void* ResolveDllImport(const Entry* resolutionTable, size_t tableLength, const char* name) +{ + for (size_t i = 0; i < tableLength; i++) + { + if (strcmp(name, resolutionTable[i].name) == 0) + { + return resolutionTable[i].method; + } + } + + return NULL; +} diff --git a/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c b/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c index 07bee5d40697d1..0eee5735e53357 100644 --- a/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c @@ -1,8 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#include -#include +#include "../../AnyOS/entrypoints.h" typedef uint16_t UChar; @@ -18,20 +17,6 @@ typedef uint16_t UChar; #include "pal_normalization.h" #include "pal_timeZoneInfo.h" -#ifndef lengthof -#define lengthof(rg) (sizeof(rg)/sizeof(rg[0])) -#endif - -typedef struct -{ - const char* name; - const void* method; -} Entry; - -// expands to: {"impl", (void*)impl}, -#define OverrideEntry(impl) \ - {#impl, (void*)impl}, - static const Entry s_globalizationNative[] = { OverrideEntry(GlobalizationNative_ChangeCase) @@ -74,13 +59,5 @@ EXTERN_C const void* GlobalizationResolveDllImport(const char* name); EXTERN_C const void* GlobalizationResolveDllImport(const char* name) { - for (size_t i = 0; i < lengthof(s_globalizationNative); i++) - { - if (strcmp(name, s_globalizationNative[i].name) == 0) - { - return s_globalizationNative[i].method; - } - } - - return NULL; + return ResolveDllImport(s_globalizationNative, lengthof(s_globalizationNative), name); } From 2f45a47e1b19076ff9892412c7ce93ec2b28e9b9 Mon Sep 17 00:00:00 2001 From: vsadov Date: Thu, 3 Dec 2020 23:31:21 -0800 Subject: [PATCH 27/32] rename OverrideEntry --> DllImportEntry --- .../entrypoints.c | 36 +++++----- src/libraries/Native/AnyOS/entrypoints.h | 2 +- .../System.Globalization.Native/entrypoints.c | 68 +++++++++---------- 3 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c b/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c index f438261e070e3e..b194b978debe23 100644 --- a/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c +++ b/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c @@ -14,24 +14,24 @@ static const Entry s_compressionNative[] = { - OverrideEntry(BrotliDecoderCreateInstance) - OverrideEntry(BrotliDecoderDecompress) - OverrideEntry(BrotliDecoderDecompressStream) - OverrideEntry(BrotliDecoderDestroyInstance) - OverrideEntry(BrotliDecoderIsFinished) - OverrideEntry(BrotliEncoderCompress) - OverrideEntry(BrotliEncoderCompressStream) - OverrideEntry(BrotliEncoderCreateInstance) - OverrideEntry(BrotliEncoderDestroyInstance) - OverrideEntry(BrotliEncoderHasMoreOutput) - OverrideEntry(BrotliEncoderSetParameter) - OverrideEntry(CompressionNative_Crc32) - OverrideEntry(CompressionNative_Deflate) - OverrideEntry(CompressionNative_DeflateEnd) - OverrideEntry(CompressionNative_DeflateInit2_) - OverrideEntry(CompressionNative_Inflate) - OverrideEntry(CompressionNative_InflateEnd) - OverrideEntry(CompressionNative_InflateInit2_) + DllImportEntry(BrotliDecoderCreateInstance) + DllImportEntry(BrotliDecoderDecompress) + DllImportEntry(BrotliDecoderDecompressStream) + DllImportEntry(BrotliDecoderDestroyInstance) + DllImportEntry(BrotliDecoderIsFinished) + DllImportEntry(BrotliEncoderCompress) + DllImportEntry(BrotliEncoderCompressStream) + DllImportEntry(BrotliEncoderCreateInstance) + DllImportEntry(BrotliEncoderDestroyInstance) + DllImportEntry(BrotliEncoderHasMoreOutput) + DllImportEntry(BrotliEncoderSetParameter) + DllImportEntry(CompressionNative_Crc32) + DllImportEntry(CompressionNative_Deflate) + DllImportEntry(CompressionNative_DeflateEnd) + DllImportEntry(CompressionNative_DeflateInit2_) + DllImportEntry(CompressionNative_Inflate) + DllImportEntry(CompressionNative_InflateEnd) + DllImportEntry(CompressionNative_InflateInit2_) }; EXTERN_C const void* CompressionResolveDllImport(const char* name); diff --git a/src/libraries/Native/AnyOS/entrypoints.h b/src/libraries/Native/AnyOS/entrypoints.h index aa29bd4a2c80c4..ce7a7e2c5a2bfb 100644 --- a/src/libraries/Native/AnyOS/entrypoints.h +++ b/src/libraries/Native/AnyOS/entrypoints.h @@ -17,7 +17,7 @@ typedef struct } Entry; // expands to: {"impl", (void*)impl}, -#define OverrideEntry(impl) \ +#define DllImportEntry(impl) \ {#impl, (void*)impl}, static const void* ResolveDllImport(const Entry* resolutionTable, size_t tableLength, const char* name) diff --git a/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c b/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c index 0eee5735e53357..85a39085270b46 100644 --- a/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c @@ -19,40 +19,40 @@ typedef uint16_t UChar; static const Entry s_globalizationNative[] = { - OverrideEntry(GlobalizationNative_ChangeCase) - OverrideEntry(GlobalizationNative_ChangeCaseInvariant) - OverrideEntry(GlobalizationNative_ChangeCaseTurkish) - OverrideEntry(GlobalizationNative_CloseSortHandle) - OverrideEntry(GlobalizationNative_CompareString) - OverrideEntry(GlobalizationNative_EndsWith) - OverrideEntry(GlobalizationNative_EnumCalendarInfo) - OverrideEntry(GlobalizationNative_GetCalendarInfo) - OverrideEntry(GlobalizationNative_GetCalendars) - OverrideEntry(GlobalizationNative_GetDefaultLocaleName) - OverrideEntry(GlobalizationNative_GetICUVersion) - OverrideEntry(GlobalizationNative_GetJapaneseEraStartDate) - OverrideEntry(GlobalizationNative_GetLatestJapaneseEra) - OverrideEntry(GlobalizationNative_GetLocaleInfoGroupingSizes) - OverrideEntry(GlobalizationNative_GetLocaleInfoInt) - OverrideEntry(GlobalizationNative_GetLocaleInfoString) - OverrideEntry(GlobalizationNative_GetLocaleName) - OverrideEntry(GlobalizationNative_GetLocales) - OverrideEntry(GlobalizationNative_GetLocaleTimeFormat) - OverrideEntry(GlobalizationNative_GetSortHandle) - OverrideEntry(GlobalizationNative_GetSortKey) - OverrideEntry(GlobalizationNative_GetSortVersion) - OverrideEntry(GlobalizationNative_GetTimeZoneDisplayName) - OverrideEntry(GlobalizationNative_IndexOf) - OverrideEntry(GlobalizationNative_InitICUFunctions) - OverrideEntry(GlobalizationNative_InitOrdinalCasingPage) - OverrideEntry(GlobalizationNative_IsNormalized) - OverrideEntry(GlobalizationNative_IsPredefinedLocale) - OverrideEntry(GlobalizationNative_LastIndexOf) - OverrideEntry(GlobalizationNative_LoadICU) - OverrideEntry(GlobalizationNative_NormalizeString) - OverrideEntry(GlobalizationNative_StartsWith) - OverrideEntry(GlobalizationNative_ToAscii) - OverrideEntry(GlobalizationNative_ToUnicode) + DllImportEntry(GlobalizationNative_ChangeCase) + DllImportEntry(GlobalizationNative_ChangeCaseInvariant) + DllImportEntry(GlobalizationNative_ChangeCaseTurkish) + DllImportEntry(GlobalizationNative_CloseSortHandle) + DllImportEntry(GlobalizationNative_CompareString) + DllImportEntry(GlobalizationNative_EndsWith) + DllImportEntry(GlobalizationNative_EnumCalendarInfo) + DllImportEntry(GlobalizationNative_GetCalendarInfo) + DllImportEntry(GlobalizationNative_GetCalendars) + DllImportEntry(GlobalizationNative_GetDefaultLocaleName) + DllImportEntry(GlobalizationNative_GetICUVersion) + DllImportEntry(GlobalizationNative_GetJapaneseEraStartDate) + DllImportEntry(GlobalizationNative_GetLatestJapaneseEra) + DllImportEntry(GlobalizationNative_GetLocaleInfoGroupingSizes) + DllImportEntry(GlobalizationNative_GetLocaleInfoInt) + DllImportEntry(GlobalizationNative_GetLocaleInfoString) + DllImportEntry(GlobalizationNative_GetLocaleName) + DllImportEntry(GlobalizationNative_GetLocales) + DllImportEntry(GlobalizationNative_GetLocaleTimeFormat) + DllImportEntry(GlobalizationNative_GetSortHandle) + DllImportEntry(GlobalizationNative_GetSortKey) + DllImportEntry(GlobalizationNative_GetSortVersion) + DllImportEntry(GlobalizationNative_GetTimeZoneDisplayName) + DllImportEntry(GlobalizationNative_IndexOf) + DllImportEntry(GlobalizationNative_InitICUFunctions) + DllImportEntry(GlobalizationNative_InitOrdinalCasingPage) + DllImportEntry(GlobalizationNative_IsNormalized) + DllImportEntry(GlobalizationNative_IsPredefinedLocale) + DllImportEntry(GlobalizationNative_LastIndexOf) + DllImportEntry(GlobalizationNative_LoadICU) + DllImportEntry(GlobalizationNative_NormalizeString) + DllImportEntry(GlobalizationNative_StartsWith) + DllImportEntry(GlobalizationNative_ToAscii) + DllImportEntry(GlobalizationNative_ToUnicode) }; EXTERN_C const void* GlobalizationResolveDllImport(const char* name); From 7b2bdefbd567fa5cee49701752d3d8ff9dcfe86a Mon Sep 17 00:00:00 2001 From: vsadov Date: Thu, 3 Dec 2020 19:22:28 -0800 Subject: [PATCH 28/32] extra libs as CMake functions --- .../cli/apphost/static/CMakeLists.txt | 6 ++ .../cli/hostpolicy/hostpolicy_context.cpp | 12 +-- .../CMakeLists.txt | 4 +- .../extra_libs.cmake | 25 +++--- .../Native/Unix/System.Native/CMakeLists.txt | 4 +- .../Unix/System.Native/extra_libs.cmake | 34 +++++---- .../System.Net.Security.Native/CMakeLists.txt | 4 +- .../extra_libs.cmake | 40 +++++----- .../CMakeLists.txt | 4 +- .../extra_libs.cmake | 76 +++++++++---------- 10 files changed, 115 insertions(+), 94 deletions(-) diff --git a/src/installer/corehost/cli/apphost/static/CMakeLists.txt b/src/installer/corehost/cli/apphost/static/CMakeLists.txt index ced89a63215df1..cf100a715d1a34 100644 --- a/src/installer/corehost/cli/apphost/static/CMakeLists.txt +++ b/src/installer/corehost/cli/apphost/static/CMakeLists.txt @@ -144,6 +144,7 @@ else() # additional requirements for System.IO.Compression.Native include(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.IO.Compression.Native/extra_libs.cmake) + append_extra_compression_libs(NATIVE_LIBS_EXTRA) endif() if(CLR_CMAKE_TARGET_OSX) @@ -197,10 +198,15 @@ if(CLR_CMAKE_TARGET_LINUX) # Additional requirements for System.Native include(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.Native/extra_libs.cmake) + append_extra_system_libs(NATIVE_LIBS_EXTRA) + # Additional requirements for System.Net.Security.Native include(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.Net.Security.Native/extra_libs.cmake) + append_extra_security_libs(NATIVE_LIBS_EXTRA) + # Additional requirements for System.Security.Cryptography.Native.OpenSsl include(${CLR_REPO_ROOT_DIR}/src/libraries/Native/Unix/System.Security.Cryptography.Native/extra_libs.cmake) + append_extra_cryptography_libs(NATIVE_LIBS_EXTRA) endif() if(CLR_CMAKE_TARGET_LINUX OR CLR_CMAKE_TARGET_FREEBSD OR CLR_CMAKE_TARGET_NETBSD OR CLR_CMAKE_TARGET_SUNOS) diff --git a/src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp b/src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp index c804ef062731a6..aba62722a0da58 100644 --- a/src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp +++ b/src/installer/corehost/cli/hostpolicy/hostpolicy_context.cpp @@ -46,15 +46,17 @@ namespace #if defined(NATIVE_LIBS_EMBEDDED) extern "C" const void* CompressionResolveDllImport(const char* name); +#if defined(_WIN32) +#define COMPRESSION_DLL_NAME "clrcompression" +#else +#define COMPRESSION_DLL_NAME "libSystem.IO.Compression.Native" +#endif + // pinvoke_override: // Check if given function belongs to one of statically linked libraries and return a pointer if found. const void* STDMETHODCALLTYPE pinvoke_override(const char* libraryName, const char* entrypointName) { -#if defined(_WIN32) - if (strcmp(libraryName, "clrcompression") == 0) -#else - if (strcmp(libraryName, "libSystem.IO.Compression.Native") == 0) -#endif + if (strcmp(libraryName, COMPRESSION_DLL_NAME) == 0) { return CompressionResolveDllImport(entrypointName); } diff --git a/src/libraries/Native/Unix/System.IO.Compression.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.IO.Compression.Native/CMakeLists.txt index cf2a68144ddc74..28f57b4f5593e7 100644 --- a/src/libraries/Native/Unix/System.IO.Compression.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.IO.Compression.Native/CMakeLists.txt @@ -4,9 +4,11 @@ if (CLR_CMAKE_TARGET_BROWSER) add_definitions(-s USE_ZLIB) endif() -set(NATIVE_LIBS_EXTRA) include(${CMAKE_CURRENT_LIST_DIR}/extra_libs.cmake) +set(NATIVE_LIBS_EXTRA) +append_extra_compression_libs(NATIVE_LIBS_EXTRA) + set(NATIVECOMPRESSION_SOURCES ../../AnyOS/zlib/pal_zlib.c ) diff --git a/src/libraries/Native/Unix/System.IO.Compression.Native/extra_libs.cmake b/src/libraries/Native/Unix/System.IO.Compression.Native/extra_libs.cmake index bbd3518078ddd5..c698ceb692ee78 100644 --- a/src/libraries/Native/Unix/System.IO.Compression.Native/extra_libs.cmake +++ b/src/libraries/Native/Unix/System.IO.Compression.Native/extra_libs.cmake @@ -1,13 +1,14 @@ -if (CLR_CMAKE_TARGET_BROWSER) - # nothing special to link -elseif (CLR_CMAKE_TARGET_ANDROID) - # need special case here since we want to link against libz.so but find_package() would resolve libz.a - set(ZLIB_LIBRARIES z) -elseif (CLR_CMAKE_TARGET_SUNOS) - set(ZLIB_LIBRARIES z m) -else () - find_package(ZLIB REQUIRED) -endif () - -list(APPEND NATIVE_LIBS_EXTRA ${ZLIB_LIBRARIES}) +function(append_extra_compression_libs NativeLibsExtra) + if (CLR_CMAKE_TARGET_BROWSER) + # nothing special to link + elseif (CLR_CMAKE_TARGET_ANDROID) + # need special case here since we want to link against libz.so but find_package() would resolve libz.a + set(ZLIB_LIBRARIES z) + elseif (CLR_CMAKE_TARGET_SUNOS) + set(ZLIB_LIBRARIES z m) + else () + find_package(ZLIB REQUIRED) + endif () + set(${NativeLibsExtra} ${${NativeLibsExtra}} ${ZLIB_LIBRARIES} PARENT_SCOPE) +endfunction(append_extra_compression_libs) diff --git a/src/libraries/Native/Unix/System.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Native/CMakeLists.txt index 743b1dcaedb76d..d41bb807b0cbac 100644 --- a/src/libraries/Native/Unix/System.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Native/CMakeLists.txt @@ -53,9 +53,11 @@ elseif (CLR_CMAKE_TARGET_FREEBSD) endif () endif () -set(NATIVE_LIBS_EXTRA) include(${CMAKE_CURRENT_LIST_DIR}/extra_libs.cmake) +set(NATIVE_LIBS_EXTRA) +append_extra_system_libs(NATIVE_LIBS_EXTRA) + if (GEN_SHARED_LIB) add_library(System.Native SHARED diff --git a/src/libraries/Native/Unix/System.Native/extra_libs.cmake b/src/libraries/Native/Unix/System.Native/extra_libs.cmake index 0e86942bb4f12f..0a41110ed5a41c 100644 --- a/src/libraries/Native/Unix/System.Native/extra_libs.cmake +++ b/src/libraries/Native/Unix/System.Native/extra_libs.cmake @@ -1,17 +1,21 @@ - -if (CLR_CMAKE_TARGET_LINUX AND NOT CLR_CMAKE_TARGET_ANDROID) - list(APPEND NATIVE_LIBS_EXTRA rt) -elseif (CLR_CMAKE_TARGET_FREEBSD) - list(APPEND NATIVE_LIBS_EXTRA pthread) - if (HAVE_INOTIFY) - find_library(INOTIFY_LIBRARY inotify HINTS /usr/local/lib) - list(APPEND NATIVE_LIBS_EXTRA ${INOTIFY_LIBRARY}) +function(append_extra_system_libs NativeLibsExtra) + set(EXTRA_LIBS) + + if (CLR_CMAKE_TARGET_LINUX AND NOT CLR_CMAKE_TARGET_ANDROID) + list(APPEND EXTRA_LIBS rt) + elseif (CLR_CMAKE_TARGET_FREEBSD) + list(APPEND EXTRA_LIBS pthread) + if (HAVE_INOTIFY) + find_library(INOTIFY_LIBRARY inotify HINTS /usr/local/lib) + list(APPEND EXTRA_LIBS ${INOTIFY_LIBRARY}) + endif () + elseif (CLR_CMAKE_TARGET_SUNOS) + list(APPEND EXTRA_LIBS socket) endif () -elseif (CLR_CMAKE_TARGET_SUNOS) - list(APPEND NATIVE_LIBS_EXTRA socket) -endif () - -if (CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) - list(APPEND NATIVE_LIBS_EXTRA "-framework Foundation") -endif () + + if (CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + list(APPEND EXTRA_LIBS "-framework Foundation") + endif () + set(${NativeLibsExtra} ${${NativeLibsExtra}} ${EXTRA_LIBS} PARENT_SCOPE) +endfunction(append_extra_system_libs) diff --git a/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt index cea72770a63d1c..bdc1678d765fd9 100644 --- a/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Net.Security.Native/CMakeLists.txt @@ -2,9 +2,11 @@ project(System.Net.Security.Native C) add_compile_options(-Wno-incompatible-pointer-types-discards-qualifiers) -set(NATIVE_LIBS_EXTRA) include(${CMAKE_CURRENT_LIST_DIR}/extra_libs.cmake) +set(NATIVE_LIBS_EXTRA) +append_extra_security_libs(NATIVE_LIBS_EXTRA) + set(NATIVEGSS_SOURCES pal_gssapi.c ) diff --git a/src/libraries/Native/Unix/System.Net.Security.Native/extra_libs.cmake b/src/libraries/Native/Unix/System.Net.Security.Native/extra_libs.cmake index a2c51653736170..39ab36497c547a 100644 --- a/src/libraries/Native/Unix/System.Net.Security.Native/extra_libs.cmake +++ b/src/libraries/Native/Unix/System.Net.Security.Native/extra_libs.cmake @@ -1,21 +1,23 @@ -if (HAVE_GSSFW_HEADERS) - find_library(LIBGSS NAMES GSS) - if(LIBGSS STREQUAL LIBGSS-NOTFOUND) - message(FATAL_ERROR "Cannot find GSS.Framework and System.Net.Security.Native cannot build without it. Try installing GSS.Framework (or the appropriate package for your platform)") - endif() -elseif(HAVE_HEIMDAL_HEADERS) - find_library(LIBGSS NAMES gssapi) - if(LIBGSS STREQUAL LIBGSS-NOTFOUND) - message(FATAL_ERROR "Cannot find libgssapi and System.Net.Security.Native cannot build without it. Try installing heimdal (or the appropriate package for your platform)") - endif() -elseif(HeimdalGssApi) - message(FATAL_ERROR "HeimdalGssApi option was set but gssapi headers could not be found and System.Net.Security.Native cannot build without the headers. Try installing heimdal (or the appropriate package for your platform)") -else() - find_library(LIBGSS NAMES gssapi_krb5) - if(LIBGSS STREQUAL LIBGSS-NOTFOUND) - message(FATAL_ERROR "Cannot find libgssapi_krb5 and System.Net.Security.Native cannot build without it. Try installing libkrb5-dev (or the appropriate package for your platform)") - endif() -endif() +function(append_extra_security_libs NativeLibsExtra) + if (HAVE_GSSFW_HEADERS) + find_library(LIBGSS NAMES GSS) + if(LIBGSS STREQUAL LIBGSS-NOTFOUND) + message(FATAL_ERROR "Cannot find GSS.Framework and System.Net.Security.Native cannot build without it. Try installing GSS.Framework (or the appropriate package for your platform)") + endif() + elseif(HAVE_HEIMDAL_HEADERS) + find_library(LIBGSS NAMES gssapi) + if(LIBGSS STREQUAL LIBGSS-NOTFOUND) + message(FATAL_ERROR "Cannot find libgssapi and System.Net.Security.Native cannot build without it. Try installing heimdal (or the appropriate package for your platform)") + endif() + elseif(HeimdalGssApi) + message(FATAL_ERROR "HeimdalGssApi option was set but gssapi headers could not be found and System.Net.Security.Native cannot build without the headers. Try installing heimdal (or the appropriate package for your platform)") + else() + find_library(LIBGSS NAMES gssapi_krb5) + if(LIBGSS STREQUAL LIBGSS-NOTFOUND) + message(FATAL_ERROR "Cannot find libgssapi_krb5 and System.Net.Security.Native cannot build without it. Try installing libkrb5-dev (or the appropriate package for your platform)") + endif() + endif() -list(APPEND NATIVE_LIBS_EXTRA ${LIBGSS}) + set(${NativeLibsExtra} ${${NativeLibsExtra}} ${LIBGSS} PARENT_SCOPE) +endfunction(append_extra_compression_libs) diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt b/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt index c752f08918442c..2ca4f235461558 100644 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native/CMakeLists.txt @@ -8,9 +8,11 @@ add_compile_options(-Wno-used-but-marked-unused) add_definitions(-DOPENSSL_API_COMPAT=0x10100000L) -set(NATIVE_LIBS_EXTRA) include(${CMAKE_CURRENT_LIST_DIR}/extra_libs.cmake) +set(NATIVE_LIBS_EXTRA) +append_extra_cryptography_libs(NATIVE_LIBS_EXTRA) + include_directories(${OPENSSL_INCLUDE_DIR}) set(NATIVECRYPTO_SOURCES diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native/extra_libs.cmake b/src/libraries/Native/Unix/System.Security.Cryptography.Native/extra_libs.cmake index 330a616c846804..3fa1b6c048c698 100644 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native/extra_libs.cmake +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native/extra_libs.cmake @@ -1,43 +1,41 @@ - -if(CMAKE_STATIC_LIB_LINK) - set(CMAKE_FIND_LIBRARY_SUFFIXES .a) -endif(CMAKE_STATIC_LIB_LINK) - -if(CLR_CMAKE_TARGET_ANDROID AND NOT CROSS_ROOTFS) - # TEMP: consume OpenSSL dependencies from external sources via env. variables - set(OPENSSL_FOUND 1) - set(OPENSSL_INCLUDE_DIR $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/include) - if(CLR_CMAKE_TARGET_ARCH_ARM64) - set(OPENSSL_CRYPTO_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/crypto/libs/android.arm64-v8a/libcrypto.so) - set(OPENSSL_SSL_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/libs/android.arm64-v8a/libssl.so) - elseif(CLR_CMAKE_TARGET_ARCH_ARM) - set(OPENSSL_CRYPTO_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/crypto/libs/android.armeabi-v7a/libcrypto.so) - set(OPENSSL_SSL_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/libs/android.armeabi-v7a/libssl.so) - elseif(CLR_CMAKE_TARGET_ARCH_I386) - set(OPENSSL_CRYPTO_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/crypto/libs/android.x86/libcrypto.so) - set(OPENSSL_SSL_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/libs/android.x86/libssl.so) +function(append_extra_cryptography_libs NativeLibsExtra) + if(CMAKE_STATIC_LIB_LINK) + set(CMAKE_FIND_LIBRARY_SUFFIXES .a) + endif(CMAKE_STATIC_LIB_LINK) + + if(CLR_CMAKE_TARGET_ANDROID AND NOT CROSS_ROOTFS) + # TEMP: consume OpenSSL dependencies from external sources via env. variables + set(OPENSSL_FOUND 1) + set(OPENSSL_INCLUDE_DIR $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/include) + if(CLR_CMAKE_TARGET_ARCH_ARM64) + set(OPENSSL_CRYPTO_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/crypto/libs/android.arm64-v8a/libcrypto.so) + set(OPENSSL_SSL_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/libs/android.arm64-v8a/libssl.so) + elseif(CLR_CMAKE_TARGET_ARCH_ARM) + set(OPENSSL_CRYPTO_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/crypto/libs/android.armeabi-v7a/libcrypto.so) + set(OPENSSL_SSL_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/libs/android.armeabi-v7a/libssl.so) + elseif(CLR_CMAKE_TARGET_ARCH_I386) + set(OPENSSL_CRYPTO_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/crypto/libs/android.x86/libcrypto.so) + set(OPENSSL_SSL_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/libs/android.x86/libssl.so) + else() + set(OPENSSL_CRYPTO_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/crypto/libs/android.x86_64/libcrypto.so) + set(OPENSSL_SSL_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/libs/android.x86_64/libssl.so) + endif() else() - set(OPENSSL_CRYPTO_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/crypto/libs/android.x86_64/libcrypto.so) - set(OPENSSL_SSL_LIBRARY $ENV{ANDROID_OPENSSL_AAR}/prefab/modules/ssl/libs/android.x86_64/libssl.so) + find_package(OpenSSL) + endif() + + if(NOT OPENSSL_FOUND) + message(FATAL_ERROR "!!! Cannot find libssl and System.Security.Cryptography.Native cannot build without it. Try installing libssl-dev (on Linux, but this may vary by distro) or openssl (on macOS) !!!. See the requirements document for your specific operating system: https://github.com/dotnet/runtime/tree/master/docs/workflow/requirements.") + endif(NOT OPENSSL_FOUND) + + + if (FEATURE_DISTRO_AGNOSTIC_SSL) + # Link with libdl.so to get the dlopen / dlsym / dlclose + set(EXTRA_LIBS dl) + else() + set(EXTRA_LIBS ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY}) endif() -else() - find_package(OpenSSL) -endif() - -if(NOT OPENSSL_FOUND) - message(FATAL_ERROR "!!! Cannot find libssl and System.Security.Cryptography.Native cannot build without it. Try installing libssl-dev (on Linux, but this may vary by distro) or openssl (on macOS) !!!. See the requirements document for your specific operating system: https://github.com/dotnet/runtime/tree/master/docs/workflow/requirements.") -endif(NOT OPENSSL_FOUND) - -if (FEATURE_DISTRO_AGNOSTIC_SSL) - # Link with libdl.so to get the dlopen / dlsym / dlclose - list(APPEND NATIVE_LIBS_EXTRA - dl - ) -else() - list(APPEND NATIVE_LIBS_EXTRA - ${OPENSSL_CRYPTO_LIBRARY} - ${OPENSSL_SSL_LIBRARY} - ) -endif() + set(${NativeLibsExtra} ${${NativeLibsExtra}} ${EXTRA_LIBS} PARENT_SCOPE) +endfunction(append_extra_cryptography_libs) From 7ab3211de1c5a22c263b3eb611a0393a874f2723 Mon Sep 17 00:00:00 2001 From: vsadov Date: Fri, 4 Dec 2020 07:45:12 -0800 Subject: [PATCH 29/32] use macros instead of functions in extra_libs.cmake --- .../extra_libs.cmake | 6 +++--- .../Native/Unix/System.Native/extra_libs.cmake | 17 +++++++---------- .../System.Net.Security.Native/extra_libs.cmake | 6 +++--- .../extra_libs.cmake | 10 ++++------ 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/libraries/Native/Unix/System.IO.Compression.Native/extra_libs.cmake b/src/libraries/Native/Unix/System.IO.Compression.Native/extra_libs.cmake index c698ceb692ee78..f4c7dcd390d30a 100644 --- a/src/libraries/Native/Unix/System.IO.Compression.Native/extra_libs.cmake +++ b/src/libraries/Native/Unix/System.IO.Compression.Native/extra_libs.cmake @@ -1,5 +1,5 @@ -function(append_extra_compression_libs NativeLibsExtra) +macro(append_extra_compression_libs NativeLibsExtra) if (CLR_CMAKE_TARGET_BROWSER) # nothing special to link elseif (CLR_CMAKE_TARGET_ANDROID) @@ -10,5 +10,5 @@ function(append_extra_compression_libs NativeLibsExtra) else () find_package(ZLIB REQUIRED) endif () - set(${NativeLibsExtra} ${${NativeLibsExtra}} ${ZLIB_LIBRARIES} PARENT_SCOPE) -endfunction(append_extra_compression_libs) + list(APPEND ${NativeLibsExtra} ${ZLIB_LIBRARIES}) +endmacro() diff --git a/src/libraries/Native/Unix/System.Native/extra_libs.cmake b/src/libraries/Native/Unix/System.Native/extra_libs.cmake index 0a41110ed5a41c..b0cb4c1aa58f24 100644 --- a/src/libraries/Native/Unix/System.Native/extra_libs.cmake +++ b/src/libraries/Native/Unix/System.Native/extra_libs.cmake @@ -1,21 +1,18 @@ -function(append_extra_system_libs NativeLibsExtra) - set(EXTRA_LIBS) - +macro(append_extra_system_libs NativeLibsExtra) if (CLR_CMAKE_TARGET_LINUX AND NOT CLR_CMAKE_TARGET_ANDROID) - list(APPEND EXTRA_LIBS rt) + list(APPEND ${NativeLibsExtra} rt) elseif (CLR_CMAKE_TARGET_FREEBSD) - list(APPEND EXTRA_LIBS pthread) + list(APPEND ${NativeLibsExtra} pthread) if (HAVE_INOTIFY) find_library(INOTIFY_LIBRARY inotify HINTS /usr/local/lib) - list(APPEND EXTRA_LIBS ${INOTIFY_LIBRARY}) + list(APPEND ${NativeLibsExtra} ${INOTIFY_LIBRARY}) endif () elseif (CLR_CMAKE_TARGET_SUNOS) - list(APPEND EXTRA_LIBS socket) + list(APPEND ${NativeLibsExtra} socket) endif () if (CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) - list(APPEND EXTRA_LIBS "-framework Foundation") + list(APPEND ${NativeLibsExtra} "-framework Foundation") endif () - set(${NativeLibsExtra} ${${NativeLibsExtra}} ${EXTRA_LIBS} PARENT_SCOPE) -endfunction(append_extra_system_libs) +endmacro() diff --git a/src/libraries/Native/Unix/System.Net.Security.Native/extra_libs.cmake b/src/libraries/Native/Unix/System.Net.Security.Native/extra_libs.cmake index 39ab36497c547a..49c6ff49610047 100644 --- a/src/libraries/Native/Unix/System.Net.Security.Native/extra_libs.cmake +++ b/src/libraries/Native/Unix/System.Net.Security.Native/extra_libs.cmake @@ -1,5 +1,5 @@ -function(append_extra_security_libs NativeLibsExtra) +macro(append_extra_security_libs NativeLibsExtra) if (HAVE_GSSFW_HEADERS) find_library(LIBGSS NAMES GSS) if(LIBGSS STREQUAL LIBGSS-NOTFOUND) @@ -19,5 +19,5 @@ function(append_extra_security_libs NativeLibsExtra) endif() endif() - set(${NativeLibsExtra} ${${NativeLibsExtra}} ${LIBGSS} PARENT_SCOPE) -endfunction(append_extra_compression_libs) + list(APPEND ${NativeLibsExtra} ${LIBGSS}) +endmacro() diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native/extra_libs.cmake b/src/libraries/Native/Unix/System.Security.Cryptography.Native/extra_libs.cmake index 3fa1b6c048c698..9d7521f51d5091 100644 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native/extra_libs.cmake +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native/extra_libs.cmake @@ -1,5 +1,5 @@ -function(append_extra_cryptography_libs NativeLibsExtra) +macro(append_extra_cryptography_libs NativeLibsExtra) if(CMAKE_STATIC_LIB_LINK) set(CMAKE_FIND_LIBRARY_SUFFIXES .a) endif(CMAKE_STATIC_LIB_LINK) @@ -32,10 +32,8 @@ function(append_extra_cryptography_libs NativeLibsExtra) if (FEATURE_DISTRO_AGNOSTIC_SSL) # Link with libdl.so to get the dlopen / dlsym / dlclose - set(EXTRA_LIBS dl) + list(APPEND ${NativeLibsExtra} dl) else() - set(EXTRA_LIBS ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY}) + list(APPEND ${NativeLibsExtra} ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY}) endif() - - set(${NativeLibsExtra} ${${NativeLibsExtra}} ${EXTRA_LIBS} PARENT_SCOPE) -endfunction(append_extra_cryptography_libs) +endmacro() From 7bf0a6314aa5f1ded9f9d5a2cecb071b6389adbc Mon Sep 17 00:00:00 2001 From: Vladimir Sadov Date: Fri, 4 Dec 2020 12:15:18 -0800 Subject: [PATCH 30/32] mono formatting style in src/mono/mono/metadata/native-library.c Co-authored-by: Ryan Lucia --- src/mono/mono/metadata/native-library.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/metadata/native-library.c b/src/mono/mono/metadata/native-library.c index 16ff1fd5230638..ee4b47b7ddc2a5 100644 --- a/src/mono/mono/metadata/native-library.c +++ b/src/mono/mono/metadata/native-library.c @@ -1265,7 +1265,7 @@ static gpointer default_resolve_dllimport(const char* dll, const char* func) { if (strcmp(dll, "libSystem.Globalization.Native") == 0) { - const void* method_impl = GlobalizationResolveDllImport(func); + const void *method_impl = GlobalizationResolveDllImport (func); if (method_impl) return (gpointer)method_impl; } From d3a15fa190e2aebff95deac6a7bb7d86323b4d38 Mon Sep 17 00:00:00 2001 From: Vladimir Sadov Date: Fri, 4 Dec 2020 12:25:12 -0800 Subject: [PATCH 31/32] mono: Remaining stylistic nits. Co-authored-by: Ryan Lucia --- src/mono/mono/metadata/native-library.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mono/mono/metadata/native-library.c b/src/mono/mono/metadata/native-library.c index ee4b47b7ddc2a5..0003bcfdae620e 100644 --- a/src/mono/mono/metadata/native-library.c +++ b/src/mono/mono/metadata/native-library.c @@ -50,7 +50,7 @@ static GHashTable *native_library_module_blocklist; #endif #if defined(ENABLE_NETCORE) && !defined(NO_GLOBALIZATION_SHIM) -extern const void* GlobalizationResolveDllImport(const char* name); +extern const void *GlobalizationResolveDllImport (const char *name); #endif #ifndef DISABLE_DLLMAP @@ -1262,9 +1262,9 @@ legacy_lookup_native_library (MonoImage *image, const char *scope) #if defined(ENABLE_NETCORE) && !defined(NO_GLOBALIZATION_SHIM) static gpointer -default_resolve_dllimport(const char* dll, const char* func) +default_resolve_dllimport (const char *dll, const char *func) { - if (strcmp(dll, "libSystem.Globalization.Native") == 0) { + if (strcmp (dll, "libSystem.Globalization.Native") == 0) { const void *method_impl = GlobalizationResolveDllImport (func); if (method_impl) return (gpointer)method_impl; @@ -1355,7 +1355,7 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou #endif #if defined(ENABLE_NETCORE) && !defined(NO_GLOBALIZATION_SHIM) - gpointer default_override = default_resolve_dllimport(new_scope, new_import); + gpointer default_override = default_resolve_dllimport (new_scope, new_import); if (default_override) return default_override; #endif From 6c55b68d34c216845abd87fc7c4b846dc03bc603 Mon Sep 17 00:00:00 2001 From: vsadov Date: Sun, 6 Dec 2020 16:04:16 -0800 Subject: [PATCH 32/32] do not set DFEATURE_DISTRO_AGNOSTIC_SSL on iOS, Android, tvOS --- eng/native/build-commons.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 7bf00e02c69b85..e77d219ce0caf1 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -454,7 +454,21 @@ if [[ "$__PortableBuild" == 0 ]]; then __CommonMSBuildArgs="$__CommonMSBuildArgs /p:PortableBuild=false" fi -__CMakeArgs="-DFEATURE_DISTRO_AGNOSTIC_SSL=$__PortableBuild $__CMakeArgs" +if [[ "$__BuildArch" == wasm ]]; then + # nothing to do here + true +elif [[ "$__TargetOS" == iOS ]]; then + # nothing to do here + true +elif [[ "$__TargetOS" == tvOS ]]; then + # nothing to do here + true +elif [[ "$__TargetOS" == Android ]]; then + # nothing to do here + true +else + __CMakeArgs="-DFEATURE_DISTRO_AGNOSTIC_SSL=$__PortableBuild $__CMakeArgs" +fi # Configure environment if we are doing a cross compile. if [[ "$__CrossBuild" == 1 ]]; then