From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by sourceware.org (Postfix) with ESMTPS id B70E7385E02B for ; Fri, 3 Apr 2020 23:01:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B70E7385E02B IronPort-SDR: 0IzE5DBgVztTNDmTLFjcpqSPqaT44aeqrTHc8SpqdskcS5bmclGwhH7K7DOtTwakvguPSFpuEy W++HYZG0UPF/UiX0DmbrE02m5px2IczwuKifF0gHV5PJBBHR3w7O2JoF2gWStTFRHCH/Kbi+ff fBaFGmwKQTCgzDpDONGm+hOhOi9rvQlvA3Jo8Acx3MHFe4CnZr0bOfMaQdO7+jOyeUm9A/wOV8 YPhP6J7z7OnvdspQeB6807hD+MVnIPNpNzL2X8Kg4iIa/NJ09lgYIr2u3HalFrUX1q5Kz8Y0I2 RXs= X-IronPort-AV: E=Sophos;i="5.72,341,1580745600"; d="scan'208";a="134547503" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 04 Apr 2020 07:01:28 +0800 IronPort-SDR: AdKmjBI7Oa0avIX7qvkL1MlMEKMKshHSngZgnzqUojiblcVvtkQFeoojr7Bsuh8J2GJI9tbu9+ HcqwBjqUppGP7VIM4MdvAfKHGtvq1IZIxBy9w/+u9Jf3xoV2q4il5yDMNiGqL8C7VKr4pFNA9o OBQWzys+4anlUUVvf3oNAXYbLI/bC/gwcqbHZEeN6cP0CZuRD7LwC4eXChRuN2544pCBcV6BgU qko2zjf/6lun5W0Y5iDpfLDpTqr4VfOWF6YsGTypyW3NMMu7el3Q6YMuc5AGOwpAVeGlH4loNq PIPUqP09WbOLGmUSLbTMgfgt Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2020 15:52:51 -0700 IronPort-SDR: kqjic910hr0LZrfqlHBGaQhFTFYvh4f2etqhn/PE25w4FOGmYUugSsrqr2FRAv8eY8W88XNImI TQ/UqowZ9HkGloLYkKZdd1Arv9T1pyeu58mtRwWgl3ESoN+arBw/Q5acPk+6riZk4x/LfnTG8I 5EnD3px6BetgXo4kToMopEDw+hCBdEMIsOwWiHtMk7lHJTGo6mq6OMR4heIS4M4W3QvDvgoOvb +6xG+cJ3CE3yEfLlqr8/yiAUTZrXfh/VJBzhTom/w6f1+Sme6sqhKEcVlMLsMAF1n3flS6XjuS 26g= WDCIronportException: Internal Received: from unknown (HELO redsun52) ([10.149.66.28]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2020 16:01:28 -0700 Date: Sat, 4 Apr 2020 00:01:25 +0100 (BST) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Jeff Law , Mike Stump , Chung-Lin Tang , Ian Lance Taylor , libffi-discuss@sourceware.org Subject: [PATCH v4 GCC 3/5] libffi/test: Make `libffi-init' use $CC_FOR_TARGET In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-17.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libffi-discuss@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libffi-discuss mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Apr 2020 23:01:32 -0000 Update code in `libffi-init' to use $CC_FOR_TARGET in determining the value of $ld_library_path, as using a different compiler location from one actually used in testing may have odd consequences. As this obviously loses the setting of $gccdir provide a replacement way to determine the directory if feasible, however prefer the location of shared libgcc over static libgcc. This helps in configurations where shared libgcc is, unlike libgcc, a location that is not specific to the compiler version, a common scenario. It does not address the scenario however where there is a shared libgcc symlink installed pointing to the actual run-time library installed elsewhere; this would have to be dealt with in a board description file specific to the installation. Use `remote_exec host' rather than `exec' to invoke the compiler so as to support remote configurations and also avoid the latter procedure's path length limitation that prevents execution in some actual scenarios. As using `remote_exec host' precludes the use of our existing file name globbing to examine directory contents reuse, with minor modifications needed to adjust to our structure, the piece I previously contributed to GCC with commit d42b84f427e4 ("testsuite: Fix run-time tracking down of `libgcc_s'"). libffi/ * testsuite/lib/libffi.exp (libffi-init): Use CC_FOR_TARGET. Update the determination of `ld_library_path' accordingly. --- This is a backport of combined upstream libffi changes as recorded here: and here: (there's no point to introduce indentation breakage only to fix it with the next change). New change in v4. --- libffi/testsuite/lib/libffi.exp | 72 ++++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 18 deletions(-) gcc-test-libffi-init-compiler.diff Index: gcc/libffi/testsuite/lib/libffi.exp =================================================================== --- gcc.orig/libffi/testsuite/lib/libffi.exp +++ gcc/libffi/testsuite/lib/libffi.exp @@ -99,7 +99,7 @@ proc libffi-init { args } { global blddirffi global objdir global blddircxx - global TOOL_OPTIONS + global CC_FOR_TARGET global tool global libffi_include global libffi_link_flags @@ -114,26 +114,62 @@ proc libffi-init { args } { set compiler_vendor "gnu" - set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a] - if {$gccdir != ""} { - set gccdir [file dirname $gccdir] - } - verbose "gccdir $gccdir" + if { [string match $compiler_vendor "gnu"] } { + if [info exists CC_FOR_TARGET] then { + set compiler "$CC_FOR_TARGET" + set libgcc_a_x [remote_exec host "$compiler" \ + "-print-file-name=libgcc.a"] + if { [lindex $libgcc_a_x 0] == 0 } { + set gccdir [file dirname [lindex $libgcc_a_x 1]] + } else { + set gccdir "" + } + } else { + set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a] + if {$gccdir != ""} { + set gccdir [file dirname $gccdir] + } + set compiler "${gccdir}/xgcc" + } + verbose "gccdir $gccdir" - set ld_library_path "." - append ld_library_path ":${gccdir}" + set shlib_ext [get_shlib_extension] + set libgcc_s_x [remote_exec host "$compiler" \ + "-print-file-name=libgcc_s.${shlib_ext}"] + if { [lindex $libgcc_s_x 0] == 0 } { + set libgcc_dir [file dirname [lindex $libgcc_s_x 1]] + } else { + set libgcc_dir $gccdir + } + verbose "libgcc_dir $libgcc_dir" - set compiler "${gccdir}/xgcc" - if { [is_remote host] == 0 && [which $compiler] != 0 } { - foreach i "[exec $compiler --print-multi-lib]" { - set mldir "" - regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir - set mldir [string trimright $mldir "\;@"] - if { "$mldir" == "." } { - continue + set ld_library_path "." + append ld_library_path ":${gccdir}" + + set multi_dir_x [remote_exec host "$compiler" "-print-multi-directory"] + set multi_lib_x [remote_exec host "$compiler" "-print-multi-lib"] + if { [lindex $multi_dir_x 0] == 0 && [lindex $multi_lib_x 0] == 0 } { + set multi_dir [string trim [lindex $multi_dir_x 1]] + set multi_lib [string trim [lindex $multi_lib_x 1]] + if { "$multi_dir" == "." } { + set multi_root "$libgcc_dir" + } else { + set multi_match [string last "/$multi_dir" "$libgcc_dir"] + if { "$multi_match" >= 0 } { + set multi_root [string range "$libgcc_dir" \ + 0 [expr $multi_match - 1]] + } else { + set multi_lib "" + } } - if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } { - append ld_library_path ":${gccdir}/${mldir}" + foreach i "$multi_lib" { + set mldir "" + regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir + set mldir [string trimright $mldir "\;@"] + if { "$mldir" == "$multi_dir" } { + continue + } + append ld_library_path ":${multi_root}/${mldir}" } } }