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
Do not depend on system tools on Darwin #2136
base: master
Are you sure you want to change the base?
Conversation
236ca50
to
237ecb7
Compare
fba3fce
to
9d5fd18
Compare
@Mergifyio rebase |
✅ Branch has been successfully rebased |
9d5fd18
to
22c032d
Compare
dedc6cd
to
42068b0
Compare
Our cc wrapper was always using the system tools from a fixed location on Darwin, which is not hermetic (and can lead to problems when using nixpkgs) and requires the Xcode command line tools to be installed. Apply the same heuristic as for the otool and install_name tool for the haskell toolchain and assume the tools are available at the same location as the `ar` binary.
... in case the `codesign` binary is not part of the directory where the `ar` tool resides. This might happen when not using a toolchain configured by nixpkgs_cc_configure, but instead using one from a nix-shell. The codesign tool is not part of a nixpkgs stdenv cc toolchain by default.
42068b0
to
be50c26
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few comments, but otherwise it looks good to me 👍
# Fall back to /usr/bin/codesign if the `CODESIGN` executable is not available | ||
# (this might happen when using a default cc toolchain from a nix shell on Darwin instead | ||
# of using a nixpkgs_cc_configure'd toolchain). | ||
codesign = CODESIGN if os.access(CODESIGN, os.X_OK) else "/usr/bin/codesign" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we do similar checks for INSTALL_NAME_TOOL
and OTOOL
?
# This is necessary on MacOS Monterey on M1. | ||
# The moving back and forth is necessary because the OS caches the signature. | ||
# See this note from nixpkgs for reference: | ||
# https://github.com/NixOS/nixpkgs/blob/5855ff74f511423e3e2646248598b3ffff229223/pkgs/os-specific/darwin/signing-utils/utils.sh#L1-L6 | ||
os.rename(output, f"{output}.resign") | ||
subprocess.check_call([CODESIGN] + ["-f", "-s", "-"] + [f"{output}.resign"]) | ||
subprocess.check_call([codesign] + ["-f", "-s", "-"] + [f"{output}.resign"], env = {'CODESIGN_ALLOCATE': CODESIGN_ALLOCATE}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe if {:bindir:}/codesign
is not available then we should not set the CODESIGN_ALLOCATE
? Since it also points to {:bindir}
.
Our cc wrapper was always using the system tools from a fixed location on Darwin, which is not hermetic
(and can lead to problems when using nixpkgs) and requires the Xcode command line tools to be installed.
Apply the same heuristic as for the otool and install_name tool for the haskell toolchain and assume
the tools are available at the same location as the
ar
binary.Depends on tweag/rules_nixpkgs#479 and depends on #2119