On algol68_link_flags remove unused variables and move finding the
link spec file to algol68_init while making it multilib aware.

Set always used compiler flags on algol68_init instead of
algol68_target_compile.  This makes the log file for RUNTESTFLAGS="-v"
4 times smaller.

Signed-off-by: Pietro Monteiro <[email protected]>
---
 gcc/testsuite/lib/algol68.exp | 77 +++++++++++++++++------------------
 1 file changed, 37 insertions(+), 40 deletions(-)

diff --git a/gcc/testsuite/lib/algol68.exp b/gcc/testsuite/lib/algol68.exp
index cd5c2aab744..acdfc4b6ba3 100644
--- a/gcc/testsuite/lib/algol68.exp
+++ b/gcc/testsuite/lib/algol68.exp
@@ -57,15 +57,12 @@ proc algol68_link_flags { paths } {
     global srcdir
     global ld_library_path
     global shlib_ext
-    global SHARED_OPTION
     global ALGOL68_UNDER_TEST
 
     set gccpath ${paths}
-    set libio_dir ""
     set flags ""
     set ld_library_path "."
     set shlib_ext [get_shlib_extension]
-    set SHARED_OPTION ""
     verbose "shared lib extension: $shlib_ext"
 
     # We need to add options to locate libga68.
@@ -75,8 +72,6 @@ proc algol68_link_flags { paths } {
     }
 
     if { $gccpath != "" } {
-       # Path to libga68.spec.
-       append flags "-B${gccpath}/libga68 "
        if { [file exists "${gccpath}/libga68/.libs/libga68.a"] \
             || [file exists "${gccpath}/libga68/.libs/libga68.${shlib_ext}"] } 
{
            if { $target_wants_B_option } {
@@ -86,16 +81,6 @@ proc algol68_link_flags { paths } {
            }
            append ld_library_path ":${gccpath}/libga68/.libs"
        }
-       # Static linking is default. If only the shared lib is available adjust
-       # flags to always use it. If both are available, set SHARED_OPTION which
-       # will be added to PERMUTE_ARGS
-       if { [file exists "${gccpath}/libga68/src/.libs/libga68.${shlib_ext}"] 
} {
-           if { [file exists "${gccpath}/libga68/src/.libs/libga68.a"] } {
-               set SHARED_OPTION "-shared-libga68"
-           } else {
-#              append flags "-shared-libga68 "
-           }
-       }
        if [file exists "${gccpath}/libiberty/libiberty.a"] {
            append flags "-L${gccpath}/libiberty "
        }
@@ -125,19 +110,31 @@ proc algol68_init { args } {
     global TESTING_IN_BUILD_TREE
     global gcc_warning_prefix
     global gcc_error_prefix
+    global TEST_ALWAYS_FLAGS
+    global algol68_init_set_ALGOL68_UNDER_TEST
 
     # We set LC_ALL and LANG to C so that we get the same error messages as 
expected.
     setenv LC_ALL C
     setenv LANG C
 
-    if ![info exists ALGOL68_UNDER_TEST] then {
+    # ALGOL68_UNDER_TEST as set below contains $specpath, which depends on
+    # the used multilib config. Thus, its value may need to be reset;
+    # that's tracked via algol68_init_set_ALGOL68_UNDER_TEST.
+    if { ![info exists ALGOL68_UNDER_TEST]
+        || [info exists algol68_init_set_ALGOL68_UNDER_TEST] } then {
        if [info exists TOOL_EXECUTABLE] {
            set ALGOL68_UNDER_TEST $TOOL_EXECUTABLE
        } else {
            if { [is_remote host] || ! [info exists TESTING_IN_BUILD_TREE] } {
                set ALGOL68_UNDER_TEST [transform ga68]
            } else {
-               set ALGOL68_UNDER_TEST [findfile $base_dir/../../ga68 
"$base_dir/../../ga68 -B$base_dir/../../" [findfile $base_dir/ga68 
"$base_dir/ga68 -B$base_dir/" [transform ga68]]]
+               if [info exists TOOL_OPTIONS] {
+                   set specpath [get_multilibs ${TOOL_OPTIONS}]
+               } else {
+                   set specpath [get_multilibs]
+               }
+               set algol68_init_set_ALGOL68_UNDER_TEST 1
+               set ALGOL68_UNDER_TEST [findfile $base_dir/../../ga68 
"$base_dir/../../ga68 -B$base_dir/../../ -B$specpath/libga68/" [findfile 
$base_dir/ga68 "$base_dir/ga68 -B$base_dir/" [transform ga68]]]
            }
        }
     }
@@ -160,29 +157,6 @@ proc algol68_init { args } {
     set gcc_warning_prefix "warning:"
     set gcc_error_prefix "(fatal )?error:"
 
-    verbose "algol68 is initialized" 3
-}
-
-#
-# algol68_target_compile -- compile a source file
-#
-
-proc algol68_target_compile { source dest type options } {
-    global tmpdir
-    global gluefile wrap_flags
-    global ALWAYS_ALGOL68FLAGS
-    global ALGOL68_UNDER_TEST
-    global individual_timeout
-    global TEST_ALWAYS_FLAGS
-
-    # HACK: guard against infinite loops in the compiler
-    set individual_timeout 20
-
-    if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
-       lappend options "libs=${gluefile}"
-       lappend options "ldflags=${wrap_flags}"
-    }
-
     set ALWAYS_ALGOL68FLAGS ""
 
     # TEST_ALWAYS_FLAGS are flags that should be passed to every
@@ -208,6 +182,29 @@ proc algol68_target_compile { source dest type options } {
 
     verbose -log "ALWAYS_ALGOL68FLAGS set to $ALWAYS_ALGOL68FLAGS"
 
+    verbose "algol68 is initialized" 3
+}
+
+#
+# algol68_target_compile -- compile a source file
+#
+
+proc algol68_target_compile { source dest type options } {
+    global tmpdir
+    global gluefile wrap_flags
+    global ALWAYS_ALGOL68FLAGS
+    global ALGOL68_UNDER_TEST
+    global TEST_ALWAYS_FLAGS
+    global individual_timeout
+
+    # HACK: guard against infinite loops in the compiler
+    set individual_timeout 20
+
+    if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
+       lappend options "libs=${gluefile}"
+       lappend options "ldflags=${wrap_flags}"
+    }
+
     lappend options "timeout=[timeout_value]"
     lappend options "compiler=$ALGOL68_UNDER_TEST"
 

base-commit: e6c378fa5200cd8eb8b4356ef33e88fd13ee5436
-- 
2.43.0

Reply via email to