Skip to content

Delete --whole-archive linking in libmscordaccore.so #115418

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

Merged
merged 1 commit into from
May 9, 2025

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented May 9, 2025

Fixes #115316

@jkotas jkotas requested review from Copilot and hoyosjs and removed request for Copilot May 9, 2025 05:43
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR removes the use of the --whole-archive linker flags in the libmscordaccore.so build, addressing issue #115316. It also refactors the DllMain entry points by making mscordac.cpp call an externally defined DllMain2 and removes a duplicated DllMain declaration from a header.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/coreclr/dlls/mscordac/mscordac.cpp Added a DllMain forwarding function that calls DllMain2 to streamline export management.
src/coreclr/dlls/mscordac/CMakeLists.txt Removed whole-archive linker flags to prevent forcing inclusion of all objects, as discussed in #115316.
src/coreclr/debug/daccess/fntableaccess.h Removed the redundant DllMain declaration to avoid conflicts and unnecessary duplication.
src/coreclr/debug/daccess/daccess.cpp Replaced the DllMain definition with a DllMain2 definition, consolidating initialization logic.
Comments suppressed due to low confidence (4)

src/coreclr/dlls/mscordac/CMakeLists.txt:148

  • The removal of the '--whole-archive' linker flags may affect the availability of certain exports. Please verify that all necessary symbols remain exported on all supported platforms after this change.
${START_WHOLE_ARCHIVE} # force all exports to be available

src/coreclr/debug/daccess/fntableaccess.h:96

  • The removal of the DllMain declaration here helps avoid duplication, but ensure that no module relies on this declaration for proper linking or export.
BOOL WINAPI             DllMain(HINSTANCE hDLL, DWORD dwReason, LPVOID pReserved);

src/coreclr/dlls/mscordac/mscordac.cpp:14

  • The DllMain function now forwards to DllMain2, which is defined elsewhere. Please ensure that this cross-file dependency is intentional and that DllMain2 is correctly linked on all target platforms.
BOOL WINAPI DllMain(HANDLE instance, DWORD reason, LPVOID reserved)

src/coreclr/debug/daccess/daccess.cpp:48

  • Replacing DllMain with DllMain2 centralizes the initialization logic. Confirm that this revised entry point meets all platform-specific initialization requirements and that all callers are updated accordingly.
EXTERN_C BOOL WINAPI DllMain2(HANDLE instance, DWORD reason, LPVOID reserved)

Copy link
Contributor

Tagging subscribers to this area: @tommcdon
See info in area-owners.md if you want to be subscribed.

@jkotas
Copy link
Member Author

jkotas commented May 9, 2025

I have verified that libmscordac.so is not missing any exports with this workaround. Also, it is only about 100kB smaller compared to --whole-archive linking.

@hoyosjs hoyosjs merged commit e67e997 into dotnet:main May 9, 2025
95 checks passed
@jkotas jkotas deleted the whole-archive branch May 9, 2025 20:38
@github-actions github-actions bot locked and limited conversation to collaborators Jun 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate usage of whole-archive in DAC
2 participants