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

The same assembly is loaded multiple times if it passed as multiple --custom-step arguments #1314

Closed
rolfbjarne opened this issue Jul 6, 2020 · 1 comment · Fixed by #2019

Comments

@rolfbjarne
Copy link
Member

The same assembly is loaded once for each --custom-step argument.

My guess is because it's loaded using the Assembly.Load(byte[]) overload: https://github.com/mono/linker/blob/da2cc0fcd6c3a8e8e5d1b5d4a655f3653baa8980/src/linker/Linker/Driver.cs#L723

This is quite confusing if you have static state in one step you expect to be around in subsequent steps (it also means that if I want to share state between steps, I have to resort to ugly workarounds.

rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this issue Jul 23, 2020
The linker will load the assemblies with the custom steps once per custom step
argument, which means that each step is effectively in a different assembly,
making it impossible to share state between steps.

This behavior is filed as a linker bug: dotnet/linker#1314

Until this is fixed, we can just have a single step that injects all the other
steps programmatically.
rolfbjarne added a commit to xamarin/xamarin-macios that referenced this issue Jul 24, 2020
* [dotnet] Only pass a single custom step to the linker.

The linker will load the assemblies with the custom steps once per custom step
argument, which means that each step is effectively in a different assembly,
making it impossible to share state between steps.

This behavior is filed as a linker bug: dotnet/linker#1314

Until this is fixed, we can just have a single step that injects all the other
steps programmatically.

* [tests] Adjust .NET tests according to new behavior.
@rolfbjarne
Copy link
Member Author

rolfbjarne commented Aug 20, 2020

Another effect of loading the custom step assembly as a byte array is that no debug information will be loaded, so stack traces won't include source code information (not even if the embedding the debug information in the dll), and neither is it possible to debug using VSCode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants