From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by sourceware.org (Postfix) with ESMTPS id A43243858D29; Mon, 10 Jun 2024 10:08:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A43243858D29 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A43243858D29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718014107; cv=none; b=d+AdDK/8wJFaBOl5MD9xzoJK1h//3vuhG6gtlQUImESSQXnSp1bVDOwuiaYRgFULfMGtIRuMbxuBKWKr7FTGkf38ok+8oaUmCrZQ1GB9ZBBZ8/bpbL0tV2bhRKAh//HaDC/SWEbX56xQ5BuC3M1xu14hPAB8kuHQbOFJ4n6nTig= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718014107; c=relaxed/simple; bh=AJ2pS4NbCNE23u4ypiG6snSU1WRAc3Bz+gHukX8pyfE=; h=MIME-Version:From:Date:Message-ID:Subject:To; b=WTrcwRWEm6w07/2Jql6rsoNKvN7jDlgfnFC0CdJe3xvOApTjcvy1yTgK3ys6SlmhHSpU0i7W3h7aYTCLaa1UzDezj26nCwrqPOShTJ2UQ7SeLSkKxvfYP3YAHdV0u0zatL66EF/30rCF+UUwFbfHPnIgC6WLplXLReBavQbxEKE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1f717b3f2d8so3836675ad.1; Mon, 10 Jun 2024 03:08:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718014104; x=1718618904; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uoXkKgmJHulHoQeb/DM46Nnf8Qfw5QWs7VY+CyUxsuM=; b=VcD2JusmpRV4/iJcowY2KK/vLccnEkfRSYZv1Zr2B4OOzV7c+0OzbcaCKgROsLkvB6 MJ4fgnBDnQIFssqovkE3UL6GPUDZ4MzjC9+A/FcsZapjcyr7Lhb76ayn0o+SBXI66Kiw 86J8YS4j35Svr2lmurW0eO3U/7ASdV9QgY/TOLCdr+lyNpMPlXOui+zERE+vDIbtYooq 2eAGjT9QtOD1TdIyx2Q7iCVJRlWbmnREKKnBDykk1uN7+QMu/dhdNhKWbs4JDD5pDAtz 00Uae5ScD0V76QAPGAGBt6ZtBGdMPKEBtCiLJyV54UyE45bZF91imQ+lIbVZ7XmF3DTz Tkzg== X-Forwarded-Encrypted: i=1; AJvYcCUBqalsFJ/GfRGeJs2tHxsYvc8ZWiKQWwVHJf6d/EK+YCk21dPweZVmhS4GhzdSaFaFy5zZAKHdH5atQn3um1JpFxc8++eq9w== X-Gm-Message-State: AOJu0YxFaKbdHlCfdTpXhh9ECGHEx45CuTJjv5r9HqmLiByW9rwtqY3R 410q+JMT2kOFS4eTnBq356uGi/yJd+pWa4NsU3d34RtElAK2sNpb0GCNewf0 X-Google-Smtp-Source: AGHT+IEOpHH26WhFsj/+B4jN/l2F/x+4sm8gDMpOKBDQWOxngQ+JP7QJY5uTMuKegj3B162Oo9cSrA== X-Received: by 2002:a17:902:fc43:b0:1f0:8cbf:c1b5 with SMTP id d9443c01a7336-1f6d0151b6fmr131459025ad.16.1718014104157; Mon, 10 Jun 2024 03:08:24 -0700 (PDT) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com. [209.85.214.181]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f71029e223sm20312985ad.170.2024.06.10.03.08.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Jun 2024 03:08:23 -0700 (PDT) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1f70fdc9644so6261535ad.0; Mon, 10 Jun 2024 03:08:23 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCWJ2pq3oF9zzq6bbu0CmNRKmpXKno1IjuWu1oM/zC/GmIc88ftrCwUT6Yqp+pC3lpgECUzwz9+rkCkHuzmuTh5+eiXlcvxc0A== X-Received: by 2002:a17:902:f54c:b0:1f6:fa4a:5083 with SMTP id d9443c01a7336-1f6fa4a536amr57840885ad.2.1718014103636; Mon, 10 Jun 2024 03:08:23 -0700 (PDT) MIME-Version: 1.0 References: <20240522095404.1825269-1-syq@gcc.gnu.org> In-Reply-To: From: YunQiang Su Date: Mon, 10 Jun 2024 18:08:09 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/2] driver: Use -as/ld/objcopy as final fallback instead of native ones for cross To: YunQiang Su , gcc-patches@gcc.gnu.org, pinskia@gmail.com, jeffreyalaw@gmail.com, doko@debian.org, richard.sandiford@arm.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,BODY_8BITS,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Richard Sandiford =E4=BA=8E2024=E5=B9=B46=E6=9C= =886=E6=97=A5=E5=91=A8=E5=9B=9B 17:54=E5=86=99=E9=81=93=EF=BC=9A > > YunQiang Su writes: > > YunQiang Su =E4=BA=8E2024=E5=B9=B45=E6=9C=8829=E6=97= =A5=E5=91=A8=E4=B8=89 10:02=E5=86=99=E9=81=93=EF=BC=9A > >> > >> Richard Sandiford =E4=BA=8E2024=E5=B9=B45= =E6=9C=8829=E6=97=A5=E5=91=A8=E4=B8=89 05:28=E5=86=99=E9=81=93=EF=BC=9A > >> > > >> > YunQiang Su writes: > >> > > If `find_a_program` cannot find `as/ld/objcopy` and we are a cross= toolchain, > >> > > the final fallback is `as/ld` of system. In fact, we can have a t= ry with > >> > > -as/ld/objcopy before fallback to native as/ld/objcopy. > >> > > > >> > > This patch is derivatived from Debian's patch: > >> > > gcc-search-prefixed-as-ld.diff > >> > > >> > I'm probably making you repeat a previous discussion, sorry, but cou= ld > >> > you describe the use case in more detail? The current approach to > >> > handling cross toolchains has been used for many years. Presumably > >> > this patch is supporting a different way of organising things, > >> > but I wasn't sure from the description what it was. > >> > > >> > AIUI, we currently assume that cross as, ld and objcopy will be > >> > installed under those names in $prefix/$target_alias/bin (aka $toold= ir/bin). > >> > E.g.: > >> > > >> > bin/aarch64-elf-as =3D aarch64-elf/bin/as > >> > > >> > GCC should then find as in aarch64-elf/bin. > >> > > >> > Is that not true in your case? > >> > > >> > >> Yes. This patch is only about the final fallback. I mean aarch64-elf/b= in/as > >> still has higher priority than bin/aarch64-elf-as. > >> > >> In the current code, we find gas with: > >> /prefix/aarch64-elf/bin/as > $PATH/as > >> > >> And this patch a new one between them: > >> /prefix/aarch64-elf/bin/as > $PATH/aarch64-elf-as > $PATH/as > >> > >> > To be clear, I'm not saying the patch is wrong. I'm just trying to > >> > understand why the patch is needed. > >> > > >> > >> Yes. If gcc is configured correctly, it is not so useful. > >> In some case for some lazy user, it may be useful, > >> for example, the binutils installed into different prefix with libc et= c. > >> > >> For example, binutils is installed into /usr/aarch64-elf/bin, while > >> libc is installed into /usr/local/aarch64-elf/. > >> > > > > Any idea about it? Is it a use case making sense? > > Yeah, I think it makes sense. GCC and binutils are separate packages. > Users could cherry-pick a GCC installation and a separate binutils > installation rather than bundling them together into a single > toolchain. And not everyone will have permission to change $tooldir. > > So I agree we should support searching the user's path for an > as/ld/etc. based on the tool prefix. Unfortunately, I don't think > I understand the code & constraints well enough to do a review. > > In particular, it seems unfortunate that we need to do a trial > subcommand invocation before committing to the prefixed name. > And, if we continue to search for "as" in the user's path as a fallback, > it's not 100% obvious that "${triple}-as" later in the path should trump > "as" earlier in the path. > > In some ways, it seems more consistent to do the replacement without > first doing a trial invocation. But I don't know whether that would > break existing use cases. (To be clear, I wouldn't feel comfortable Yes. This is also my worry as some users may set $PATH manually to a path which contains target `as`, such as export PATH=3D"/usr/aarch64-linux-gnu/bin:$PATH" > approving a patch to do that without buy-in from other maintainers.) > > Thanks, > Richard