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

setup-hooks/strip: print strip stderr if command fails #244400

Merged
merged 3 commits into from
Jul 23, 2023

Conversation

Artturin
Copy link
Member

@Artturin Artturin commented Jul 19, 2023

this is easiest to do through a file

mktemp needs six X because busybox only accepts exactly six X #178626

Description of changes
Things done
  • 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.

@Artturin Artturin merged commit 2afcd08 into NixOS:staging Jul 23, 2023
4 checks passed
@Artturin Artturin deleted the stripprinterr branch July 23, 2023 00:38
@trofi
Copy link
Contributor

trofi commented Jul 23, 2023

[ -z "$ranlibCmd" ] && echo "stripDirs: Ranlib command is empty" 1>&2 && exit 1

Looks like this broke macos xnu package building in staging (somewhere early in the bootstrap):

...
@nix { "action": "setPhase", "phase": "fixupPhase" }
post-installation fixup
checking for references to /private/tmp/nix-build-xnu-3789.70.16.drv-0/ in /nix/store/xm41xjvqazqwxjlk38aispfprrc6xyri-xnu-3789.70.16...
stripDirs: Ranlib command is empty

@Artturin
Copy link
Member Author

Artturin commented Jul 23, 2023

Maybe this will work

diff --git a/pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix b/pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix
index 266c2ef4dfef..b490b6f2195b 100644
--- a/pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix
+++ b/pkgs/os-specific/darwin/apple-source-releases/xnu/default.nix
@@ -63,6 +63,7 @@ appleDerivation' (if headersOnly then stdenvNoCC else stdenv) (
   MIG = "mig";
   MIGCOM = "migcom";
   STRIP = "${stdenv.cc.bintools.targetPrefix or ""}strip";
+  RANLIB = "${stdenv.cc.bintools.targetPrefix or ""}ranlib";
   NM = "${stdenv.cc.bintools.targetPrefix or ""}nm";
   UNIFDEF = "unifdef";
   DSYMUTIL = "dsymutil";

ranlib is copied

for i in as ld ar ranlib nm strip otool install_name_tool lipo codesign_allocate; do
cp ${cctools_}/bin/$i $out/bin
done
to bootstrap tools

@trofi
Copy link
Contributor

trofi commented Jul 23, 2023

RANLIB = "${stdenv.cc.bintools.targetPrefix or ""}ranlib";

Seems to work! The darwin.xnu installed successfully. Will take some time for stdenv to complete, but look healthy so far.

@Artturin
Copy link
Member Author

#245021

@trofi
Copy link
Contributor

trofi commented Jul 30, 2023

@vcunat noticed seemingly related failures on staging-next: https://hydra.nixos.org/log/ssd7k0nhyc4pnvyffphs4l4i1c5031qc-libsmbios-2.4.3.drv and https://hydra.nixos.org/build/229681745/nixlog/2

The failures is:

$ nix build -f. libsmbios -L
...
gzipping man pages under /nix/store/zg67ja6p7ix78rxnv5zawgdk3g7zkk67-libsmbios-2.4.3/share/man/
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
...
moving /nix/store/zg67ja6p7ix78rxnv5zawgdk3g7zkk67-libsmbios-2.4.3/sbin/* to /nix/store/zg67ja6p7ix78rxnv5zawgdk3g7zkk67-libsmbios-2.4.3/bin
...
mktemp: failed to create file via template 'striperr.XXXXXX': No such file or directory

As if something removed TMP or current working directory from under current process.

@Artturin
Copy link
Member Author

Artturin commented Jul 30, 2023

The shell-init errors are there on master

Maybe this line causes it

preFixup = ''rm -rf "$(pwd)" ''; # Hack to avoid TMPDIR in RPATHs

Building

@Artturin
Copy link
Member Author

#246264

@vcunat
Copy link
Member

vcunat commented Aug 7, 2023

This invocation if mktemp creates the file in the current directory, which is bad practice. We should add "--tmpdir=$TMPDIR" or make the template absolute.

I noticed because one package did cd $src during installing, which is a read-only path...

@vcunat
Copy link
Member

vcunat commented Aug 7, 2023

I suppose a worse case is if come package does cd $out or similar and the file then remains in the result.

@Artturin
Copy link
Member Author

Artturin commented Aug 7, 2023

#247759

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.

4 participants