1 # Copyright
(C
) 2013-2014 Free Software Foundation
, Inc.
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.
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.
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
/>.
18 # ubsan_link_flags
-- compute library path and flags to find libubsan.
19 #
(originally from g
++.exp
)
22 proc ubsan_link_flags
{ paths
} {
24 global ld_library_path
30 set shlib_ext
[get_shlib_extension
]
32 if { $gccpath
!= "" } {
33 if { [file
exists "${gccpath}/libsanitizer/ubsan/.libs/libubsan.a"]
34 ||
[file
exists "${gccpath}/libsanitizer/ubsan/.libs/libubsan.${shlib_ext}"] } {
35 append flags
" -B${gccpath}/libsanitizer/ "
36 append flags
" -B${gccpath}/libsanitizer/ubsan/ "
37 append flags
" -L${gccpath}/libsanitizer/ubsan/.libs"
38 append ld_library_path
":${gccpath}/libsanitizer/ubsan/.libs"
43 set libubsan
[lookfor_file $
{tool_root_dir
} libubsan
]
44 if { $libubsan
!= "" } {
45 append flags
"-L${libubsan} "
46 append ld_library_path
":${libubsan}"
50 set_ld_library_path_env_vars
56 # ubsan_init
-- called at the start of each subdir of tests
59 proc ubsan_init
{ args } {
60 global TEST_ALWAYS_FLAGS
61 global ALWAYS_CXXFLAGS
63 global ubsan_saved_TEST_ALWAYS_FLAGS
66 if ![is_remote host
] {
67 if [info exists TOOL_OPTIONS
] {
68 set link_flags
"[ubsan_link_flags [get_multilibs ${TOOL_OPTIONS}]]"
70 set link_flags
"[ubsan_link_flags [get_multilibs]]"
74 if [info exists TEST_ALWAYS_FLAGS
] {
75 set ubsan_saved_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS
77 if [info exists ALWAYS_CXXFLAGS
] {
78 set ALWAYS_CXXFLAGS
[concat
"{ldflags=$link_flags}" $ALWAYS_CXXFLAGS]
80 if [info exists TEST_ALWAYS_FLAGS
] {
81 set TEST_ALWAYS_FLAGS
"$link_flags $TEST_ALWAYS_FLAGS"
83 set TEST_ALWAYS_FLAGS
"$link_flags"
86 if { $link_flags
!= "" } {
93 # ubsan_finish
-- called at the end of each subdir of tests
96 proc ubsan_finish
{ args } {
97 global TEST_ALWAYS_FLAGS
98 global ubsan_saved_TEST_ALWAYS_FLAGS
100 if [info exists ubsan_saved_TEST_ALWAYS_FLAGS
] {
101 set TEST_ALWAYS_FLAGS $ubsan_saved_TEST_ALWAYS_FLAGS
103 unset TEST_ALWAYS_FLAGS