go-algorand
go-algorand copied to clipboard
Some binaries are dynamically linked
Subject of the issue
After running "make install" several binaries are dynamically linked. This prevents building a docker container on debian and copying artifacts to alpine for a smaller image.
I did not check all binaries, but here is a subset of binaries which are not building correctly:
- algocfg
- algons
- algorelay
- algotmpl
Expected behavior
All binaries should be statically linked.
Could be complicated by testing that the changes work, and testing across platforms.
We probably need to do a little more digging on this. I believe we tried this in indexer, and ended up reverting it due to warnings/errors that resulted.
See also:
- https://github.com/algorand/indexer/issues/720
- https://github.com/algorand/indexer/pull/730 (Implementation)
- https://github.com/algorand/indexer/pull/751 (Revert)
This is a nice to have, but low priority. alpine is questionable as a base container for many use cases, so we might consider this down the road. Additionally, algod is statically compiled in go-algorand, so this is matching the other binaries to this standard. We should consider indexer separately.
works for me?
ubuntu@ip-172-31-31-128:~/go/bin$ ldd algorelay
statically linked
ubuntu@ip-172-31-31-128:~/go/bin$ ldd algotmpl
statically linked
ubuntu@ip-172-31-31-128:~/go/bin$ ldd algocfg
statically linked
ubuntu@ip-172-31-31-128:~/go/bin$ ldd algons
statically linked
@winder - what do you think of @cce comment?
Possibly. I checked on the docker container and there is still something odd. Why are some marked not a dynamic executable, and others are marked statically linked?
root@056078ce268b:/node/bin# ldd goal
not a dynamic executable
root@056078ce268b:/node/bin# ldd tealcut
not a dynamic executable
root@056078ce268b:/node/bin# ldd algoh
not a dynamic executable
root@056078ce268b:/node/bin# ldd algod
not a dynamic executable
root@056078ce268b:/node/bin# ldd algocfg
statically linked
root@056078ce268b:/node/bin# ldd updater
statically linked
root@056078ce268b:/node/bin# ldd carpenter
statically linked
root@056078ce268b:/node/bin# ldd updater
statically linked
Steps to reproduce.
In one terminal
docker run --rm -it \
-p 4190:8080 \
-e NETWORK=mainnet \
-e FAST_CATCHUP=1 \
-e TELEMETRY_NAME=name \
-e TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
--name mainnet-container \
wwinder/algod:latest
In another
# lookup container hash with
docker ps
# enter container with
docker exec -it {hash} bash
Btw, I can't actually run ldd in this container without getting a segfault. Probably a docker-desktop on M1 issue?
@winder the file command gives the exact opposite result of static vs. dynamic:
root@dc4165650705:/node/bin# file goal
goal: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=6ec26b9d54c6d10197a9fb2f85a18932959662b4, for GNU/Linux 3.2.0, not stripped
root@dc4165650705:/node/bin# file algod
algod: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=097c8c829fb8ef8f0f7a7921687f96b538f667e0, for GNU/Linux 3.2.0, not stripped
root@dc4165650705:/node/bin# file tealcut
tealcut: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=ad63ceb630f6fec946118203aa575e944d6b8d42, for GNU/Linux 3.2.0, not stripped
root@dc4165650705:/node/bin# file carpenter
carpenter: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, Go BuildID=4UOo9_7C46AAmWYYz_Yt/MFkQeLR76n3XOREjz1VD/tywk65QIXCHWwN48vvH6/25QCIBkABNSa_wx59YXo, not stripped
root@dc4165650705:/node/bin# file algocfg
algocfg: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, Go BuildID=9rJ1ZqCJpx7g-2O_G-op/IYsGUqdSTS-kCQv2O4OS/OvHtlB8jFKXWBeDsnoLj/EeeMTtzL_lE_OjVMnf6A, not stripped
root@dc4165650705:/node/bin# file updater
updater: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, Go BuildID=Tr0ykfXaPJDXO3pf05hs/UO7tbxmKqiTuv7NnaiQW/gf0O27Yzuhty3XNuhGwq/0yOZgQQNlYPjTAYb-0FC, not stripped
root@dc4165650705:/node/bin# file algoh
algoh: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=5ec28bbc35ec768134548cb5d0c5b47a155effc1, for GNU/Linux 3.2.0, not stripped
I'm past the depth of my understanding on this, but https://stackoverflow.com/a/61554975 suggests some confusing aspects of what ldd considers static.