[Toybox] [PATCH] Pass cflags and hostcc in mkroot.

Rob Landley rob at landley.net
Sat Sep 28 10:16:37 PDT 2019


On 9/26/19 3:53 PM, Denys Nykula wrote:
> Nevermind, the very next line in the mkroot script explains how I needn't
> have patched it, I just needed to pass variables this way:
> 
> make CROSS_COMPILE=$cc HOSTCC="${cc}cc -static" PATH="`dirname $cc`:$PATH" \
>   defconfig
> ...
> make CROSS_COMPILE=$cc PATH="`dirname $cc`:$PATH" root \
>   CFLAGS="$CFLAGS -static" HOSTCC="${cc}cc -static"

The string HOSTCC does not occur in scripts/mkroot.sh?

> While initially my script didn't work because it called like this:
> 
> make CROSS_COMPILE=$cc HOSTCC="${cc}cc -static" PATH="`dirname $cc`:$PATH" \
>   defconfig
> ...
> make CFLAGS="$CFLAGS -static" CROSS_COMPILE=$cc HOSTCC="${cc}cc -static" \
>   PATH="`dirname $cc`:$PATH" root

Yeah, it's confusing. I pass through _some_ variables from the environment
because they're mandatory ($PATH) and other because it's convenient
($CROSS_COMPILE), but...

Way back when Wolfgang Denk (the u-boot guy) tried Aboriginal Linux and it
exploded because his environment had space aliens in it that confused the build
(and the third time I fixed it he wandered off). But I came up with
infrastructure for this:

https://github.com/landley/aboriginal/blob/master/sources/variables.sh

Which has a longish list of preserved variables. Most of which were from the
config file it used to have, I think TEMP TMPDIR FORK MUSL were internal to the
plumbing, START_TIME and STAGE_NAME too, but the rest were used by something (I
think TOOLCHAIN_PREFIX is used by the gcc build maybe? Or autoconf? But I don't
think I _want_ to pass that through...?)

Sigh, I need to look at the commit log and see why each one was added. I think I
have a dirty mkroot tree somewhere with $(env | egrep '^(DISTCC|CCACHE)_) in it...

> For this thread to be less of a waste, I'll try to better explain the use
> case. A hosting provider has an old system image that broke own toolchain
> when I tried upgrading it. So I download toybox and a musl toolchain, and
> use the remaining host bash, coreutils and gmake to build from them a
> complete new musl image and replace the host's glibc system with it.

Cool. I should make this use case easier.

I've stripped mkroot way down so it's not doing stuff aboriginal was doing. The
question is have I stripped it down too much and what's the right thing to do?
the _proxy variables should probably get passed through...

Except I'm not downloading anything in the current version, or using the host
toolchain for anything, and mcm doesn't have distcc or ccache...

The problem with passing through CFLAGS and LDFLAGS and friends is those are
generally for the _host_ toolchain... :)

I made puppy eyes at Rich to make it possible to build native toolchains with
mcm, and I beat working host toolchains out of it (haven't tested all targets
but they at least build the same way), but I haven't added "make" to toybox yet
(which comes after the shell), and it'll need an awk too...

I take it you're cross compiling more stuff? There isn't really plumbing fo rtha
tin the merged version. (There was in the seperate version...)

Rob



More information about the Toybox mailing list