From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by sourceware.org (Postfix) with ESMTPS id 9CDC83858D31 for ; Sun, 19 Apr 2020 18:49:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9CDC83858D31 Received: by mail-io1-xd42.google.com with SMTP id 19so8388818ioz.10 for ; Sun, 19 Apr 2020 11:49:46 -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:cc:content-transfer-encoding; bh=/nDiOxCSPD6usGUeCuqVkkRsDysxlMFoEUzRH3V71WA=; b=Bbl67RmWaKo7AFx0r/gBydLJP16Us9KaUz/PuCkjRuPRkq1P7H/0DqvyvFs5wfueSZ 0c4nISav+U1Dlf29hIop2N1xEGXBigRJKouIzdX43bkw+k3gi8p2+m3l1n/aO3Pc+xMc 6zyZ0OHivs5QCnChPPSR9bPH2FAt7+6kAlzTNZKHIbsUg9OLR80BdADecPOzNX+aYz1j 3/lWVnaT+r6EuHUg5JMijl31iAfjxuv4NH0ozLl3Mvjc35FB6nK0FlO3ABtTGcDatj1G LtVRs44XyWLn28jLkNxNE3R5/W6kBb1Q/fEFbbYXKs8+y0s8G1zsrynNSl34xae71ed5 hX6A== X-Gm-Message-State: AGi0PubKUwGlW+wzjnd+wnwIka7jVApjKhHMU2B4lQOhQ5y3kWHyIega C4Nphx8YnBniUMZGlYF34rhvwScoZc6CLdzNCsc= X-Google-Smtp-Source: APiQypIFeiFByx24s0VgLXGRa1oGQ+hggmTfVfY1O8lX6CmoVvgSu9MZ6ARdpN0IHXCQ9nDS/6pexWBCq87wVQbiytY= X-Received: by 2002:a6b:e412:: with SMTP id u18mr11796627iog.95.1587322186033; Sun, 19 Apr 2020 11:49:46 -0700 (PDT) MIME-Version: 1.0 References: <921250919.1086849.1587309283539.ref@mail.yahoo.com> <921250919.1086849.1587309283539@mail.yahoo.com> In-Reply-To: <921250919.1086849.1587309283539@mail.yahoo.com> From: Jonathan Wakely Date: Sun, 19 Apr 2020 19:49:35 +0100 Message-ID: Subject: Re: Specifying where Binutils is and what it is called To: "R. Diez" Cc: "gcc-help@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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: Sun, 19 Apr 2020 18:49:48 -0000 On Sun, 19 Apr 2020 at 16:16, R. Diez via Gcc-help w= rote: > > Hi all: > > I have been building cross-compiler toolchains for years with makefiles s= imilar to this one: > > https://github.com/rdiez/JtagDue/blob/master/Toolchain/Makefile > > I have always been worried that installing GCC phase 2 on top of GCC phas= e 1 (with the same --prefix=3D/my/dir) may leave some undesired remnants be= hind. That seems like an unnecessary worry. Why would the phase 1 compiler install *more* than the final one? > So I thought I should build and install GCC phase 1 somewhere else. After= all, GCC phase 1 is not needed after the toolchain is complete. > > The steps would look like this: > > - Build and install Binutils with --prefix=3D/final/destination > - Build and install GCC phase 1 (minimal compiler) with --prefix=3D/tempo= rary/destination > - Build and install Newlib with GCC phase 1 with --prefix=3D/final/destin= ation > - Build and install GCC phase 2 with --prefix=3D/final/destination > - At this point, we could delete /temporary/destination > > Unfortunately, I am having trouble with GCC phase 1 and Newlib: > > a) If I configure GCC phase 1 with --prefix=3D/final/destination, it pick= s up the Binutils correctly. > > The names it finds are arm-none-eabi-ar etc. Right, that's how it should work. > But that is not what I want after all. Why not? > b) If I configure GCC phase 1 with --prefix=3D/temporary/destination, it = does not find arm-none-eabi-ar and the like, even if they are in the PATH. > > It then picks up 'ar' for the host. Compilation fails later on with a mes= sage like this: > > Assembler messages: > Fatal error: invalid -march=3D option: `armv7-m' > > It took some time to build everything and to realise what the error cause= was. I wish that GCC checked during the configuration phase that the found= 'ar' etc. actually support the asked target architecture. > > c) I can specify --with-build-time-tools=3D/some/dir , but then GCC does = not pick full names like arm-none-eabi-ar . I have to specify a path like /= home/rdiez/rdiez/arduino/toolchain-test-09-bin/arm-none-eabi/bin , which co= ntains the same tools but with short names like "ar". > > The trouble is, GCC needs then those 'ar' etc. tool on the path when buil= ding Newlib. Because 'ar' for the host has then the same name as 'ar' for t= he cross-compilation target, the host tools are not available anymore, whic= h causes problems later on. I really need --with-build-time-tools to pick f= ull names like "arm-none-eabi-ar". > > d) I guess I could use --with-as and --with-ld to manually specify the ri= ght Binutils. The trouble is, there are other tools like objdump. GCC's own= documentation warns about this: > > "When you use this option, you should ensure that dir includes ar, as, ld= , nm, ranlib and strip if necessary, and possibly objdump. Otherwise, GCC m= ay use an inconsistent set of tools." > > e) I could use the same --prefix for both GCC phase 1 and phase 2, delete= the /final/destination when Newlib is complete, and reinstall to that /fin= al/destination Binutils, Newlib and GCC phase 2. But that does not play wel= l with Makefiles that are building in parallel. So I wish there is another = way. Why bother with the deleting things step?