[release-branch.go1.4] all: fixes for modern compilers
This makes make.bash pass without any warnings for
$ clang --version
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ gcc --version
gcc (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$
The change in src/liblink/asm5.c silences a warning building
on modern macOS, which doesn't actually produce a working
toolchain anyway, but it still seems worth silencing the warning.
These warnings surface now in the reproducible builds reports
(for example https://gorebuild.storage.googleapis.com/gorebuild.html,
click on "Bootstrap go1.4"). I'd rather not look at them anymore.
For golang/go#58884.
Change-Id: I689c862ad360ca23153438f9e143a1cb840730e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/514415
TryBot-Bypass: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
diff --git a/include/u.h b/include/u.h
index 489b2a3..64f1a9b 100644
--- a/include/u.h
+++ b/include/u.h
@@ -83,7 +83,7 @@
#ifdef _WIN32
typedef jmp_buf sigjmp_buf;
#endif
-typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
+typedef long p9jmp_buf[sizeof(sigjmp_buf)/(sizeof(long))];
#if defined(__linux__)
# include <sys/types.h>
diff --git a/src/cmd/6c/txt.c b/src/cmd/6c/txt.c
index 3bdbf41..8008512 100644
--- a/src/cmd/6c/txt.c
+++ b/src/cmd/6c/txt.c
@@ -992,7 +992,7 @@
f->vconst &= 0xffff;
if(f->vconst & 0x8000){
f->vconst |= 0xffff0000;
- f->vconst |= (vlong)~0 << 32;
+ f->vconst |= (vlong)((~(uvlong)0) << 32);
}
a = AMOVL;
}
@@ -1042,7 +1042,7 @@
f->vconst &= 0xff;
if(f->vconst & 0x80){
f->vconst |= 0xffffff00;
- f->vconst |= (vlong)~0 << 32;
+ f->vconst |= (vlong)((~(uvlong)0) << 32);
}
a = AMOVQ;
}
diff --git a/src/cmd/6g/peep.c b/src/cmd/6g/peep.c
index 2461783..deed9d2 100644
--- a/src/cmd/6g/peep.c
+++ b/src/cmd/6g/peep.c
@@ -768,7 +768,7 @@
return 3;
case ACALL:
- if(REGEXT && v->type <= REGEXT && v->type > exregoffset)
+ if(REGEXT != 0 && v->type <= REGEXT && v->type > exregoffset)
return 2;
if(REGARG >= 0 && v->type == (uchar)REGARG)
return 2;
diff --git a/src/cmd/dist/build.c b/src/cmd/dist/build.c
index 8d82167..614989b 100644
--- a/src/cmd/dist/build.c
+++ b/src/cmd/dist/build.c
@@ -475,6 +475,7 @@
"-Wstrict-prototypes",
"-Wextra",
"-Wunused",
+ "-Wno-unknown-warning-option",
"-Wno-sign-compare",
"-Wno-missing-braces",
"-Wno-parentheses",
@@ -482,6 +483,8 @@
"-Wno-switch",
"-Wno-comment",
"-Wno-missing-field-initializers",
+ "-Wno-implicit-fallthrough",
+ "-Wno-stringop-truncation",
"-fno-common",
"-ggdb",
"-pipe",
diff --git a/src/cmd/ld/dwarf.c b/src/cmd/ld/dwarf.c
index dfe515c..15db46c 100644
--- a/src/cmd/ld/dwarf.c
+++ b/src/cmd/ld/dwarf.c
@@ -86,7 +86,7 @@
}
static int
-uleb128enc(uvlong v, char* dst)
+uleb128enc(uvlong v, uchar* dst)
{
uint8 c, len;
@@ -104,7 +104,7 @@
};
static int
-sleb128enc(vlong v, char *dst)
+sleb128enc(vlong v, uchar *dst)
{
uint8 c, s, len;
@@ -125,15 +125,15 @@
static void
uleb128put(vlong v)
{
- char buf[10];
- strnput(buf, uleb128enc(v, buf));
+ uchar buf[10];
+ strnput((char*)buf, uleb128enc(v, buf));
}
static void
sleb128put(vlong v)
{
- char buf[10];
- strnput(buf, sleb128enc(v, buf));
+ uchar buf[10];
+ strnput((char*)buf, sleb128enc(v, buf));
}
/*
@@ -854,7 +854,7 @@
static void
newmemberoffsetattr(DWDie *die, int32 offs)
{
- char block[10];
+ uchar block[10];
int i;
i = 0;
@@ -1471,7 +1471,7 @@
static void
newcfaoffsetattr(DWDie *die, int32 offs)
{
- char block[10];
+ uchar block[10];
int i;
i = 0;
@@ -1760,7 +1760,7 @@
uleb128put(DWARFREGSP); // register SP (**ABI-dependent, defined in l.h)
uleb128put(PtrSize); // offset
- cput(DW_CFA_offset + FAKERETURNCOLUMN); // return address
+ cput((char)(DW_CFA_offset + FAKERETURNCOLUMN)); // return address
uleb128put(-PtrSize / DATAALIGNMENTFACTOR); // at cfa - x*4
// 4 is to exclude the length field.
diff --git a/src/liblink/asm5.c b/src/liblink/asm5.c
index 96df9f7..b8aff1a 100644
--- a/src/liblink/asm5.c
+++ b/src/liblink/asm5.c
@@ -298,7 +298,7 @@
{ ASTREXD, C_SOREG,C_REG, C_REG, 92, 4, 0 },
{ APLD, C_SOREG,C_NONE, C_NONE, 95, 4, 0 },
-
+
{ AUNDEF, C_NONE, C_NONE, C_NONE, 96, 4, 0 },
{ ACLZ, C_REG, C_NONE, C_REG, 97, 4, 0 },
@@ -644,11 +644,12 @@
int m, bflag, i, v, times;
int32 c, opc, out[6+3];
uchar *bp;
+ int debug = 0;
p = cursym->text;
if(p == nil || p->link == nil) // handle external functions and ELF section symbols
return;
-
+
if(oprange[AAND].start == nil)
buildop(ctxt);
@@ -758,7 +759,7 @@
m = asmoutnacl(ctxt, c, p, o, nil);
if(p->pc != opc) {
bflag = 1;
- //print("%P pc changed %d to %d in iter. %d\n", p, opc, (int32)p->pc, times);
+ if(debug) print("%P pc changed %d to %d in iter. %d\n", p, opc, (int32)p->pc, times);
}
c = p->pc + m;
if(m % 4 != 0 || p->pc % 4 != 0) {
@@ -912,7 +913,7 @@
t.to.sym = a->sym;
t.to.type = a->type;
t.to.name = a->name;
-
+
if(ctxt->flag_shared && t.to.sym != nil)
t.pcrel = p;
break;
@@ -1639,7 +1640,7 @@
rel->siz = 4;
rel->sym = p->to.sym;
rel->add = p->to.offset;
-
+
// runtime.tlsg is special.
// Its "address" is the offset from the TLS thread pointer
// to the thread-local g and m pointers.
@@ -1829,7 +1830,7 @@
o1 |= p->to.reg << 16;
aclass(ctxt, &p->to);
break;
-
+
case 39: /* movm oreg,$con -> ldm */
o1 = (0x4 << 25) | (1 << 20);
o1 |= p->to.offset & 0xffff;
@@ -2305,7 +2306,7 @@
o1 = 0xe125be70;
break;
}
-
+
out[0] = o1;
out[1] = o2;
out[2] = o3;