Skip to content

Commit 3aacfce

Browse files
Clément Chigotianlancetaylor
authored andcommitted
runtime, cmd/dist, misc/cgo: enable c-archive for aix/ppc64
Change-Id: Ib9a40d5596f5735a00483e2d2db965402f05671b Reviewed-on: https://go-review.googlesource.com/c/go/+/169120 Run-TryBot: Tobias Klauser <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 5651721 commit 3aacfce

16 files changed

+50
-14
lines changed

misc/cgo/testcarchive/carchive_test.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ func testMain(m *testing.M) int {
110110
// TODO(crawshaw): can we do better?
111111
cc = append(cc, []string{"-framework", "CoreFoundation", "-framework", "Foundation"}...)
112112
}
113+
if GOOS == "aix" {
114+
// -Wl,-bnoobjreorder is mandatory to keep the same layout
115+
// in .text section.
116+
cc = append(cc, "-Wl,-bnoobjreorder")
117+
}
113118
libbase := GOOS + "_" + GOARCH
114119
if runtime.Compiler == "gccgo" {
115120
libbase = "gccgo_" + libgodir + "_fPIC"
@@ -318,7 +323,7 @@ func TestSignalForwarding(t *testing.T) {
318323
}
319324

320325
func TestSignalForwardingExternal(t *testing.T) {
321-
if GOOS == "freebsd" {
326+
if GOOS == "freebsd" || GOOS == "aix" {
322327
t.Skipf("skipping on %s/%s; signal always goes to the Go runtime", GOOS, GOARCH)
323328
}
324329
checkSignalForwardingTest(t)
@@ -594,13 +599,15 @@ func TestPIE(t *testing.T) {
594599
t.Fatal(err)
595600
}
596601

597-
f, err := elf.Open("testp" + exeSuffix)
598-
if err != nil {
599-
t.Fatal("elf.Open failed: ", err)
600-
}
601-
defer f.Close()
602-
if hasDynTag(t, f, elf.DT_TEXTREL) {
603-
t.Errorf("%s has DT_TEXTREL flag", "testp"+exeSuffix)
602+
if GOOS != "aix" {
603+
f, err := elf.Open("testp" + exeSuffix)
604+
if err != nil {
605+
t.Fatal("elf.Open failed: ", err)
606+
}
607+
defer f.Close()
608+
if hasDynTag(t, f, elf.DT_TEXTREL) {
609+
t.Errorf("%s has DT_TEXTREL flag", "testp"+exeSuffix)
610+
}
604611
}
605612
}
606613

misc/cgo/testcarchive/testdata/main4.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414

1515
#include "libgo4.h"
1616

17+
#ifdef _AIX
18+
// On AIX, CSIGSTKSZ is too small to handle Go sighandler.
19+
#define CSIGSTKSZ 0x4000
20+
#else
21+
#define CSIGSTKSZ SIGSTKSZ
22+
#endif
23+
1724
static void die(const char* msg) {
1825
perror(msg);
1926
exit(EXIT_FAILURE);
@@ -53,12 +60,12 @@ static void* thread1(void* arg __attribute__ ((unused))) {
5360

5461
// Set up an alternate signal stack for this thread.
5562
memset(&ss, 0, sizeof ss);
56-
ss.ss_sp = malloc(SIGSTKSZ);
63+
ss.ss_sp = malloc(CSIGSTKSZ);
5764
if (ss.ss_sp == NULL) {
5865
die("malloc");
5966
}
6067
ss.ss_flags = 0;
61-
ss.ss_size = SIGSTKSZ;
68+
ss.ss_size = CSIGSTKSZ;
6269
if (sigaltstack(&ss, NULL) < 0) {
6370
die("sigaltstack");
6471
}
@@ -112,12 +119,12 @@ static void* thread2(void* arg __attribute__ ((unused))) {
112119

113120
// Set up an alternate signal stack for this thread.
114121
memset(&ss, 0, sizeof ss);
115-
ss.ss_sp = malloc(SIGSTKSZ);
122+
ss.ss_sp = malloc(CSIGSTKSZ);
116123
if (ss.ss_sp == NULL) {
117124
die("malloc");
118125
}
119126
ss.ss_flags = 0;
120-
ss.ss_size = SIGSTKSZ;
127+
ss.ss_size = CSIGSTKSZ;
121128
if (sigaltstack(&ss, NULL) < 0) {
122129
die("sigaltstack");
123130
}

misc/cgo/testcarchive/testdata/main5.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
#include "libgo2.h"
1616

17+
int *nilp;
18+
1719
int main(int argc, char** argv) {
1820
int verbose;
1921
int test;
@@ -39,7 +41,7 @@ int main(int argc, char** argv) {
3941
printf("attempting segfault\n");
4042
}
4143

42-
volatile int crash = *(int *) 0;
44+
*nilp = 0;
4345
break;
4446
}
4547

src/cmd/dist/test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,8 @@ func (t *tester) supportedBuildmode(mode string) bool {
928928
return false
929929
}
930930
switch pair {
931-
case "darwin-386", "darwin-amd64", "darwin-arm", "darwin-arm64",
931+
case "aix-ppc64",
932+
"darwin-386", "darwin-amd64", "darwin-arm", "darwin-arm64",
932933
"linux-amd64", "linux-386", "linux-ppc64le", "linux-s390x",
933934
"freebsd-amd64",
934935
"windows-amd64", "windows-386":

src/runtime/os3_solaris.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ func sigdelset(mask *sigset, i int) {
273273
mask.__sigbits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
274274
}
275275

276+
//go:nosplit
276277
func (c *sigctxt) fixsigcode(sig uint32) {
277278
}
278279

src/runtime/os_aix.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,15 @@ func setSignalstackSP(s *stackt, sp uintptr) {
296296
*(*uintptr)(unsafe.Pointer(&s.ss_sp)) = sp
297297
}
298298

299+
//go:nosplit
299300
func (c *sigctxt) fixsigcode(sig uint32) {
301+
switch sig {
302+
case _SIGPIPE:
303+
// For SIGPIPE, c.sigcode() isn't set to _SI_USER as on Linux.
304+
// Therefore, raisebadsignal won't raise SIGPIPE again if
305+
// it was deliver in a non-Go thread.
306+
c.set_sigcode(_SI_USER)
307+
}
300308
}
301309

302310
//go:nosplit

src/runtime/os_dragonfly.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ func sigdelset(mask *sigset, i int) {
252252
mask.__bits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
253253
}
254254

255+
//go:nosplit
255256
func (c *sigctxt) fixsigcode(sig uint32) {
256257
}
257258

src/runtime/os_freebsd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ func sigdelset(mask *sigset, i int) {
365365
mask.__bits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
366366
}
367367

368+
//go:nosplit
368369
func (c *sigctxt) fixsigcode(sig uint32) {
369370
}
370371

src/runtime/os_linux.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ func setSignalstackSP(s *stackt, sp uintptr) {
395395
*(*uintptr)(unsafe.Pointer(&s.ss_sp)) = sp
396396
}
397397

398+
//go:nosplit
398399
func (c *sigctxt) fixsigcode(sig uint32) {
399400
}
400401

src/runtime/os_netbsd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ func sigdelset(mask *sigset, i int) {
328328
mask.__bits[(i-1)/32] &^= 1 << ((uint32(i) - 1) & 31)
329329
}
330330

331+
//go:nosplit
331332
func (c *sigctxt) fixsigcode(sig uint32) {
332333
}
333334

0 commit comments

Comments
 (0)