From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x142.google.com (mail-il1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) by sourceware.org (Postfix) with ESMTPS id 128623857C4E for ; Sat, 17 Oct 2020 11:59:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 128623857C4E Received: by mail-il1-x142.google.com with SMTP id i7so3562584ils.7 for ; Sat, 17 Oct 2020 04:59:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=rr4mYreHfyyxKOQk5y1lkRSbq6OtpOiaDZuJ+3ZNipM=; b=rt3ZTr38yxZPA2KU3CU3Cbq2+aFa1T+pntmvuDFlOfEtPNzvHHeOJJ9LZKmmX6lE2a Z/nbo7IOcuF/145d3aiUmPtkjIz1tRmCJhU+StGx1q7FK8lsGkPPwubwkDhcD0P8aPdo /xrH2ZK9lbKN5BLxiHo3Z/B/KVWcTumA/EJH/YIYT6QX54pKUDI9aRYqFOXLKquwsbXM fg209lhUAR4GwhU5+IjJ2iVlGB++RO3p+n+7JVgIlWBqZAS99qrMjQgSsZDiMBAV04Eg 6VyZG0F3iMmh9dR9zBCJUFc9XNe/z1ShdknluHGcMn+Q/CfAe4H/s9LmsgBXwXQohgRw urRA== X-Gm-Message-State: AOAM531ccywKiX6FgIT+yFM/yRrzChgnyZqXz4mriyaihWOSbli+Jy4h YUP3lS/8bRo0i0TuwhGt3e9J0xIG2+dzzqyQBa1EQI+y X-Google-Smtp-Source: ABdhPJxtsmq0M00MSaqLc5D/gAsy90lZuFR05/h0KQyN+vaEenBouXb3YXs6w+GgPKnv6VMLT5HJXS4JMOCXni/rWy0= X-Received: by 2002:a05:6e02:d01:: with SMTP id g1mr5432061ilj.246.1602935970282; Sat, 17 Oct 2020 04:59:30 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: William ML Leslie Date: Sat, 17 Oct 2020 22:59:18 +1100 Message-ID: Subject: Re: Building a cross compiler fails due to hardcoding host=target in gcc/Makefile.in To: gcc-help@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Oct 2020 11:59:32 -0000 > On Fri, 16 Oct 2020, 11:39 pm William ML Leslie, 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.