Skip to content

Commit a0673ec

Browse files
committed
Testsuite: allow non-installed testing on darwin
DYLD_LIBRARY_PATH is now removed from the environment for all system tools, including the shell. Adapt the testsuite and pass the right options to allow testing, even when the compiler and libraries have not been installed. gcc/ChangeLog: * Makefile.in: set ENABLE_DARWIN_AT_RPATH in site.tmp. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/caf.exp: Correctly set libatomic flags. * gfortran.dg/dg.exp: Likewise. * lib/asan-dg.exp: Set correct -B flags. * lib/atomic-dg.exp: Likewise. * lib/target-libpath.exp: Handle ENABLE_DARWIN_AT_RPATH. libatomic/ChangeLog: * testsuite/lib/libatomic.exp: Pass correct flags on darwin. libffi/ChangeLog: * testsuite/lib/libffi.exp: Likewise. libitm/ChangeLog: * testsuite/lib/libitm.exp: Likewise. * testsuite/libitm.c++/c++.exp: Likewise.
1 parent 8fe73ef commit a0673ec

File tree

10 files changed

+84
-18
lines changed

10 files changed

+84
-18
lines changed

gcc/Makefile.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4245,6 +4245,9 @@ site.exp: ./config.status Makefile
42454245
echo "set COMPAT_OPTIONS \"$(COMPAT_OPTIONS)\"" >> ./site.tmp; \
42464246
else true; \
42474247
fi
4248+
@if test "x@enable_darwin_at_rpath@" = "xyes" ; then \
4249+
echo "set ENABLE_DARWIN_AT_RPATH 1" >> ./site.tmp; \
4250+
fi
42484251
@echo "## All variables above are generated by configure. Do Not Edit ##" >> ./site.tmp
42494252
@cat ./site.tmp > site.exp
42504253
@cat site.bak | sed \

gcc/testsuite/gfortran.dg/coarray/caf.exp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
# Load procedures from common libraries.
3030
load_lib gfortran-dg.exp
31+
load_lib atomic-dg.exp
3132

3233
# If a testcase doesn't have special options, use these.
3334
global DEFAULT_FFLAGS
@@ -47,6 +48,7 @@ global gfortran_test_path
4748
global gfortran_aux_module_flags
4849
set gfortran_test_path $srcdir/$subdir
4950
set gfortran_aux_module_flags $DEFAULT_FFLAGS
51+
5052
proc dg-compile-aux-modules { args } {
5153
global gfortran_test_path
5254
global gfortran_aux_module_flags
@@ -71,7 +73,15 @@ proc dg-compile-aux-modules { args } {
7173
# Add -latomic only where supported. Assume built-in support elsewhere.
7274
set maybe_atomic_lib ""
7375
if [check_effective_target_libatomic_available] {
74-
set maybe_atomic_lib "-latomic"
76+
if ![is_remote host] {
77+
if [info exists TOOL_OPTIONS] {
78+
set maybe_atomic_lib "[atomic_link_flags [get_multilibs ${TOOL_OPTIONS}]]"
79+
} else {
80+
set maybe_atomic_lib "[atomic_link_flags [get_multilibs]]"
81+
}
82+
}
83+
set t [get_multilibs]
84+
puts "maybe al $maybe_atomic_lib ml $t"
7585
}
7686

7787
# Main loop.
@@ -97,14 +107,14 @@ foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ]]
97107
foreach flags $option_list {
98108
verbose "Testing $nshort (single), $flags" 1
99109
set gfortran_aux_module_flags "-fcoarray=single $flags"
100-
dg-test $test "-fcoarray=single $flags $maybe_atomic_lib" ""
110+
dg-test $test "-fcoarray=single $flags" $maybe_atomic_lib
101111
cleanup-modules ""
102112
}
103113

104114
foreach flags $option_list {
105115
verbose "Testing $nshort (libcaf_single), $flags" 1
106116
set gfortran_aux_module_flags "-fcoarray=lib $flags -lcaf_single"
107-
dg-test $test "-fcoarray=lib $flags -lcaf_single $maybe_atomic_lib" ""
117+
dg-test $test "-fcoarray=lib $flags -lcaf_single" $maybe_atomic_lib
108118
cleanup-modules ""
109119
}
110120
}

gcc/testsuite/gfortran.dg/dg.exp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
# Load support procs.
2020
load_lib gfortran-dg.exp
21+
load_lib atomic-dg.exp
2122

2223
# If a testcase doesn't have special options, use these.
2324
global DEFAULT_FFLAGS
@@ -53,13 +54,38 @@ proc dg-compile-aux-modules { args } {
5354
}
5455
}
5556

57+
# coarray tests might need libatomic. Assume that it is either not needed or
58+
# provided by builtins if it's not available.
59+
set maybe_atomic_lib ""
60+
if [check_effective_target_libatomic_available] {
61+
if ![is_remote host] {
62+
if [info exists TOOL_OPTIONS] {
63+
set maybe_atomic_lib "[atomic_link_flags [get_multilibs ${TOOL_OPTIONS}]]"
64+
} else {
65+
set maybe_atomic_lib "[atomic_link_flags [get_multilibs]]"
66+
}
67+
} else {
68+
set maybe_atomic_lib ""
69+
}
70+
set t [get_multilibs]
71+
puts "dg set al $maybe_atomic_lib ml $t"
72+
}
73+
74+
set all_flags $DEFAULT_FFLAGS
75+
if { $maybe_atomic_lib != "" } {
76+
foreach f $maybe_atomic_lib {
77+
lappend all_flags $f
78+
}
79+
}
80+
81+
puts "revised FFLAGS $all_flags"
82+
5683
# Main loop.
5784
gfortran-dg-runtest [lsort \
58-
[glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ] ] "" $DEFAULT_FFLAGS
85+
[glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ] ] "" $all_flags
5986

6087
gfortran-dg-runtest [lsort \
61-
[glob -nocomplain $srcdir/$subdir/g77/*.\[fF\] ] ] "" $DEFAULT_FFLAGS
62-
88+
[glob -nocomplain $srcdir/$subdir/g77/*.\[fF\] ] ] "" $all_flags
6389

6490
# All done.
6591
dg-finish

gcc/testsuite/lib/asan-dg.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ proc asan_link_flags_1 { paths lib } {
7878
|| [file exists "${gccpath}/libsanitizer/${lib}/.libs/lib${lib}.${shlib_ext}"] } {
7979
append flags " -B${gccpath}/libsanitizer/ "
8080
append flags " -B${gccpath}/libsanitizer/${lib}/ "
81-
append flags " -L${gccpath}/libsanitizer/${lib}/.libs "
81+
append flags " -B${gccpath}/libsanitizer/${lib}/.libs "
8282
append ld_library_path ":${gccpath}/libsanitizer/${lib}/.libs"
8383
}
8484
} else {

gcc/testsuite/lib/atomic-dg.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ proc atomic_link_flags { paths } {
3333
if { [file exists "${gccpath}/libatomic/.libs/libatomic.a"]
3434
|| [file exists "${gccpath}/libatomic/.libs/libatomic.${shlib_ext}"] } {
3535
append flags " -B${gccpath}/libatomic/ "
36-
append flags " -L${gccpath}/libatomic/.libs"
36+
append flags " -B${gccpath}/libatomic/.libs"
3737
append ld_library_path ":${gccpath}/libatomic/.libs"
3838
}
3939
} else {

gcc/testsuite/lib/target-libpath.exp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ proc set_ld_library_path_env_vars { } {
6767
global orig_dyld_library_path
6868
global orig_path
6969
global orig_gcc_exec_prefix
70+
global ENABLE_DARWIN_AT_RPATH
7071
global env
7172

7273
# Save the original GCC_EXEC_PREFIX.
@@ -133,6 +134,7 @@ proc set_ld_library_path_env_vars { } {
133134
#
134135
# Doing this is somewhat of a hack as ld_library_path gets repeated in
135136
# SHLIB_PATH and LD_LIBRARY_PATH when unix_load sets these variables.
137+
if { ![istarget *-*-darwin*] } {
136138
if { $orig_ld_library_path_saved } {
137139
setenv LD_LIBRARY_PATH "$ld_library_path:$orig_ld_library_path"
138140
} else {
@@ -166,10 +168,22 @@ proc set_ld_library_path_env_vars { } {
166168
} else {
167169
setenv LD_LIBRARY_PATH_64 "$ld_library_path"
168170
}
169-
if { $orig_dyld_library_path_saved } {
170-
setenv DYLD_LIBRARY_PATH "$ld_library_path:$orig_dyld_library_path"
171-
} else {
172-
setenv DYLD_LIBRARY_PATH "$ld_library_path"
171+
}
172+
if { [istarget *-*-darwin*] } {
173+
if { [info exists ENABLE_DARWIN_AT_RPATH] || [istarget *-*-darwin1\[5-9\]*]
174+
|| [istarget *-*-darwin20*] } {
175+
# Either we are not using DYLD_LIBRARY_PATH or we're on a version of the
176+
# OS for which it is not passed through system exes.
177+
if [info exists env(DYLD_LIBRARY_PATH)] {
178+
unsetenv DYLD_LIBRARY_PATH
179+
}
180+
} else {
181+
if { $orig_dyld_library_path_saved } {
182+
setenv DYLD_LIBRARY_PATH "$ld_library_path:$orig_dyld_library_path"
183+
} else {
184+
setenv DYLD_LIBRARY_PATH "$ld_library_path"
185+
}
186+
}
173187
}
174188
if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
175189
if { $orig_path_saved } {
@@ -179,6 +193,7 @@ proc set_ld_library_path_env_vars { } {
179193
}
180194
}
181195

196+
verbose -log "set paths"
182197
verbose -log "LD_LIBRARY_PATH=[getenv LD_LIBRARY_PATH]"
183198
verbose -log "LD_RUN_PATH=[getenv LD_RUN_PATH]"
184199
verbose -log "SHLIB_PATH=[getenv SHLIB_PATH]"

libatomic/testsuite/lib/libatomic.exp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,15 @@ proc libatomic_init { args } {
148148
if { $blddir != "" } {
149149
lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/"
150150
lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}"
151-
lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs"
151+
if [istarget *-*-darwin*] {
152+
lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/.libs"
153+
} else {
154+
lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs"
155+
}
152156
}
153157
lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.."
154158

155-
if [istarget *-*-darwin*] {
159+
if [istarget *-*-darwin\[89\]*] {
156160
lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc"
157161
}
158162

libffi/testsuite/lib/libffi.exp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,13 @@ proc libffi-init { args } {
337337
verbose "libffi_dir $libffi_dir"
338338
if { $libffi_dir != "" } {
339339
set libffi_dir [file dirname ${libffi_dir}]
340-
set libffi_link_flags "-L${libffi_dir}/.libs"
341-
lappend libffi_link_flags "-L${blddircxx}/src/.libs"
340+
if [istarget *-*-darwin*] {
341+
set libffi_link_flags "-B${libffi_dir}/.libs"
342+
lappend libffi_link_flags "-B${blddircxx}/src/.libs"
343+
} else {
344+
set libffi_link_flags "-L${libffi_dir}/.libs"
345+
lappend libffi_link_flags "-L${blddircxx}/src/.libs"
346+
}
342347
}
343348

344349
set_ld_library_path_env_vars
@@ -382,7 +387,7 @@ proc libffi_target_compile { source dest type options } {
382387
# Darwin needs a stack execution allowed flag.
383388

384389
if { [istarget "*-*-darwin9*"] || [istarget "*-*-darwin1*"]
385-
|| [istarget "*-*-darwin2*"] } {
390+
|| [istarget "x86_64-*-darwin2*"] } {
386391
lappend options "additional_flags=-Wl,-allow_stack_execute"
387392
lappend options "additional_flags=-Wl,-search_paths_first"
388393
}

libitm/testsuite/lib/libitm.exp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ proc libitm_init { args } {
159159
}
160160

161161
if [istarget *-*-darwin*] {
162+
lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/.libs"
162163
lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc"
163164
}
164165

libitm/testsuite/libitm.c++/c++.exp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ if { $lang_test_file_found } {
5656
# Gather a list of all tests.
5757
set tests [lsort [glob -nocomplain $srcdir/$subdir/*.C]]
5858

59+
set stdcxxadder ""
5960
if { $blddir != "" } {
6061
set ld_library_path "$always_ld_library_path:${blddir}/${lang_library_path}"
62+
set stdcxxadder "-B ${blddir}/${lang_library_path}"
6163
} else {
6264
set ld_library_path "$always_ld_library_path"
6365
}
@@ -72,7 +74,7 @@ if { $lang_test_file_found } {
7274
}
7375

7476
# Main loop.
75-
dg-runtest $tests "" $libstdcxx_includes
77+
dg-runtest $tests $stdcxxadder $libstdcxx_includes
7678
}
7779

7880
# All done.

0 commit comments

Comments
 (0)