Skip to content

Identify DLLs from the stage#23

Merged
scheibelp merged 2 commits intospack:mainfrom
johnwparent:inject-dll-identifiers
Apr 28, 2026
Merged

Identify DLLs from the stage#23
scheibelp merged 2 commits intospack:mainfrom
johnwparent:inject-dll-identifiers

Conversation

@johnwparent
Copy link
Copy Markdown
Collaborator

@johnwparent johnwparent commented Nov 20, 2025

Relocating DLL and their corresponding libs from the stage currently has a pitfall, where post installation, the paths inside import libraries to their corresponding DLLs is no longer valid, as it points to the DLL as it existed at link time, which is the stage. We cannot presume where the DLL will end up in the install tree vs the stage, and we need valid "rpaths" at test time, so we are forced to marshall libs and their dlls post install.

Since we cannot 1:1 map a location in an install tree to a location in the stage, we need some other mechanism for aligning these two binaries. Previously we simply used the symbols exported by each, but since import libraries and DLLs can export different sets of symbols, despite the fact they are a import lib/dll pair, we cannot use that approach.

Instead, inject the stage path inside the dll via a resource file, so when we go to do relocation post install, we can simply query the stage dll path from the import library, search for a dll with a corresponding entry in the string table, and know we've identified a pair.

This PR:

Creates a resource descriptor file (res) and injects the current path to the dll (stage time) into the string table with the identifier as a custom, unique to Spack, "spackresource" type added into the first pass link line that creates the initial dll.

@johnwparent johnwparent force-pushed the inject-dll-identifiers branch from 0f18e5d to 10f0031 Compare November 24, 2025 23:40
Copy link
Copy Markdown
Member

@scheibelp scheibelp left a comment

Choose a reason for hiding this comment

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

A few preliminary questions/requests

Comment thread src/linker_invocation.cxx Outdated
Comment thread src/ld.cxx Outdated
Comment thread src/ld.cxx Outdated
Comment thread src/ld.cxx Outdated
Comment thread src/ld.cxx Outdated
@johnwparent
Copy link
Copy Markdown
Collaborator Author

Rebased on #32

…has a pitfall, where post installation, the paths inside import libraries to their corresponding DLLs is no longer valid, as it points to the DLL as it existed at link time, which is the stage. We cannot presume where the DLL will end up in the install tree vs the stage, and we need valid "rpaths" at test time, so we are forced to marshall libs and their dlls post install.

Since we cannot 1:1 map a location in an install tree to a location in the stage, we need some other mechanism for aligning these two binaries. Previously we simply used the symbols exported by each, but since import libraries and DLLs can export different sets of symbols, despite the fact they are a import lib/dll pair, we cannot use that approach.

Instead, inject the stage path inside the dll via a resource file, so when we go to do relocation post install, we can simply query the stage dll path from the import library, search for a dll with a corresponding entry in the string table, and know we've identified a pair.

This PR:

Creates a resource descriptor file (res) and injects the current path to the dll (stage time) into the string table with the identifier "59673" (randomly selected number, it just needs to be any consistent identifier) it into the first pass link line that creates the initial dll.
The identifier needs to be a numeric, and this is a random one I chose.

Signed-off-by: John Parent <john.parent@kitware.com>
Signed-off-by: John Parent <john.parent@kitware.com>
@johnwparent johnwparent force-pushed the inject-dll-identifiers branch from f60bde8 to 8dcfe60 Compare April 28, 2026 20:36
Comment thread src/ld.cxx
}

ExecuteCommand rc_executor("rc",
{"/fo" + res_file_name + " " + rc_file_name});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like these files are being created in the CWD. I think as a follow-up they should be made in a temp dir.

@scheibelp scheibelp merged commit 0af6570 into spack:main Apr 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants