1# Copyright (C) 2013-2016 Free Software Foundation, Inc. 2 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; either version 3 of the License, or 6# (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with GCC; see the file COPYING3. If not see 15# <http://www.gnu.org/licenses/>. 16 17# 18# atomic_link_flags -- compute library path and flags to find libatomic. 19# (originally from g++.exp) 20# 21 22proc atomic_link_flags { paths } { 23 global srcdir 24 global ld_library_path 25 global shlib_ext 26 27 set gccpath ${paths} 28 set flags "" 29 30 set shlib_ext [get_shlib_extension] 31 32 if { $gccpath != "" } { 33 if { [file exists "${gccpath}/libatomic/.libs/libatomic.a"] 34 || [file exists "${gccpath}/libatomic/.libs/libatomic.${shlib_ext}"] } { 35 append flags " -B${gccpath}/libatomic/ " 36 append flags " -L${gccpath}/libatomic/.libs" 37 append ld_library_path ":${gccpath}/libatomic/.libs" 38 } 39 } else { 40 global tool_root_dir 41 42 set libatomic [lookfor_file ${tool_root_dir} libatomic] 43 if { $libatomic != "" } { 44 append flags "-L${libatomic} " 45 append ld_library_path ":${libatomic}" 46 } 47 } 48 49 set_ld_library_path_env_vars 50 51 return "$flags" 52} 53 54# 55# atomic_init -- called at the start of each subdir of tests 56# 57 58proc atomic_init { args } { 59 global TEST_ALWAYS_FLAGS 60 global ALWAYS_CXXFLAGS 61 global TOOL_OPTIONS 62 global atomic_saved_TEST_ALWAYS_FLAGS 63 global atomic_saved_ALWAYS_CXXFLAGS 64 65 set link_flags "" 66 if ![is_remote host] { 67 if [info exists TOOL_OPTIONS] { 68 set link_flags "[atomic_link_flags [get_multilibs ${TOOL_OPTIONS}]]" 69 } else { 70 set link_flags "[atomic_link_flags [get_multilibs]]" 71 } 72 } 73 74 append link_flags " -latomic " 75 76 if [info exists TEST_ALWAYS_FLAGS] { 77 set atomic_saved_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS 78 } 79 if [info exists ALWAYS_CXXFLAGS] { 80 set atomic_saved_ALWAYS_CXXFLAGS $ALWAYS_CXXFLAGS 81 set ALWAYS_CXXFLAGS [concat "{ldflags=$link_flags}" $ALWAYS_CXXFLAGS] 82 } else { 83 if [info exists TEST_ALWAYS_FLAGS] { 84 set TEST_ALWAYS_FLAGS "$link_flags $TEST_ALWAYS_FLAGS" 85 } else { 86 set TEST_ALWAYS_FLAGS "$link_flags" 87 } 88 } 89 return [check_no_compiler_messages_nocache libatomic_available executable { 90 int main (void) { return 0; } 91 }] 92} 93 94# 95# atomic_finish -- called at the end of each subdir of tests 96# 97 98proc atomic_finish { args } { 99 global TEST_ALWAYS_FLAGS 100 global atomic_saved_TEST_ALWAYS_FLAGS 101 global atomic_saved_ALWAYS_CXXFLAGS 102 103 if [info exists atomic_saved_ALWAYS_CXXFLAGS] { 104 set ALWAYS_CXXFLAGS $atomic_saved_ALWAYS_CXXFLAGS 105 } else { 106 if [info exists atomic_saved_TEST_ALWAYS_FLAGS] { 107 set TEST_ALWAYS_FLAGS $atomic_saved_TEST_ALWAYS_FLAGS 108 } else { 109 unset TEST_ALWAYS_FLAGS 110 } 111 } 112 clear_effective_target_cache 113} 114