Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Nov 2017 21:35:56 +0200
From:      Guy Yur <guyyur@gmail.com>
To:        Bryan Drewery <bdrewery@freebsd.org>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: using native-xtools's make and MACHINE, MACHINE_ARCH values
Message-ID:  <CAC67Hz-vcGkz7eg5aO6rFzC79dW5LtkxeJDPEaFKR=P%2B54PoCQ@mail.gmail.com>
In-Reply-To: <04a972e9-16b7-7751-dbee-4af0a598d84b@FreeBSD.org>
References:  <CAC67Hz-LUi-sL4pWxpCCOpzPPfp7menwTqP_vusAkeN=-PUTUg@mail.gmail.com> <9961305b-1b1e-8de0-8df8-94bc427cbbee@FreeBSD.org> <CAC67Hz9M3hDiKchBPtB86ou7XJT4o2irwWHyrehdno0cRsho6g@mail.gmail.com> <04a972e9-16b7-7751-dbee-4af0a598d84b@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,


On 19 November 2017 at 00:56, Bryan Drewery <bdrewery@freebsd.org> wrote:
> On 11/18/17 2:52 PM, Guy Yur wrote:
>> Hi,
>>
>> On 18 November 2017 at 23:44, Bryan Drewery <bdrewery@freebsd.org> wrote:
>>> On 11/18/17 7:26 AM, Guy Yur wrote:
>>>> Hi,
>>>>
>>>> I am trying to use native-xtools's make (amd64 targeting armv7)
>>>> on an amd64 host in an armv7 chroot.
>>>
>>> My guess is that it's because you're using a chroot rather than a jail.
>>> When poudriere creates the jail with 'jail -c' it does not do things
>>> like setup the make.conf or even setup nxb-bin hardlinks.  It only does
>>> this stuff at Jail Startup time (bulk/testport/jail -s).
>>> Checkout jail -s and jail -k rather than using a chroot.
>>>
>>>
>>>> (qemu-arm-static and binmiscctl used for the arm binaries.)
>>>> Running /nxb-bin/usr/bin/make -V MACHINE and -V MACHINE_ARCH it
>>>> reports amd64, amd64 not arm, armv7.
>>>> (12.0-CURRENT r325963)
>>>>
>>>> Do I need to override MACHINE and MACHINE_ARCH explicitly when
>>>> running nxb's make or should it report the target values?
>>>>
>>>> bmake is compiled with -DMAKE_NATIVE in usr.bin/bmake/Makefile
>>>> so it uses uname, sysctl to get the values.
>>>> If I add -UMAKE_NATIVE -DMAKE_MACHINE=\"${MACHINE}\"
>>>> -DMACHINE_ARCH=\"${MACHINE_ARCH}\" to the nxb's make
>>>> compilation it reports arm and armv7.
>>>> Turning off MAKE_NATIVE also affects other things so it is
>>>> probably not be the correct change to make.
>>>>
>>>
>>>
>>> Poudriere sets MACHINE and MACHINE_ARCH in /etc/make.conf.  It seems ok
>>> to me in a Jail.
>>>
>>>> # grep MACHINE /etc/make.conf
>>>> MACHINE=arm64
>>>> MACHINE_ARCH=aarch64
>>>> # /nxb-bin/usr/bin/make -V MACHINE -V MACHINE_ARCH
>>>> arm64
>>>> aarch64
>>>
>>> If I change it to something else it takes the value.
>>>
>>>> # grep MACHINE /etc/make.conf
>>>> MACHINE=machine
>>>> MACHINE_ARCH=machine_arch
>>>> # /nxb-bin/usr/bin/make -V MACHINE -V MACHINE_ARCH
>>>> machine
>>>> machine_arch
>>>
>>> As for chroot it's wrong:
>>>
>>>> # /nxb-bin/usr/bin/make -V MACHINE -V MACHINE_ARCH
>>>> amd64
>>>> amd64
>>>
>>
>> If I set them in /etc/make.conf it works in a chroot as well.
>>
>> But shouldn't a crosstool make have the MACHINE and MACHINE_ARCH
>> of the target regardless of where it is running?
>
> Not expected to, no.  Perhaps it makes sense but there's no reason for
> it right now.

Ok.
Setting them in /etc/make.conf is simple enough.

>
>> clang built by native-xtools has Target set to the target arch.
>>
>> I can try to prepare and try to upstream a patch for an option
>> to compile bmake for cross-compilation of same os version but
>> different archs if it will be useful.
>>
>>>
>>> It's not using uname as far as I can tell.  The /etc/make.conf is setup
>>> at Jail Startup time but the jail's /etc/login.conf is setup at 'jail
>>> -c' time currently, which sets UNAME_m and UNAME_p so uname should be
>>> fine anyway:
>>>
>>>
>>>> # grep arm /etc/login.conf
>>>>         :setenv=MAIL=/var/mail/$,BLOCKSIZE=K,UNAME_r=12.0-CURRENT,UNAME_v=FreeBSD 12.0-CURRENT 1200051,OSVERSION=1200051,ABI_FILE=/usr/lib/crt1.o,UNAME_m=arm64,UNAME_p=aarch64:\
>>>
>>
>> make uses uname(3) for MACHINE and I see UNAME_m affects it.
>> For MACHINE_ARCH it uses HW_MACHINE_ARCH sysctl(3)
>> which isn't effected by UNAME_p.
>> Of course, MACHINE/MACHINE_ARCH can be overriden in
>> /etc/make.conf after the initial value is set by uname/sysctl.
>> > So I guess I will have to set MACHINE and MACHINE_ARCH
>> explicitly in make.conf like Poudriere.
>
> Sorry I missed that you were not using Poudriere. What's the use case here?

Building ports.
It is just simpler for me right now to use a chroot
and build the ports manually and update using portmaster.
I keep the chroot and host os version in sync so I am less
worried about the host environment affecting the chroot.
When flavors hit the tree I will have to reevaluate.

Thanks,
Guy

>
>>
>> Thanks,
>> Guy
>>
>>>
>>> --
>>> Regards,
>>> Bryan Drewery
>>>
>
>
> --
> Regards,
> Bryan Drewery
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAC67Hz-vcGkz7eg5aO6rFzC79dW5LtkxeJDPEaFKR=P%2B54PoCQ>