forked from alexellis/docker-arm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Go 1.7.4 and Prometheus/Alertmanager for armv6
- Loading branch information
Showing
5 changed files
with
97 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go | ||
index 14f4fa9..bf2de57 100644 | ||
--- a/src/cmd/link/internal/ld/lib.go | ||
+++ b/src/cmd/link/internal/ld/lib.go | ||
@@ -1251,6 +1251,28 @@ func hostlink() { | ||
} | ||
} | ||
|
||
+ // When building a program with the default -buildmode=exe the | ||
+ // gc compiler generates code requires DT_TEXTREL in a | ||
+ // position independent executable (PIE). On systems where the | ||
+ // toolchain creates PIEs by default, and where DT_TEXTREL | ||
+ // does not work, the resulting programs will not run. See | ||
+ // issue #17847. To avoid this problem pass -no-pie to the | ||
+ // toolchain if it is supported. | ||
+ if Buildmode == BuildmodeExe { | ||
+ src := filepath.Join(tmpdir, "trivial.c") | ||
+ if err := ioutil.WriteFile(src, []byte{}, 0666); err != nil { | ||
+ Ctxt.Diag("WriteFile trivial.c failed: %v", err) | ||
+ } | ||
+ cmd := exec.Command(argv[0], "-c", "-no-pie", "trivial.c") | ||
+ cmd.Dir = tmpdir | ||
+ cmd.Env = append([]string{"LC_ALL=C"}, os.Environ()...) | ||
+ out, err := cmd.CombinedOutput() | ||
+ supported := err == nil && !bytes.Contains(out, []byte("unrecognized")) | ||
+ if supported { | ||
+ argv = append(argv, "-no-pie") | ||
+ } | ||
+ } | ||
+ | ||
for _, p := range strings.Fields(extldflags) { | ||
argv = append(argv, p) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
FROM armhf/alpine:latest | ||
|
||
RUN apk add --no-cache ca-certificates git | ||
|
||
ENV GOLANG_VERSION 1.7.4 | ||
ENV GOLANG_SRC_URL https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz | ||
ENV GOLANG_SRC_SHA256 4c189111e9ba651a2bb3ee868aa881fab36b2f2da3409e80885ca758a6b614cc | ||
|
||
# https://golang.org/issue/14851 | ||
COPY no-pic.patch / | ||
# https://golang.org/issue/17847 | ||
COPY 17847.patch / | ||
|
||
RUN set -ex \ | ||
&& apk add --no-cache --virtual .build-deps \ | ||
bash \ | ||
gcc \ | ||
musl-dev \ | ||
openssl \ | ||
go \ | ||
\ | ||
&& export GOROOT_BOOTSTRAP="$(go env GOROOT)" \ | ||
\ | ||
&& wget -q "$GOLANG_SRC_URL" -O golang.tar.gz \ | ||
&& echo "$GOLANG_SRC_SHA256 golang.tar.gz" | sha256sum -c - \ | ||
&& tar -C /usr/local -xzf golang.tar.gz \ | ||
&& rm golang.tar.gz \ | ||
&& cd /usr/local/go/src \ | ||
&& patch -p2 -i /no-pic.patch \ | ||
&& patch -p2 -i /17847.patch \ | ||
&& ./make.bash \ | ||
\ | ||
&& rm -rf /*.patch \ | ||
&& apk del .build-deps | ||
|
||
ENV GOPATH /go | ||
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH | ||
|
||
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" | ||
WORKDIR $GOPATH | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters