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

Use $HOME/.tmp as temp dir if TMPDIR is unset #2

Merged
merged 1 commit into from Feb 18, 2024

Conversation

direc85
Copy link
Collaborator

@direc85 direc85 commented Feb 1, 2024

When Rust is determining the temp directory to use during compilation, tempfile uses env::temp_dir() which in *nix returns /tmp if TMPDIR is unset. This leads to a situation where the linker can't find symbols.o file during the linking phase.

This could be mitigated already by setting TMPDIR in a .spec file, but this needs to be done in every project separately. Instead, make the compiler default to $HOME/.tmp if TMPDIR is unset instead. The patch uses $HOME, which exists in both Sailfish SDK and Platform SDK.

Patching how env::temp_dir() works in std feels overkill and could lead to other issues. Hence this patch targets the compiler itself during compiling and linking.

With Rust packages compiled with this patch, Whisperfish was able to compile without errors without the TMPDIR commands in the .spec file.

@mlehtima
Copy link

mlehtima commented Feb 1, 2024

Appears to also work on OBS

@rubdos
Copy link
Owner

rubdos commented Feb 2, 2024

My only issue with this kind of patch is that it's a rather hacky workaround: if Rust decides to start using /tmp in other places where the same issue might appear, we'll have to keep throwing in this logic all over the place. Your call @mlehtima!

@mlehtima
Copy link

I think this is fine for now, if we figure out a better way or if there is need to rethink this in the future if rust changes we can always change it later.

@rubdos
Copy link
Owner

rubdos commented Feb 17, 2024

@mlehtima would you like to pull it in via the Sailfish repo, or do I have you take the scraps and put everything together? :-)

@rubdos rubdos merged commit 62fed52 into rubdos:1.75.0 Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants