build
build copied to clipboard
Support cross-building
Is there some way to use CROSS_COMPILE or specify the cross-building toolchain to use?
My primary use case for a c/c++ build system would be in a cross compiling environment as well. I'm playing around with places to add hooks to build
.
One that pops to mind is allowing the user to override the config folder directory, or perhaps instead the initial specific config file that gets included. kamathba/build@7147959
Actually, one of the first projects to use build
was using it mostly for cross-compilation.
Typically, you would simply create a config.gcc-cross-arm.mk
and set your BUILDENV
to match. It may be as simple as:
CC=cross-gcc
CXX=cross-g++
LD=cross-ld
include $(BUILD)config.gnu.mk
Please re-open the issue if you feel this is not good enough.
I would prefer that CROSS_COMPILE is considered automatically, or that there is a built in profile to account for it. I would not like to create config for each target I need to build, but pick the configuration from environment variable compatible with autotools. CROSS_COMPILE is used widely for this purpose, and most distro build systems set it appropriately.
Makes sense.
Would something like https://github.com/c3d/build/commit/a7e9b464d9c822c8650fb44c2748b68ba82df0b8 be the right direction?
What I'm not too sure about is: how to deal with the -I path. I'm surprised that at least on Fedora 26, the cross-compilers don't seem to set the right paths for include and libraries. Any suggestion?
Looks like right direction. Normally cross compilers are configured for sysroot, and often CFLAGS or similar will contain --sysroot=$target_root or similar. The affect of this is that all -I paths are searched under the given sysroot.
The CFLAGS and others are usually (at least in case of yocto) setup using environment-setup-* file which is sourced into the shell running cross-compilation. See https://www.yoctoproject.org/docs/2.3/sdk-manual/sdk-manual.html for example.