4b9acf4e21
When running universal binaries like /bin/bash, Darwin XNU will choose which architecture of the binary to use based on "binary preferences". This change sets that to the current platform for aarch64 and x86_64 builds. In addition it now uses posix_spawn instead of the usual execve. Note, that this does not prevent the other architecture from being run, just advises which to use. Unfortunately, posix_spawnattr_setbinpref_np does not appear to be inherited by child processes in x86_64 Rosetta 2 translations, meaning that this will not always work as expected. For example: { arm = derivation { name = "test"; system = "aarch64-darwin"; builder = "/bin/bash"; args = [ "-e" (builtins.toFile "test" '' set -x /usr/sbin/sysctl sysctl.proc_translated /usr/sbin/sysctl sysctl.proc_native [ "$(/usr/bin/arch)" = arm64 ] /usr/bin/touch $out '') ]; }; rosetta = derivation { name = "test"; system = "x86_64-darwin"; builder = "/bin/bash"; args = [ "-e" (builtins.toFile "test" '' set -x /usr/sbin/sysctl sysctl.proc_translated /usr/sbin/sysctl sysctl.proc_native [ "$(/usr/bin/arch)" = i386 ] echo It works! /usr/bin/touch $out '') ]; }; } `arm' fails on x86_64-compiled Nix, but `arm' and `rosetta' succeed on aarch64-compiled Nix. I suspect there is a way to fix this since: $ /usr/bin/arch -arch x86_64 /bin/bash \ -c '/usr/bin/arch -arch arm64e /bin/bash -c /usr/bin/arch' arm64 seems to work correctly. We may need to wait for Apple to update system_cmds in opensource.apple.com to find out how though. |
||
---|---|---|
.. | ||
build | ||
builtins | ||
binary-cache-store.cc | ||
binary-cache-store.hh | ||
builtins.hh | ||
content-address.cc | ||
content-address.hh | ||
crypto.cc | ||
crypto.hh | ||
daemon.cc | ||
daemon.hh | ||
derivations.cc | ||
derivations.hh | ||
dummy-store.cc | ||
export-import.cc | ||
filetransfer.cc | ||
filetransfer.hh | ||
fs-accessor.hh | ||
gc.cc | ||
globals.cc | ||
globals.hh | ||
http-binary-cache-store.cc | ||
legacy-ssh-store.cc | ||
local-binary-cache-store.cc | ||
local-fs-store.cc | ||
local-fs-store.hh | ||
local-store.cc | ||
local-store.hh | ||
local.mk | ||
lock.cc | ||
lock.hh | ||
machines.cc | ||
machines.hh | ||
misc.cc | ||
names.cc | ||
names.hh | ||
nar-accessor.cc | ||
nar-accessor.hh | ||
nar-info-disk-cache.cc | ||
nar-info-disk-cache.hh | ||
nar-info.cc | ||
nar-info.hh | ||
nix-store.pc.in | ||
optimise-store.cc | ||
parsed-derivations.cc | ||
parsed-derivations.hh | ||
path-info.hh | ||
path.cc | ||
path.hh | ||
pathlocks.cc | ||
pathlocks.hh | ||
profiles.cc | ||
profiles.hh | ||
references.cc | ||
references.hh | ||
remote-fs-accessor.cc | ||
remote-fs-accessor.hh | ||
remote-store.cc | ||
remote-store.hh | ||
s3-binary-cache-store.cc | ||
s3-binary-cache-store.hh | ||
s3.hh | ||
sandbox-defaults.sb | ||
sandbox-minimal.sb | ||
sandbox-network.sb | ||
schema.sql | ||
serve-protocol.hh | ||
sqlite.cc | ||
sqlite.hh | ||
ssh-store.cc | ||
ssh.cc | ||
ssh.hh | ||
store-api.cc | ||
store-api.hh | ||
uds-remote-store.cc | ||
uds-remote-store.hh | ||
worker-protocol.hh |