-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Comments
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! |
It looks like adding |
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. |
I think the easiest method is: |
Could you please consider to release Linux static builds too? |
I've looked into this a bit, but it's not as smooth as one might The problem is that when I link statically, I get these warnings:
And sure enough, I can run the binary, even on other systems, but |
What linker command is it used? You should not statically link to glibc, that is why there are those warnings. |
Using ghc flags:
I could also compile without these flags, but then the executable |
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.
|
Can anyone provide some suggestions on how to statically link this with cabal ? |
Modify pandoc.cabal. After every place where it has Ghc-Options,
See if that does what you want. +++ James [Oct 14 14 19:41 ]:
|
On Tue, 2014-10-14 at 20:49 -0700, John MacFarlane wrote:
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 Cheers, |
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! |
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 |
It's not really difficult to do a self-contained static build +++ aaren [Oct 25 14 10:40 ]:
|
@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 :) |
Do you have +++ James [Oct 28 14 14:15 ]:
|
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. |
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. |
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. |
This goes together with my pull request to pandoc...
@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 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 Thanks. |
+++ Kaushal Modi [Jul 10 17 08:16 ]:
***@***.*** Can you please reconsider providing static binaries for Linux
with each release?
I've already got a procedure set up for producing completely
static linux binaries. We'll have them starting with the
next release.
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.
… 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, ***@***.***, author of another awesome Haskell project
[3]ShellCheck, added auto-building of static Linux executables in
[4]this commit. Could that possibly be reused to generate static
binaries for pandoc too?
|
That's great! Thank you.
I believe you can configure CI to execute only for releases (when a commit is tagged) and not for each commit. |
+++ Kaushal Modi [Jul 10 17 17:50 ]:
I believe you can configure CI to execute only for releases (on when a
commit is [1]tagged) and not for each commit.
Yes. In any case I'll be releasing static binaries with
each release.
|
Added NFData instances for use with deepseq
Hello, |
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. |
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.
The text was updated successfully, but these errors were encountered: