public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: John MACFARLANE <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: help wanted producing a statically linked executable
Date: Thu, 7 Sep 2017 17:28:25 -0700	[thread overview]
Message-ID: <20170908002825.GA15447@protagoras.berkeley.edu> (raw)

I had a build process in place to produce a fully static
linux executable, but it no longer works.  And I'm a bit
baffled at what I'm seeing, so I'm hoping someone can help.

Easiest way to reproduce is with Docker.

Dockerfile:

```
FROM alpine:edge
RUN apk update
RUN apk add alpine-sdk git ca-certificates ghc cabal zlib-dev \
    dpkg fakeroot sed gawk grep bash linux-headers
RUN cabal update
RUN mkdir -p /usr/src/
WORKDIR /usr/src/
RUN git clone https://github.com/jgm/pandoc
WORKDIR /usr/src/pandoc
```

Now, get an interactive session in the docker image:

docker run -it alpine-pandoc:latest /bin/bash

You'll find yourself in /usr/src/pandoc.  Let's try a static
build:

cabal new-build --disable-executable-dynamic \
  --ghc-options='-optl=-static -optl=-pthread -fPIC' \
  -fembed_data_files

When that's done, we can see what we have:

bash-4.3# ldd dist-newstyle/build/pandoc-2.0/build/pandoc/pandoc
        /lib/ld64.so.1 (0x7ff84a618000)

Not a static executable.  When I transfer it outside the
container and examine it with OSX's 'file', I see:

artifacts/pandoc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), stripped

When I try to run it, I get:

bash-4.3# dist-newstyle/build/pandoc-2.0/build/pandoc/pandoc --version
bash: dist-newstyle/build/pandoc-2.0/build/pandoc/pandoc: No such file or directory

because /lib/ld64.so.1 doesn't exist.

Does anyone know why I'm not getting a fully statically
linked executable?


                 reply	other threads:[~2017-09-08  0:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170908002825.GA15447@protagoras.berkeley.edu \
    --to=jgm-tvlzxgkolnx2fbvcvol8/a@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).