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

MacOS compatible mktemp in cc-wrapper #258608

Merged
merged 1 commit into from
Oct 8, 2023
Merged

Conversation

aherrmann
Copy link
Member

@aherrmann aherrmann commented Oct 2, 2023

Description of changes

Closes #258607

The commit 6f2b3ba introduced a mktemp invokation that uses the --tmpdir flag, which is not available on MacOS.

This changes the invokation to a portable one based on the following StackOverflow answer https://stackoverflow.com/a/31397073/841562 .

Things done

I have tested the patch in isolation by patching the cc-wrapper at the use-site, see this commit.

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@Mindavi
Copy link
Contributor

Mindavi commented Oct 3, 2023

I think this is fine to do, even if it ultimately may be obsoleted by using tools from the store, at some point. Making these parts more portable is IMHO a good thing.

Copy link
Contributor

@Mindavi Mindavi left a comment

Choose a reason for hiding this comment

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

Should target staging.

@aherrmann aherrmann changed the base branch from master to staging October 4, 2023 07:33
@aherrmann
Copy link
Member Author

Thanks @Mindavi. I've changed the base branch to staging.

Copy link
Contributor

@Mindavi Mindavi left a comment

Choose a reason for hiding this comment

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

Looks ok, but hopefully we can get some more eyes on this

@delroth delroth added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Oct 4, 2023
Copy link
Member

@Artturin Artturin left a comment

Choose a reason for hiding this comment

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

Same thing is done in the prefetch scripts

tmpPath="$(mktemp -d "${TMPDIR:-/tmp}/hg-checkout-tmp-XXXXXXXX")"

https://man7.org/linux/man-pages/man1/mktemp.1.html

@Artturin
Copy link
Member

Artturin commented Oct 5, 2023

Commit name is wrong though, should be cc-wrapper: ...

@delroth delroth added 12.approvals: 2 This PR was reviewed and approved by two reputable people and removed 12.approvals: 1 This PR was reviewed and approved by one reputable person labels Oct 5, 2023
Copy link
Contributor

@malt3 malt3 left a comment

Choose a reason for hiding this comment

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

Was able to reproduce the issue in Bazel / rules_nixpkgs on macOS and this does fix it.

The commit 6f2b3ba introduced a
`mktemp` invokation that uses the `--tmpdir` flag, which is not
available on MacOS.

This changes the invokation to a portable one based on the following
StackOverflow answer https://stackoverflow.com/a/31397073/841562 .
@aherrmann
Copy link
Member Author

Thank you!

Commit name is wrong though, should be cc-wrapper: ...

@Artturin I've fixed the commit name.

@delroth delroth removed the 12.approvals: 2 This PR was reviewed and approved by two reputable people label Oct 5, 2023
@jaudiger
Copy link
Contributor

jaudiger commented Oct 8, 2023

Ohhhh, this one will resolve the issue I encountered a while ago... #254104

@Artturin Artturin merged commit 187f681 into NixOS:staging Oct 8, 2023
18 checks passed
@aherrmann aherrmann deleted the macos-mktemp branch October 9, 2023 07:10
reckenrode added a commit to reckenrode/nixpkgs that referenced this pull request May 31, 2024
This changes ld-wrapper to use a temporary file for the response file
passed to ld instead of using process substitution.

ld64 does not handle long command-lines when reading from the response
file, which defeats the point of using a response file to handle long
command-lines. cctools-port was patched to work around this, but nixpkgs
is now using Apple’s source release directly instead of the port.

Since it’s preferable not to patch Apple’s release heavily (to reduce
the difficulty of updating to new versions and to match upstream’s
behavior), use the approach that was adopted in cc-wrapper to work
around issues with response files in newer versions of clang.

Related PRs (cctools-port):
- NixOS#213831
- tpoechtrager/cctools-port#132

Related PRs (cc-wrapper):
- NixOS#245282
- NixOS#258608
reckenrode added a commit to reckenrode/nixpkgs that referenced this pull request Jun 2, 2024
This changes ld-wrapper to use a temporary file for the response file
passed to ld instead of using process substitution.

ld64 does not handle long command-lines when reading from the response
file, which defeats the point of using a response file to handle long
command-lines. cctools-port was patched to work around this, but nixpkgs
is now using Apple’s source release directly instead of the port.

Since it’s preferable not to patch Apple’s release heavily (to reduce
the difficulty of updating to new versions and to match upstream’s
behavior), use the approach that was adopted in cc-wrapper to work
around issues with response files in newer versions of clang.

Related PRs (cctools-port):
- NixOS#213831
- tpoechtrager/cctools-port#132

Related PRs (cc-wrapper):
- NixOS#245282
- NixOS#258608
reckenrode added a commit to reckenrode/nixpkgs that referenced this pull request Jul 13, 2024
This changes ld-wrapper to use a temporary file for the response file
passed to ld instead of using process substitution.

ld64 does not handle long command-lines when reading from the response
file, which defeats the point of using a response file to handle long
command-lines. cctools-port was patched to work around this, but nixpkgs
is now using Apple’s source release directly instead of the port.

Since it’s preferable not to patch Apple’s release heavily (to reduce
the difficulty of updating to new versions and to match upstream’s
behavior), use the approach that was adopted in cc-wrapper to work
around issues with response files in newer versions of clang.

Related PRs (cctools-port):
- NixOS#213831
- tpoechtrager/cctools-port#132

Related PRs (cc-wrapper):
- NixOS#245282
- NixOS#258608
reckenrode added a commit to reckenrode/nixpkgs that referenced this pull request Jul 16, 2024
This changes ld-wrapper to use a temporary file for the response file
passed to ld instead of using process substitution.

ld64 does not handle long command-lines when reading from the response
file, which defeats the point of using a response file to handle long
command-lines. cctools-port was patched to work around this, but nixpkgs
is now using Apple’s source release directly instead of the port.

Since it’s preferable not to patch Apple’s release heavily (to reduce
the difficulty of updating to new versions and to match upstream’s
behavior), use the approach that was adopted in cc-wrapper to work
around issues with response files in newer versions of clang.

Related PRs (cctools-port):
- NixOS#213831
- tpoechtrager/cctools-port#132

Related PRs (cc-wrapper):
- NixOS#245282
- NixOS#258608
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cc-wrapper mktemp invokation incompatible with MacOS
6 participants