On Thu, Apr 21, 2016 at 01:38:54AM +0200, Adam Wolk wrote:
> Hi,
>
> While testing a port for net/syncthing sthen@ noticed the following
> warnings:
>
> 00:44 < sthen> hm, there are some funny messages from that port in
> 'make fake' 00:45 < sthen>
> BFD: /usr/obj/ports/syncthing-0.12.22/fake-amd64/usr/local/bin//stVnev2l:
> warning: allocated section `.gosymtab' not in segment 00:45 < sthen>
> BFD: /usr/obj/ports/syncthing-0.12.22/fake-amd64/usr/local/bin//stVnev2l:
> warning: allocated section `.gnu.version_r' not in segment
>
> the cause for those errors is trying to strip a Go binary which doesn't
> output all expected segments. Upstream officially doesn't support
> stripping and it might lead to undefined behavior.
>
> Debian Bug report logs - #717172
> Stripping golang binaries causes crashes:
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=717172
>
> go get ... fails with SIGILL on armhf
> https://bugs.launchpad.net/ubuntu/+source/golang/+bug/1200255
>
> docker: Stripping Binaries
> https://github.com/docker/docker/blob/2a95488f7843a773de2b541a47d9b971a635bfff/project/PACKAGERS.md#stripping-binaries
>
> relevant blog post:
> https://blog.filippo.io/shrink-your-go-binaries-with-this-one-weird-trick/
>
> I went through existing go ports to see how many of them actually strip
> the binaries.
>
> https://gist.github.com/mulander/a0dd5d5b49ca81001628d690b70ba111
>
> Apparently from the existing ports only sysutils/logstash/forwarder is
> affected.
> This issue was initially reported by Fritjof Bornebusch (thanks!) in
> July last year: http://marc.info/?l=openbsd-ports&m=143766040011892&w=2
>
> I'm inlining a patch for sysutils/logstash/forwarder replacing the
> usage of INSTALL_PROGRAM with INSTALL_SCRIPT and a comment informing
> why this choice is made. Any OK's?
OK with me; go binaries can still be stripped but that's a compile/link option
and not something strip(1) should get involved with.
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/sysutils/logstash/forwarder/Makefile,v
> retrieving revision 1.7
> diff -u -p -r1.7 Makefile
> --- Makefile 6 Jan 2016 20:02:19 -0000 1.7
> +++ Makefile 20 Apr 2016 23:37:17 -0000
> @@ -5,7 +5,7 @@ COMMENT= collect logs locally in prepara
> GH_ACCOUNT= elastic
> GH_PROJECT= logstash-forwarder
> GH_TAGNAME= v0.4.0
> -REVISION= 1
> +REVISION= 2
>
> MODULES= lang/go
>
> @@ -16,8 +16,9 @@ WANTLIB += c pthread
> pre-configure:
> ${SUBST_CMD} ${WRKSRC}/logstash-forwarder.conf.example
>
> +# Use INSTALL_SCRIPT to prevent stripping go binaries
> do-install:
> - ${INSTALL_PROGRAM} ${MODGO_WORKSPACE}/bin/logstash-forwarder \
> + ${INSTALL_SCRIPT} ${MODGO_WORKSPACE}/bin/logstash-forwarder \
> ${PREFIX}/sbin/
> ${INSTALL_DATA_DIR} ${PREFIX}/share/{doc,examples}/logstash-forwarder/
> ${INSTALL_DATA} ${WRKSRC}/README.md \
>
--
jasper