From owner-freebsd-arm@freebsd.org Tue Oct 24 06:20:04 2017 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E9DA8E4163A for ; Tue, 24 Oct 2017 06:20:04 +0000 (UTC) (envelope-from eddy.petrisor@gmail.com) Received: from mail-wm0-x22b.google.com (mail-wm0-x22b.google.com [IPv6:2a00:1450:400c:c09::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6C9B4720A0 for ; Tue, 24 Oct 2017 06:20:04 +0000 (UTC) (envelope-from eddy.petrisor@gmail.com) Received: by mail-wm0-x22b.google.com with SMTP id b189so13296396wmd.4 for ; Mon, 23 Oct 2017 23:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=aTRDlBAiDzg2954LXRN/TUlDhO2LtnSegr1KXL3unbE=; b=BE57DcS2I5yZYdomJVJMasuZmMi6PCxXvvEy3YOOBtn5iceKtw15oxxSkimmXnCDVM fNSKMk6qRhIfbRtYc0QnKKvnbxvkEQiJCtz6vHTKG0xVOzDz00XCpDCszMnadfvkF7vz NhBU4OMbh07H1ORhoa+D0YD5m1o1WFfPQjrC+T5lP+SjOrsppnkzVScj57DrJ/4IFurC agzF7lBT6g1MWS1HZjrvCvhlw2zjfYZv3QlA/q0KkSN9erYk3iYpHNKmCIGCFFmpo1KA sKKLEeoSutWw2A0LvnQ70qCCXUhxonYilDArBDyfl21Z1Qyh0U85FpQeu623KDV+M5up BEww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=aTRDlBAiDzg2954LXRN/TUlDhO2LtnSegr1KXL3unbE=; b=tT5uqe0feRAe3EZAwMTJmnW8/hW09jzLjxN2mGRpI43fOnOe5lgDoYLowGA+3nJz5X jfm7++hBT3iz2QjgOQx0nPZFE/VFaZZ5/imDizIsRfWbbvjFy1ipv////WlL6ksZhRTl /k0GnvbwqxHiMaCPfGcXYx0955iJPA3ygujxrZXQP6RgXjEnoN7OJbOdpIPUAW9J+IJC pfKs4QWey8YsJJpHMFClmi/9N1yrauD/3C4E1iB25kFnmmolE6LaR7bIeLyTZcCfp5BF sc3g1BcQpMo/2Bb6UVQAViG6XDZUlObGiiHFxXtR2w39Wreuey6wnnxIWIkzbJL0Puc0 DsbQ== X-Gm-Message-State: AMCzsaWpGznjkwN6aIva6EvkVuKtdXBzVwjnlt82JKYzcG81P9HDe8oQ xJeBxDrvHeqjMPxSR7SpVXImyBOQQHS2C4xLl7sKQQ== X-Google-Smtp-Source: ABhQp+SUUpaBPjgQued/GymjnF0JExDI12jgEVp1fXEm/aI9Vo+CfU2qRyB91ViXtmWYiGh5Qux/T35wbFAJ1X7VNw8= X-Received: by 10.28.231.25 with SMTP id e25mr5663897wmh.157.1508826002846; Mon, 23 Oct 2017 23:20:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.173.129 with HTTP; Mon, 23 Oct 2017 23:20:01 -0700 (PDT) Received: by 10.223.173.129 with HTTP; Mon, 23 Oct 2017 23:20:01 -0700 (PDT) In-Reply-To: References: From: =?UTF-8?Q?Eddy_Petri=C8=99or?= Date: Tue, 24 Oct 2017 09:20:01 +0300 Message-ID: Subject: Re: How does (src)/sys/x86/machine/endian.h get deplyoed as DESTDIR/usr/include/x86/endian.h To: Warner Losh Cc: freebsd-arm@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Oct 2017 06:20:05 -0000 Pe 23 oct. 2017 10:30 PM, "Warner Losh" a scris: On Mon, Oct 23, 2017 at 1:26 PM, Eddy Petri=C8=99or 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=3Damd64 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