-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Android] Minimal (and quick) set of changes to make CoreCLR host on Android work #112705
base: main
Are you sure you want to change the base?
[Android] Minimal (and quick) set of changes to make CoreCLR host on Android work #112705
Conversation
Tagging subscribers to this area: @mangod9 |
/azp run runtime |
Azure Pipelines successfully started running 1 pipeline(s). |
@grendello I think a bunch of these changes make sense to me, for example, a bunch of the bundling logic. My pushback would be either we are doing something quick and dirty or we are chasing optimizations, not both. For example I would change the android side to conform, where possible, to existing APIs for now and put a bunch of the cost there. |
This change was incorrectly merged with main and a lot of unrelated commits from main are showing up as part of the delta. Could you please rebase against main and force push so that the delta is reviewable? |
I use |
Using UTF-8 strings on the Android side is easy and bears no costs for us, I can make the change without any effort. This is not the only issue with
👍 |
ff6a948
to
b285800
Compare
…em.native library for the singlefilehost
… R2R that acts like linux
… msbuild places instead.
Co-authored-by: Jan Kotas <[email protected]>
Co-authored-by: Jan Kotas <[email protected]>
src/coreclr/vm/bundle.cpp
Outdated
|
||
if (m_probe != nullptr) | ||
{ | ||
assemblyFound = m_probe(utf8Path, &loc.Offset, &fileSize, &compressedSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a slight change in the existing behavior. Currently the existing probe is defined as returning bool, but the code ignored it, now it doesn't. Given that we don't really expose this probe as an external API it's probably OK, but we should make it a concious decision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made / documented this to be an explicit check - the outs aren't used if the probe returns false.
@@ -51,6 +51,12 @@ struct host_runtime_contract | |||
const void* (HOST_CONTRACT_CALLTYPE* pinvoke_override)( | |||
const char* library_name, | |||
const char* entry_point_name); | |||
|
|||
// Probe the host for `path`. Sets pointer to data start and its size, if found. | |||
bool(HOST_CONTRACT_CALLTYPE* external_assembly_probe)( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grendello I moved this to the end of the struct to keep the existing order. I don't think this should require updating your changes in dotnet/android, since they use designators.
src/coreclr/vm/peimage.cpp
Outdated
#if defined(TARGET_ANDROID) | ||
m_hFile = GetData(nullptr); | ||
#else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#if defined(TARGET_ANDROID) | |
m_hFile = GetData(nullptr); | |
#else |
If the GetFileHandle
is still called after the other changes. fix the caller instead of this hack?
@@ -64,6 +65,13 @@ BundleFileLocation Bundle::Probe(const SString& path, bool pathIsBundleRelative) | |||
pathBuffer.SetAndConvertToUTF8(path.GetUnicode()); | |||
LPCSTR utf8Path(pathBuffer.GetUTF8()); | |||
|
|||
#if defined(TARGET_ANDROID) | |||
// On Android we always strip away the assembly path, if any |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grendello Thoughts on doing this stripping on the Android host side instead? For the runtime, I think it would make more sense to just pass the raw path to external_assembly_probe
.
src/coreclr/inc/clrconfigvalues.h
Outdated
@@ -383,6 +383,7 @@ RETAIL_CONFIG_DWORD_INFO(INTERNAL_LogToConsole, W("LogToConsole"), 0 , "Writes t | |||
CONFIG_DWORD_INFO(INTERNAL_LogToDebugger, W("LogToDebugger"), 0 , "Writes the CLR log to debugger (OutputDebugStringA).") | |||
CONFIG_DWORD_INFO(INTERNAL_LogToFile, W("LogToFile"), 0 , "Writes the CLR log to a file.") | |||
CONFIG_DWORD_INFO(INTERNAL_LogWithPid, W("LogWithPid"), FALSE, "Appends pid to filename for the CLR log.") | |||
CONFIG_DWORD_INFO(INTERNAL_LogToAndroid, W("LogToAndroid"), 0 , "Writes the CLR log to android logcat") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed. Given the conversations about Android, we are really printing to the "console". I'm removing this and Android scenarios should reuse LogToConsole
.
This is a draft set of minimal changes required to make dotnet/android#9572 (the
.NET for Android
CoreCLR host) work with standard .NET for Android applications.