How does (src)/sys/x86/machine/endian.h get deplyoed as DESTDIR/usr/include/x86/endian.h

Eddy Petrișor eddy.petrisor at gmail.com
Tue Oct 24 06:20:05 UTC 2017


Pe 23 oct. 2017 10:30 PM, "Warner Losh" <imp at bsdimp.com> a scris:



On Mon, Oct 23, 2017 at 1:26 PM, Eddy Petrișor <eddy.petrisor at gmail.com>
wrote:

> Hello,
>
> I am trying to add cross build support of FreeBSD from a Linux build
> system and I am taking it one small step at a time.
>
> I have a wrapper script to consistently set environment variables, to
> set the correct bmake and the proper MAKEFLAGS to pass the correct
> dirs for the .mk files and made some changes to map the uname -p/uname
> -m's reported x86_64 to amd64 for the MACHINE* variables.
>
> During 'make TARGET=amd64 toolchain' the compilation of
> contrib/libc-pwcache/pwcache.c fails to find some definitions. Of
> course, before implementing the changes in the build system (or my
> Linux wrapper script) definitons that might make sense for a build
> from Linux, I am trying to compile by hand the offending pwcache.c
> file, and, although some of them I was able to resolve either by using
> the files from freebsd-glue or by adding -Isys, I am a little puzzled
> by the mix of build and freebsd headers/definitions and also got stuck
> because in my mind the compilation at this stage needs to generate
> binaries for running on a linux system, but some definitions seem to
> be freebsd specfic.
>
> In either case, I saw that on the FreeBSD system I am using as a
> reference there are some files (such as endian.h) are in
> /usr/include/x86, but in the source tree they were in the source tree
> in sys/x86/machine.
>
> Since at this stage it looks like I need some kind of way to do an
> install-headers(?) from sys/$MACHINE/machine (+x86, in case of x86_64)
> to a $NON_BSD_WRAPPERSDIR/$MACHINE/usr/include directory:
>
> 1) does it make sense to try to use the headers from src, or is the
> right way (tm) to add definitions which are 100% correct for Linux?
> 1.1) I am thinking that since the definitions were originally in the
> src tree under sys, they are related to the FreeBSD kernel, so it
> makes little sense to try to define something for Linux. Am I wrong?
> Does it make sense to continue on this route?
> 2) is there such a target/script that I can run to populate my
> wrappers dir with the right headers no matter which $MACHINE we're
> talking about?


In the past, I've walked through the bootstrapping steps to get a full
sysroot to do the build of the rest of the system.


I have thought of simply downloading a base.txz to get the headers, but I
dislike that idea because I should be able to bootstrap everything without
involving precompiled/prebuilt base.txz since all sources are available.

That's likely the best path forward (so the binaries you are building for
FreeBSD/arm are all built with gcc/clang --sysroot /path/to/arm/sysroot).


Please note that I am still at the stage when I am trying to build the
cross tool chain, so the TARGET at this stage is still amd64 (not arm64).
Because of this there is no sysroot yet. That's why I was asking at 2 for a
simple way to install the headers, and if that made sense 1.1. Does it?

I preferred to try amd64 since I know there are some things to be ironed
out for arm64/aarch64, while for amd64 things should be pretty solid.

I expect that after I make my cross tool chain (to be ran on Linux) I will
be able to generate binaries for FreeBSD and can buildworld and buildkernel
no matter the TARGET (after building the proper toolchain).



Warner


More information about the freebsd-arm mailing list