generate go_std_tables.go in its entirety

No more having to manually run the script and adapting it to Go code.
pull/655/head
Daniel Martí 1 year ago
parent 33ceca7ef8
commit 0b096c9e75

@ -1,13 +1,16 @@
// Code generated by scripts/gen-go-std-tables.sh; DO NOT EDIT.
// Generated from Go version devel go1.21-733ba92187 Tue Jan 24 13:28:54 2023 +0000.
package main
// Obtained from "go list -deps runtime" as of June 29th.
// Note that the same command on Go 1.18 results in the same list.
var runtimeAndDeps = map[string]bool{
"internal/goarch": true,
"unsafe": true,
"internal/abi": true,
"internal/cpu": true,
"internal/bytealg": true,
"internal/coverage/rtcov": true,
"internal/goexperiment": true,
"internal/goos": true,
"runtime/internal/atomic": true,
@ -17,7 +20,6 @@ var runtimeAndDeps = map[string]bool{
"runtime": true,
}
// Obtained via scripts/runtime-linknamed-nodeps.sh as of 2022-11-01.
var runtimeLinknamed = []string{
"arena",
"crypto/internal/boring",
@ -37,6 +39,7 @@ var runtimeLinknamed = []string{
"runtime/coverage",
"runtime/debug",
"runtime/metrics",
"runtime/metrics_test",
"runtime/pprof",
"runtime/trace",
"sync",

@ -0,0 +1,38 @@
#!/bin/bash
# We can rewrite this bash script in Go if a dependency on bash and coreutils
# is a problem during development.
go_version=$(go env GOVERSION) # not "go version", to exclude GOOS/GOARCH
runtime_and_deps=$(go list -deps runtime)
# All packages that the runtime linknames to, except runtime and its dependencies.
# This resulting list is what we need to "go list" when obfuscating the runtime,
# as they are the packages that we may be missing.
runtime_linknamed=$(comm -23 <(
sed -rn 's@//go:linkname .* ([^.]*)\.[^.]*@\1@p' $(go env GOROOT)/src/runtime/*.go | grep -vE '^main|^runtime\.' | sort -u
) <(
# Note that we assume this is constant across platforms.
go list -deps runtime | sort -u
))
gofmt >go_std_tables.go <<EOF
// Code generated by scripts/gen-go-std-tables.sh; DO NOT EDIT.
// Generated from Go version ${go_version}.
package main
var runtimeAndDeps = map[string]bool{
$(for path in ${runtime_and_deps}; do
echo "\"${path}\": true,"
done)
}
var runtimeLinknamed = []string{
$(for path in ${runtime_linknamed}; do
echo "\"${path}\"",
done)
}
EOF

@ -1,11 +0,0 @@
#!/bin/bash
# All packages that the runtime linknames to, except runtime and its dependencies.
# This resulting list is what we need to "go list" when obfuscating the runtime,
# as they are the packages that we may be missing.
comm -23 <(
sed -rn 's@//go:linkname .* ([^.]*)\.[^.]*@\1@p' $(go env GOROOT)/src/runtime/*.go | grep -vE '^main|^runtime\.' | sort -u
) <(
# Note that we assume this is constant across platforms.
go list -deps runtime | sort -u
)

@ -19,6 +19,8 @@ import (
"golang.org/x/mod/module"
)
//go:generate ./scripts/gen-go-std-tables.sh
// sharedCache is shared as a read-only cache between the many garble toolexec
// sub-processes.
//

Loading…
Cancel
Save