Closed secinthenet closed 3 years ago
Since it works in all of the CI builds I encourage you to find out what is different.
How do you know it works there? It's not that the build fails, it's that the resulting binaries are dynamically linked to libraries. I don't see a test for that in the CI build.
You’re right, the tests are run against executables that link the same libraries. So this should be sufficient. But I also know that this is the (recommended) build that others are using and haven’t had problems with (including myself). libthread and librt are dependencies on the OS that don’t get statically linked.
You could modify the test execution to run a smoke test on binaries. The pull request for that would verify linkage in CI.
The produced bx
binary does work, it's just not statically linked, so it's not surprising that others didn't have problems with this.
For context, I want fully static linking to make it always work when it's used offline in different air gapped scenarios.
BTW, can't libpthread and librt be statically linked as well?
It is statically linked. You cannot avoid dynamic linking to necessary OS components. I reduced the dynamic linkage to the lowest level possible form the same reason. I’m surprised those components are not present in the OS.
Why can't you link everything statically? golang does it, and while I remember it may be tricky in C/C++, it seems possible: https://stackoverflow.com/questions/35116327/when-g-static-link-pthread-cause-segmentation-fault-why
BTW, what does ldd
show on your system? I'm curious why the static linking doesn't work for me (and neither in a docker container, which is a good sign something is wrong and not related to my setup)
Feel free to do it. ldd has always shown OS dependencies, same for Windows and macOS. The binary needs to talk to the OS.
Yes, but it doesn't have to use a dynamic library to talk to the OS. Again, golang does it, and I've seen it done with C++ too, though it's a bit harder. Do you see any less libraries on Linux, or is what I'm seeing normal? (see output in original message in the issue)
Again, feel free to do it. I’m not a Linux guru, so couldn’t find a way. But it didn’t seem necessary. It links on Ubuntu out of the box.
Closed for lack of activity. Feel free to open a PR with resolution!
I reproduced this in debian stable with Docker in https://github.com/libbitcoin/libbitcoin-explorer/pull/676
Steps to reproduce (you need that PR):
Output: