Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/coding-guidelines/interop-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal static partial class Interop
### File organization

- The Interop partial class definitions should live in Interop.*.cs files. These Interop.*.cs files should all live under Common rather than within a given assembly's folder.
- The only exception to this should be when an assembly P/Invokes to its own native library that isn't available to or consumed by anyone else, e.g. System.IO.Compression P/Invoking to clrcompression.dll. In such cases, System.IO.Compression should have its own Interop folder which follows a similar scheme as outlined in this proposal, but just for these private P/Invokes.
- The only exception to this should be when an assembly P/Invokes to its own native library that isn't available to or consumed by anyone else, e.g. System.IO.Compression P/Invoking to System.IO.Compression.Native.dll. In such cases, System.IO.Compression should have its own Interop folder which follows a similar scheme as outlined in this proposal, but just for these private P/Invokes.
- Under Common\src\Interop, we'll have a folder for each target platform, and within each platform, for each library from which functionality is being consumed. The Interop.*.cs files will live within those library folders, e.g.

```
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/scripts/superpmi-setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
parser.add_argument("-max_size", help="Max size of each partition in MB")
is_windows = platform.system() == "Windows"
native_binaries_to_ignore = [
"clrcompression.dll",
"System.IO.Compression.Native.dll",
"clretwrc.dll",
"clrgc.dll",
"clrjit.dll",
Expand Down
8 changes: 7 additions & 1 deletion src/coreclr/vm/pinvokeoverride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ extern "C" const void* GlobalizationResolveDllImport(const char* name);

static PInvokeOverrideFn* s_overrideImpl = nullptr;

#if defined(_WIN32)
#define GLOBALIZATION_DLL_NAME "System.Globalization.Native"
#else
#define GLOBALIZATION_DLL_NAME "libSystem.Globalization.Native"
#endif

// 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)
if (strcmp(libraryName, GLOBALIZATION_DLL_NAME) == 0)
{
return GlobalizationResolveDllImport(entrypointName);
}
Expand Down
2 changes: 1 addition & 1 deletion src/installer/corehost/cli/apphost/static/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,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
${CORECLR_STATIC_LIB_LOCATION}/System.IO.Compression.Native.lib
kernel32.lib
advapi32.lib
ole32.lib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace
extern "C" const void* CompressionResolveDllImport(const char* name);

#if defined(_WIN32)
#define COMPRESSION_DLL_NAME "clrcompression"
#define COMPRESSION_DLL_NAME "System.IO.Compression.Native"
#else
#define COMPRESSION_DLL_NAME "libSystem.IO.Compression.Native"
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
<PlatformManifestFileEntry Include="API-MS-Win-core-xstate-l2-1-0.dll" IsNative="true" FallbackFileVersion="$(WindowsForwarderFileVersion)" />
<PlatformManifestFileEntry Include="ucrtbase.dll" IsNative="true" />
<PlatformManifestFileEntry Include="clrcompression.dll" IsNative="true" />
<PlatformManifestFileEntry Include="System.IO.Compression.Native.dll" IsNative="true" />
<PlatformManifestFileEntry Include="createdump.exe" IsNative="true" />
<PlatformManifestFileEntry Include="createdump" IsNative="true" />
<PlatformManifestFileEntry Include="libcoreclrtraceptprovider.so" IsNative="true" />
Expand Down
10 changes: 0 additions & 10 deletions src/libraries/Common/src/Interop/Interop.Libraries.cs

This file was deleted.

1 change: 1 addition & 0 deletions src/libraries/Common/src/Interop/Unix/Interop.Libraries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ internal static partial class Libraries
internal const string NetSecurityNative = "libSystem.Net.Security.Native";
internal const string CryptoNative = "libSystem.Security.Cryptography.Native.OpenSsl";
internal const string CompressionNative = "libSystem.IO.Compression.Native";
internal const string GlobalizationNative = "libSystem.Globalization.Native";
internal const string IOPortsNative = "libSystem.IO.Ports.Native";
internal const string Libdl = "libdl";
internal const string HostPolicy = "libhostpolicy";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ 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";
internal const string CompressionNative = "System.IO.Compression.Native";
internal const string GlobalizationNative = "System.Globalization.Native";
internal const string MsQuic = "msquic.dll";
internal const string HostPolicy = "hostpolicy.dll";
}
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/Native/AnyOS/zlib/pal_zlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#ifdef _WIN32
#define c_static_assert(e) static_assert((e),"")
#include "../../Windows/clrcompression/zlib/zlib.h"
#include "../../Windows/System.IO.Compression.Native/zlib/zlib.h"
#else
#include "pal_utilities.h"
#include <zlib.h>
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/Native/Windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ if(STATIC_LIBS_ONLY)
add_subdirectory(../Unix/System.Globalization.Native System.Globalization.Native)
endif()

add_subdirectory(clrcompression)
add_subdirectory(System.IO.Compression.Native)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project(clrcompression)
project(System.IO.Compression.Native)

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.")
Expand Down Expand Up @@ -81,46 +81,46 @@ set (NATIVECOMPRESSION_SOURCES
include_directories("../../AnyOS/brotli/include")

if (GEN_SHARED_LIB)
add_library(clrcompression
add_library(System.IO.Compression.Native
SHARED
${NATIVECOMPRESSION_SOURCES}
clrcompression.def
System.IO.Compression.Native.def
# This will add versioning to the library
${CMAKE_REPO_ROOT}/artifacts/obj/NativeVersion.rc
)
endif()

add_library(clrcompression-static
add_library(System.IO.Compression.Native-static
STATIC
${NATIVECOMPRESSION_SOURCES}
)

SET_TARGET_PROPERTIES(clrcompression-static PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(clrcompression-static PROPERTIES OUTPUT_NAME libclrcompression)
SET_TARGET_PROPERTIES(System.IO.Compression.Native-static PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(System.IO.Compression.Native-static PROPERTIES OUTPUT_NAME System.IO.Compression.Native)

# Allow specification of arguments that should be passed to the linker
if (GEN_SHARED_LIB)
SET_TARGET_PROPERTIES(clrcompression PROPERTIES LINK_OPTIONS "${__LinkArgs};${__SharedLinkArgs}")
SET_TARGET_PROPERTIES(System.IO.Compression.Native PROPERTIES LINK_OPTIONS "${__LinkArgs};${__SharedLinkArgs}")
endif()
SET_TARGET_PROPERTIES(clrcompression-static PROPERTIES STATIC_LIBRARY_OPTIONS "${__LinkArgs}")
SET_TARGET_PROPERTIES(System.IO.Compression.Native-static PROPERTIES STATIC_LIBRARY_OPTIONS "${__LinkArgs}")

# Allow specification of libraries that should be linked against
if (GEN_SHARED_LIB)
target_link_libraries(clrcompression ${__LinkLibraries})
target_link_libraries(System.IO.Compression.Native ${__LinkLibraries})
endif()
target_link_libraries(clrcompression-static ${__LinkLibraries})
target_link_libraries(System.IO.Compression.Native-static ${__LinkLibraries})

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
GENERATE_EXPORT_HEADER( System.IO.Compression.Native
BASE_NAME System.IO.Compression.Native
EXPORT_MACRO_NAME System.IO.Compression.Native_EXPORT
EXPORT_FILE_NAME System.IO.Compression.Native_Export.h
STATIC_DEFINE System.IO.Compression.Native_BUILT_AS_STATIC
)

install (TARGETS clrcompression DESTINATION .)
install (FILES $<TARGET_PDB_FILE:clrcompression> DESTINATION .)
install (TARGETS System.IO.Compression.Native DESTINATION .)
install (FILES $<TARGET_PDB_FILE:System.IO.Compression.Native> DESTINATION .)
endif()

install (TARGETS clrcompression-static DESTINATION ${STATIC_LIB_DESTINATION})
install (TARGETS System.IO.Compression.Native-static DESTINATION ${STATIC_LIB_DESTINATION})

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LIBRARY clrcompression.dll
LIBRARY System.IO.Compression.Native.dll

EXPORTS
CompressionNative_Crc32
Expand Down Expand Up @@ -31,4 +31,4 @@ EXPORTS
BrotliDecoderTakeOutput
BrotliDecoderVersion
BrotliGetDictionary
BrotliSetDictionaryData
BrotliSetDictionaryData
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace System.IO.Compression
{
/// <summary>
/// This class provides declaration for constants and PInvokes as well as some basic tools for exposing the
/// native CLRCompression.dll (effectively, ZLib) library to managed code.
/// native System.IO.Compression.Native.dll (effectively, ZLib) library to managed code.
///
/// See also: How to choose a compression level (in comments to <code>CompressionLevel</code>.
/// </summary>
Expand Down Expand Up @@ -159,12 +159,12 @@ public enum CompressionMethod : int
* This was done on purpose to:
*
* - Achieve the right encapsulation in a situation where <code>ZLibNative</code> may be compiled division-wide
* into different assemblies that wish to consume <code>CLRCompression</code>. Since <code>internal</code>
* into different assemblies that wish to consume <code>System.IO.Compression.Native</code>. Since <code>internal</code>
* scope is effectively like <code>public</code> scope when compiling <code>ZLibNative</code> into a higher
* level assembly, we need a combination of inner types and <code>private</code>-scope members to achieve
* the right encapsulation.
*
* - Achieve late dynamic loading of <code>CLRCompression.dll</code> at the right time.
* - Achieve late dynamic loading of <code>System.IO.Compression.Native.dll</code> at the right time.
* The native assembly will not be loaded unless it is actually used since the loading is performed by a static
* constructor of an inner type that is not directly referenced by user code.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1047,9 +1047,6 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Void.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\WeakReference.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\WeakReference.T.cs" />
<Compile Include="$(CommonPath)Interop\Interop.Libraries.cs">
<Link>Common\Interop\Interop.Libraries.cs</Link>
</Compile>
<Compile Include="$(CommonPath)Interop\Interop.Calendar.cs">
<Link>Common\Interop\Interop.Calendar.cs</Link>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<Compile Include="$(CommonPath)Microsoft\Win32\SafeHandles\SafeTokenHandle.cs"
Link="Microsoft\Win32\SafeHandles\SafeTokenHandle.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Interop.Libraries.cs"
Link="Common\Interop\Interop.Libraries.cs" />
Link="Common\Interop\Windows\Interop.Libraries.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Advapi32\Interop.LUID.cs"
Link="Common\Interop\Interop.LUID.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Advapi32\Interop.LUID_AND_ATTRIBUTES.cs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<Compile Include="System\Security\Principal\WindowsIdentity.cs" />
<Compile Include="System\Security\Principal\WindowsPrincipal.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Interop.Libraries.cs"
Link="Common\Interop\Interop.Libraries.cs" />
Link="Common\Interop\Windows\Interop.Libraries.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Interop.UNICODE_STRING.cs"
Link="Common\Interop\Windows\Advapi32\Interop.UNICODE_STRING.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Interop.OBJECT_ATTRIBUTES.cs"
Expand Down
5 changes: 0 additions & 5 deletions src/libraries/pkg/descriptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1023,11 +1023,6 @@
"System.IO.Compression.ZipArchiveMode"
]
},
{
"Name": "System.IO.Compression.clrcompression",
"Description": "Internal implementation package not meant for direct consumption. Please do not reference directly. Provides native implementation dll used for GZIP compression.",
"CommonTypes": []
},
{
"Name": "System.IO.Compression.ZipFile",
"Description": "Provides classes that support the compression and decompression of streams using file system paths.",
Expand Down
4 changes: 3 additions & 1 deletion src/libraries/shims/manual/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
<ReferencePath Include="$(NetCoreAppCurrentRuntimePath)System.*.dll;
$(NetCoreAppCurrentRuntimePath)Microsoft.Win32.*.dll;
$(NetCoreAppCurrentRuntimePath)netstandard.dll"
Exclude="$(NetCoreAppCurrentRuntimePath)$(MSBuildProjectName).dll" />
Exclude="$(NetCoreAppCurrentRuntimePath)$(MSBuildProjectName).dll;
$(NetCoreAppCurrentRuntimePath)System.*.Native.dll"
/>
<ProjectReference Include="$(CoreLibProject)" />
</ItemGroup>
</Project>
9 changes: 8 additions & 1 deletion src/mono/mono/metadata/native-library.c
Original file line number Diff line number Diff line change
Expand Up @@ -1261,10 +1261,17 @@ legacy_lookup_native_library (MonoImage *image, const char *scope)
#endif // ENABLE_NETCORE

#if defined(ENABLE_NETCORE) && !defined(NO_GLOBALIZATION_SHIM)

#ifdef HOST_WIN32
#define GLOBALIZATION_DLL_NAME "System.Globalization.Native"
#else
#define GLOBALIZATION_DLL_NAME "libSystem.Globalization.Native"
#endif

static gpointer
default_resolve_dllimport (const char *dll, const char *func)
{
if (strcmp (dll, "libSystem.Globalization.Native") == 0) {
if (strcmp (dll, GLOBALIZATION_DLL_NAME) == 0) {
const void *method_impl = GlobalizationResolveDllImport (func);
if (method_impl)
return (gpointer)method_impl;
Expand Down