public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: William ML Leslie <william.leslie.ttg@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: Re: Building a cross compiler fails due to hardcoding host=target in gcc/Makefile.in
Date: Sat, 17 Oct 2020 22:59:18 +1100	[thread overview]
Message-ID: <CAHgd1hEAWBGtJ36Z-Z8gbFE-FE1tJZHEuGYBF_ZyjFLtfHZhUA@mail.gmail.com> (raw)
In-Reply-To: <CAHgd1hHJttBHw-FJdbTmo0CROoq8URsi6CovUgoA2sJTeHH2jQ@mail.gmail.com>

> On Fri, 16 Oct 2020, 11:39 pm William ML Leslie, <william.leslie.ttg@gmail.com> wrote:
>>
>> Greetings,
>>
>> Please keep me CC'd as I'm not subscribed.
>>
>> I've been trying to build a cross compilation toolchain (for a new OS)
>> and ran into a confusing error while building gcc 10.2.0.  While
>> building libgcc, it fails running libgcc/config.host as it gets passed
>> my target instead of the actual host.  I traced this back to the root
>> Makefile.in, for which the `configure-target-libgcc` rule ends with:
>>
>>     CONFIG_SITE=no-such-file $(SHELL) \
>>       $$s/$$module_srcdir/configure \
>>       --srcdir=$${topdir}/$$module_srcdir \
>>       $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
>>       --target=${target_alias}  \
>>       || exit 1
>>
>> This is probably someone trying to be helpful when building a Canadian
>> Cross (host == target), however there is already a host_alias variable
>> defined at the very top of `Makefile.in`.  When using a traditional
>> cross compiler, the host is equal to the build machine; but the
>> makefile ignores this case.
>>
>> Have I missed something, or should I send a patch for this?
>>

So this turned out to be PEBKAC; I'll describe further in detail in
case anybody else is hitting this.

Libgcc describes some compiler built-ins, standard features etc of the
compiler, things which are linked in with programs on the target
machine.  So, it makes sense to have --host=target here.  That is, the
code within libgcc runs only on the target, so the target /is/ the
host.  This is also true for many of the other libraries built along
with gcc.

Builds I tried failed here for two possible reasons.  Since I was
trying to target a new OS, there was no configuration for this "host"
in libgcc/configure.host.  If you're starting out on common
architectures and don't need e.g. PIC support, you can reasonably
leave these blank, but check other systems on your CPU family for what
is commonly included.  The `tmake_file` variables used reference files
in libgcc/config/.  If you're porting an older toolchain like I am,
you might be providing your own crt files; if you wanted to integrate
these, this might be a good place to do so as quite a lot of
functionality is available.

The other reason I found while attempting to diagnose the issue by
building other cross compilers is that you'll need system headers if
you're trying to build a gcc to target an operating system (as opposed
to a bare machine such as mips64eb-elf).  For example,
ia64-unknown-linux-gnu expects certain system headers to be available.

-- 
William Leslie

Q: What is your boss's password?
A: "Authentication", clearly

Notice:
Likely much of this email is, by the nature of copyright, covered
under copyright law.  You absolutely MAY reproduce any part of it in
accordance with the copyright law of the nation you are reading this
in.  Any attempt to DENY YOU THOSE RIGHTS would be illegal without
prior contractual agreement.

      reply	other threads:[~2020-10-17 11:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16 12:39 William ML Leslie
2020-10-16 13:18 ` William ML Leslie
2020-10-17 11:59   ` William ML Leslie [this message]

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=CAHgd1hEAWBGtJ36Z-Z8gbFE-FE1tJZHEuGYBF_ZyjFLtfHZhUA@mail.gmail.com \
    --to=william.leslie.ttg@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).