From patchwork Mon Jan 1 16:48:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YunQiang Su X-Patchwork-Id: 1881451 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=iieBv90n; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T3hll0ZQ7z20LT for ; Tue, 2 Jan 2024 03:49:21 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 416ED3858428 for ; Mon, 1 Jan 2024 16:49:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 416ED3858428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704127757; bh=RJlWR1SY93Zw4Fg22JnXDtwmPoH2eG/hNO8vCmIDpsI=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=iieBv90nGT82HHTsjkkOSz8hgJmotxMQhh1DNvw4nyRFdu13fMtHFdVhDKZYmpFS+ KtH3z1fVBJsmsHzxAvmwwErF/RXr1rhT+GP6cZKKx9vu/oDtNff0GYCRdsWkz5Thlv pwmJ3Rm2f089mmoDZ1xqpklO9z+e/QggXAhgedGw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by sourceware.org (Postfix) with ESMTPS id 765C03858D1E; Mon, 1 Jan 2024 16:48:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 765C03858D1E 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 765C03858D1E 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=1704127717; cv=none; b=sx51hPdwKHXAsFn25/kQKzRS5v8Wyu7PllBgtT3HXYOHVxAnD2vYvNkz6lu7cSmkpOo7ZOM2XNY2belu8xtCHkH5WBScTi/kiiisdwW1mfwpGOxBaHY2qSIwDIcbFICvYCu7sG0FpH8AXYoLoBSgXUfKyo+cWNYT9KzqOsVsMkY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704127717; c=relaxed/simple; bh=Q2/wZj+V5C/oTyll/MWbpxw+iVsTzcfFZ++IPQV53VY=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=LcHD7ne1ysDau6/IJnRGiZMBbCjTu2Djv9lOP7MW4FfKdau5fku2e5bqVyjN3q2+n8lD+viyE9jHlZbiZkCPRhtAWKOX9sRrIbWi/dkb/rAIBsiBQE8vqDA2lY2EYJr0gZqCK371fAJZ1T/DmzDb5hq2Q7hO84NAKuyJCsaJh90= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1d4b650bc9cso6343205ad.0; Mon, 01 Jan 2024 08:48:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704127714; x=1704732514; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RJlWR1SY93Zw4Fg22JnXDtwmPoH2eG/hNO8vCmIDpsI=; b=dqer5Lvf5n8yqIJHcZDdUhW9Ei49mO8Sniz0O9CFiqjcwVDcaLZyTPQFfnU/5tT6qm huZX0XCqW3EZAv3FztLH6NzftP5BGm6wa/mdWFMydULtWunm9RSErB5riSSTi/BoxAH3 5dLvJ/wWvPvDb+QhAvZigRcE+MPd40JH4hBcq7eCVzWaiD9cL73vXmeuEF8AZkdCsSfL 8ormUBDZ6A3cMM19/SQ2NBh/qPdKQkQSUDXZ6hpNBU90wc7YXB7/+4UgLF7d/4rJdhXn hjSAaoZONoepKMDh0mLn4oXGopmmbUpPpydsywafgk7+c1DDWsIbsyosYIvDxifrBULz 5aig== X-Gm-Message-State: AOJu0YzXUrVprBukvf7kTZR3RjGPG4nfO++cYqM7BXSGP2LBzWW5rc12 /IR70VmVMe349X4IEupASaDBxf4B1ZoYJQ== X-Google-Smtp-Source: AGHT+IHMnT977hkZO5HYbHjFyETqQ3kL53zlLk3e7kU6dkvnlTyEF1QP4fxHippOCd4DAOgJNeAmtA== X-Received: by 2002:a17:902:bf42:b0:1d3:bedd:ad with SMTP id u2-20020a170902bf4200b001d3bedd00admr17364661pls.35.1704127713688; Mon, 01 Jan 2024 08:48:33 -0800 (PST) Received: from localhost.localdomain ([149.248.38.156]) by smtp.gmail.com with ESMTPSA id iz2-20020a170902ef8200b001d49c061804sm6229553plb.202.2024.01.01.08.48.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 08:48:33 -0800 (PST) From: YunQiang Su To: gcc-patches@gcc.gnu.org Cc: doko@debian.org, YunQiang Su Subject: [PATCH] config-ml.in: Fix multi-os-dir search Date: Tue, 2 Jan 2024 00:48:07 +0800 Message-Id: <20240101164807.3812140-1-syq@gcc.gnu.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, 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=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org When building multilib libraries, CC/CXX etc are set with an option -B*/lib/, instead of -B/lib/. This will make some trouble in some case, for example building cross toolchain based on Debian's cross packages: If we have libc6-dev-i386-amd64-cross packages installed on a non-x86 machine. This package will have the files in /usr/x86_4-linux-gnu/lib32. The fellow configure will fail when build libgcc for i386, with complains the libc is not i386 ones: ../configure --enable-multilib --enable-multilib \ --target=x86_64-linux-gnu Let's insert a "-B*/lib/`CC ${flags} --print-multi-os-directory`" before "-B*/lib/". This patch is based on the patch used by Debian now. ChangeLog * config-ml.in: Insert an -B option with multi-os-dir into compiler commands used to build libraries. --- config-ml.in | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/config-ml.in b/config-ml.in index 68854a4f16c..645cac822fd 100644 --- a/config-ml.in +++ b/config-ml.in @@ -514,7 +514,12 @@ multi-do: else \ if [ -d ../$${dir}/$${lib} ]; then \ flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \ - if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) \ + libsuffix_=`$${compiler} $${flags} --print-multi-os-directory`; \ + if (cd ../$${dir}/$${lib}; $(MAKE) $(subst \ + -B$(build_tooldir)/lib/, \ + -B$(build_tooldir)/lib/$${libsuffix_}/ \ + -B$(build_tooldir)/lib/, \ + $(FLAGS_TO_PASS)) \ CFLAGS="$(CFLAGS) $${flags}" \ CCASFLAGS="$(CCASFLAGS) $${flags}" \ FCFLAGS="$(FCFLAGS) $${flags}" \ @@ -768,6 +773,7 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then # Create a regular expression that matches any string as long # as ML_POPDIR. popdir_rx=`echo "${ML_POPDIR}" | sed 's,.,.,g'` + multi_osdir=`${CC-gcc} ${flags} --print-multi-os-directory 2>/dev/null` CC_= for arg in ${CC}; do case $arg in @@ -775,6 +781,8 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then CC_="${CC_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\1/p"`' ' ;; "${ML_POPDIR}"/*) CC_="${CC_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; + -B*/lib/) + CC_="${CC_}${arg}${multi_osdir} ${arg} " ;; *) CC_="${CC_}${arg} " ;; esac @@ -787,6 +795,8 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then CXX_="${CXX_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; "${ML_POPDIR}"/*) CXX_="${CXX_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; + -B*/lib/) + CXX_="${CXX_}${arg}${multi_osdir} ${arg} " ;; *) CXX_="${CXX_}${arg} " ;; esac @@ -799,6 +809,8 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then F77_="${F77_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; "${ML_POPDIR}"/*) F77_="${F77_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; + -B*/lib/) + F77_="${F77_}${arg}${multi_osdir} ${arg} " ;; *) F77_="${F77_}${arg} " ;; esac @@ -811,6 +823,8 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then GFORTRAN_="${GFORTRAN_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; "${ML_POPDIR}"/*) GFORTRAN_="${GFORTRAN_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; + -B*/lib/) + GFORTRAN_="${GFORTRAN_}${arg}${multi_osdir} ${arg} " ;; *) GFORTRAN_="${GFORTRAN_}${arg} " ;; esac @@ -823,6 +837,8 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then GOC_="${GOC_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; "${ML_POPDIR}"/*) GOC_="${GOC_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; + -B*/lib/) + GOC_="${GOC_}${arg}${multi_osdir} ${arg} " ;; *) GOC_="${GOC_}${arg} " ;; esac @@ -835,6 +851,8 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then GDC_="${GDC_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; "${ML_POPDIR}"/*) GDC_="${GDC_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; + -B*/lib/) + GDC_="${GDC_}${arg}${multi_osdir} ${arg} " ;; *) GDC_="${GDC_}${arg} " ;; esac