atomic-dg.exp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # Copyright (C) 2013-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. #
  16. # atomic_link_flags -- compute library path and flags to find libatomic.
  17. # (originally from g++.exp)
  18. #
  19. proc atomic_link_flags { paths } {
  20. global srcdir
  21. global ld_library_path
  22. global shlib_ext
  23. set gccpath ${paths}
  24. set flags ""
  25. set shlib_ext [get_shlib_extension]
  26. if { $gccpath != "" } {
  27. if { [file exists "${gccpath}/libatomic/.libs/libatomic.a"]
  28. || [file exists "${gccpath}/libatomic/.libs/libatomic.${shlib_ext}"] } {
  29. append flags " -B${gccpath}/libatomic/ "
  30. append flags " -L${gccpath}/libatomic/.libs"
  31. append ld_library_path ":${gccpath}/libatomic/.libs"
  32. }
  33. } else {
  34. global tool_root_dir
  35. set libatomic [lookfor_file ${tool_root_dir} libatomic]
  36. if { $libatomic != "" } {
  37. append flags "-L${libatomic} "
  38. append ld_library_path ":${libatomic}"
  39. }
  40. }
  41. set_ld_library_path_env_vars
  42. append flags " -latomic "
  43. return "$flags"
  44. }
  45. #
  46. # atomic_init -- called at the start of each subdir of tests
  47. #
  48. proc atomic_init { args } {
  49. global TEST_ALWAYS_FLAGS
  50. global ALWAYS_CXXFLAGS
  51. global TOOL_OPTIONS
  52. global atomic_saved_TEST_ALWAYS_FLAGS
  53. set link_flags ""
  54. if ![is_remote host] {
  55. if [info exists TOOL_OPTIONS] {
  56. set link_flags "[atomic_link_flags [get_multilibs ${TOOL_OPTIONS}]]"
  57. } else {
  58. set link_flags "[atomic_link_flags [get_multilibs]]"
  59. }
  60. }
  61. if [info exists TEST_ALWAYS_FLAGS] {
  62. set atomic_saved_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS
  63. }
  64. if [info exists ALWAYS_CXXFLAGS] {
  65. set ALWAYS_CXXFLAGS [concat "{ldflags=$link_flags}" $ALWAYS_CXXFLAGS]
  66. } else {
  67. if [info exists TEST_ALWAYS_FLAGS] {
  68. set TEST_ALWAYS_FLAGS "$link_flags $TEST_ALWAYS_FLAGS"
  69. } else {
  70. set TEST_ALWAYS_FLAGS "$link_flags"
  71. }
  72. }
  73. return [check_no_compiler_messages_nocache libatomic_available executable {
  74. int main (void) { return 0; }
  75. }]
  76. }
  77. #
  78. # atomic_finish -- called at the end of each subdir of tests
  79. #
  80. proc atomic_finish { args } {
  81. global TEST_ALWAYS_FLAGS
  82. global atomic_saved_TEST_ALWAYS_FLAGS
  83. if [info exists atomic_saved_TEST_ALWAYS_FLAGS] {
  84. set TEST_ALWAYS_FLAGS $atomic_saved_TEST_ALWAYS_FLAGS
  85. } else {
  86. unset TEST_ALWAYS_FLAGS
  87. }
  88. }