Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static build of pandoc? #11

Closed
dubiousjim opened this issue Dec 23, 2010 · 27 comments
Closed

static build of pandoc? #11

dubiousjim opened this issue Dec 23, 2010 · 27 comments

Comments

@dubiousjim
Copy link

Hi John, does your build system easily permit one to make a completely static build of pandoc? Currently I use this build invocation: http://aur.archlinux.org/packages/pandoc/pandoc/PKGBUILD (ignore the metadata, all that's important here is the build() function). And I think that does eliminate any dependencies on ghc or haskell libraries. Running ldd pandoc gives:
linux-vdso.so.1 => (0x...)
libz.so.1 => /usr/lib/libz.so.1 (0x...)
librt.so.1 => /lib/librt.so.1 (0x...)
libutil.so.1 => /lib/libutil.so.1 (0x...)
libdl.so.2 => /lib/libdl.so.2 (0x...)
libgmp.so.10 => /usr/lib/libgmp.so.10 (0x...)
libm.so.6 => /lib/libm.so.6 (0x...)
libc.so.6 => /lib/libc.so.6 (0x...)
libpthread.so.0 => /lib/libpthread.so.0 (0x...)
/lib/ld-linux-x86-64.so.2 (0x...)

But I need to build pandoc on my linux system (which has ghc and all the necessary libs) and deploy it on an unattended mac server, where it's too much work to get the necessary build chain set up and keep it maintained. If it's not too hard to make a fully static build of pandoc, that might be the easiest solution.

@jgm
Copy link
Owner

jgm commented Dec 23, 2010

Jim, I don't know of a way to do this. Actually, I'd love to know how to produce a fully standalone Mac binary, without dependencies on GMP or anything else, because then I could distribute it the same way I distribute the windows binary. So if you find out, let me know!

@dubiousjim
Copy link
Author

It looks like adding --ghc-options="-static -optl-static -optl-pthread" to the runhaskell Setup configure ... line makes a static build. Can confirm that the binaries I get on my Linux system aren't dynamic executables... But reading up about what's required to cross-compile for Mac on Linux makes that look like too much hassle. But perhaps knowing this invocation will enable you to release static Mac binaries?

@dubiousjim
Copy link
Author

Here's how I took care of my own needs: a lot of the tools in the MacPorts distro are dated (ghc 6.10.4, pandoc 2.something). But I could use it to install ghc and haskell-platform, then use cabal to install a more recent version of pandoc (as suggested on http://johnmacfarlane.net/pandoc/installing.html). But I'm sure many other users would find a static Mac build more accessible, so I hope the switches above, or something like them, help.

@jgm
Copy link
Owner

jgm commented Dec 25, 2010

I think the easiest method is:
brew install haskell-platform
cabal install pandoc

@jgm
Copy link
Owner

jgm commented Dec 25, 2010

@jgm jgm closed this as completed Jun 10, 2011
@frol
Copy link

frol commented Sep 20, 2014

Could you please consider to release Linux static builds too?

@jgm
Copy link
Owner

jgm commented Sep 21, 2014

I've looked into this a bit, but it's not as smooth as one might
think. (See the deb-static branch on github.)

The problem is that when I link statically, I get these warnings:

Linking dist/build/pandoc/pandoc ...
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/hslua-0.3.13/libHShslua-0.3.13.a(loadlib.o):
In function `ll_loadfunc':
loadlib.c:(.text+0xa58): warning: Using 'dlopen' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/usr/local/lib/ghc-7.8.3/unix-2.7.0.1/libHSunix-2.7.0.1.a(HsUnix.o): In
function `__hsunix_getpwent':
HsUnix.c:(.text+0x101): warning: Using 'getpwent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/usr/local/lib/ghc-7.8.3/unix-2.7.0.1/libHSunix-2.7.0.1.a(HsUnix.o): In
function `__hsunix_getpwnam_r':
HsUnix.c:(.text+0x111): warning: Using 'getpwnam_r' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/usr/local/lib/ghc-7.8.3/unix-2.7.0.1/libHSunix-2.7.0.1.a(HsUnix.o): In
function `__hsunix_getpwuid_r':
HsUnix.c:(.text+0x121): warning: Using 'getpwuid_r' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(HsNet.o):
In function `hsnet_getaddrinfo':
HsNet.c:(.text+0x31): warning: Using 'getaddrinfo' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cR8r_info':
(.text+0xca37): warning: Using 'gethostbyaddr' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cR3N_info':
(.text+0xc76d): warning: Using 'gethostbyname' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cR8Z_info':
(.text+0xcc5f): warning: Using 'gethostent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cQnn_info':
(.text+0x9e68): warning: Using 'sethostent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `rNsb_info':
(.text+0xbc8): warning: Using 'endhostent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cRfd_info':
(.text+0xd006): warning: Using 'getnetbyaddr' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cRbz_info':
(.text+0xcdeb): warning: Using 'getnetbyname' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cRfd_info':
(.text+0xd153): warning: Using 'getnetent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cQml_info':
(.text+0x9d94): warning: Using 'setnetent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `rNsc_info':
(.text+0xc44): warning: Using 'endnetent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cR0I_info':
(.text+0xc3f3): warning: Using 'getprotobynumber' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cR0I_info':
(.text+0xc567): warning: Using 'getprotoent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cQop_info':
(.text+0x9f3c): warning: Using 'setprotoent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `rNsa_info':
(.text+0xb4c): warning: Using 'endprotoent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cQYn_info':
(.text+0xc097): warning: Using 'getprotobyname' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cQR0_info':
(.text+0xb986): warning: Using 'getservbyname' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cQUx_info':
(.text+0xbd36): warning: Using 'getservbyport' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cQU1_info':
(.text+0xbee3): warning: Using 'getservent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cQpr_info':
(.text+0xa010): warning: Using 'setservent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `rNs9_info':
(.text+0xad0): warning: Using 'endservent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
Preprocessing executable 'make-pandoc-man-pages' for pandoc-1.13.0.1...
[1 of 1] Compiling Main             ( man/make-pandoc-man-pages.hs,
dist/build/make-pandoc-man-pages/make-pandoc-man-pages-tmp/Main.o )
Linking dist/build/make-pandoc-man-pages/make-pandoc-man-pages ...
/usr/local/lib/ghc-7.8.3/rts-1.0/libHSrts.a(Linker.o): In function
`internal_dlopen':
Linker.c:(.text+0x52d): warning: Using 'dlopen' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/usr/local/lib/ghc-7.8.3/unix-2.7.0.1/libHSunix-2.7.0.1.a(HsUnix.o): In
function `__hsunix_getpwent':
HsUnix.c:(.text+0x101): warning: Using 'getpwent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/usr/local/lib/ghc-7.8.3/unix-2.7.0.1/libHSunix-2.7.0.1.a(HsUnix.o): In
function `__hsunix_getpwnam_r':
HsUnix.c:(.text+0x111): warning: Using 'getpwnam_r' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/usr/local/lib/ghc-7.8.3/unix-2.7.0.1/libHSunix-2.7.0.1.a(HsUnix.o): In
function `__hsunix_getpwuid_r':
HsUnix.c:(.text+0x121): warning: Using 'getpwuid_r' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(HsNet.o):
In function `hsnet_getaddrinfo':
HsNet.c:(.text+0x31): warning: Using 'getaddrinfo' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cR8r_info':
(.text+0xca37): warning: Using 'gethostbyaddr' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cR3N_info':
(.text+0xc76d): warning: Using 'gethostbyname' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cR8Z_info':
(.text+0xcc5f): warning: Using 'gethostent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cQnn_info':
(.text+0x9e68): warning: Using 'sethostent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `rNsb_info':
(.text+0xbc8): warning: Using 'endhostent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cRfd_info':
(.text+0xd006): warning: Using 'getnetbyaddr' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cRbz_info':
(.text+0xcdeb): warning: Using 'getnetbyname' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cRfd_info':
(.text+0xd153): warning: Using 'getnetent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cQml_info':
(.text+0x9d94): warning: Using 'setnetent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `rNsc_info':
(.text+0xc44): warning: Using 'endnetent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cR0I_info':
(.text+0xc3f3): warning: Using 'getprotobynumber' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cR0I_info':
(.text+0xc567): warning: Using 'getprotoent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cQop_info':
(.text+0x9f3c): warning: Using 'setprotoent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `rNsa_info':
(.text+0xb4c): warning: Using 'endprotoent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cQYn_info':
(.text+0xc097): warning: Using 'getprotobyname' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cQR0_info':
(.text+0xb986): warning: Using 'getservbyname' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cQUx_info':
(.text+0xbd36): warning: Using 'getservbyport' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cQU1_info':
(.text+0xbee3): warning: Using 'getservent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `cQpr_info':
(.text+0xa010): warning: Using 'setservent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/jgm/.cabal/lib/i386-linux-ghc-7.8.3/network-2.6.0.1/libHSnetwork-2.6.0.1.a(BSD.o):
In function `rNs9_info':
(.text+0xad0): warning: Using 'endservent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking

And sure enough, I can run the binary, even on other systems, but
the networking operations don't work if the other system has a different
libc version.

@frol
Copy link

frol commented Sep 21, 2014

What linker command is it used? You should not statically link to glibc, that is why there are those warnings.

@jgm
Copy link
Owner

jgm commented Sep 21, 2014

Using ghc flags:

-static -pthread

I could also compile without these flags, but then the executable
would link dynamically to libgmp and libc, which would make it less
portable, no? I don't mind creating one linux executable, but I don't
want to get into the business of creating a bunch of different ones for
different library versions, i386 vs x86_64, etc.

@frol
Copy link

frol commented Sep 21, 2014

Then you will need to build only i386 and say that one who wants to run it on x86_64 will have to install libc:i386 and libgmp10:i386. As I said before, you don't want to link libc statically because it might conflict with kernel syscalls if kernel is another version than you build on.
Thus, the best you can do is to statically build with all third-party libraries and keep system ones dynamically linked. The linker command would be like this:

$ gcc objectfiles -o program -Wl,-Bstatic -ls1 -ls2 -Wl,-Bdynamic -ld1 -ld2

@purpleidea
Copy link

Can anyone provide some suggestions on how to statically link this with cabal ?
I'm trying to get pandoc insto a state where I can dump it onto an openshift instance...

@jgm
Copy link
Owner

jgm commented Oct 15, 2014

Modify pandoc.cabal. After every place where it has Ghc-Options,
add a stanza

ld-options:  -static -pthread

See if that does what you want.

+++ James [Oct 14 14 19:41 ]:

Can anyone provide some suggestions on how to statically link this with cabal ?
I'm trying to get pandoc insto a state where I can dump it onto an openshift instance...


Reply to this email directly or view it on GitHub:
#11 (comment)

@purpleidea
Copy link

On Tue, 2014-10-14 at 20:49 -0700, John MacFarlane wrote:

Modify pandoc.cabal. After every place where it has Ghc-Options,
add a stanza

ld-options:  -static -pthread

See if that does what you want.

Unfortunately it did not seem to work:

/home/james/.cabal/lib/hslua-0.3.13/ghc-7.6.3/libHShslua-0.3.13.a(loadlib.o): In function `ll_loadfunc':
loadlib.c:(.text+0x8d9): warning: Using 'dlopen' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/usr/bin/ld: cannot find -lgmp
/usr/bin/ld: cannot find -lffi
/home/james/.cabal/lib/unix-2.7.0.1/ghc-7.6.3/libHSunix-2.7.0.1.a(HsUnix.o): In function `__hsunix_getpwent':
HsUnix.c:(.text+0xb1): warning: Using 'getpwent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/unix-2.7.0.1/ghc-7.6.3/libHSunix-2.7.0.1.a(HsUnix.o): In function `__hsunix_getpwnam_r':
HsUnix.c:(.text+0xc1): warning: Using 'getpwnam_r' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/unix-2.7.0.1/ghc-7.6.3/libHSunix-2.7.0.1.a(HsUnix.o): In function `__hsunix_getpwuid_r':
HsUnix.c:(.text+0xd1): warning: Using 'getpwuid_r' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(HsNet.o): In function `hsnet_getaddrinfo':
HsNet.c:(.text+0x21): warning: Using 'getaddrinfo' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `sDcx_info':
(.text+0x11d0e): warning: Using 'gethostbyaddr' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `sD9t_info':
(.text+0x11949): warning: Using 'gethostbyname' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `sDgd_info':
(.text+0x1211b): warning: Using 'gethostent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `sCeM_info':
(.text+0xda34): warning: Using 'sethostent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `ryDE_info':
(.text+0x11f2): warning: Using 'endhostent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `sDlz_info':
(.text+0x12740): warning: Using 'getnetbyaddr' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `sDj2_info':
(.text+0x1246e): warning: Using 'getnetbyname' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `sDof_info':
(.text+0x12a4b): warning: Using 'getnetent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `sCdY_info':
(.text+0xd8c4): warning: Using 'setnetent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `ryDF_info':
(.text+0x12a2): warning: Using 'endnetent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `sD3P_info':
(.text+0x11236): warning: Using 'getprotobynumber' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `sD6r_info':
(.text+0x11513): warning: Using 'getprotoent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `sCg0_info':
(.text+0xdba4): warning: Using 'setprotoent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `ryDD_info':
(.text+0x1142): warning: Using 'endprotoent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `sD0o_info':
(.text+0x10d86): warning: Using 'getprotobyname' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `sCQS_info':
(.text+0x10220): warning: Using 'getservbyname' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `sCVg_info':
(.text+0x10758): warning: Using 'getservbyport' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `sCXZ_info':
(.text+0x10a83): warning: Using 'getservent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `sChe_info':
(.text+0xdd14): warning: Using 'setservent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
/home/james/.cabal/lib/network-2.6.0.2/ghc-7.6.3/libHSnetwork-2.6.0.2.a(BSD.o): In function `ryDC_info':
(.text+0x1092): warning: Using 'endservent' in statically linked
applications requires at runtime the shared libraries from the glibc
version used for linking
collect2: error: ld returned 1 exit status

I do have libffi-devel and gmp-devel and zlib-devel installed though.

Not sure what's wrong, but I'd like to make one giant pandoc executable
somehow :) I like your "relocatable binary" idea, and I'd like to do
this together!

Cheers,
James

@purpleidea
Copy link

This feature would help out pdfdoc a lot!

Example of how we do the install of pandoc:

https://github.com/purpleidea/pdfdoc/blob/master/INSTALL.md

YUCK! The static binary would be a better way! Thanks!

@aaren
Copy link

aaren commented Oct 25, 2014

Rstudio have managed to build pandoc binaries for debian, redhat, mac and windows. I can't find how they do it but the build is here:

https://s3.amazonaws.com/rstudio-buildtools/pandoc-1.12.3.zip

@jgm
Copy link
Owner

jgm commented Oct 25, 2014

It's not really difficult to do a self-contained static build
for a particular platform. cabal install -fembed_data_files will do
this by default. But the more binary packages we supply, the more
cumbersome the release process becomes.

+++ aaren [Oct 25 14 10:40 ]:

Rstudio have managed to build pandoc binaries for debian, redhat, mac and windows. I can't find how they do it but the build is here:

https://s3.amazonaws.com/rstudio-buildtools/pandoc-1.12.3.zip


Reply to this email directly or view it on GitHub:
#11 (comment)

@purpleidea
Copy link

@jgm This doesn't seem to work... I've tried multiple things:

# this works...
$ cabal install hsb2hs
Resolving dependencies...
Configuring hsb2hs-0.2...
Building hsb2hs-0.2...
Preprocessing executable 'hsb2hs' for hsb2hs-0.2...
[1 of 1] Compiling Main             ( hsb2hs.hs, dist/build/hsb2hs/hsb2hs-tmp/Main.o )
Linking dist/build/hsb2hs/hsb2hs ...
Installing executable(s) in /home/james/.cabal/bin
Installed hsb2hs-0.2
# this doesn't work either
$ cabal install pandoc -fembed_data_files 
Resolving dependencies...
[1 of 1] Compiling Main             ( /tmp/pandoc-1.13.1-22339/pandoc-1.13.1/Setup.hs, /tmp/pandoc-1.13.1-22339/pandoc-1.13.1/dist/setup/Main.o )
Linking /tmp/pandoc-1.13.1-22339/pandoc-1.13.1/dist/setup/setup ...
Configuring pandoc-1.13.1...
Building pandoc-1.13.1...
Preprocessing library pandoc-1.13.1...
setup: hsb2hs is needed to build this program: cabal install hsb2hs
Failed to install pandoc-1.13.1
cabal: Error: some packages failed to install:
pandoc-1.13.1 failed during the building phase. The exception was:
ExitFailure 1
$
# neither does this...
$ cabal install pandoc -fembed_data_files --force-reinstalls
Resolving dependencies...
[1 of 1] Compiling Main             ( /tmp/pandoc-1.13.1-22245/pandoc-1.13.1/Setup.hs, /tmp/pandoc-1.13.1-22245/pandoc-1.13.1/dist/setup/Main.o )
Linking /tmp/pandoc-1.13.1-22245/pandoc-1.13.1/dist/setup/setup ...
Configuring pandoc-1.13.1...
Building pandoc-1.13.1...
Preprocessing library pandoc-1.13.1...
setup: hsb2hs is needed to build this program: cabal install hsb2hs
Failed to install pandoc-1.13.1
cabal: Error: some packages failed to install:
pandoc-1.13.1 failed during the building phase. The exception was:
ExitFailure 1
$ 
# this doesn't work either :(
$ cabal install pandoc -fembed_data_files --force-reinstalls hsb2hs
Resolving dependencies...
Configuring hsb2hs-0.2...
Building hsb2hs-0.2...
Preprocessing executable 'hsb2hs' for hsb2hs-0.2...
[1 of 1] Compiling Main             ( hsb2hs.hs, dist/build/hsb2hs/hsb2hs-tmp/Main.o )
Linking dist/build/hsb2hs/hsb2hs ...
Installing executable(s) in /home/james/.cabal/bin
Installed hsb2hs-0.2
[1 of 1] Compiling Main             ( /tmp/pandoc-1.13.1-18051/pandoc-1.13.1/Setup.hs, /tmp/pandoc-1.13.1-18051/pandoc-1.13.1/dist/setup/Main.o )
Linking /tmp/pandoc-1.13.1-18051/pandoc-1.13.1/dist/setup/setup ...
Configuring pandoc-1.13.1...
Building pandoc-1.13.1...
Preprocessing library pandoc-1.13.1...
setup: hsb2hs is needed to build this program: cabal install hsb2hs
Failed to install pandoc-1.13.1
cabal: Error: some packages failed to install:
pandoc-1.13.1 failed during the building phase. The exception was:
ExitFailure 1
$

So IDK what I'm doing wrong, but I would love for this to work somehow :)

@jgm
Copy link
Owner

jgm commented Oct 28, 2014

Do you have ~/.cabal/bin in your path? It sounds like hsb2hs
is installed, but it's not being found in your path.

+++ James [Oct 28 14 14:15 ]:

@jgm This doesn't seem to work... I've tried multiple things:

# this works...
$ cabal install hsb2hs
Resolving dependencies...
Configuring hsb2hs-0.2...
Building hsb2hs-0.2...
Preprocessing executable 'hsb2hs' for hsb2hs-0.2...
[1 of 1] Compiling Main             ( hsb2hs.hs, dist/build/hsb2hs/hsb2hs-tmp/Main.o )
Linking dist/build/hsb2hs/hsb2hs ...
Installing executable(s) in /home/james/.cabal/bin
Installed hsb2hs-0.2
# this doesn't work either
$ cabal install pandoc -fembed_data_files
Resolving dependencies...
[1 of 1] Compiling Main             ( /tmp/pandoc-1.13.1-22339/pandoc-1.13.1/Setup.hs, /tmp/pandoc-1.13.1-22339/pandoc-1.13.1/dist/setup/Main.o )
Linking /tmp/pandoc-1.13.1-22339/pandoc-1.13.1/dist/setup/setup ...
Configuring pandoc-1.13.1...
Building pandoc-1.13.1...
Preprocessing library pandoc-1.13.1...
setup: hsb2hs is needed to build this program: cabal install hsb2hs
Failed to install pandoc-1.13.1
cabal: Error: some packages failed to install:
pandoc-1.13.1 failed during the building phase. The exception was:
ExitFailure 1
$
# neither does
$ cabal install pandoc -fembed_data_files --force-reinstalls
Resolving dependencies...
[1 of 1] Compiling Main             ( /tmp/pandoc-1.13.1-22245/pandoc-1.13.1/Setup.hs, /tmp/pandoc-1.13.1-22245/pandoc-1.13.1/dist/setup/Main.o )
Linking /tmp/pandoc-1.13.1-22245/pandoc-1.13.1/dist/setup/setup ...
Configuring pandoc-1.13.1...
Building pandoc-1.13.1...
Preprocessing library pandoc-1.13.1...
setup: hsb2hs is needed to build this program: cabal install hsb2hs
Failed to install pandoc-1.13.1
cabal: Error: some packages failed to install:
pandoc-1.13.1 failed during the building phase. The exception was:
ExitFailure 1
$
# this doesn't work either :(
$ cabal install pandoc -fembed_data_files --force-reinstalls hsb2hs
Resolving dependencies...
Configuring hsb2hs-0.2...
Building hsb2hs-0.2...
Preprocessing executable 'hsb2hs' for hsb2hs-0.2...
[1 of 1] Compiling Main             ( hsb2hs.hs, dist/build/hsb2hs/hsb2hs-tmp/Main.o )
Linking dist/build/hsb2hs/hsb2hs ...
Installing executable(s) in /home/james/.cabal/bin
Installed hsb2hs-0.2
[1 of 1] Compiling Main             ( /tmp/pandoc-1.13.1-18051/pandoc-1.13.1/Setup.hs, /tmp/pandoc-1.13.1-18051/pandoc-1.13.1/dist/setup/Main.o )
Linking /tmp/pandoc-1.13.1-18051/pandoc-1.13.1/dist/setup/setup ...
Configuring pandoc-1.13.1...
Building pandoc-1.13.1...
Preprocessing library pandoc-1.13.1...
setup: hsb2hs is needed to build this program: cabal install hsb2hs
Failed to install pandoc-1.13.1
cabal: Error: some packages failed to install:
pandoc-1.13.1 failed during the building phase. The exception was:
ExitFailure 1
$

So IDK what I'm doing wrong, but I would love for this to work somehow :)


Reply to this email directly or view it on GitHub:
#11 (comment)

@msabramo
Copy link

msabramo commented Feb 4, 2015

I wonder if a lot of folks who want a static build for Linux could also address their problem by using a Docker container with pandoc -- e.g.: https://registry.hub.docker.com/u/jagregory/pandoc/

That said, I'm trying to build a static binary for Mac OS X.

@jtprince
Copy link

On arch (3.18.6-1-ARCH), the following build process worked for me (using purpleidea and jgm's suggestions):

sudo pacman -S cabal-install ghc
cabal update
export PATH="$HOME/.cabal/bin:$PATH"
cabal install pandoc -fembed_data_files --force-reinstalls hsb2hs

The pandoc-static AUR package install appears to still be broken as reported up above. Next, I will try doing that install with ~/.cabal/bin in my $PATH.

@petrelharp
Copy link

Clarification: what libraries should the resulting binary be linked to? I thought the answer was "none", but no matter which way I do it, I always get ones linked to libgmp, libc, etcetera.

jgm added a commit that referenced this issue Feb 27, 2017
This goes together with my pull request to pandoc...
@kaushalmodi
Copy link

@jgm Can you please reconsider providing static binaries for Linux with each release?

At my work, I do not have admin rights on my Linux machine (RHEL 6.6) and I cannot install cabal locally or have the admin install it as no one codes in Haskell at work.

Recently, @koalaman, author of another awesome Haskell project ShellCheck, added auto-building of static Linux executables in this commit. Could that possibly be reused to generate static binaries for pandoc too?

Thanks.

@jgm
Copy link
Owner

jgm commented Jul 10, 2017 via email

@kaushalmodi
Copy link

kaushalmodi commented Jul 10, 2017

I've already got a procedure set up for producing completely
static linux binaries. We'll have them starting with the
next release.

That's great! Thank you.

I could have this built with continuous integration, but
I've hesitated because in addition to being static, the builds
use -shared-objects to minimize the executable size, and
they take forever. Maybe it will be faster with the new
version of ghc.

I believe you can configure CI to execute only for releases (when a commit is tagged) and not for each commit.

@jgm
Copy link
Owner

jgm commented Jul 10, 2017 via email

link2xt pushed a commit that referenced this issue Nov 5, 2017
Added NFData instances for use with deepseq
@scrutinizer11
Copy link

Hello,
I'd like to chime in asking how's it going now? Have you successfully kept up building static pandoc? I endured constant fails and errors trying to compile it from the source on my Mac (true it runs a very old macOS so I'm not sure whether that is the culprit) and gave up. The procedure is too tedious and multi-layered for what I need it which is to compile another executable, I don't plan to use pandoc extensively on its own. I'm looking for static builds and so far have downloaded following the provided link to Rstudio builds.

@jgm
Copy link
Owner

jgm commented Jun 1, 2022

We can produce a completely static executable on linux (and that's what you'll find on our Releases page). However, as I understand things, it is not possible on macos; there will be a dependency on dynamic system libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants