Skip to content

Commit 8558bee

Browse files
committed
Add apply_patches function and initial patches
These patches are for two issues: * Enabling Go to build on Alpine by disabling PIC per: golang/go#6940 https://github.com/docker-library/golang/blob/master/1.7/alpine/no-pic.patch * Fixing Go 1.4 bug appearing on macOS 10.12.1 per: golang/go#16352 (comment)
1 parent f38923c commit 8558bee

File tree

9 files changed

+476
-0
lines changed

9 files changed

+476
-0
lines changed

patches/alpine/README.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
All no-pic patches were based upon:
2+
https://raw.githubusercontent.com/docker-library/golang/master/1.6/alpine/no-pic.patch
3+
https://raw.githubusercontent.com/docker-library/golang/master/1.7/alpine/no-pic.patch
4+
5+
go1.4/no-pic.patch was hand-crafted from the above, based upon:
6+
https://go.googlesource.com/go/+/go1.4.3/src/cmd/ld/lib.c

patches/alpine/go1.4/no-pic.patch

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/src/cmd/ld/lib.c b/src/cmd/ld/lib.c
2+
--- a/src/cmd/ld/lib.c
3+
+++ b/src/cmd/ld/lib.c
4+
@@ -692,6 +692,11 @@ hostlink(void) {
5+
p = strchr(p + 1, ' ');
6+
}
7+
8+
+ // The Go linker does not currently support building PIE
9+
+ // executables when using the external linker. See:
10+
+ // https://github.com/golang/go/issues/6940
11+
+ argv[argc++] = "-fno-PIC";
12+
+
13+
argv[argc] = nil;
14+
15+
quotefmtinstall();

patches/alpine/go1.5/no-pic.patch

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
2+
--- a/src/cmd/link/internal/ld/lib.go
3+
+++ b/src/cmd/link/internal/ld/lib.go
4+
@@ -1071,6 +1071,11 @@ func hostlink() {
5+
argv = append(argv, peimporteddlls()...)
6+
}
7+
8+
+ // The Go linker does not currently support building PIE
9+
+ // executables when using the external linker. See:
10+
+ // https://github.com/golang/go/issues/6940
11+
+ argv = append(argv, "-fno-PIC")
12+
+
13+
if Debug['v'] != 0 {
14+
fmt.Fprintf(&Bso, "host link:")
15+
for _, v := range argv {

patches/alpine/go1.6/no-pic.patch

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
2+
index 8ccbec9dd634..4e96bfadc260 100644
3+
--- a/src/cmd/link/internal/ld/lib.go
4+
+++ b/src/cmd/link/internal/ld/lib.go
5+
@@ -1194,6 +1194,11 @@ func hostlink() {
6+
argv = append(argv, peimporteddlls()...)
7+
}
8+
9+
+ // The Go linker does not currently support building PIE
10+
+ // executables when using the external linker. See:
11+
+ // https://github.com/golang/go/issues/6940
12+
+ argv = append(argv, "-fno-PIC")
13+
+
14+
if Debug['v'] != 0 {
15+
fmt.Fprintf(&Bso, "host link:")
16+
for _, v := range argv {

patches/alpine/go1.7/no-pic.patch

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
2+
index 14f4fa9..5599307 100644
3+
--- a/src/cmd/link/internal/ld/lib.go
4+
+++ b/src/cmd/link/internal/ld/lib.go
5+
@@ -1272,6 +1272,11 @@ func hostlink() {
6+
argv = append(argv, peimporteddlls()...)
7+
}
8+
9+
+ // The Go linker does not currently support building PIE
10+
+ // executables when using the external linker. See:
11+
+ // https://github.com/golang/go/issues/6940
12+
+ argv = append(argv, "-fno-PIC")
13+
+
14+
if Debug['v'] != 0 {
15+
fmt.Fprintf(Bso, "host link:")
16+
for _, v := range argv {

patches/alpine/go1.8/no-pic.patch

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
2+
index 14f4fa9..5599307 100644
3+
--- a/src/cmd/link/internal/ld/lib.go
4+
+++ b/src/cmd/link/internal/ld/lib.go
5+
@@ -1272,6 +1272,11 @@ func hostlink() {
6+
argv = append(argv, peimporteddlls()...)
7+
}
8+
9+
+ // The Go linker does not currently support building PIE
10+
+ // executables when using the external linker. See:
11+
+ // https://github.com/golang/go/issues/6940
12+
+ argv = append(argv, "-fno-PIC")
13+
+
14+
if Debug['v'] != 0 {
15+
fmt.Fprintf(Bso, "host link:")
16+
for _, v := range argv {

0 commit comments

Comments
 (0)