Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to change System.Private.CoreLib.dll find path? #109633

Open
CeSun opened this issue Nov 8, 2024 · 9 comments
Open

How to change System.Private.CoreLib.dll find path? #109633

CeSun opened this issue Nov 8, 2024 · 9 comments
Labels
area-Host untriaged New issue has not been triaged by the area owner

Comments

@CeSun
Copy link

CeSun commented Nov 8, 2024

I am embedding coreclr using a custom host on a linux based mobile device.

When I initialized coreclr, coreclr prompted me that it could not find the path to System.Private.CoreLib.dll, and then it told me that the path to System.Private.CoreLib.dll was:
Path: /data/storage/el1/bundle/libs/arm64/System.Private.CoreLib.dll

The system I am using now has a sandbox mechanism. The system's software installer will only automatically copy native shared libraries to the "/data/storage/el1/bundle/libs/arm64/" directory. I do not have permission to automatically copy System.Private.CoreLib.dll there. Is there a way to modify the search directory for System.Private.CoreLib.dll?

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Nov 8, 2024
@CeSun
Copy link
Author

CeSun commented Nov 8, 2024

Image
Image
Image

@CeSun
Copy link
Author

CeSun commented Nov 8, 2024

When I enter the system through the shell and manually copy System.Private.CoreLib.dll to the /data/storage/el1/bundle/libs/arm64/ directory, coreclr can be initialized successfully

@huoyaoyuan
Copy link
Member

CoreLib is hardcoded to be next to coreclr because its tight relationship:

HRESULT AssemblyBinderCommon::BindToSystem(SString &systemDirectory,
Assembly **ppSystemAssembly)
{
HRESULT hr = S_OK;
_ASSERTE(ppSystemAssembly != NULL);
ReleaseHolder<Assembly> pSystemAssembly;
// System.Private.CoreLib.dll is expected to be found at one of the following locations:
// * Non-single-file app: In systemDirectory, beside coreclr.dll
// * Framework-dependent single-file app: In systemDirectory, beside coreclr.dll
// * Self-contained single-file app: Within the single-file bundle.
//
// CoreLib path (sCoreLib):
// * Absolute path when looking for a file on disk
// * Bundle-relative path when looking within the single-file bundle.

I'm afraid there's no viable workaround currently. Since you are writing custom host, single file bundling will not be an option.

@CeSun
Copy link
Author

CeSun commented Nov 8, 2024

CoreLib is hardcoded to be next to coreclr because its tight relationship:

runtime/src/coreclr/binder/assemblybindercommon.cpp

Lines 253 to 269 in b567474

HRESULT AssemblyBinderCommon::BindToSystem(SString &systemDirectory,
Assembly **ppSystemAssembly)
{
HRESULT hr = S_OK;

 _ASSERTE(ppSystemAssembly != NULL); 

 ReleaseHolder<Assembly> pSystemAssembly; 

 // System.Private.CoreLib.dll is expected to be found at one of the following locations: 
 //   * Non-single-file app: In systemDirectory, beside coreclr.dll 
 //   * Framework-dependent single-file app: In systemDirectory, beside coreclr.dll 
 //   * Self-contained single-file app: Within the single-file bundle. 
 // 
 //   CoreLib path (sCoreLib): 
 //   * Absolute path when looking for a file on disk 
 //   * Bundle-relative path when looking within the single-file bundle. 

I'm afraid there's no viable workaround currently. Since you are writing custom host, single file bundling will not be an option.

Bad news, I want to complain: not as good as mono.

@huoyaoyuan
Copy link
Member

For the we-know-which platform that applies special processing for native executables/libraries, nativeaot would fit better since the compiled file is just a native object.

I'm also curious about how it handles multiple CLR copies from different applications. The versions of libcoreclr.so and System.Private.CoreLib must match exactly.

@CeSun
Copy link
Author

CeSun commented Nov 8, 2024

For the we-know-which platform that applies special processing for native executables/libraries, nativeaot would fit better since the compiled file is just a native object.

I'm also curious about how it handles multiple CLR copies from different applications. The versions of libcoreclr.so and System.Private.CoreLib must match exactly.

Well, I'm trying to embed .net runtime for HarmonyOS. Nativeaot has been verified to be available, so I want to see the support of virtual machines. After all, virtual machines can do more things: easier reflection, dynamic il generation, etc.

Copy link
Contributor

Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.

@driver1998
Copy link

driver1998 commented Nov 16, 2024

I guess you can just add System.Private.CoreLib.dll inside the hap app package as well and let the system package manager handle it?

Update: oh if this is considered as data content it won't be copied to the same location...

@huoyaoyuan
Copy link
Member

Yeah, it's better to submit a request to change how package manager handles it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Host untriaged New issue has not been triaged by the area owner
Projects
Status: No status
Status: No status
Development

No branches or pull requests

4 participants