From patchwork Fri Jun 14 12:12:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YunQiang Su X-Patchwork-Id: 1947883 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=KmV6Q/Yp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4W0yq00MJkz20KL for ; Fri, 14 Jun 2024 22:13:16 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1F3523882161 for ; Fri, 14 Jun 2024 12:13:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1F3523882161 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1718367194; bh=HxVPZgFbOLiXxXOIf2Zq1GN8cOeFLq7cl2O1HSrvSOY=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=KmV6Q/YpNlWfVs2FBNEdWKl7jaawUWxoqtEwywP9LDkw2P4/LCNenL4BgdX5DWpDX PIMprXlqRm5u9J9+ij58d+eyrP1zK/haCpNgQySdCmWO9bG76lo3S+JGhbyduieaU1 4KPkCDyB3dPkpXEBneZySLcoI2bF0LOVCKPucRH0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by sourceware.org (Postfix) with ESMTPS id 91CCF3882648; Fri, 14 Jun 2024 12:12:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 91CCF3882648 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 91CCF3882648 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718367158; cv=none; b=qq+9rj6LKOrBl+EAJ/wJrAnXyb+JbDvgh7C/sY1oVQEkiWS974wzCyvQVWVKOacA7Lz1sp5HgXaE/Lo2uX0A1ygf2xZjdMKDJHnBM34omGgmD5H8HV0sTt1zAGqFQ4gozG4ecHxwfEAwgDDpR5/5/8cKRhv669lpYiIsrTwA998= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718367158; c=relaxed/simple; bh=j4uTbjnwGeYBic6qjEKM0nWn9h5xhZYukQWwRdxReSo=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=kpMH6beoAj0x+eLC6RSDh6vF4Nsza0Nq5A8GlwpxvtdmAYsD+FuzpbYVlZC+oOJW7BduNgJNNki+4ldB8DpztYCvSvFXlUeOppGUz7DA9uGF5rWMlG4LDLIDz9X5b1eQBI1JOOupZqz+HlMC5wpqGFxFfg82auJSAgmuaaOmxrQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6f6a045d476so1704085b3a.1; Fri, 14 Jun 2024 05:12:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718367148; x=1718971948; 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=HxVPZgFbOLiXxXOIf2Zq1GN8cOeFLq7cl2O1HSrvSOY=; b=gPUmQeF9rKpWG2G4s5lS5cAXfEz4jCO+Dud14mPfm1WNBxuj9mo2QNBd1/+zgdh9J2 d6uv+bkISczEFL1YjVODVPcgvnzHLfKGzbqknCCOrwPyD97vKpHcJxBxboksrq/a8+O7 JEAh46C1lHV98gh4H+xOjlJQ2uGJ+i29TXoYDHBN4ALUGNI3+ZALw584pmBnITJpMyXv rzvLlvZ6CWKVzp2xlHiJY/Lg13TZbVCG2aVRNJnm1Z4LChzLaQSvhVzd+0oXJlVd0O6R UoWLAT93hxrpjvlNILYNymHZoJP8MxdhR51jswlBLPUKM35D2Vo6hAr8QiuL1TT4CGs6 QRHQ== X-Forwarded-Encrypted: i=1; AJvYcCVc6IXKLI2O4Txc0H9URdgSRiNO1mmoqZR8qD5DrDOj+RWKdQo7D1ws8Gtdm+9HblfDqThrGdctfkeol+YWoMAwQbsbD2GXkSZjJiqhjwSvnktE+w== X-Gm-Message-State: AOJu0YzpvaD5gGvAJx23dgg/l1qG3lTQGgZfd9ffGzfZtvwx1lU/oNDl WgKHKQcheCgKyG+sqF4gqSjsq1vWfab7G2jg5tF9xA/6+nd0tQwFucIcaQ== X-Google-Smtp-Source: AGHT+IE54p7mFMtgvU90tWaLNUxVotFOn1f44fgDl/eaPz+CXHPyeE1vL2uuVKWHDZFDsJ/iDzevMQ== X-Received: by 2002:aa7:8f8f:0:b0:704:2152:e4d2 with SMTP id d2e1a72fcca58-705d7177310mr2186692b3a.17.1718367148360; Fri, 14 Jun 2024 05:12:28 -0700 (PDT) Received: from localhost.localdomain ([194.169.55.179]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705ccba0a33sm2906041b3a.218.2024.06.14.05.12.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 14 Jun 2024 05:12:27 -0700 (PDT) From: YunQiang Su To: gcc-patches@gcc.gnu.org Cc: marcuscalhounlopez@gmail.com, sjames@gcc.gnu.org, jeffreyalaw@gmail.com, richard.sandiford@arm.com, doko@debian.org, YunQiang Su Subject: [PATCH] Build/Cross: Look for target headers from include if sys-include doesn't exist Date: Fri, 14 Jun 2024 20:12:18 +0800 Message-Id: <20240614121218.63375-1-syq@gcc.gnu.org> X-Mailer: git-send-email 2.39.3 (Apple Git-146) MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 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 PR 115416 When we build a cross toolchain, while without --with-sysroot, target headers are expected in ${test_exec_prefix}/${target_noncanonical}/sys-include while it is true only with --with-headers option is used. In other cases, the path should be ${test_exec_prefix}/${target_noncanonical}/include such as Debian's cross toolchain. Debian's cross toolchain has directory structures like: /usr//lib /include /bin/ For this case, we cannot use "--prefix=/usr --with-sysroot=/", as gcc/configure will use headers of build, aka in /usr/include to detect features. And fixinclude also uses the headers of build. Let's use the `include` if `sys-include` doesn't exist. For Makefile.in, the compare @includedir@ and $(prefix)/include is not correct, as the --includedir option is used to set where the headers should be installed. gcc: PR 115415. configure.ac: Set target_header_dir and CROSS_SYSTEM_HEADER_DIR to ${test_exec_prefix}/${target_noncanonical}/include when cross and without --with-sysroot and without --with-headers. configure: Regenerate. Makefile.in: Set CROSS_SYSTEM_HEADER_DIR as configure, and don't compare @includedir@ and $(prefix)/include. --- gcc/Makefile.in | 6 +----- gcc/configure | 8 ++++++-- gcc/configure.ac | 4 ++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gcc/Makefile.in b/gcc/Makefile.in index f5adb647d3f..349f988dc08 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -560,11 +560,7 @@ LINKER_PLUGIN_API_H = $(srcdir)/../include/plugin-api.h # Default native SYSTEM_HEADER_DIR, to be overridden by targets. NATIVE_SYSTEM_HEADER_DIR = @NATIVE_SYSTEM_HEADER_DIR@ # Default cross SYSTEM_HEADER_DIR, to be overridden by targets. -ifeq (@includedir@,$(prefix)/include) - CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@ -else - CROSS_SYSTEM_HEADER_DIR = @includedir@ -endif +CROSS_SYSTEM_HEADER_DIR = @CROSS_SYSTEM_HEADER_DIR@ # autoconf sets SYSTEM_HEADER_DIR to one of the above. # Purge it of unnecessary internal relative paths diff --git a/gcc/configure b/gcc/configure index aaf5899cc03..d11e97d1758 100755 --- a/gcc/configure +++ b/gcc/configure @@ -15124,6 +15124,10 @@ if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x || target_header_dir="${with_build_sysroot}${native_system_header_dir}" elif test "x$with_sysroot" = x; then target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-include" + if ! test -d ${target_header_dir};then + target_header_dir="${test_exec_prefix}/${target_noncanonical}/include" + fi + CROSS_SYSTEM_HEADER_DIR=${target_header_dir} elif test "x$with_sysroot" = xyes; then target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-root${native_system_header_dir}" else @@ -21410,7 +21414,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 21413 "configure" +#line 21417 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -21516,7 +21520,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 21519 "configure" +#line 21523 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac index f8d67efeb98..54e6776747e 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -2512,6 +2512,10 @@ if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x || target_header_dir="${with_build_sysroot}${native_system_header_dir}" elif test "x$with_sysroot" = x; then target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-include" + if test -d ${target_header_dir};then + target_header_dir="${test_exec_prefix}/${target_noncanonical}/include" + fi + CROSS_SYSTEM_HEADER_DIR=${target_header_dir} elif test "x$with_sysroot" = xyes; then target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-root${native_system_header_dir}" else