diff --git a/internal/rosa/bison.go b/internal/rosa/bison.go new file mode 100644 index 00000000..b79ed9e1 --- /dev/null +++ b/internal/rosa/bison.go @@ -0,0 +1,78 @@ +package rosa + +import ( + "slices" + "strconv" + "strings" + + "hakurei.app/internal/pkg" +) + +// skipGNUTests generates a string for skipping specific tests by number in a +// GNU test suite. This is nontrivial because the test suite does not support +// excluding tests in any way, so ranges for all but the skipped tests have to +// be specified instead. +// +// For example, to skip test 764, ranges around the skipped test must be +// specified: +// +// 1-763 765- +// +// Tests are numbered starting from 1. The resulting string is unquoted. +func skipGNUTests(tests ...int) string { + tests = slices.Clone(tests) + slices.Sort(tests) + + var buf strings.Builder + + if tests[0] != 1 { + buf.WriteString("1-") + } + + for i, n := range tests { + if n != 1 && (i == 0 || tests[i-1] != n-1) { + buf.WriteString(strconv.Itoa(n - 1)) + buf.WriteString(" ") + } + if i == len(tests)-1 || tests[i+1] != n+1 { + buf.WriteString(strconv.Itoa(n + 1)) + buf.WriteString("-") + } + } + return buf.String() +} + +func (t Toolchain) newBison() (pkg.Artifact, string) { + const ( + version = "3.8.2" + checksum = "BhRM6K7URj1LNOkIDCFDctSErLS-Xo5d9ba9seg10o6ACrgC1uNhED7CQPgIY29Y" + ) + return t.NewPackage("bison", version, newTar( + "https://ftpmirror.gnu.org/gnu/bison/bison-"+version+".tar.gz", + checksum, + pkg.TarGzip, + ), nil, &MakeHelper{ + Check: []string{ + "TESTSUITEFLAGS=" + jobsFlagE + "' " + skipGNUTests( + // clang miscompiles (SIGILL) + 764, + ) + "'", + "check", + }, + }, + M4, + Diffutils, + Sed, + ), version +} +func init() { + native.MustRegister(&Artifact{ + f: Toolchain.newBison, + + Name: "bison", + Description: "a general-purpose parser generator", + Website: "https://www.gnu.org/software/bison/", + + ID: 193, + }) +} diff --git a/internal/rosa/gnu_test.go b/internal/rosa/bison_test.go similarity index 100% rename from internal/rosa/gnu_test.go rename to internal/rosa/bison_test.go diff --git a/internal/rosa/gnu.go b/internal/rosa/package/gcc/musl-legacy-lfs.patch similarity index 51% rename from internal/rosa/gnu.go rename to internal/rosa/package/gcc/musl-legacy-lfs.patch index 9ec83da4..3643fea9 100644 --- a/internal/rosa/gnu.go +++ b/internal/rosa/package/gcc/musl-legacy-lfs.patch @@ -1,145 +1,4 @@ -package rosa - -import ( - "slices" - "strconv" - "strings" - - "hakurei.app/internal/pkg" -) - -// skipGNUTests generates a string for skipping specific tests by number in a -// GNU test suite. This is nontrivial because the test suite does not support -// excluding tests in any way, so ranges for all but the skipped tests have to -// be specified instead. -// -// For example, to skip test 764, ranges around the skipped test must be -// specified: -// -// 1-763 765- -// -// Tests are numbered starting from 1. The resulting string is unquoted. -func skipGNUTests(tests ...int) string { - tests = slices.Clone(tests) - slices.Sort(tests) - - var buf strings.Builder - - if tests[0] != 1 { - buf.WriteString("1-") - } - - for i, n := range tests { - if n != 1 && (i == 0 || tests[i-1] != n-1) { - buf.WriteString(strconv.Itoa(n - 1)) - buf.WriteString(" ") - } - if i == len(tests)-1 || tests[i+1] != n+1 { - buf.WriteString(strconv.Itoa(n + 1)) - buf.WriteString("-") - } - } - return buf.String() -} - -func (t Toolchain) newBison() (pkg.Artifact, string) { - const ( - version = "3.8.2" - checksum = "BhRM6K7URj1LNOkIDCFDctSErLS-Xo5d9ba9seg10o6ACrgC1uNhED7CQPgIY29Y" - ) - return t.NewPackage("bison", version, newTar( - "https://ftpmirror.gnu.org/gnu/bison/bison-"+version+".tar.gz", - checksum, - pkg.TarGzip, - ), nil, &MakeHelper{ - Check: []string{ - "TESTSUITEFLAGS=" + jobsFlagE + "' " + skipGNUTests( - // clang miscompiles (SIGILL) - 764, - ) + "'", - "check", - }, - }, - M4, - Diffutils, - Sed, - ), version -} -func init() { - native.MustRegister(&Artifact{ - f: Toolchain.newBison, - - Name: "bison", - Description: "a general-purpose parser generator", - Website: "https://www.gnu.org/software/bison/", - - ID: 193, - }) -} - -func (t Toolchain) newBinutils() (pkg.Artifact, string) { - const ( - version = "2.46.0" - checksum = "4kK1_EXQipxSqqyvwD4LbiMLFKCUApjq6PeG4XJP4dzxYGqDeqXfh8zLuTyOuOVR" - ) - return t.NewPackage("binutils", version, newTar( - "https://ftpmirror.gnu.org/gnu/binutils/binutils-"+version+".tar.bz2", - checksum, - pkg.TarBzip2, - ), nil, (*MakeHelper)(nil), - Bash, - ), version -} -func init() { - native.MustRegister(&Artifact{ - f: Toolchain.newBinutils, - - Name: "binutils", - Description: "a collection of binary tools", - Website: "https://www.gnu.org/software/binutils/", - - ID: 7981, - }) -} - -func (t Toolchain) newGCC() (pkg.Artifact, string) { - const ( - version = "16.1.0" - checksum = "4ASoWbxaA2FW7PAB0zzHDPC5XnNhyaAyjtDPpGzceSLeYnEIXsNYZR3PA_Zu5P0K" - ) - - var configureExtra []KV - switch t.arch { - case "amd64", "arm64": - configureExtra = append(configureExtra, KV{"with-multilib-list", "''"}) - } - - return t.NewPackage("gcc", version, newTar( - "https://ftp.tsukuba.wide.ad.jp/software/gcc/releases/"+ - "gcc-"+version+"/gcc-"+version+".tar.gz", - checksum, - pkg.TarGzip, - ), &PackageAttr{ - Patches: []KV{ - {"musl-off64_t-loff_t", `diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c -index 180f5c31d74..44d7ea73f7d 100644 ---- a/libgo/sysinfo.c -+++ b/libgo/sysinfo.c -@@ -365,11 +365,7 @@ enum { - typedef loff_t libgo_loff_t_type; - #endif - --#if defined(HAVE_OFF64_T) --typedef off64_t libgo_off_t_type; --#else - typedef off_t libgo_off_t_type; --#endif - - // The following section introduces explicit references to types and - // constants of interest to support bootstrapping libgo using a -`}, - - {"musl-legacy-lfs", `diff --git a/libgo/go/internal/syscall/unix/at_largefile.go b/libgo/go/internal/syscall/unix/at_largefile.go +diff --git a/libgo/go/internal/syscall/unix/at_largefile.go b/libgo/go/internal/syscall/unix/at_largefile.go index 82e0dcfd074..16151ecad1b 100644 --- a/libgo/go/internal/syscall/unix/at_largefile.go +++ b/libgo/go/internal/syscall/unix/at_largefile.go @@ -267,62 +126,3 @@ index f84860891e6..7efc9615985 100644 } #endif -`}, - }, - - ScriptEarly: ` -ln -s system/lib / -ln -s system/lib /work/ -`, - - // GCC spends most of its time in its many configure scripts, however - // it also saturates the CPU for a consequential amount of time. - Flag: TExclusive, - }, &MakeHelper{ - Configure: append([]KV{ - {"disable-multilib"}, - {"enable-default-pie"}, - {"disable-nls"}, - {"with-gnu-as"}, - {"with-gnu-ld"}, - {"with-system-zlib"}, - {"enable-languages", "c,c++,go"}, - {"with-native-system-header-dir", "/system/include"}, - }, configureExtra...), - Make: []string{ - "BOOT_CFLAGS='-O2 -g'", - "bootstrap", - }, - - // This toolchain is hacked to pieces, it is not expected to ever work - // well in its current state. That does not matter as long as the - // toolchain it produces passes its own test suite. - SkipCheck: true, - }, - Binutils, - - MPC, - Zlib, - Libucontext, - KernelHeaders, - ), version -} -func init() { - native.MustRegister(&Artifact{ - f: Toolchain.newGCC, - - Name: "gcc", - Description: "The GNU Compiler Collection", - Website: "https://www.gnu.org/software/gcc/", - - Dependencies: P{ - Binutils, - - MPC, - Zlib, - Libucontext, - }, - - ID: 6502, - }) -} diff --git a/internal/rosa/package/gcc/musl-off64_t-loff_t.patch b/internal/rosa/package/gcc/musl-off64_t-loff_t.patch new file mode 100644 index 00000000..33a25a8d --- /dev/null +++ b/internal/rosa/package/gcc/musl-off64_t-loff_t.patch @@ -0,0 +1,16 @@ +diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c +index 180f5c31d74..44d7ea73f7d 100644 +--- a/libgo/sysinfo.c ++++ b/libgo/sysinfo.c +@@ -365,11 +365,7 @@ enum { + typedef loff_t libgo_loff_t_type; + #endif + +-#if defined(HAVE_OFF64_T) +-typedef off64_t libgo_off_t_type; +-#else + typedef off_t libgo_off_t_type; +-#endif + + // The following section introduces explicit references to types and + // constants of interest to support bootstrapping libgo using a diff --git a/internal/rosa/package/gcc/package.az b/internal/rosa/package/gcc/package.az new file mode 100644 index 00000000..ce59641f --- /dev/null +++ b/internal/rosa/package/gcc/package.az @@ -0,0 +1,87 @@ +package binutils { + description = "a collection of binary tools"; + website = "https://www.gnu.org/software/binutils"; + anitya = 7981; + + version* = "2.46.0"; + source = remoteTar { + url = "https://ftpmirror.gnu.org/gnu/binutils/binutils-"+version+".tar.bz2"; + checksum = "4kK1_EXQipxSqqyvwD4LbiMLFKCUApjq6PeG4XJP4dzxYGqDeqXfh8zLuTyOuOVR"; + compress = bzip2; + }; + + exec = make {}; + + inputs = [ bash ]; +} + +package gcc { + description = "The GNU Compiler Collection"; + website = "https://www.gnu.org/software/gcc"; + anitya = 6502; + + version* = "16.1.0"; + source = remoteTar { + url = "https://ftp.tsukuba.wide.ad.jp/software/gcc/releases/"+ + "gcc-"+version+"/gcc-"+version+".tar.gz"; + checksum = "4ASoWbxaA2FW7PAB0zzHDPC5XnNhyaAyjtDPpGzceSLeYnEIXsNYZR3PA_Zu5P0K"; + compress = gzip; + }; + patches = [ + "musl-off64_t-loff_t.patch", + "musl-legacy-lfs.patch", + ]; + + // GCC spends most of its time in its many configure scripts, however + // it also saturates the CPU for a consequential amount of time. + exclusive = true; + + early = ` +ln -s system/lib / +ln -s system/lib /work/ +`; + + exec = make { + configure = { + "disable-multilib"; + "enable-default-pie"; + "disable-nls"; + "with-gnu-as"; + "with-gnu-ld"; + "with-system-zlib"; + "enable-languages": "c,c++,go"; + "with-native-system-header-dir": "/system/include"; + + "with-multilib-list": arch { + amd64, arm64 = "''"; + }; + }; + + make = [ + "BOOT_CFLAGS='-O2 -g'", + "bootstrap", + ]; + + // This toolchain is hacked to pieces, it is not expected to ever work + // well in its current state. That does not matter as long as the + // toolchain it produces passes its own test suite. + skipCheck = true; + }; + + inputs = [ + binutils, + + mpc, + zlib, + libucontext, + kernel-headers, + ]; + + runtime = [ + binutils, + + mpc, + zlib, + libucontext, + ]; +}