From patchwork Tue Jun 18 09:51:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 1949007 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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 4W3MVD2GvTz20KL for ; Tue, 18 Jun 2024 19:52:04 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 928B43882AC9 for ; Tue, 18 Jun 2024 09:52:02 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from angie.orcam.me.uk (angie.orcam.me.uk [78.133.224.34]) by sourceware.org (Postfix) with ESMTP id A2F2E3882ACD for ; Tue, 18 Jun 2024 09:51:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A2F2E3882ACD Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=orcam.me.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=orcam.me.uk ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A2F2E3882ACD Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=78.133.224.34 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718704300; cv=none; b=NnSpDgLRUCle79I40XzlYOZSB89/36kZem3tX61nZ9naopDgmS6S5ZGbj1kPHX2BbMb8Cr8tdHES6dV5IzjjsCbasaC1UspdZm8QotABqyGPVfsJTBW/u8dNI90Pa/vnC7EgMwB7Iw0RzIxSBGREqus2BKogcjMjE+M/Di0eBCs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718704300; c=relaxed/simple; bh=xkD65RAGEGXC0Dq01spWEokO0aQQ5TTiU7vuFgozt+s=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=TbC2wip3rylLDY2stuF5kH3/NGDHy/7bsgPgEBYtlG0HE4c0L0GjCbV++EhqaDaKvIVwu9xzKA957qdHvHtwFX42a8Kfh4ATSMWOY+kUtP5n7JYT94SNYd9mxfU2oCGLK4AUILSvFu62ThY70KQZ+IQlsCKIpybTxOEvPKVVc8s= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by angie.orcam.me.uk (Postfix, from userid 500) id B0AC592009C; Tue, 18 Jun 2024 11:51:34 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id AD58B92009B; Tue, 18 Jun 2024 10:51:34 +0100 (BST) Date: Tue, 18 Jun 2024 10:51:34 +0100 (BST) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Arnaud Charlet , Eric Botcazou , =?utf-8?q?Marc_Poulhi=C3=A8s?= , Pierre-Marie de Rodat Subject: [PATCH 1/1] ada: Make the names of uninstalled cross-gnattools consistent across builds In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 X-Spam-Status: No, score=-1162.8 required=5.0 tests=BAYES_00, KAM_ASCII_DIVIDERS, KAM_DMARC_STATUS, KAM_INFOUSMEBIZ, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, 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 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 We suffer from an inconsistency in the names of uninstalled gnattools executables in cross-compiler configurations. The cause is a recipe we have: ada.all.cross: for tool in $(ADA_TOOLS) ; do \ if [ -f $$tool$(exeext) ] ; \ then \ $(MV) $$tool$(exeext) $$tool-cross$(exeext); \ fi; \ done the intent of which is to give the names of gnattools executables the '-cross' suffix, consistently with the compiler drivers: 'gcc-cross', 'g++-cross', etc. A problem with the recipe is that this 'make' target is called too early in the build process, before gnattools have been made. Consequently no renames happen and owing to that they are conditional on the presence of the individual executables the recipe succeeds doing nothing. However if a target is requested later on such as 'make pdf' that does not cause gnattools executables to be rebuilt, then 'ada.all.cross' does succeed in renaming the executables already present in the build tree. Then if the 'gnat' testsuite is run later on which expects non-suffixed 'gnatmake' executable, it does not find the 'gnatmake-cross' executable in the build tree and may either catastrophically fail or incorrectly use a system-installed copy of 'gnatmake'. Of course if a target is requested such as `make all' that does cause gnattools executables to be rebuilt, then both suffixed and non-suffixed uninstalled executables result. Fix the problem by moving the renaming of gnattools to a separate 'make' recipe, pasted into a new 'gnattools-cross-mv' target and the existing legacy 'cross-gnattools' target. Then invoke the new target explicitly from the 'gnattools-cross' recipe in gnattools/. Update the test harness accordingly, so that suffixed gnattools are used in cross-compilation testsuite runs. gcc/ * ada/gcc-interface/Make-lang.in (ada.all.cross): Move recipe to... (GNATTOOLS_CROSS_MV): ... this new variable. (cross-gnattools): Paste it here. (gnattools-cross-mv): New target. gnattools/ * Makefile.in (gnattools-cross): Also build 'gnattools-cross-mv' in GCC_DIR. gcc/testsuite/ * lib/gnat.exp (local_find_gnatmake, find_gnatclean): Use '-cross' suffix where testing a cross-compiler. --- gcc/ada/gcc-interface/Make-lang.in | 19 ++++++++++++------- gcc/testsuite/lib/gnat.exp | 22 ++++++++++++++++++---- gnattools/Makefile.in | 1 + 3 files changed, 31 insertions(+), 11 deletions(-) gcc-ada-all-cross-gnattools.diff Index: gcc/gcc/ada/gcc-interface/Make-lang.in =================================================================== --- gcc.orig/gcc/ada/gcc-interface/Make-lang.in +++ gcc/gcc/ada/gcc-interface/Make-lang.in @@ -780,6 +780,7 @@ gnattools: $(GCC_PARTS) $(CONFIG_H) pref cross-gnattools: force $(MAKE) -C ada $(ADA_TOOLS_FLAGS_TO_PASS) gnattools1-re $(MAKE) -C ada $(ADA_TOOLS_FLAGS_TO_PASS) gnattools2 + $(GNATTOOLS_CROSS_MV) canadian-gnattools: force $(MAKE) -C ada $(ADA_TOOLS_FLAGS_TO_PASS) gnattools1-re @@ -795,19 +796,23 @@ gnatlib gnatlib-sjlj gnatlib-zcx gnatlib FORCE_DEBUG_ADAFLAGS="$(FORCE_DEBUG_ADAFLAGS)" \ $@ +gnattools-cross-mv: + $(GNATTOOLS_CROSS_MV) + +GNATTOOLS_CROSS_MV=\ + for tool in $(ADA_TOOLS) ; do \ + if [ -f $$tool$(exeext) ] ; \ + then \ + $(MV) $$tool$(exeext) $$tool-cross$(exeext); \ + fi; \ + done + # use only for native compiler gnatlib_and_tools: gnatlib gnattools # Build hooks: ada.all.cross: - for tool in $(ADA_TOOLS) ; do \ - if [ -f $$tool$(exeext) ] ; \ - then \ - $(MV) $$tool$(exeext) $$tool-cross$(exeext); \ - fi; \ - done - ada.start.encap: ada.rest.encap: ada.man: Index: gcc/gcc/testsuite/lib/gnat.exp =================================================================== --- gcc.orig/gcc/testsuite/lib/gnat.exp +++ gcc/gcc/testsuite/lib/gnat.exp @@ -199,12 +199,19 @@ proc prune_gnat_output { text } { # which prevent multilib from working, so define a new one. proc local_find_gnatmake {} { + global target_triplet global tool_root_dir + global host_triplet if ![is_remote host] { - set file [lookfor_file $tool_root_dir gnatmake] + if { "$host_triplet" == "$target_triplet" } { + set gnatmake gnatmake + } else { + set gnatmake gnatmake-cross + } + set file [lookfor_file $tool_root_dir $gnatmake] if { $file == "" } { - set file [lookfor_file $tool_root_dir gcc/gnatmake] + set file [lookfor_file $tool_root_dir gcc/$gnatmake] } if { $file != "" } { set root [file dirname $file] @@ -225,12 +232,19 @@ proc local_find_gnatmake {} { } proc find_gnatclean {} { + global target_triplet global tool_root_dir + global host_triplet if ![is_remote host] { - set file [lookfor_file $tool_root_dir gnatclean] + if { "$host_triplet" == "$target_triplet" } { + set gnatclean gnatclean + } else { + set gnatclean gnatclean-cross + } + set file [lookfor_file $tool_root_dir $gnatclean] if { $file == "" } { - set file [lookfor_file $tool_root_dir gcc/gnatclean] + set file [lookfor_file $tool_root_dir gcc/$gnatclean] } if { $file != "" } { set gnatclean $file; Index: gcc/gnattools/Makefile.in =================================================================== --- gcc.orig/gnattools/Makefile.in +++ gcc/gnattools/Makefile.in @@ -223,6 +223,7 @@ gnattools-cross: $(GCC_DIR)/stamp-tools # gnattools2 $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \ $(TOOLS_FLAGS_TO_PASS_CROSS) common-tools + $(MAKE) -C $(GCC_DIR) gnattools-cross-mv # Other # -----