-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Single-File: Run from Bundle #36052
Single-File: Run from Bundle #36052
Conversation
Tagging subscribers to this area: @swaroop-sridhar |
CC: @jkotas |
// If found, the assembly is loaded from the bundle. | ||
if (Bundle::AppIsBundle()) | ||
{ | ||
SString candidates[] = { W(".dll"), W(".ni.dll") }; |
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.
Do we still use the .ni.dll
suffix for anything?
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 we do decide to keep it it should use the same order as in BindAssemblyByProbingPaths
which is that .ni.dll
is preferred over .dll
. (or rather BindAssemblyByProbingPaths
is first called with useNativeImages=true
).
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.
@davidwrighton mentioned here that .ni.dll is used for managed C++ R2R. Has this changed?
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.
Well, I think its still probably the way we should make it work. I'm not sure if it works in practice today though. I know it doesn't work in crossgen2.
StackSString sCoreLib; | ||
StackSString sCoreLib(sCoreLibDir); | ||
StackSString coreLibName(CoreLibName_IL_W); | ||
sCoreLib.Append(coreLibName); |
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.
Is this fake path going to be actually used for anything in the bundle case? Would it be better to not build it and pass it in at all when we find the payload in the bundle?
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.
Aside from the tracing just minor stuff.
sCoreLib.Append(CoreLibName_IL_W); | ||
// 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 system directory, beside coreclr.dll |
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.
// * Framework-dependent single-file app: In system directory, beside coreclr.dll | |
// * Framework-dependent single-file app: In systemDirectory, beside coreclr.dll |
// If found, the assembly is loaded from the bundle. | ||
if (Bundle::AppIsBundle()) | ||
{ | ||
SString candidates[] = { W(".dll"), W(".ni.dll") }; |
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 we do decide to keep it it should use the same order as in BindAssemblyByProbingPaths
which is that .ni.dll
is preferred over .dll
. (or rather BindAssemblyByProbingPaths
is first called with useNativeImages=true
).
&pTPAAssembly, | ||
NULL, // szMDAssemblyPath | ||
Bundle::ProbeAppBundle(assemblyFileName, /* pathIsBundleRelative */ true)); | ||
|
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.
We should trace the attempt, just like below whenever we probe we also trace the attempt.
// Any other error is fatal | ||
IF_FAIL_GO(hr); | ||
|
||
if (TestCandidateRefMatchesDef(pRequestedAssemblyName, pTPAAssembly->GetAssemblyName(), true /*tpaListAssembly*/)) |
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.
And similarly here, if this fails we should trace that - look below for an example.
src/coreclr/src/vm/appdomain.cpp
Outdated
@@ -1775,27 +1775,27 @@ void SystemDomain::Init() | |||
m_pSystemAssembly = NULL; | |||
|
|||
DWORD size = 0; | |||
|
|||
AppDomain* pAppDomain = ::GetAppDomain(); |
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.
Is this necessary? I don't see it used anywhere.
src/coreclr/src/vm/appdomain.hpp
Outdated
@@ -29,6 +29,7 @@ | |||
#include "gchandleutilities.h" | |||
#include "../binder/inc/applicationcontext.hpp" | |||
#include "rejit.h" | |||
#include "bundle.h" |
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.
Given that there are no changes in appdomain.cpp
do we need the include here?
@@ -281,10 +281,13 @@ void deps_resolver_t::setup_additional_probes(const std::vector<pal::string_t>& | |||
* -- When servicing directories are looked up, look up only if the deps file marks the entry as serviceable. | |||
* -- When a deps json based probe is performed, the deps entry's package name and version must match. | |||
* -- When looking into a published dir, for rid specific assets lookup rid split folders; for non-rid assets lookup the layout dir. | |||
* The path to the resolved file is returned in candidate out parameter | |||
* If the candidate is embedded within the single-file bundle (rather than an actual file on disk), found_in_bundle will be set to true. |
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 the candidate is embedded within the single-file bundle (rather than an actual file on disk), found_in_bundle will be set to true. | |
* If the candidate is embedded within the single-file bundle (rather than an actual file on disk), loaded_from_bundle will be set to true. |
src/coreclr/src/vm/peimage.cpp
Outdated
{ | ||
bIsFlatLayoutSuitable = FALSE; | ||
} | ||
bIsFlatLayoutSuitable = IsInBundle() || !bIsMappedLayoutSuitable; |
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 doesn't look right. We are completely discarding the previously computed value of the bIsFlatLayoutSuitable
.
Implemented few of the suggested changes, remaining to come shortly. |
This change implements: * Runtime changes necessary to load assemblies directly from the bundle: * Design notes about [Load from Bundle](https://github.com/dotnet/designs/blob/master/accepted/2020/single-file/design.md#peimage-loader) * Most of these changes are directly from dotnet/coreclr#26504 and dotnet/coreclr#26904 * Hostpolicy change to not add bundled assemblies to TPA list: * Design notes about [Dependency Resolution](https://github.com/dotnet/designs/blob/master/accepted/2020/single-file/design.md#dependency-resolution) * TBD (separately) items: Fix for hammer servicing dotnet#36031 Fixes dotnet#32822
1b46420
to
7cc1384
Compare
@jkotas, @vitek-karas @janvorli Thanks for the comments. I've fixed these issues now. |
31bb483
to
368b189
Compare
* Fix Assembly.ni.dll and Assembly.dll path usage. * Remove unused full-path computation for corelib when loading from bundle. * Add tracing when loading from bundle. * Add bundle-probing for satellite assemblies. * Adapt the BundleRename test to the .net5 scenario where assemblies are loaded from bundle.
This change implements:
Runtime changes necessary to load assemblies directly from the bundle:
Hostpolicy change to not add bundled assemblies to TPA list:
Fixes #32822