slightly simplify how we deal with linknamed runtime deps
Obfuscating the runtime only needs to list the linknamed packages, and doesn't need to know about their dependencies directly. Refactor the script to return a "flat" list that includes all packages we need, except those that we know the runtime already pulled in. This allows us to simplify the script and avoid passing -deps to cmd/go. Performance is unaffected, but I reckon it's worthwhile given how much we simplified the script. Longer term, it's also best to avoid using -deps when we don't need it, as cmd/go could avoid computing information we don't need. name old time/op new time/op delta Build/NoCache-16 1.68s ± 1% 1.68s ± 0% ~ (p=1.000 n=5+5) name old bin-B new bin-B delta Build/NoCache-16 6.72M ± 0% 6.72M ± 0% +0.01% (p=0.008 n=5+5) name old sys-time/op new sys-time/op delta Build/NoCache-16 1.88s ± 1% 1.89s ± 2% ~ (p=0.548 n=5+5) name old user-time/op new user-time/op delta Build/NoCache-16 19.9s ± 1% 19.8s ± 0% ~ (p=0.421 n=5+5)pull/472/head
parent
f7ed99aa25
commit
8652271db2
@ -1,21 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# The list of all packages the runtime source linknames to.
|
# All packages that the runtime linknames to, except runtime and its dependencies.
|
||||||
linked="$(sed -rn 's@//go:linkname .* ([^.]*)\.[^.]*@\1@p' $(go env GOROOT)/src/runtime/*.go | grep -vE '^main|^runtime\.' | sort -u)"
|
|
||||||
|
|
||||||
# The list of all implied dependencies of the packages above,
|
|
||||||
# across all main GOOS targets.
|
|
||||||
implied="$(for GOOS in linux darwin windows js; do
|
|
||||||
for pkg in $linked; do
|
|
||||||
GOOS=$GOOS GOARCH=$GOARCH go list -e -deps $pkg | grep -v '^'$pkg'$'
|
|
||||||
done
|
|
||||||
done | sort -u)"
|
|
||||||
|
|
||||||
# All packages in linked, except those implied by others already.
|
|
||||||
# This resulting list is what we need to "go list" when obfuscating the runtime,
|
# This resulting list is what we need to "go list" when obfuscating the runtime,
|
||||||
# as they are the packages that we may be missing.
|
# as they are the packages that we may be missing.
|
||||||
comm -23 <(
|
comm -23 <(
|
||||||
echo "$linked"
|
sed -rn 's@//go:linkname .* ([^.]*)\.[^.]*@\1@p' $(go env GOROOT)/src/runtime/*.go | grep -vE '^main|^runtime\.' | sort -u
|
||||||
) <(
|
) <(
|
||||||
echo "$implied"
|
# Note that we assume this is constant across platforms.
|
||||||
|
go list -deps runtime | sort -u
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue