package rosa

import "hakurei.app/internal/pkg"

func (t Toolchain) newTamaGo() (pkg.Artifact, string) {
	const (
		version  = "1.26.3"
		checksum = "-nH3MjAzDDLTeJ2hRKYJcJwo5-Ikci4zOHfB8j1vKn7zrF9TS6zYaoLi8qohGwAE"
	)
	return t.New("tamago-go"+version, 0, t.AppendPresets(nil,
		Bash,
		Go,
	), nil, []string{
		"CC=cc",
		"GOCACHE=/tmp/gocache",
		"CGO_ENABLED=0",
	}, `
mkdir /work/system # "${TMPDIR}"
cp -r /usr/src/tamago /work/system
cd /work/system/tamago/src
chmod -R +w ..

sed -i \
	's,/lib/ld-musl-`+linuxArch()+`.so.1,/system/bin/linker,' \
	cmd/link/internal/`+arch+`/obj.go
sed -i \
	's/cpu.X86.HasAVX512VBMI/& \&\& cpu.X86.HasPOPCNT/' \
	internal/runtime/gc/scan/scan_amd64.go

rm \
	os/root_unix_test.go \
	cmd/cgo/internal/testsanitizers/tsan_test.go \
	cmd/cgo/internal/testsanitizers/cshared_test.go

./all.bash
`, pkg.Path(AbsUsrSrc.Append("tamago"), false, newFromGitHub(
		"usbarmory/tamago-go",
		"tamago-go"+version,
		checksum,
	))), version
}
func init() {
	artifactsM[TamaGo] = Metadata{
		f: Toolchain.newTamaGo,

		Name:        "tamago",
		Description: "a Go toolchain extended with support for bare metal execution",
		Website:     "https://github.com/usbarmory/tamago-go",

		ID: 388872,
	}
}
