Skip to content

Commit

Permalink
Add apply_patches function and initial patches
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
mbland committed Dec 11, 2016
1 parent f38923c commit 8558bee
Show file tree
Hide file tree
Showing 9 changed files with 476 additions and 0 deletions.
6 changes: 6 additions & 0 deletions patches/alpine/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
All no-pic patches were based upon:
https://raw.githubusercontent.com/docker-library/golang/master/1.6/alpine/no-pic.patch
https://raw.githubusercontent.com/docker-library/golang/master/1.7/alpine/no-pic.patch

go1.4/no-pic.patch was hand-crafted from the above, based upon:
https://go.googlesource.com/go/+/go1.4.3/src/cmd/ld/lib.c
15 changes: 15 additions & 0 deletions patches/alpine/go1.4/no-pic.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/src/cmd/ld/lib.c b/src/cmd/ld/lib.c
--- a/src/cmd/ld/lib.c
+++ b/src/cmd/ld/lib.c
@@ -692,6 +692,11 @@ hostlink(void) {
p = strchr(p + 1, ' ');
}

+ // The Go linker does not currently support building PIE
+ // executables when using the external linker. See:
+ // https://github.com/golang/go/issues/6940
+ argv[argc++] = "-fno-PIC";
+
argv[argc] = nil;

quotefmtinstall();
15 changes: 15 additions & 0 deletions patches/alpine/go1.5/no-pic.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
--- a/src/cmd/link/internal/ld/lib.go
+++ b/src/cmd/link/internal/ld/lib.go
@@ -1071,6 +1071,11 @@ func hostlink() {
argv = append(argv, peimporteddlls()...)
}

+ // The Go linker does not currently support building PIE
+ // executables when using the external linker. See:
+ // https://github.com/golang/go/issues/6940
+ argv = append(argv, "-fno-PIC")
+
if Debug['v'] != 0 {
fmt.Fprintf(&Bso, "host link:")
for _, v := range argv {
16 changes: 16 additions & 0 deletions patches/alpine/go1.6/no-pic.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
index 8ccbec9dd634..4e96bfadc260 100644
--- a/src/cmd/link/internal/ld/lib.go
+++ b/src/cmd/link/internal/ld/lib.go
@@ -1194,6 +1194,11 @@ func hostlink() {
argv = append(argv, peimporteddlls()...)
}

+ // The Go linker does not currently support building PIE
+ // executables when using the external linker. See:
+ // https://github.com/golang/go/issues/6940
+ argv = append(argv, "-fno-PIC")
+
if Debug['v'] != 0 {
fmt.Fprintf(&Bso, "host link:")
for _, v := range argv {
16 changes: 16 additions & 0 deletions patches/alpine/go1.7/no-pic.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
index 14f4fa9..5599307 100644
--- a/src/cmd/link/internal/ld/lib.go
+++ b/src/cmd/link/internal/ld/lib.go
@@ -1272,6 +1272,11 @@ func hostlink() {
argv = append(argv, peimporteddlls()...)
}

+ // The Go linker does not currently support building PIE
+ // executables when using the external linker. See:
+ // https://github.com/golang/go/issues/6940
+ argv = append(argv, "-fno-PIC")
+
if Debug['v'] != 0 {
fmt.Fprintf(Bso, "host link:")
for _, v := range argv {
16 changes: 16 additions & 0 deletions patches/alpine/go1.8/no-pic.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
index 14f4fa9..5599307 100644
--- a/src/cmd/link/internal/ld/lib.go
+++ b/src/cmd/link/internal/ld/lib.go
@@ -1272,6 +1272,11 @@ func hostlink() {
argv = append(argv, peimporteddlls()...)
}

+ // The Go linker does not currently support building PIE
+ // executables when using the external linker. See:
+ // https://github.com/golang/go/issues/6940
+ argv = append(argv, "-fno-PIC")
+
if Debug['v'] != 0 {
fmt.Fprintf(Bso, "host link:")
for _, v := range argv {
Loading

0 comments on commit 8558bee

Please sign in to comment.