Open sfackler opened 2 years ago
Looking at .build/HOST-x86_64-apple-darwin/x86_64-linux-gnu/state/cc_for_host/env.sh
, CFLAGS_FOR_BUILD and CFLAGS_FOR_HOST are still set properly at the point the cc_for_host step starts:
declare -g -- CT_CFLAGS_FOR_BUILD="-O2 -g -I/tmp/crosstool-ng/.build/HOST-x86_64-apple-darwin/x86_64-linux-gnu/buildtools/include "
declare -g -- CT_CFLAGS_FOR_HOST="-O2 -g -pipe -I/tmp/crosstool-ng/.build/HOST-x86_64-apple-darwin/x86_64-linux-gnu/buildtools/complibs-host/include -Qunused-arguments -fno-common"
It looks like the problem is in do_gcc_backend - CFLAGS_FOR_BUILD
is based off of cflags
, which is set to CT_CFLAGS_FOR_HOST
:
https://github.com/crosstool-ng/crosstool-ng/blob/3d706748b49f9fa5adda5553227ddf16a1b0d552/scripts/build/cc/gcc.sh#L1179 https://github.com/crosstool-ng/crosstool-ng/blob/3d706748b49f9fa5adda5553227ddf16a1b0d552/scripts/build/cc/gcc.sh#L841
hmm probably goes back to the unification of the core passes. We may have lost some changes that were specific to the canadian scenario.
I have a WIP commit that gets closer to fixing things. It ironically appears that GCC's build system also doesn't handle this properly (it doesn't propagate CXXFLAGS_FOR_BUILD down to the libcpp sub-make). I have a gcc patch in that commit but it doesn't seem to fix the libcpp sub-make for some reason: https://github.com/sfackler/crosstool-ng/commit/4cba68d6abed45f40fac512ce86c20825f0fc945
I'm trying to set up a canadian cross build: x86_64-linux -> x86_64-macos -> x86_64-linux. I'm using https://github.com/tpoechtrager/osxcross for the macos cross compiler, with little shims to forward
<prefix>-gcc
to<prefix>-clang
since it seems like crosstool-ng can't be told to look for clang directly.One interesting aspect of this setup is that the build compiler is gcc and the host compiler is clang. This appears to break the final gcc compiler stage, with all of CFLAGS, CFLAGS_FOR_BUILD, and CFLAGS_FOR_HOST appearing to use the host configuration. In particular, the
-Qunused-arguments
flag is passed, which is only set when crosstool detects that a compiler is clang. Since this isn't true for the build compiler, things break. I've attached the failing config.log for reference as well.It also looks like the build process is only overriding CC and not CXX for this final gcc step - I'm not sure if that's intentional or not? With crosstools configured to build an older gcc that doesn't have any C++, it gets a bit further along but fails in the libiberty build for the same reason.
build.log.gz config.log .config.txt