unix/linux: update to glibc 2.36

Support for LoongArch has been merged upstream. This allows to
drop the loong64 specific glibc patches.

Because the header file sys/mount.h of glibc 2.36 includes fcntl.h
(commit 78a408ee7ba041fc8d5dbd5f67065b4a982c11e5), this will leads to
duplicate definition of structure stat on MIPS64.  In order to solve
this error, use the custom type my_stat to generate the Go Stat_t.

Change-Id: I888280d777d1c7089548acf1b3821762011d79b0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/453555
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
This commit is contained in:
chenguoqi
2023-01-29 16:48:35 +08:00
committed by Gopher Robot
parent 4112509618
commit 7a75290698
4 changed files with 19 additions and 22 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -21,6 +21,7 @@ package unix
#define _GNU_SOURCE
#include <dirent.h>
#include <fcntl.h>
#include <poll.h>
#include <sched.h>
#include <signal.h>
@@ -50,6 +51,7 @@ package unix
#include <sys/timerfd.h>
#include <sys/times.h>
#include <sys/timex.h>
#include <sys/types.h>
#include <sys/un.h>
#include <sys/user.h>
#include <sys/utsname.h>
@@ -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 <linux/fcntl.h>
#include <linux/fadvise.h>
} my_stat;
#else
// Use the stat defined by glibc
#include <fcntl.h>
#include <sys/types.h>
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

View File

@@ -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