-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
Native support for Apple Silicon #105026
Native support for Apple Silicon #105026
Changes from all commits
0a5dcc9
5293467
4e09c26
9ad03b1
2931a2e
1fc0499
9088e44
24a378c
aa33613
cbe172f
8e33b34
48a1e1c
c9af80e
5ed7e55
e44dd84
bd4a45f
314c92c
1182552
257cb1c
b7abec3
eb8f8af
15637fe
0ba7a04
fe0d5a5
9fb8924
c696fcd
9e05276
a7bcb6b
4c890ce
bfd9a77
7eb1e36
772b665
3eacdfe
768aae6
33b59b8
a6753d0
3e7034a
1a2cb94
3a3df31
d2c9670
1a45df1
c99904e
23cae56
bac1418
2eb97f2
da3ae02
6815776
f067102
79e3429
755d980
aadc07a
3e47747
577bcf3
d0eff87
68733c1
f9e6eb0
ea2e64c
c96c858
e00c4cd
0ec1e50
1f0ae93
417a96c
c022642
3706fe5
92d5324
7f216a4
e592d34
4851956
4b569c1
c31591c
56fcbcd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#! @shell@ | ||
# shellcheck shell=bash | ||
|
||
set -eu -o pipefail +o posix | ||
shopt -s nullglob | ||
|
||
if (( "${NIX_DEBUG:-0}" >= 7 )); then | ||
set -x | ||
fi | ||
|
||
source @signingUtils@ | ||
|
||
extraAfter=() | ||
extraBefore=() | ||
params=("$@") | ||
|
||
input= | ||
|
||
pprev= | ||
prev= | ||
for p in \ | ||
${extraBefore+"${extraBefore[@]}"} \ | ||
${params+"${params[@]}"} \ | ||
${extraAfter+"${extraAfter[@]}"} | ||
do | ||
if [ "$pprev" != "-change" ] && [[ "$prev" != -* ]] && [[ "$p" != -* ]]; then | ||
input="$p" | ||
fi | ||
pprev="$prev" | ||
prev="$p" | ||
done | ||
|
||
# Optionally print debug info. | ||
if (( "${NIX_DEBUG:-0}" >= 1 )); then | ||
# Old bash workaround, see above. | ||
echo "extra flags before to @prog@:" >&2 | ||
printf " %q\n" ${extraBefore+"${extraBefore[@]}"} >&2 | ||
echo "original flags to @prog@:" >&2 | ||
printf " %q\n" ${params+"${params[@]}"} >&2 | ||
echo "extra flags after to @prog@:" >&2 | ||
printf " %q\n" ${extraAfter+"${extraAfter[@]}"} >&2 | ||
fi | ||
|
||
@prog@ \ | ||
${extraBefore+"${extraBefore[@]}"} \ | ||
${params+"${params[@]}"} \ | ||
${extraAfter+"${extraAfter[@]}"} | ||
|
||
sign "$input" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#! @shell@ | ||
# shellcheck shell=bash | ||
|
||
set -eu -o pipefail +o posix | ||
shopt -s nullglob | ||
|
||
if (( "${NIX_DEBUG:-0}" >= 7 )); then | ||
set -x | ||
fi | ||
|
||
source @signingUtils@ | ||
|
||
extraAfter=() | ||
extraBefore=() | ||
params=("$@") | ||
|
||
output= | ||
inputs=() | ||
|
||
restAreFiles= | ||
prev= | ||
for p in \ | ||
${extraBefore+"${extraBefore[@]}"} \ | ||
${params+"${params[@]}"} \ | ||
${extraAfter+"${extraAfter[@]}"} | ||
do | ||
if [ "$restAreFiles" ]; then | ||
inputs+=("$p") | ||
else | ||
case "$prev" in | ||
-s|-R|-d|-arch) | ||
# Unrelated arguments with values | ||
;; | ||
-o) | ||
# Explicit output | ||
output="$p" | ||
;; | ||
*) | ||
# Any other orgument either takes no value, or is a file. | ||
if [[ "$p" != -* ]]; then | ||
inputs+=("$p") | ||
fi | ||
;; | ||
esac | ||
|
||
if [ "$p" == - ]; then | ||
restAreFiles=1 | ||
fi | ||
fi | ||
|
||
prev="$p" | ||
done | ||
|
||
# Optionally print debug info. | ||
if (( "${NIX_DEBUG:-0}" >= 1 )); then | ||
# Old bash workaround, see above. | ||
echo "extra flags before to @prog@:" >&2 | ||
printf " %q\n" ${extraBefore+"${extraBefore[@]}"} >&2 | ||
echo "original flags to @prog@:" >&2 | ||
printf " %q\n" ${params+"${params[@]}"} >&2 | ||
echo "extra flags after to @prog@:" >&2 | ||
printf " %q\n" ${extraAfter+"${extraAfter[@]}"} >&2 | ||
fi | ||
|
||
@prog@ \ | ||
${extraBefore+"${extraBefore[@]}"} \ | ||
${params+"${params[@]}"} \ | ||
${extraAfter+"${extraAfter[@]}"} | ||
|
||
if [ "$output" ]; then | ||
# Single explicit output | ||
signIfRequired "$output" | ||
else | ||
# Multiple inputs, rewritten in place | ||
for input in "${inputs[@]}"; do | ||
signIfRequired "$input" | ||
done | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,8 @@ declare -a libDirs | |
declare -A libs | ||
declare -i relocatable=0 link32=0 | ||
|
||
linkerOutput="a.out" | ||
|
||
if | ||
[ "$NIX_DONT_SET_RPATH_@suffixSalt@" != 1 ] \ | ||
|| [ "$NIX_SET_BUILD_ID_@suffixSalt@" = 1 ] \ | ||
|
@@ -153,6 +155,24 @@ then | |
done | ||
fi | ||
|
||
# Determine linkerOutput | ||
prev= | ||
for p in \ | ||
${extraBefore+"${extraBefore[@]}"} \ | ||
${params+"${params[@]}"} \ | ||
${extraAfter+"${extraAfter[@]}"} | ||
do | ||
case "$prev" in | ||
-o) | ||
# Informational for post-link-hook | ||
linkerOutput="$p" | ||
;; | ||
*) | ||
;; | ||
esac | ||
prev="$p" | ||
done | ||
|
||
if [[ "$link32" = "1" && "$setDynamicLinker" = 1 && -e "@out@/nix-support/dynamic-linker-m32" ]]; then | ||
# We have an alternate 32-bit linker and we're producing a 32-bit ELF, let's | ||
# use it. | ||
|
@@ -223,7 +243,11 @@ fi | |
|
||
PATH="$path_backup" | ||
# Old bash workaround, see above. | ||
exec @prog@ \ | ||
@prog@ \ | ||
${extraBefore+"${extraBefore[@]}"} \ | ||
${params+"${params[@]}"} \ | ||
${extraAfter+"${extraAfter[@]}"} | ||
|
||
if [ -e "@out@/nix-support/post-link-hook" ]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a hook to sign everything the linker produces, without putting explicit signing references in the general linker wrapper. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this interact with stripping binaries? Don't signatures cover the whole binaries? (I am just driving by and reading through the comments) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any modification of the binary, including Initially I used a fixup phase hook, which generally worked, but ran into a few cases that needed extra work. |
||
source @out@/nix-support/post-link-hook | ||
fi |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Fixup hook for nukeReferences, not stdenv | ||
|
||
source @signingUtils@ | ||
|
||
fixupHooks+=(signIfRequired) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#! @shell@ | ||
|
||
fixupHooks=() | ||
|
||
if [ -e @out@/nix-support/setup-hooks.sh ]; then | ||
source @out@/nix-support/setup-hooks.sh | ||
fi | ||
|
||
excludes="" | ||
while getopts e: o; do | ||
case "$o" in | ||
e) storeId=$(echo "$OPTARG" | @perl@/bin/perl -ne "print \"\$1\" if m|^\Q@storeDir@\E/([a-z0-9]{32})-.*|") | ||
if [ -z "$storeId" ]; then | ||
echo "-e argument must be a Nix store path" | ||
exit 1 | ||
fi | ||
excludes="$excludes(?!$storeId)" | ||
;; | ||
esac | ||
done | ||
shift $(($OPTIND-1)) | ||
|
||
for i in "$@"; do | ||
if test ! -L "$i" -a -f "$i"; then | ||
cat "$i" | @perl@/bin/perl -pe "s|\Q@storeDir@\E/$excludes[a-z0-9]{32}-|@storeDir@/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" > "$i.tmp" | ||
if test -x "$i"; then chmod +x "$i.tmp"; fi | ||
mv "$i.tmp" "$i" | ||
|
||
for hook in "${fixupHooks[@]}"; do | ||
eval "$hook" "$i" | ||
done | ||
fi | ||
done |
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.
GCC doesn't like either of these things:
But we force them in wrappers. Is there a better way?
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.
Huh, that is weird. @thefloweringash does this help somewhere else?
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.
Yes: #105026 (comment)