# Copyright (C) 2014-2016 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GCC; see the file COPYING3. If not see # . # Return 1 if compilation with "-fcheck-pointer-bounds -mmpx" is # error-free for trivial code, 0 otherwise. proc check_effective_target_mpx {} { return [check_no_compiler_messages mpx executable { int *foo (int *arg) { return arg; } int main (void) { int *p = (int *)__builtin_malloc (sizeof (int)); int res = foo (p) == 0; __builtin_free (p); return res; } } "-fcheck-pointer-bounds -mmpx"] } # # mpx_link_flags -- compute library path and flags to find libmpx. # proc mpx_link_flags { paths } { global srcdir global ld_library_path global shlib_ext global mpx_saved_library_path set gccpath ${paths} set flags "" set shlib_ext [get_shlib_extension] set mpx_saved_library_path $ld_library_path if { $gccpath != "" } { if { [file exists "${gccpath}/libmpx/mpxrt/.libs/libmpx.a"] || [file exists "${gccpath}/libmpx/mpxrt/.libs/libmpx.${shlib_ext}"] } { append flags " -B${gccpath}/libmpx/ " append flags " -B${gccpath}/libmpx/mpxrt " append flags " -L${gccpath}/libmpx/mpxrt/.libs " append ld_library_path ":${gccpath}/libmpx/mpxrt/.libs" } if { [file exists "${gccpath}/libmpx/mpxwrap/.libs/libmpxwrappers.a"] || [file exists "${gccpath}/libmpx/mpxwrap/.libs/libmpxwrappers.${shlib_ext}"] } { append flags " -B${gccpath}/libmpx/ " append flags " -B${gccpath}/libmpx/mpxwrap " append flags " -L${gccpath}/libmpx/mpxwrap/.libs " append ld_library_path ":${gccpath}/libmpx/mpxwrap/.libs" } } else { global tool_root_dir set libmpx [lookfor_file ${tool_root_dir} libmpx] if { $libmpx != "" } { append flags "-L${libmpx} " append ld_library_path ":${libmpx}" } set libmpxwrappers [lookfor_file ${tool_root_dir} libmpxwrappers] if { $libmpxwrappers != "" } { append flags "-L${libmpxwrappers} " append ld_library_path ":${libmpxwrappers}" } } set_ld_library_path_env_vars return "$flags" } # # mpx_init -- called at the start of each subdir of tests # proc mpx_init { args } { global TEST_ALWAYS_FLAGS global ALWAYS_CXXFLAGS global TOOL_OPTIONS global mpx_saved_TEST_ALWAYS_FLAGS global mpx_saved_ALWAYS_CXXFLAGS setenv CHKP_RT_MODE "stop" set link_flags "" if ![is_remote host] { if [info exists TOOL_OPTIONS] { set link_flags "[mpx_link_flags [get_multilibs ${TOOL_OPTIONS}]]" } else { set link_flags "[mpx_link_flags [get_multilibs]]" } } if [info exists TEST_ALWAYS_FLAGS] { set mpx_saved_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS } if [info exists ALWAYS_CXXFLAGS] { set mpx_saved_ALWAYS_CXXFLAGS $ALWAYS_CXXFLAGS set ALWAYS_CXXFLAGS [concat "{ldflags=$link_flags}" $ALWAYS_CXXFLAGS] } else { if [info exists TEST_ALWAYS_FLAGS] { set TEST_ALWAYS_FLAGS "$link_flags $TEST_ALWAYS_FLAGS" } else { set TEST_ALWAYS_FLAGS "$link_flags" } } } # # mpx_finish -- called at the end of each subdir of tests # proc mpx_finish { args } { global TEST_ALWAYS_FLAGS global mpx_saved_TEST_ALWAYS_FLAGS global mpx_saved_ALWAYS_CXXFLAGS global mpx_saved_library_path global ld_library_path if [info exists mpx_saved_ALWAYS_CXXFLAGS ] { set ALWAYS_CXXFLAGS $mpx_saved_ALWAYS_CXXFLAGS } else { if [info exists mpx_saved_TEST_ALWAYS_FLAGS] { set TEST_ALWAYS_FLAGS $mpx_saved_TEST_ALWAYS_FLAGS } else { unset TEST_ALWAYS_FLAGS } } set ld_library_path $mpx_saved_library_path set_ld_library_path_env_vars clear_effective_target_cache }