From: Michael Forney <mforney@mforney.org>
To: Rich Felker <dalias@libc.org>
Cc: musl@lists.openwall.com
Subject: Re: [musl] Re: [musl-cross-make] [PATCH v2] litecross: Fix system header dir when building native toolchains
Date: Wed, 13 May 2020 01:18:05 -0700 [thread overview]
Message-ID: <CAGw6cBtPsPOod3xkU+ADB3-4srMLs3HaTh+vV3ZQwDGBqS2mbg@mail.gmail.com> (raw)
In-Reply-To: <20200510215257.GW21576@brightrain.aerifal.cx>
On 2020-05-10, Rich Felker <dalias@libc.org> wrote:
> On Sun, May 10, 2020 at 01:35:23PM -0700, Michael Forney wrote:
>> My understanding was that musl-cross-make toolchains (native or cross)
>> were meant to be self-contained units, so the include directory
>> relative to the sysroot is always /include.
>
> This is true for cross compilers, which were the original only
> in-scope task of musl-cross-make. Adding NATIVE=y mode was a quick
> hack that was later fleshed out somewhat, but there was never any
> real design behind how it should work, and it shows. I'm not really
> sure whether it should be a proper native compiler for the target, or
> effectively a sysrooted self-targeting cross compiler that runs on the
> target. In some sense these are two different things and the user
> should be aware of which one they're requesting/getting....
Again, forgetting NATIVE=1 compilers entirely, this still fixes a bug
for cross-compilers that is currently hidden by the fact that the
sysroot (/$TARGET) happens to match the gcc tool directory.
>> Merging a native toolchain into / can't work, even using the default
>> /usr/include search directory, because you'd still have musl headers
>> installed into /include, so the compiler would be unable to find the
>> musl headers (this is the same reason why you currently need the usr
>> -> . symlink). To support something like this, I think you'd need to
>> make the prefix configurable.
>
> I think the symlink is just missing (not done via the same rule as for
> cross compilers because the sysroot base is different for a non-cross
> compiler).
I don't quite understand what you mean here, or why you think a
symlink should be necessary in the first place. The sysroot base
doesn't matter here; for both native and cross toolchains,
musl-cross-make installs musl headers to $SYSROOT/include
($OUTPUT/include for native, and $OUTPUT/$TARGET/include for cross).
Currently, gcc is searching for headers in $SYSROOT/usr/include, as it
does by default, but we can configure gcc to instead search
$SYSROOT/include (where the headers actually are) by using
--with-native-system-header-dir=/include.
What I meant above is that if you were to try to merge a
musl-cross-make toolchain into /, you'd have two separate directories,
/include containing the toolchain headers, and /usr/include containing
the system library headers. gcc would only search for headers in
/usr/include, and you couldn't use a symlink since both are separate
directories with separate contents. To support this, you'd need to set
--prefix=/usr and install musl headers to $SYSROOT/usr/include, but I
think this is probably out of scope of musl-cross-make (at least, out
of scope of this patch). Also note that the proposed patch does not
conflict with a change like this, you'd just set
--with-native-system-header-dir=$(PREFIX)/include instead.
> At least relative to what I remember of my original intent.
> But I'm doubtful that this was well thought out at all since the only
> real intent at the time I added it was "can I make a compiler run on a
> nommu j2?" where I didn't want to bootstrap a whole distro or have
> anything serious actually compiled on the target where it would have
> been prohibitively slow.
I get that you're unhappy with the current state of musl-cross-make
and NATIVE=1, and sure, there are probably some improvements to be
made, but I think you're making this out to be trickier than it
actually is. Once you have time to take a closer look at this, I think
you'll find that it really is a simple issue of gcc searching the
wrong directory by default.
next prev parent reply other threads:[~2020-05-13 8:18 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-07 6:49 [musl-cross-make] [PATCH] " Michael Forney
2020-03-23 4:34 ` [musl] [musl-cross-make] [PATCH v2] " Michael Forney
2020-05-09 0:27 ` [musl] " Michael Forney
2020-05-10 16:35 ` Rich Felker
2020-05-10 20:35 ` Michael Forney
2020-05-10 21:52 ` Rich Felker
2020-05-13 8:18 ` Michael Forney [this message]
2020-05-13 14:37 ` Rich Felker
2020-05-13 18:48 ` Michael Forney
2020-05-13 18:55 ` Rich Felker
2020-05-13 19:34 ` Michael Forney
2020-05-13 20:04 ` Laurent Bercot
2020-05-13 21:51 ` Rich Felker
2020-05-14 8:40 ` Laurent Bercot
2020-08-19 21:00 ` Michael Forney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGw6cBtPsPOod3xkU+ADB3-4srMLs3HaTh+vV3ZQwDGBqS2mbg@mail.gmail.com \
--to=mforney@mforney.org \
--cc=dalias@libc.org \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).