Skip to content

netcore: Static linking of native libs#20589

Merged
akoeplinger merged 1 commit intomono:masterfrom
monojenkins:sync-pr-44505-from-runtime
Dec 7, 2020
Merged

netcore: Static linking of native libs#20589
akoeplinger merged 1 commit intomono:masterfrom
monojenkins:sync-pr-44505-from-runtime

Conversation

@monojenkins
Copy link
Contributor

@monojenkins monojenkins commented Nov 17, 2020

!! This PR is a copy of dotnet/runtime#44505, please do not edit or review it in this repo !!
Do not automatically approve this PR:

* Consider how the changes affect configurations in this repo,
* Check effects on files that are not mirrored,
* Identify test cases that may be needed in this repo.

!! Merge the PR only after the original PR is merged !!



@monojenkins monojenkins force-pushed the sync-pr-44505-from-runtime branch 17 times, most recently from c2c934e to 19d5f8f Compare November 25, 2020 02:13
@monojenkins monojenkins force-pushed the sync-pr-44505-from-runtime branch 13 times, most recently from fd2e8a9 to 2ddc1ff Compare December 3, 2020 00:21
@monojenkins monojenkins force-pushed the sync-pr-44505-from-runtime branch 21 times, most recently from d682118 to 9fca8fe Compare December 6, 2020 23:31
Statically linking `libSystem.Globalization.Native` and `libSystem.IO.Compression.Native`/`clrcompression` and use overrider mechanism to invoke.

- Added support for PInvoke overriding mechanism.  A static host or embedder can provide a callback to participate in PInvoke resolution,
- At the time of PInvoke resolution, if there is an override it gets a chance to provide an implementation before normal PInvoke resolution process.
- `libSystem.Globalization.Native` no longer relies on "QCall" mechanism.
Instead there is a default/built-in override, which runs right after the host-provided one. Host-provided override has preference since it runs first.
- The default overrider can be extended if we add more cases where PInvokes are backed by implementations statically linked into runtime (regardless of single-file or .dll/.so scenarios)
- The signature of the overrider callback is:
```c
const void* (PInvokeOverrideFn)(const char* libraryName, const char* entrypointName);
```
Returning `NULL` is interpreted as "no-match" case.
- The overrider is passed to `coreclr_initialize` as a property named `PINVOKE_OVERRIDE`. The value is a pointer encoded as a hex-based string value. This is similar to `BUNDLE_PROBE`.
- The implementation of an override is up to the overrider.
In this change the following scheme was used:
-- Host overrider dispatches on the name of the library (text match) and defers to one of the embedded libraries, if there is a match.
-- The library dispatches on the _native_ name of the Dll Import and provides a method pointer of there is a match.
@monojenkins monojenkins force-pushed the sync-pr-44505-from-runtime branch from 9fca8fe to aecab1f Compare December 7, 2020 00:11
@akoeplinger akoeplinger changed the title [WIP] Static linking of native libs netcore: Static linking of native libs Dec 7, 2020
@akoeplinger akoeplinger marked this pull request as ready for review December 7, 2020 12:24
@akoeplinger akoeplinger merged commit 4a9ea1f into mono:master Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants