fortran.exp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. load_lib libgomp-dg.exp
  2. load_gcc_lib gcc-dg.exp
  3. load_gcc_lib gfortran-dg.exp
  4. global shlib_ext
  5. global ALWAYS_CFLAGS
  6. set shlib_ext [get_shlib_extension]
  7. set lang_library_path "../libgfortran/.libs"
  8. set lang_link_flags "-lgfortran"
  9. if [info exists lang_include_flags] then {
  10. unset lang_include_flags
  11. }
  12. set lang_test_file_found 0
  13. set quadmath_library_path "../libquadmath/.libs"
  14. # Initialize dg.
  15. dg-init
  16. # Turn on OpenMP.
  17. lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
  18. if { $blddir != "" } {
  19. set lang_source_re {^.*\.[fF](|90|95|03|08)$}
  20. set lang_include_flags "-fintrinsic-modules-path=${blddir}"
  21. # Look for a static libgfortran first.
  22. if [file exists "${blddir}/${lang_library_path}/libgfortran.a"] {
  23. set lang_test_file "${lang_library_path}/libgfortran.a"
  24. set lang_test_file_found 1
  25. # We may have a shared only build, so look for a shared libgfortran.
  26. } elseif [file exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] {
  27. set lang_test_file "${lang_library_path}/libgfortran.${shlib_ext}"
  28. set lang_test_file_found 1
  29. } else {
  30. puts "No libgfortran library found, will not execute fortran tests"
  31. }
  32. } elseif [info exists GFORTRAN_UNDER_TEST] {
  33. set lang_test_file_found 1
  34. # Needs to exist for libgomp.exp.
  35. set lang_test_file ""
  36. } else {
  37. puts "GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
  38. }
  39. if { $lang_test_file_found } {
  40. # Gather a list of all tests.
  41. set tests [lsort [find $srcdir/$subdir *.\[fF\]{,90,95,03,08}]]
  42. if { $blddir != "" } {
  43. if { [file exists "${blddir}/${quadmath_library_path}/libquadmath.a"]
  44. || [file exists "${blddir}/${quadmath_library_path}/libquadmath.${shlib_ext}"] } {
  45. lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/${quadmath_library_path}/"
  46. # Allow for spec subsitution.
  47. lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/${quadmath_library_path}/"
  48. set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}:${blddir}/${quadmath_library_path}"
  49. } else {
  50. set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
  51. }
  52. } else {
  53. set ld_library_path "$always_ld_library_path"
  54. }
  55. append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
  56. set_ld_library_path_env_vars
  57. # For Fortran we're doing torture testing, as Fortran has far more tests
  58. # with arrays etc. that testing just -O0 or -O2 is insufficient, that is
  59. # typically not the case for C/C++.
  60. gfortran-dg-runtest $tests "" ""
  61. }
  62. # All done.
  63. dg-finish