It seems strange that linux host definition in depends just calls the native system compiler with -m32/-m64 flags, instead of supporting cross compilers, and that it doesn’t use a -sysroot value to prevent picking up system libraries:
https://github.com/bitcoin/bitcoin/blob/master/depends/hosts/linux.mk
This is pretty different than the other windows/darwin/android hosts defined in the same directory, and seems like it would prevent make HOST=x86_64-pc-linux-gnu
from working on anything other than a matching native platform.
Another side-effect of using the native compiler without a -sysroot value is that the build currently pick ups system libraries like BDB. From #bitcoin-builds:
[19:57:12] <achow101> when I build with the depends system, is it supposed to fallback to my system libs if the depends build misses a dependendency? [22:40:02] <dongcarl> achow101: What’s the full context? [22:45:13] <achow101> dongcarl: I modified depends to build a version of bdb that we didn’t support. configure then ignored that version and used my system lib instead of erroring as i was expecting it to
This is also causing headaches in #18677. I first added new packages there not even using host_CC
etc variables, so native builds on linux and mac worked fine, but the cross compiled linux->mac build didn’t work, which fanquake reported. To fix that, I started using the host_CC
etc variables and passing along -sysroot
values for host packages to fix the reported linux->mac cross-compile problem. But this turned out to break the i686-linux-gnu build on travis, because specifying -sysroot
prevents gcc from using include files like stdio.h
from /usr/include/
and instead only use /usr/x86_64-linux-gnu/include/stdio.h
. This worked fine on my system, but didn’t work on travis because the libc6-dev-amd64-cross package wasn’t installed. So I added that package and travis turned green.
But now hebasto is reporting the same error I was seeing on travis in an local linux mint build #18677 (comment) and it seems like linux mint might not have a libc6-dev-amd64-cross
package.
I fixed this by not setting -sysroot for the new packages for the native linux build, and I probably should have done this before to respect the host_CC
etc variables more. But it would also be good to understand why the linux host variables are set the way they are to begin with. Are they actually intended to pick up outside system libraries and not support cross compiling?
It’s unclear if they’re set the current way for expediency, or if there’s a different design goal for the linux host compared to the other hosts.