From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1033) id 835023857836; Fri, 28 May 2021 20:50:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 835023857836 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: David Edelsohn To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-8482] testuite: fix libtdc++ libatomic flags X-Act-Checkin: gcc X-Git-Author: David Edelsohn X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 0be51abf080f1d7515e3777dd5e5a983b47573a8 X-Git-Newrev: 15c41a11ee5c1e917804f57315ba8968852ca016 Message-Id: <20210528205041.835023857836@sourceware.org> Date: Fri, 28 May 2021 20:50:41 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 May 2021 20:50:41 -0000 https://gcc.gnu.org/g:15c41a11ee5c1e917804f57315ba8968852ca016 commit r11-8482-g15c41a11ee5c1e917804f57315ba8968852ca016 Author: David Edelsohn Date: Fri Apr 23 17:45:10 2021 -0400 testuite: fix libtdc++ libatomic flags Some ports require libatomic for atomic operations, at least for some data types and widths. The libstdc++ testsuite previously was updated to link against libatomic, but the search path was hard-coded to something that is not always correct, and the shared library search path was not set. The search path was hard-coded to the expected location of the libatomic build directory relative to the libstdc++ testsuite directory, but if one uses parallelism when invoking the libstdc++ testsuite, the tests are run in the "normalXX" sub-directories, for which the hard-coded search path is incorrect. The path also is incorrect for alternative multilib and tool options. This patch adopts the logic from gcc/testsuite/lib/atomic-dg.exp to search for the library and adds the logic to the libstdc++ testsuite libatomic seatch path code. Previously the libstdc++ testsuite atomic tests failed depending on the build configuration and if a build of libatomic was installed in the default search path. Bootstrapped on powerpc-ibm-aix7.2.3.0. libstdc++-v3/ChangeLog: * testsuite/lib/dg-options.exp (atomic_link_flags): New. (add_options_for_libatomic): Use atomic_link_flags. (cherry picked from commit fb6b24c66ea5a2ccbf6fb9f299c20a69f962ac9b) Diff: --- libstdc++-v3/testsuite/lib/dg-options.exp | 47 ++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp index 7894973bcca..872768f2620 100644 --- a/libstdc++-v3/testsuite/lib/dg-options.exp +++ b/libstdc++-v3/testsuite/lib/dg-options.exp @@ -260,13 +260,58 @@ proc add_options_for_net_ts { flags } { # Add to FLAGS all the target-specific flags to link to libatomic, # if required for atomics on pointers and 64-bit types. +proc atomic_link_flags { paths } { + global srcdir + global ld_library_path + global shlib_ext + + set gccpath ${paths} + set flags "" + + set shlib_ext [get_shlib_extension] + + if { $gccpath != "" } { + if { [file exists "${gccpath}/libatomic/.libs/libatomic.a"] + || [file exists "${gccpath}/libatomic/.libs/libatomic.${shlib_ext}"] } { + append flags " -B${gccpath}/libatomic/ " + append flags " -L${gccpath}/libatomic/.libs" + append ld_library_path ":${gccpath}/libatomic/.libs" + } + } else { + global tool_root_dir + + set libatomic [lookfor_file ${tool_root_dir} libatomic] + if { $libatomic != "" } { + append flags "-L${libatomic} " + append ld_library_path ":${libatomic}" + } + } + + set_ld_library_path_env_vars + + return "$flags" +} + proc add_options_for_libatomic { flags } { if { [istarget hppa*-*-hpux*] || ([istarget powerpc*-*-*] && [check_effective_target_ilp32]) || [istarget riscv*-*-*] || ([istarget sparc*-*-linux-gnu] && [check_effective_target_ilp32]) } { - return "$flags -L../../libatomic/.libs -latomic" + global TOOL_OPTIONS + + set link_flags "" + if ![is_remote host] { + if [info exists TOOL_OPTIONS] { + set link_flags "[atomic_link_flags [get_multilibs ${TOOL_OPTIONS}]]" + } else { + set link_flags "[atomic_link_flags [get_multilibs]]" + } + } + + append link_flags " -latomic " + + return "$flags $link_flags" } return $flags }