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

Avoid creation of a temporary probe file for newer compilers #1316

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wilzbach
Copy link
Member

@wilzbach wilzbach commented Dec 25, 2017

When I chated with @RazvanN7 today, he complained about DUB creating a lot of temporary probing files in his current working directory.
A quick look at the code revealed that DUB uses this probing hack to extract information
from DMD. Since dlang/dmd#6880 (2.076.0), it's possible
to avoid the need of creating a temporary file for this hack.
Of course, it would be better to read this file from the compiler directly...

@dlang-bot
Copy link
Collaborator

Thanks for your pull request, @wilzbach!


auto fil = generatePlatformProbeFile();
bool canUseStdin = this.canUseStdin(compiler_binary);
string fil = canUseStdin ? generatePlatformProbeFile().toNativeString() : "-";
Copy link
Member Author

Choose a reason for hiding this comment

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

Of course we could also remove the temp file after the exit of the current scope.

@MartinNowak
Copy link
Member

Temp files get deleted at the end of the run, would be better to make that mechanism more reliable instead of increasing the complexity for that single task.

NativePath getTempFile(string prefix, string extension = null)
{
import std.uuid : randomUUID;
auto path = getTempDir() ~ (prefix ~ "-" ~ randomUUID.toString() ~ extension);
temporary_files ~= path;
return path;
}

I'd guess the main source for the remaining temp files is dub's missing CTRL+C sigint handling, in particular in combination with dub run where you want to exit the child process, but terminate the parent instead.

@wilzbach
Copy link
Member Author

FYI: the new JSON API (e.g. dmd -Xi=compilerInfo -Xf=- has been released with 2.079 and we should be able to use it for new LDC + DMD compilers.

See also: https://dlang.org/changelog/2.079.0.html#json_includes

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.

3 participants