Skip to content

Commit

Permalink
unix/linux: update to glibc 2.36
Browse files Browse the repository at this point in the history
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 <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Auto-Submit: Ian Lance Taylor <[email protected]>
  • Loading branch information
abner-chenc authored and gopherbot committed Jan 31, 2023
1 parent 4112509 commit 7a75290
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
10 changes: 2 additions & 8 deletions unix/linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion unix/linux/mkall.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 6 additions & 13 deletions unix/linux/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package unix
#define _GNU_SOURCE
#include <dirent.h>
#include <fcntl.h>
#include <poll.h>
#include <sched.h>
#include <signal.h>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions unix/zerrors_linux.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7a75290

Please sign in to comment.