Discussion:
COMPILER_TYPE and installworld
Adrian Chadd
2015-11-05 06:01:29 UTC
Permalink
Hi,

I started digging into why "make installworld" doesn't work when using
the external toolchain support using CROSS_TOOLCHAIN= support. This is
one of the big hurdles to just using 100% external toolchain using
bapt's CROSS_TOOLCHAIN support.

The TL;DR seems to be:

* buildworld/buildkernel: CC gets set right; PATH doesn't include
/usr/bin:/usr/sbin
* installkernel: MACHINE is set, CC is not set (so it's 'cc') and PATH
includes /usr/bin:/usr/sbin
* installworld: MACHINE is set, CC is not set, PATH doesn't include
/usr/bin:/usr/sbin

The result is that during installkernel it finds 'cc' in /usr/bin and
detects it as clang, even though I'm doing a mips-gcc build. During
installworld it fails because it can't find 'cc'.

So! In the short term, is there any way that during
installworld/installkernel we can also set CC, etc appropriately?
Otherwise we're either using the wrong compiler logic/version
(installkernel) or we're just plain not going to work (installworld.)

Also - why is PATH including /usr/bin:/usr/sbin when doing
installkernel, but not installworld?

To reproduce:

* pkg install mips-gcc mips-xtoolchain-gcc mips-binutils
* env MAKEOBJDIRPREFIX=/tmp/mips-obj make CROSS_TOOLCHAIN=mips-gcc
TARGET=mips TARGET_ARCH=mips TARGET_CPUTYPE=mips32
DESTDIR=/tmp/mips-root -j 4 buildworld buildkernel installworld
installkernel KERNCONF=MALTA

...

make[4]: "/usr/home/adrian/work/freebsd/head-embedded-gcc5/src/share/mk/bsd.compiler.mk"
line 50: warning: "machine: mips, X_COMPILER_TYPE: , CC: cc"
make[4]: "/usr/home/adrian/work/freebsd/head-embedded-gcc5/src/share/mk/bsd.compiler.mk"
line 96: warning: "Finished; COMPILER_TYPE=clang,
COMPILER_VERSION=30700, COMPILER_FEATURES=c++11"

.. so in the installkernel setup, the PATH includes /usr/bin which
means 'cc' works, and thus it's detecting the compiler as clang even
though we're supposed to be using mips-gcc.

in the installworld setup, there's no /usr/bin in PATH, so it can't find cc.

buildworld is ok:

make[6]: "/usr/home/adrian/work/freebsd/head-embedded-gcc5/src/share/mk/bsd.compiler.mk"
line 50: warning: "machine: amd64, X_COMPILER_TYPE: , CC: cc"
make[6]: "/usr/home/adrian/work/freebsd/head-embedded-gcc5/src/share/mk/bsd.compiler.mk"
line 96: warning: "Finished; COMPILER_TYPE=clang,
COMPILER_VERSION=30700, COMPILER_FEATURES=c++11"
===> gnu/usr.bin/groff/src/devices/grops (obj)

.. for the local stuff, and:

make[5]: "/usr/home/adrian/work/freebsd/head-embedded-gcc5/src/share/mk/bsd.compiler.mk"
line 50: warning: "machine: mips, X_COMPILER_TYPE: , CC:
/usr/local/bin/mips-portbld-freebsd11.0-gcc -isystem
/home/adrian/work/freebsd/head-embedded-gcc5/src/../obj/mips_ap//mips.mips/usr/home/adrian/work/freebsd/head-embedded-gcc5/src/tmp/usr/include
-L/home/adrian/work/freebsd/head-embedded-gcc5/src/../obj/mips_ap//mips.mips/usr/home/adrian/work/freebsd/head-embedded-gcc5/src/tmp/usr/lib
--sysroot=/home/adrian/work/freebsd/head-embedded-gcc5/src/../obj/mips_ap//mips.mips/usr/home/adrian/work/freebsd/head-embedded-gcc5/src/tmp
-B/usr/local/mips-freebsd/bin/"
make[5]: "/usr/home/adrian/work/freebsd/head-embedded-gcc5/src/share/mk/bsd.compiler.mk"
line 96: warning: "Finished; COMPILER_TYPE=gcc,
COMPILER_VERSION=50200, COMPILER_FEATURES=c++11"

.. for the building mips stuff.

So installkernel works only "by magic" because of PATH, and CC is just
not being set right for installkernel/installworld.

ok, so what now? :)



-adrian
O'Connor, Daniel
2015-11-05 07:08:40 UTC
Permalink
Post by Adrian Chadd
So! In the short term, is there any way that during
installworld/installkernel we can also set CC, etc appropriately?
Otherwise we're either using the wrong compiler logic/version
(installkernel) or we're just plain not going to work (installworld.)
Why does installworld/kernel care what the compiler type is?

Or is it just something incidental which gets pulled in that complains because it can't work it out? If so perhaps the easiest way would be to add a flag which turns off compiler detection and set it for install*

If install* _do_ need to know the compiler type then, bleh..

--
Daniel O'Connor
"The nice thing about standards is that there
are so many of them to choose from."
-- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C
Adrian Chadd
2015-11-05 07:28:18 UTC
Permalink
Post by O'Connor, Daniel
Post by Adrian Chadd
So! In the short term, is there any way that during
installworld/installkernel we can also set CC, etc appropriately?
Otherwise we're either using the wrong compiler logic/version
(installkernel) or we're just plain not going to work (installworld.)
Why does installworld/kernel care what the compiler type is?
There's some stuff that's conditionally compiled based ont he
compiler. Don't ask. :)


-a
Post by O'Connor, Daniel
Or is it just something incidental which gets pulled in that complains because it can't work it out? If so perhaps the easiest way would be to add a flag which turns off compiler detection and set it for install*
If install* _do_ need to know the compiler type then, bleh..
--
Daniel O'Connor
"The nice thing about standards is that there
are so many of them to choose from."
-- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C
NGie Cooper
2015-11-05 07:46:21 UTC
Permalink
Post by O'Connor, Daniel
Post by Adrian Chadd
So! In the short term, is there any way that during
installworld/installkernel we can also set CC, etc appropriately?
Otherwise we're either using the wrong compiler logic/version
(installkernel) or we're just plain not going to work (installworld.)
Why does installworld/kernel care what the compiler type is?
Or is it just something incidental which gets pulled in that complains because it can't work it out? If so perhaps the easiest way would be to add a flag which turns off compiler detection and set it for install*
If install* _do_ need to know the compiler type then, bleh..
It shouldn’t care. bsd.compiler.mk just has the intelligence of a stump and Makefile.inc1 doesn’t tell bsd.compiler.mk to do otherwise in the distribution/install phases.

If it were up to me, CC would be false when make install* is run from Makefile.inc1.
Adrian Chadd
2015-11-05 16:02:46 UTC
Permalink
Post by NGie Cooper
Post by O'Connor, Daniel
Post by Adrian Chadd
So! In the short term, is there any way that during
installworld/installkernel we can also set CC, etc appropriately?
Otherwise we're either using the wrong compiler logic/version
(installkernel) or we're just plain not going to work (installworld.)
Why does installworld/kernel care what the compiler type is?
Or is it just something incidental which gets pulled in that complains because it can't work it out? If so perhaps the easiest way would be to add a flag which turns off compiler detection and set it for install*
If install* _do_ need to know the compiler type then, bleh..
It shouldn’t care. bsd.compiler.mk just has the intelligence of a stump and Makefile.inc1 doesn’t tell bsd.compiler.mk to do otherwise in the distribution/install phases.
If it were up to me, CC would be false when make install* is run from Makefile.inc1.
I don't mind what people do, I'd just really appreciate some help
fixing this up. I think we're pretty close to being able to transition
mips over to using 100% external toolchain only, and this is the
starting point.

So, what can we do? Pretty please? :)



-adrian
Warner Losh
2015-11-05 18:13:21 UTC
Permalink
Post by O'Connor, Daniel
Post by NGie Cooper
Post by O'Connor, Daniel
Post by Adrian Chadd
So! In the short term, is there any way that during
installworld/installkernel we can also set CC, etc appropriately?
Otherwise we're either using the wrong compiler logic/version
(installkernel) or we're just plain not going to work (installworld.)
Why does installworld/kernel care what the compiler type is?
Or is it just something incidental which gets pulled in that complains
because it can't work it out? If so perhaps the easiest way would be to add
a flag which turns off compiler detection and set it for install*
Post by NGie Cooper
Post by O'Connor, Daniel
If install* _do_ need to know the compiler type then, bleh..
It shouldn’t care. bsd.compiler.mk just has the intelligence of a stump
and Makefile.inc1 doesn’t tell bsd.compiler.mk to do otherwise in the
distribution/install phases.
Post by NGie Cooper
If it were up to me, CC would be false when make install* is run from
Makefile.inc1.
I don't mind what people do, I'd just really appreciate some help
fixing this up. I think we're pretty close to being able to transition
mips over to using 100% external toolchain only, and this is the
starting point.
So, what can we do? Pretty please? :)
Sadly, CC=true (or CC=false) doesn't solve the problem.
The defaults on the system depend, stupidly[*], on the compiler
you are using and it's capabilities. This means you won't install
all the bits that need C++11 to build, for example.

I'm joining this discussion late. What circumstances do we get CC
wrong in install*? For ages, that's been working properly. What
changed? I suspect 'nothing' and this is nothing more than a
pilot error, but it's possible it's a real bug. Most likely it's the
specific flavor of external toolchain that Bapt added isn't quite
setting variables the way it should.

Warner

[*] I've railed against this in the past to no good effect, mind you.
Loading...