Skip to content

File cleanup support - #58

Open
johnwparent wants to merge 2 commits into
spack:mainfrom
johnwparent:file-cleanup-support
Open

File cleanup support#58
johnwparent wants to merge 2 commits into
spack:mainfrom
johnwparent:file-cleanup-support

Conversation

@johnwparent

Copy link
Copy Markdown
Collaborator

Signed-off-by: John Parent john.parent@kitware.com

Signed-off-by: John Parent <john.parent@kitware.com>
@johnwparent
johnwparent force-pushed the file-cleanup-support branch from 82e4a85 to 1404535 Compare August 5, 2026 21:36
Signed-off-by: John Parent <john.parent@kitware.com>

@scheibelp scheibelp left a comment

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.

I have one request and a couple questions

Comment thread src/ld.cxx
ScopedTempFile def_rename_cleanup(link_run.get_def_file());
if (!link_run.def_file_is_temp()) {
def_rename_cleanup.Keep();
}

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.

I prefer

if (link_run.def_file_is_temp()) {
    ScopedTempFile def_rename_cleanup(link_run.get_def_file());
}

Is this the only use of keep? If so, I think that definition can be removed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Will remove keep. I think the later comment also has implications for this, so perhaps this stanza will end up coming out entirely.

Comment thread src/linker_invocation.cxx
}
def_out.close();
this->def_file_ = rename_def;
this->def_file_is_temp_ = true;

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.

Question: could this LinkerInvocation object maintain a ScopedTempFile itself, so that it is cleaned up? Or would it be cleaned up at the wrong time?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think there's no good reason why we couldn't have the destructor implicitly clean this. Will switch to that approach.

Comment thread src/winrpath.cxx
// Release the handle used to capture dumpbin's output now, otherwise it
// stays open (and blocks removal of tmp_def_file below) until def_executor
// is destroyed.
this->def_executor.CleanupHandles();

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.

Question: are executors ever called multiple times, or would it make sense to do this automatically after one call to .Execute?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

They could be. They are not in practice, but running the same command multiple times may be of interest in the future, i.e. if we wanted to verify a library's exported symbols haven't changed after our operations, or similar.

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