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

View File

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

View File

@ -768,7 +768,7 @@ copyu(Prog *p, Adr *v, Adr *s)
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;

View File

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

View File

@ -86,7 +86,7 @@ addrput(vlong addr)
}
static int
uleb128enc(uvlong v, char* dst)
uleb128enc(uvlong v, uchar* dst)
{
uint8 c, len;
@ -104,7 +104,7 @@ uleb128enc(uvlong v, char* dst)
};
static int
sleb128enc(vlong v, char *dst)
sleb128enc(vlong v, uchar *dst)
{
uint8 c, s, len;
@ -125,15 +125,15 @@ sleb128enc(vlong v, char *dst)
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 @@ reversetree(DWDie** list)
static void
newmemberoffsetattr(DWDie *die, int32 offs)
{
char block[10];
uchar block[10];
int i;
i = 0;
@ -1471,7 +1471,7 @@ putpclcdelta(vlong delta_pc, vlong delta_lc)
static void
newcfaoffsetattr(DWDie *die, int32 offs)
{
char block[10];
uchar block[10];
int i;
i = 0;
@ -1760,7 +1760,7 @@ writeframes(void)
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.

View File

@ -644,6 +644,7 @@ span5(Link *ctxt, LSym *cursym)
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
@ -758,7 +759,7 @@ span5(Link *ctxt, LSym *cursym)
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) {