I have an executable build via ghc which I know is statically compiled. I want to find if it's statically linked via glibc or musl based (Mostly because glibc based static linking is discouraged: Why is statically linking glibc discouraged? )
I would be also interested in an answer to see if there a non Haskell based solution which is applicable to any executable (basically executable which doesn't ship with Haskell's RTS).
One way of finding it, although it's limited to haskell based executable is using the --info
option:
Example:
$ ./tldr +RTS --info -RTS
[("GHC RTS", "YES")
,("GHC version", "8.6.5")
,("RTS way", "rts_thr")
,("Build platform", "x86_64-alpine-linux")
,("Build architecture", "x86_64")
,("Build OS", "linux")
,("Build vendor", "alpine")
,("Host platform", "x86_64-alpine-linux")
,("Host architecture", "x86_64")
,("Host OS", "linux")
,("Host vendor", "alpine")
,("Target platform", "x86_64-alpine-linux")
,("Target architecture", "x86_64")
,("Target OS", "linux")
,("Target vendor", "alpine")
,("Word size", "64")
,("Compiler unregisterised", "NO")
,("Tables next to code", "YES")
]
From the x86_64-apline-linux
, I can confirm that the build was based on Alpine Linux which is based on musl. You can explicitly confirm via ldd
that it is indeed statically linked then:
$ ldd ./tldr
not a dynamic executable