[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>
This commit is contained in:
Russ Cox 2023-07-31 12:30:43 -04:00
parent bdd4b9503e
commit ceb95ea6ae
6 changed files with 24 additions and 20 deletions

View File

@ -83,7 +83,7 @@ extern "C" {
#ifdef _WIN32 #ifdef _WIN32
typedef jmp_buf sigjmp_buf; typedef jmp_buf sigjmp_buf;
#endif #endif
typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)]; typedef long p9jmp_buf[sizeof(sigjmp_buf)/(sizeof(long))];
#if defined(__linux__) #if defined(__linux__)
# include <sys/types.h> # include <sys/types.h>

View File

@ -992,7 +992,7 @@ gmove(Node *f, Node *t)
f->vconst &= 0xffff; f->vconst &= 0xffff;
if(f->vconst & 0x8000){ if(f->vconst & 0x8000){
f->vconst |= 0xffff0000; f->vconst |= 0xffff0000;
f->vconst |= (vlong)~0 << 32; f->vconst |= (vlong)((~(uvlong)0) << 32);
} }
a = AMOVL; a = AMOVL;
} }
@ -1042,7 +1042,7 @@ gmove(Node *f, Node *t)
f->vconst &= 0xff; f->vconst &= 0xff;
if(f->vconst & 0x80){ if(f->vconst & 0x80){
f->vconst |= 0xffffff00; f->vconst |= 0xffffff00;
f->vconst |= (vlong)~0 << 32; f->vconst |= (vlong)((~(uvlong)0) << 32);
} }
a = AMOVQ; a = AMOVQ;
} }

View File

@ -768,7 +768,7 @@ copyu(Prog *p, Adr *v, Adr *s)
return 3; return 3;
case ACALL: case ACALL:
if(REGEXT && v->type <= REGEXT && v->type > exregoffset) if(REGEXT != 0 && v->type <= REGEXT && v->type > exregoffset)
return 2; return 2;
if(REGARG >= 0 && v->type == (uchar)REGARG) if(REGARG >= 0 && v->type == (uchar)REGARG)
return 2; return 2;

View File

@ -475,6 +475,7 @@ static char *proto_gccargs[] = {
"-Wstrict-prototypes", "-Wstrict-prototypes",
"-Wextra", "-Wextra",
"-Wunused", "-Wunused",
"-Wno-unknown-warning-option",
"-Wno-sign-compare", "-Wno-sign-compare",
"-Wno-missing-braces", "-Wno-missing-braces",
"-Wno-parentheses", "-Wno-parentheses",
@ -482,6 +483,8 @@ static char *proto_gccargs[] = {
"-Wno-switch", "-Wno-switch",
"-Wno-comment", "-Wno-comment",
"-Wno-missing-field-initializers", "-Wno-missing-field-initializers",
"-Wno-implicit-fallthrough",
"-Wno-stringop-truncation",
"-fno-common", "-fno-common",
"-ggdb", "-ggdb",
"-pipe", "-pipe",

View File

@ -86,7 +86,7 @@ addrput(vlong addr)
} }
static int static int
uleb128enc(uvlong v, char* dst) uleb128enc(uvlong v, uchar* dst)
{ {
uint8 c, len; uint8 c, len;
@ -104,7 +104,7 @@ uleb128enc(uvlong v, char* dst)
}; };
static int static int
sleb128enc(vlong v, char *dst) sleb128enc(vlong v, uchar *dst)
{ {
uint8 c, s, len; uint8 c, s, len;
@ -125,15 +125,15 @@ sleb128enc(vlong v, char *dst)
static void static void
uleb128put(vlong v) uleb128put(vlong v)
{ {
char buf[10]; uchar buf[10];
strnput(buf, uleb128enc(v, buf)); strnput((char*)buf, uleb128enc(v, buf));
} }
static void static void
sleb128put(vlong v) sleb128put(vlong v)
{ {
char buf[10]; uchar buf[10];
strnput(buf, sleb128enc(v, buf)); strnput((char*)buf, sleb128enc(v, buf));
} }
/* /*
@ -854,7 +854,7 @@ reversetree(DWDie** list)
static void static void
newmemberoffsetattr(DWDie *die, int32 offs) newmemberoffsetattr(DWDie *die, int32 offs)
{ {
char block[10]; uchar block[10];
int i; int i;
i = 0; i = 0;
@ -1471,7 +1471,7 @@ putpclcdelta(vlong delta_pc, vlong delta_lc)
static void static void
newcfaoffsetattr(DWDie *die, int32 offs) newcfaoffsetattr(DWDie *die, int32 offs)
{ {
char block[10]; uchar block[10];
int i; int i;
i = 0; i = 0;
@ -1760,7 +1760,7 @@ writeframes(void)
uleb128put(DWARFREGSP); // register SP (**ABI-dependent, defined in l.h) uleb128put(DWARFREGSP); // register SP (**ABI-dependent, defined in l.h)
uleb128put(PtrSize); // offset 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 uleb128put(-PtrSize / DATAALIGNMENTFACTOR); // at cfa - x*4
// 4 is to exclude the length field. // 4 is to exclude the length field.

View File

@ -298,7 +298,7 @@ static Optab optab[] =
{ ASTREXD, C_SOREG,C_REG, C_REG, 92, 4, 0 }, { ASTREXD, C_SOREG,C_REG, C_REG, 92, 4, 0 },
{ APLD, C_SOREG,C_NONE, C_NONE, 95, 4, 0 }, { APLD, C_SOREG,C_NONE, C_NONE, 95, 4, 0 },
{ AUNDEF, C_NONE, C_NONE, C_NONE, 96, 4, 0 }, { AUNDEF, C_NONE, C_NONE, C_NONE, 96, 4, 0 },
{ ACLZ, C_REG, C_NONE, C_REG, 97, 4, 0 }, { ACLZ, C_REG, C_NONE, C_REG, 97, 4, 0 },
@ -644,11 +644,12 @@ span5(Link *ctxt, LSym *cursym)
int m, bflag, i, v, times; int m, bflag, i, v, times;
int32 c, opc, out[6+3]; int32 c, opc, out[6+3];
uchar *bp; uchar *bp;
int debug = 0;
p = cursym->text; p = cursym->text;
if(p == nil || p->link == nil) // handle external functions and ELF section symbols if(p == nil || p->link == nil) // handle external functions and ELF section symbols
return; return;
if(oprange[AAND].start == nil) if(oprange[AAND].start == nil)
buildop(ctxt); buildop(ctxt);
@ -758,7 +759,7 @@ span5(Link *ctxt, LSym *cursym)
m = asmoutnacl(ctxt, c, p, o, nil); m = asmoutnacl(ctxt, c, p, o, nil);
if(p->pc != opc) { if(p->pc != opc) {
bflag = 1; 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; c = p->pc + m;
if(m % 4 != 0 || p->pc % 4 != 0) { if(m % 4 != 0 || p->pc % 4 != 0) {
@ -912,7 +913,7 @@ addpool(Link *ctxt, Prog *p, Addr *a)
t.to.sym = a->sym; t.to.sym = a->sym;
t.to.type = a->type; t.to.type = a->type;
t.to.name = a->name; t.to.name = a->name;
if(ctxt->flag_shared && t.to.sym != nil) if(ctxt->flag_shared && t.to.sym != nil)
t.pcrel = p; t.pcrel = p;
break; break;
@ -1639,7 +1640,7 @@ if(0 /*debug['G']*/) print("%ux: %s: arm %d\n", (uint32)(p->pc), p->from.sym->na
rel->siz = 4; rel->siz = 4;
rel->sym = p->to.sym; rel->sym = p->to.sym;
rel->add = p->to.offset; rel->add = p->to.offset;
// runtime.tlsg is special. // runtime.tlsg is special.
// Its "address" is the offset from the TLS thread pointer // Its "address" is the offset from the TLS thread pointer
// to the thread-local g and m pointers. // to the thread-local g and m pointers.
@ -1829,7 +1830,7 @@ if(0 /*debug['G']*/) print("%ux: %s: arm %d\n", (uint32)(p->pc), p->from.sym->na
o1 |= p->to.reg << 16; o1 |= p->to.reg << 16;
aclass(ctxt, &p->to); aclass(ctxt, &p->to);
break; break;
case 39: /* movm oreg,$con -> ldm */ case 39: /* movm oreg,$con -> ldm */
o1 = (0x4 << 25) | (1 << 20); o1 = (0x4 << 25) | (1 << 20);
o1 |= p->to.offset & 0xffff; o1 |= p->to.offset & 0xffff;
@ -2305,7 +2306,7 @@ if(0 /*debug['G']*/) print("%ux: %s: arm %d\n", (uint32)(p->pc), p->from.sym->na
o1 = 0xe125be70; o1 = 0xe125be70;
break; break;
} }
out[0] = o1; out[0] = o1;
out[1] = o2; out[1] = o2;
out[2] = o3; out[2] = o3;