Fix static builds
Supersedes !3531 (closed) because this fixes the issues uncovered by actually doing a static build. The topic structure is a bit wonky due to the tandem changes for backporting, but that's what testing is for.
Cc: @danlipsa
Backport: release:HEAD^2