diff --git a/unix/linux/Dockerfile b/unix/linux/Dockerfile index 59c2ada14..76aa8374c 100644 --- a/unix/linux/Dockerfile +++ b/unix/linux/Dockerfile @@ -17,14 +17,8 @@ WORKDIR /git RUN git config --global advice.detachedHead false # Linux Kernel: Released 11 Dec 2022 RUN git clone --branch v6.1 --depth 1 https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux -# GNU C library: Released 03 Feb 2022 -RUN git clone --branch release/2.35/master --depth 1 https://sourceware.org/git/glibc.git - -# Only for loong64, add kernel and glibc patch -RUN git clone https://github.com/loongson/golang-infra.git /git/loong64-patches \ - && git config --global user.name "golang" && git config --global user.email "golang@localhost" \ - && cd /git/loong64-patches && git checkout glibc-v2.35 && cd /git/glibc && git am /git/loong64-patches/*.patch \ - && curl -fsSL https://git.savannah.gnu.org/cgit/config.git/plain/config.sub -o /git/glibc/scripts/config.sub +# GNU C library: Released 30 Jul 2022 +RUN git clone --branch release/2.36/master --depth 1 https://sourceware.org/git/glibc.git # Get Go ENV GOLANG_VERSION 1.20rc2 diff --git a/unix/linux/mkall.go b/unix/linux/mkall.go index 8c773d93d..f849e1a48 100644 --- a/unix/linux/mkall.go +++ b/unix/linux/mkall.go @@ -411,7 +411,16 @@ func (t *target) makeHeaders() error { // Make the glibc headers we need for this architecture confScript := filepath.Join(GlibcDir, "configure") - glibcConf := t.makeCommand(confScript, "--prefix="+filepath.Join(TempDir, t.GoArch), "--host="+t.GNUArch, "--enable-kernel="+MinKernel) + glibcArgs := []string{"--prefix=" + filepath.Join(TempDir, t.GoArch), "--host=" + t.GNUArch} + if t.LinuxArch == "loongarch" { + // The minimum version requirement of the Loongarch for the kernel in glibc + // is 5.19, if --enable-kernel is less than 5.19, glibc handles errors + glibcArgs = append(glibcArgs, "--enable-kernel=5.19.0") + } else { + glibcArgs = append(glibcArgs, "--enable-kernel="+MinKernel) + } + glibcConf := t.makeCommand(confScript, glibcArgs...) + glibcConf.Dir = buildDir if err := glibcConf.Run(); err != nil { return err diff --git a/unix/linux/types.go b/unix/linux/types.go index f24909e7e..3855ce3c2 100644 --- a/unix/linux/types.go +++ b/unix/linux/types.go @@ -21,6 +21,7 @@ package unix #define _GNU_SOURCE #include +#include #include #include #include @@ -50,6 +51,7 @@ package unix #include #include #include +#include #include #include #include @@ -156,7 +158,7 @@ struct termios2 { // struct (like st_atim) for consistency with the glibc fields. // * The padding fields get different names to not break compatibility. // * st_blocks is signed, again for compatibility. -struct stat { +typedef struct { unsigned int st_dev; unsigned int st_pad1[3]; // Reserved for st_dev expansion @@ -183,18 +185,9 @@ struct stat { unsigned int st_pad4; long st_blocks; -}; - -// These are needed because we do not include fcntl.h or sys/types.h -#include -#include - +} my_stat; #else - -// Use the stat defined by glibc -#include -#include - +typedef struct stat my_stat; #endif // These are defined in linux/fcntl.h, but including it globally causes @@ -510,7 +503,7 @@ type _Gid_t C.gid_t // Files -type Stat_t C.struct_stat +type Stat_t C.my_stat type StatxTimestamp C.struct_statx_timestamp diff --git a/unix/zerrors_linux.go b/unix/zerrors_linux.go index 35de885cf..e174685ad 100644 --- a/unix/zerrors_linux.go +++ b/unix/zerrors_linux.go @@ -1814,6 +1814,7 @@ const ( MADV_DONTDUMP = 0x10 MADV_DONTFORK = 0xa MADV_DONTNEED = 0x4 + MADV_DONTNEED_LOCKED = 0x18 MADV_FREE = 0x8 MADV_HUGEPAGE = 0xe MADV_HWPOISON = 0x64