Skip to content

Commit ceb95ea

Browse files
committed
[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 #58884. Change-Id: I689c862ad360ca23153438f9e143a1cb840730e4 Reviewed-on: https://go-review.googlesource.com/c/go/+/514415 TryBot-Bypass: Russ Cox <[email protected]> Run-TryBot: Russ Cox <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent bdd4b95 commit ceb95ea

File tree

6 files changed

+24
-20
lines changed

6 files changed

+24
-20
lines changed

include/u.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ extern "C" {
8383
#ifdef _WIN32
8484
typedef jmp_buf sigjmp_buf;
8585
#endif
86-
typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
86+
typedef long p9jmp_buf[sizeof(sigjmp_buf)/(sizeof(long))];
8787

8888
#if defined(__linux__)
8989
# include <sys/types.h>

src/cmd/6c/txt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ gmove(Node *f, Node *t)
992992
f->vconst &= 0xffff;
993993
if(f->vconst & 0x8000){
994994
f->vconst |= 0xffff0000;
995-
f->vconst |= (vlong)~0 << 32;
995+
f->vconst |= (vlong)((~(uvlong)0) << 32);
996996
}
997997
a = AMOVL;
998998
}
@@ -1042,7 +1042,7 @@ gmove(Node *f, Node *t)
10421042
f->vconst &= 0xff;
10431043
if(f->vconst & 0x80){
10441044
f->vconst |= 0xffffff00;
1045-
f->vconst |= (vlong)~0 << 32;
1045+
f->vconst |= (vlong)((~(uvlong)0) << 32);
10461046
}
10471047
a = AMOVQ;
10481048
}

src/cmd/6g/peep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ copyu(Prog *p, Adr *v, Adr *s)
768768
return 3;
769769

770770
case ACALL:
771-
if(REGEXT && v->type <= REGEXT && v->type > exregoffset)
771+
if(REGEXT != 0 && v->type <= REGEXT && v->type > exregoffset)
772772
return 2;
773773
if(REGARG >= 0 && v->type == (uchar)REGARG)
774774
return 2;

src/cmd/dist/build.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,16 @@ static char *proto_gccargs[] = {
475475
"-Wstrict-prototypes",
476476
"-Wextra",
477477
"-Wunused",
478+
"-Wno-unknown-warning-option",
478479
"-Wno-sign-compare",
479480
"-Wno-missing-braces",
480481
"-Wno-parentheses",
481482
"-Wno-unknown-pragmas",
482483
"-Wno-switch",
483484
"-Wno-comment",
484485
"-Wno-missing-field-initializers",
486+
"-Wno-implicit-fallthrough",
487+
"-Wno-stringop-truncation",
485488
"-fno-common",
486489
"-ggdb",
487490
"-pipe",

src/cmd/ld/dwarf.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ addrput(vlong addr)
8686
}
8787

8888
static int
89-
uleb128enc(uvlong v, char* dst)
89+
uleb128enc(uvlong v, uchar* dst)
9090
{
9191
uint8 c, len;
9292

@@ -104,7 +104,7 @@ uleb128enc(uvlong v, char* dst)
104104
};
105105

106106
static int
107-
sleb128enc(vlong v, char *dst)
107+
sleb128enc(vlong v, uchar *dst)
108108
{
109109
uint8 c, s, len;
110110

@@ -125,15 +125,15 @@ sleb128enc(vlong v, char *dst)
125125
static void
126126
uleb128put(vlong v)
127127
{
128-
char buf[10];
129-
strnput(buf, uleb128enc(v, buf));
128+
uchar buf[10];
129+
strnput((char*)buf, uleb128enc(v, buf));
130130
}
131131

132132
static void
133133
sleb128put(vlong v)
134134
{
135-
char buf[10];
136-
strnput(buf, sleb128enc(v, buf));
135+
uchar buf[10];
136+
strnput((char*)buf, sleb128enc(v, buf));
137137
}
138138

139139
/*
@@ -854,7 +854,7 @@ reversetree(DWDie** list)
854854
static void
855855
newmemberoffsetattr(DWDie *die, int32 offs)
856856
{
857-
char block[10];
857+
uchar block[10];
858858
int i;
859859

860860
i = 0;
@@ -1471,7 +1471,7 @@ putpclcdelta(vlong delta_pc, vlong delta_lc)
14711471
static void
14721472
newcfaoffsetattr(DWDie *die, int32 offs)
14731473
{
1474-
char block[10];
1474+
uchar block[10];
14751475
int i;
14761476

14771477
i = 0;
@@ -1760,7 +1760,7 @@ writeframes(void)
17601760
uleb128put(DWARFREGSP); // register SP (**ABI-dependent, defined in l.h)
17611761
uleb128put(PtrSize); // offset
17621762

1763-
cput(DW_CFA_offset + FAKERETURNCOLUMN); // return address
1763+
cput((char)(DW_CFA_offset + FAKERETURNCOLUMN)); // return address
17641764
uleb128put(-PtrSize / DATAALIGNMENTFACTOR); // at cfa - x*4
17651765

17661766
// 4 is to exclude the length field.

src/liblink/asm5.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static Optab optab[] =
298298
{ ASTREXD, C_SOREG,C_REG, C_REG, 92, 4, 0 },
299299

300300
{ APLD, C_SOREG,C_NONE, C_NONE, 95, 4, 0 },
301-
301+
302302
{ AUNDEF, C_NONE, C_NONE, C_NONE, 96, 4, 0 },
303303

304304
{ ACLZ, C_REG, C_NONE, C_REG, 97, 4, 0 },
@@ -644,11 +644,12 @@ span5(Link *ctxt, LSym *cursym)
644644
int m, bflag, i, v, times;
645645
int32 c, opc, out[6+3];
646646
uchar *bp;
647+
int debug = 0;
647648

648649
p = cursym->text;
649650
if(p == nil || p->link == nil) // handle external functions and ELF section symbols
650651
return;
651-
652+
652653
if(oprange[AAND].start == nil)
653654
buildop(ctxt);
654655

@@ -758,7 +759,7 @@ span5(Link *ctxt, LSym *cursym)
758759
m = asmoutnacl(ctxt, c, p, o, nil);
759760
if(p->pc != opc) {
760761
bflag = 1;
761-
//print("%P pc changed %d to %d in iter. %d\n", p, opc, (int32)p->pc, times);
762+
if(debug) print("%P pc changed %d to %d in iter. %d\n", p, opc, (int32)p->pc, times);
762763
}
763764
c = p->pc + m;
764765
if(m % 4 != 0 || p->pc % 4 != 0) {
@@ -912,7 +913,7 @@ addpool(Link *ctxt, Prog *p, Addr *a)
912913
t.to.sym = a->sym;
913914
t.to.type = a->type;
914915
t.to.name = a->name;
915-
916+
916917
if(ctxt->flag_shared && t.to.sym != nil)
917918
t.pcrel = p;
918919
break;
@@ -1639,7 +1640,7 @@ if(0 /*debug['G']*/) print("%ux: %s: arm %d\n", (uint32)(p->pc), p->from.sym->na
16391640
rel->siz = 4;
16401641
rel->sym = p->to.sym;
16411642
rel->add = p->to.offset;
1642-
1643+
16431644
// runtime.tlsg is special.
16441645
// Its "address" is the offset from the TLS thread pointer
16451646
// 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
18291830
o1 |= p->to.reg << 16;
18301831
aclass(ctxt, &p->to);
18311832
break;
1832-
1833+
18331834
case 39: /* movm oreg,$con -> ldm */
18341835
o1 = (0x4 << 25) | (1 << 20);
18351836
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
23052306
o1 = 0xe125be70;
23062307
break;
23072308
}
2308-
2309+
23092310
out[0] = o1;
23102311
out[1] = o2;
23112312
out[2] = o3;

0 commit comments

Comments
 (0)