mpx-dg.exp 4.1 KB

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