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

xar: fix Linux build on staging-next #352507

Merged
merged 1 commit into from
Nov 10, 2024
Merged

Conversation

reckenrode
Copy link
Contributor

@reckenrode reckenrode commented Oct 31, 2024

Adds an alternate implementation of F_GETPATH for Linux. Avoids rebuilds on Darwin. Fixes failure on staging-next #348827. I tested that it builds. It would be good if a Linux user could confirm this is the right approach.

Closes #352453.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • 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/)
  • 24.11 Release Notes (or backporting 23.11 and 24.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.

Add a 👍 reaction to pull requests you find important.

@yu-re-ka
Copy link
Contributor

I can not judge the contents of the patch in detail, but the approach for avoiding rebuilds seems fine.
Just don't forget to make another PR to remove the conditionals in staging.

@emilazy
Copy link
Member

emilazy commented Oct 31, 2024

Since the only report of a Linux failure was related to trying to get Linux‐to‐Darwin cross working, maybe this is sufficiently non‐urgent that we can just throw it in the next staging cycle anyway?

}
+#elif defined(__linux__)
+ // Linux has to get the path to the file via `/proc`.
+ if (readlink("/proc/self/fd/<n>", &path_buff, PATH_MAX) < 0) {
Copy link
Member

Choose a reason for hiding this comment

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

This <n> cannot possibly be right, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it’s not. It was a placeholder I forgot to convert because I didn’t have much time tonight to work on stuff. I’ve marked this draft until I can get a chance to fix it tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated it to use snprintf to generate the path to pass to readlink.

@reckenrode reckenrode marked this pull request as draft October 31, 2024 00:50
@reckenrode reckenrode force-pushed the push-oypsukxklmsk branch 2 times, most recently from 16b344e to c739a09 Compare October 31, 2024 01:32
@reckenrode reckenrode marked this pull request as ready for review October 31, 2024 01:32
@reckenrode
Copy link
Contributor Author

Since the only report of a Linux failure was related to trying to get Linux‐to‐Darwin cross working, maybe this is sufficiently non‐urgent that we can just throw it in the next staging cycle anyway?

I can retarget staging if that would be preferred. @tie?

+ close(fd);
+ return NULL;
+ }
+ // The filename is the file’s when the fd was created. Check to make sure it still exists.
Copy link
Member

@tie tie Oct 31, 2024

Choose a reason for hiding this comment

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

Do we really have to check that the file exists? How does F_GETPATH on Darwin handle this case (e.g. fcntl after unlink)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure. The documentation just says it gets the path. I’m going to write some test programs later today to probe the behavior to see what Darwin does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Darwin tracks name changes for renames. When the file is unlinked, F_GETPATH appears to return the last name it had. It may be possible to track renames in Linux (not sure), but it’s probably not worth the effort. Bailing if the underlying file was removed or renamed seems like the safest/easiest option.

@vcunat vcunat changed the base branch from staging-next to master October 31, 2024 09:47
@ofborg ofborg bot requested review from emilazy, copumpkin, tie and toonn October 31, 2024 13:28
@ofborg ofborg bot added 11.by: package-maintainer This PR was created by the maintainer of the package it changes 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 11-100 labels Oct 31, 2024
Copy link
Member

@tie tie left a comment

Choose a reason for hiding this comment

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

LGTM

@emilazy emilazy merged commit 35305f2 into NixOS:master Nov 10, 2024
27 of 28 checks passed
@reckenrode reckenrode deleted the push-oypsukxklmsk branch November 11, 2024 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 11-100 11.by: package-maintainer This PR was created by the maintainer of the package it changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[staging-next] xar: cannot build on x86_64-linux
4 participants