Skip to content

Commit

Permalink
Go 1.7.4 and Prometheus/Alertmanager for armv6
Browse files Browse the repository at this point in the history
  • Loading branch information
alexellis committed Mar 1, 2017
1 parent 90e3967 commit a6f52c0
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 5 deletions.
4 changes: 2 additions & 2 deletions images/armhf/alertmanager/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM armhf/alpine:latest
FROM armhf/alpine:3.5
workdir /root
RUN apk add --update libarchive-tools
ADD https://github.com/prometheus/alertmanager/releases/download/v0.5.1/alertmanager-0.5.1.linux-armv7.tar.gz /root/
ADD https://github.com/prometheus/alertmanager/releases/download/v0.5.1/alertmanager-0.5.1.linux-armv6.tar.gz /root/
RUN bsdtar -xvf *.tar.gz -C ./ --strip-components=1
RUN mkdir /etc/alertmanager

Expand Down
33 changes: 33 additions & 0 deletions images/armhf/go-1.7.4/17847.patch
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)

41 changes: 41 additions & 0 deletions images/armhf/go-1.7.4/Dockerfile
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

16 changes: 16 additions & 0 deletions images/armhf/go-1.7.4/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 {
8 changes: 5 additions & 3 deletions images/armhf/prometheus/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FROM armhf/alpine:latest
FROM armhf/alpine:3.5

workdir /root
RUN apk add --update libarchive-tools
ADD https://github.com/prometheus/prometheus/releases/download/v1.4.1/prometheus-1.4.1.linux-armv7.tar.gz /root/
RUN bsdtar -xvf prometheus-1.4.1.linux-armv7.tar.gz -C ./ --strip-components=1

ADD https://github.com/prometheus/prometheus/releases/download/v1.5.2/prometheus-1.5.2.linux-armv6.tar.gz /root/
RUN bsdtar -xvf prometheus-*.tar.gz -C ./ --strip-components=1

RUN mkdir -p /usr/share/prometheus
RUN mkdir -p /etc/prometheus
Expand Down

0 comments on commit a6f52c0

Please sign in to comment.