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"
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
__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
+
# Configure environment if we are doing a cross compile.
if [[ "$__CrossBuild" == 1 ]]; then
CROSSCOMPILE=1
if (MSVC)
# Compile options for targeting windows
- add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/TP>) # compile all files as C++
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/nologo>) # Suppress Startup Banner
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/W3>) # set warning level to 3
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/WX>) # treat warnings as errors
if [[ "$#" -lt 4 ]]; then
echo "Usage..."
- echo "gen-buildsys.sh <path to top level CMakeLists.txt> <path to tryrun.cmake directory> <path to intermediate directory> <Architecture> <compiler> <compiler major version> <compiler minor version> [build flavor] [ninja] [scan-build] [cmakeargs]"
+ echo "gen-buildsys.sh <path to top level CMakeLists.txt> <path to intermediate directory> <Architecture> <compiler> <compiler major version> <compiler minor version> [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."
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"
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.
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"
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 \
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)
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()
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)
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)
# 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)
#-----------------------------------------
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" "$intermediatesForBuild" "$__CMakeArgs" "cross-architecture components"
CROSSCOMPILE=1
export CROSSCOMPILE
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" "$__IntermediatesDir" "$__CMakeArgs" "CoreCLR component"
# Build cross-architecture components
if [[ "$__SkipCrossArchNative" != 1 ]]; then
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")
#include "../../vm/gdbjithelpers.h"
#endif // FEATURE_GDBJIT
#include "bundle.h"
+#include "pinvokeoverride.h"
#define ASSERTE_ALL_BUILDS(expr) _ASSERTE_ALL_BUILDS(__FILE__, (expr))
int propertyCount,
LPCWSTR** propertyKeysWRef,
LPCWSTR** propertyValuesWRef,
- BundleProbe** bundleProbe,
+ BundleProbeFn** bundleProbe,
+ PInvokeOverrideFn** pinvokeOverride,
bool* hostPolicyEmbedded)
{
LPCWSTR* propertyKeysW = new (nothrow) LPCWSTR[propertyCount];
{
// 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)
+ {
+ // 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)
{
LPCWSTR* propertyKeysW;
LPCWSTR* propertyValuesW;
- BundleProbe* bundleProbe = nullptr;
+ BundleProbeFn* bundleProbe = nullptr;
bool hostPolicyEmbedded = false;
+ PInvokeOverrideFn* pinvokeOverride = nullptr;
ConvertConfigPropertiesToUnicode(
propertyKeys,
&propertyKeysW,
&propertyValuesW,
&bundleProbe,
+ &pinvokeOverride,
&hostPolicyEmbedded);
#ifdef TARGET_UNIX
g_hostpolicy_embedded = hostPolicyEmbedded;
+ if (pinvokeOverride != nullptr)
+ {
+ PInvokeOverride::SetPInvokeOverride(pinvokeOverride);
+ }
+
ReleaseHolder<ICLRRuntimeHost4> host;
hr = CorHost2::CreateObject(IID_ICLRRuntimeHost4, (void**)&host);
#define CORECLR_CALLING_CONVENTION
#endif
+#include <stdint.h>
+
// 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)
#undef CORECLR_HOSTING_API
+//
+// Callback types used by the hosts
+//
+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__
/*****************************************************************************
** **
- ** bundle.h - Information about applications bundled as a single-file **
+ ** bundle.h - Information about applications bundled as a single-file **
** **
*****************************************************************************/
#define _BUNDLE_H_
#include <sstring.h>
+#include "coreclrhost.h"
class Bundle;
bool IsValid() const { LIMITED_METHOD_CONTRACT; return Offset != 0; }
};
-typedef bool(__stdcall 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; }
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;
};
#endif // _BUNDLE_H_
-// EOF =======================================================================
#endif // __cplusplus
#endif // _COR_H_
-// EOF =======================================================================
typedef GUID CORCOMPILE_NGEN_SIGNATURE;
#endif // _CORPRIV_H_
-// EOF =======================================================================
--- /dev/null
+// 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_
+
+#include "coreclrhost.h"
+
+class PInvokeOverride
+{
+public:
+ static void SetPInvokeOverride(PInvokeOverrideFn* overrideImpl);
+ static const void* GetMethodImpl(const char* libraryName, const char* entrypointName);
+};
+
+#endif // _PINVOKEOVERRIDE_H_
+++ /dev/null
-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")
-
-add_subdirectory(${GLOBALIZATION_NATIVE_DIR} System.Globalization.Native)
-
perfmap.cpp
perfinfo.cpp
pgo.cpp
+ pinvokeoverride.cpp
precode.cpp
prestub.cpp
profilerdiagnosticprotocolhelper.cpp
return Bundle::AppBundle->Path();
}
-Bundle::Bundle(LPCSTR bundlePath, BundleProbe *probe)
+Bundle::Bundle(LPCSTR bundlePath, BundleProbeFn *probe)
{
STANDARD_VM_CONTRACT;
// ECalls
//
-// ECalls defined by libraries-native shims
-EXTERN_C const LPVOID gPalGlobalizationNative[];
-
// When compiling crossgen, we only need the target version of the ecall tables
#if !defined(CROSSGEN_COMPILE) || defined(CROSSGEN_CORELIB)
#include "strongnameholders.h"
#include "ecall.h"
#include "fieldmarshaler.h"
+#include "pinvokeoverride.h"
#include <formattype.h>
#include "../md/compiler/custattr.h"
if (callConv == pmCallConvThiscall)
ndirectflags |= NDirectMethodDesc::kThisCall;
- if (pNMD->GetLoaderModule()->IsSystem() && strcmp(szLibName, "QCall") == 0)
+ if (pNMD->GetLoaderModule()->IsSystem() && (strcmp(szLibName, "QCall") == 0))
{
ndirectflags |= NDirectMethodDesc::kIsQCall;
}
// 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")
};
// Loading unmanaged dlls can trigger dllmains which certainly count as code execution!
pMD->EnsureActive();
+ {
+ LPVOID pvTarget = (LPVOID)PInvokeOverride::GetMethodImpl(pMD->GetLibNameRaw(), pMD->GetEntrypointName());
+ if (pvTarget != NULL)
+ {
+ pMD->SetNDirectTarget(pvTarget);
+ return;
+ }
+ }
+
LoadLibErrorTracker errorTracker;
BOOL fSuccess = FALSE;
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)
--- /dev/null
+// 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 "common.h"
+#include "pinvokeoverride.h"
+
+extern "C" const void* GlobalizationResolveDllImport(const char* name);
+
+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::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);
+}
check_prereqs
# Build the installer native components.
-build_native "$__TargetOS" "$__BuildArch" "$__scriptpath" "$__scriptpath" "$__IntermediatesDir" "$__CMakeArgs" "installer component"
+build_native "$__TargetOS" "$__BuildArch" "$__scriptpath" "$__IntermediatesDir" "$__CMakeArgs" "installer component"
add_definitions(-D_NO_PPLXIMP)
add_definitions(-DEXPORT_SHARED_API=1)
add_definitions(-DHOSTPOLICY_EMBEDDED)
+add_definitions(-DNATIVE_LIBS_EMBEDDED)
include(../../fxr/files.cmake)
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")
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
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
${CORECLR_STATIC_LIB_LOCATION}/libnativeresourcestring.a
)
+
+ # 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)
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.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
)
- 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.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
- 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.Net.Security.Native/extra_libs.cmake)
+ append_extra_security_libs(NATIVE_LIBS_EXTRA)
# 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)
+ 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)
- # 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)
${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()
_X("APP_NI_PATHS"),
_X("RUNTIME_IDENTIFIER"),
_X("BUNDLE_PROBE"),
- _X("HOSTPOLICY_EMBEDDED")
+ _X("HOSTPOLICY_EMBEDDED"),
+ _X("PINVOKE_OVERRIDE")
};
static_assert((sizeof(PropertyNameMapping) / sizeof(*PropertyNameMapping)) == static_cast<size_t>(common_property::Last), "Invalid property count");
RuntimeIdentifier,
BundleProbe,
HostPolicyEmbedded,
+ PInvokeOverride,
// Sentinel value - new values should be defined above
Last
};
return bundle::runner_t::app()->probe(file_path, offset, size);
}
+
+#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 (strcmp(libraryName, COMPRESSION_DLL_NAME) == 0)
+ {
+ return CompressionResolveDllImport(entrypointName);
+ }
+
+ return nullptr;
+ }
+#endif
}
int hostpolicy_context_t::initialize(hostpolicy_init_t &hostpolicy_init, const arguments_t &args, bool enable_breadcrumbs)
}
}
+#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")))
{
+++ /dev/null
-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()
<!-- LINUX -->
<!-- OSX -->
- <SingleFileHostIncludeFilename Include="libSystem.IO.Compression.Native.dylib" />
<SingleFileHostIncludeFilename Include="libSystem.Native.dylib" />
<SingleFileHostIncludeFilename Include="libSystem.Net.Security.Native.dylib" />
<SingleFileHostIncludeFilename Include="libSystem.Security.Cryptography.Native.Apple.dylib" />
<SingleFileHostIncludeFilename Include="libSystem.Security.Cryptography.Native.OpenSsl.dylib" />
<!-- Windows -->
- <SingleFileHostIncludeFilename Include="clrcompression.dll" />
<SingleFileHostIncludeFilename Include="mscordaccore.dll" />
</ItemGroup>
{
internal static partial class Libraries
{
- internal const string GlobalizationNative = "QCall";
+ internal const string GlobalizationNative = "libSystem.Globalization.Native";
}
}
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";
}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+#include "../../AnyOS/entrypoints.h"
+
+// 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"
+
+#include "../../AnyOS/entrypoints.h"
+
+static const Entry s_compressionNative[] =
+{
+ 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);
+
+EXTERN_C const void* CompressionResolveDllImport(const char* name)
+{
+ return ResolveDllImport(s_compressionNative, lengthof(s_compressionNative), name);
+}
--- /dev/null
+// 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 <stdint.h>
+#include <string.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 DllImportEntry(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;
+}
add_compile_options(-Werror)
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()
+ 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)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
-#include <stdint.h>
+#include "../../AnyOS/entrypoints.h"
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 */ };
+static const Entry s_globalizationNative[] =
+{
+ 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)
+};
-#define QCFuncElement(name,impl) \
- (void*)0x8 /* FCFuncFlag_QCall */, (void*)(impl), (void*)name,
+EXTERN_C const void* GlobalizationResolveDllImport(const char* 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()
+EXTERN_C const void* GlobalizationResolveDllImport(const char* name)
+{
+ return ResolveDllImport(s_globalizationNative, lengthof(s_globalizationNative), name);
+}
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()
+
+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
../../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
)
target_link_libraries(System.IO.Compression.Native
- ${ZLIB_LIBRARIES}
+ ${NATIVE_LIBS_EXTRA}
)
install_with_stripped_symbols (System.IO.Compression.Native PROGRAMS .)
endif ()
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})
--- /dev/null
+
+macro(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 ()
+ list(APPEND ${NativeLibsExtra} ${ZLIB_LIBRARIES})
+endmacro()
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
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})
endif ()
endif ()
+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
${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 ()
${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 .)
+install (TARGETS System.Native-Static DESTINATION ${STATIC_LIB_DESTINATION})
--- /dev/null
+
+macro(append_extra_system_libs NativeLibsExtra)
+ if (CLR_CMAKE_TARGET_LINUX AND NOT CLR_CMAKE_TARGET_ANDROID)
+ list(APPEND ${NativeLibsExtra} rt)
+ elseif (CLR_CMAKE_TARGET_FREEBSD)
+ list(APPEND ${NativeLibsExtra} pthread)
+ if (HAVE_INOTIFY)
+ find_library(INOTIFY_LIBRARY inotify HINTS /usr/local/lib)
+ list(APPEND ${NativeLibsExtra} ${INOTIFY_LIBRARY})
+ endif ()
+ elseif (CLR_CMAKE_TARGET_SUNOS)
+ list(APPEND ${NativeLibsExtra} socket)
+ endif ()
+
+ if (CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS)
+ list(APPEND ${NativeLibsExtra} "-framework Foundation")
+ endif ()
+endmacro()
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()
+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
)
-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
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
+ ${NATIVE_LIBS_EXTRA}
+ )
+
+ 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})
--- /dev/null
+
+macro(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 ${NativeLibsExtra} ${LIBGSS})
+endmacro()
// 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
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
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})
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()
+include(${CMAKE_CURRENT_LIST_DIR}/extra_libs.cmake)
-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)
+append_extra_cryptography_libs(NATIVE_LIBS_EXTRA)
include_directories(${OPENSSL_INCLUDE_DIR})
add_library(objlib OBJECT ${NATIVECRYPTO_SOURCES} ${VERSION_FILE_PATH})
-add_library(System.Security.Cryptography.Native.OpenSsl
- SHARED
- $<TARGET_OBJECTS:objlib>
-)
+if (GEN_SHARED_LIB)
+ add_library(System.Security.Cryptography.Native.OpenSsl
+ SHARED
+ $<TARGET_OBJECTS:objlib>
+ )
+endif()
add_library(System.Security.Cryptography.Native.OpenSsl-Static
STATIC
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
- $<TARGET_FILE:System.Security.Cryptography.Native.OpenSsl>
- "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
+ $<TARGET_FILE:System.Security.Cryptography.Native.OpenSsl>
+ "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()
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}
+ ${NATIVE_LIBS_EXTRA}
)
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})
--- /dev/null
+
+macro(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()
+ 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 ${NativeLibsExtra} dl)
+ else()
+ list(APPEND ${NativeLibsExtra} ${OPENSSL_CRYPTO_LIBRARY} ${OPENSSL_SSL_LIBRARY})
+ endif()
+endmacro()
+++ /dev/null
-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()
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)
+ # Suppress exporting of the PAL APIs
+ add_definitions(-DPALEXPORT=EXTERN_C)
+
+ 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
# as other asserts should still be included.
add_compile_definitions($<$<CONFIG:RELEASE>: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)
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
../../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
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 $<TARGET_PDB_FILE:clrcompression> DESTINATION .)
+endif()
-install (TARGETS clrcompression DESTINATION .)
-install (TARGETS clrcompression-static DESTINATION .)
-install (FILES $<TARGET_PDB_FILE:clrcompression> DESTINATION .)
+install (TARGETS clrcompression-static DESTINATION ${STATIC_LIB_DESTINATION})
check_prereqs
# Build the corefx native components.
-build_native "$__TargetOS" "$__BuildArch" "$__nativeroot" "$__nativeroot" "$__IntermediatesDir" "$__CMakeArgs" "native libraries component"
+build_native "$__TargetOS" "$__BuildArch" "$__nativeroot" "$__IntermediatesDir" "$__CMakeArgs" "native libraries component"
#include "mono/utils/mono-path.h"
#include "mono/metadata/native-library.h"
-extern const void* gPalGlobalizationNative[];
-
enum {
func_flag_end_of_array = 0x01,
func_flag_has_signature = 0x02,
func_flag_qcall = 0x08, // QCall - mscorlib.dll to mscorwks.dll transition implemented as PInvoke
};
-#if defined(NO_GLOBALIZATION_SHIM) || !defined(ENABLE_NETCORE)
-const void* gPalGlobalizationNative[] = { (void*)func_flag_end_of_array };
-#endif
-
static const MonoQCallDef c_qcalls[] =
{
#ifndef DISABLE_QCALLS
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
#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)
{
}
#endif
+#if defined(ENABLE_NETCORE) && !defined(NO_GLOBALIZATION_SHIM)
+ gpointer default_override = default_resolve_dllimport (new_scope, new_import);
+ if (default_override)
+ return default_override;
+#endif
+
#ifdef ENABLE_NETCORE
#ifndef HOST_WIN32
retry_with_libcoreclr:
* have to end with a func_flag_end_of_array (0x01) entry.
**/
-FCClassElement("Globalization", "", gPalGlobalizationNative)
+FCClassElement("", "", NULL)
<ItemGroup>
<WasmPInvokeModule Include="libSystem.Native" />
<WasmPInvokeModule Include="libSystem.IO.Compression.Native" />
- <WasmPInvokeModule Include="QCall" />
+ <WasmPInvokeModule Include="libSystem.Globalization.Native" />
<WasmPInvokeAssembly Include="@(LibrariesRuntimeFiles)" Condition="'%(Extension)' == '.dll' and '%(IsNative)' != 'true'" />
</ItemGroup>
fi
if [[ "$__SkipNative" != 1 && "$__TargetOS" != "Browser" && "$__TargetOS" != "Android" ]]; then
- build_native "$__TargetOS" "$__BuildArch" "$__TestDir" "$__TryRunDir" "$__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)"
__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"