Hi all,
Tejas noticed that libstdc++.exp currently builds nlocale driver
(libstc++.exp:check_v3_target_namedlocale())
once for a test run. This is done irrespective of the number of variants in the
site.exp file.
For eg. if we have more than one variant for different target profiles i.e.
/-mthumb/-march=armv8-a/-mfpu=crypto-neon-fp-armv8/-mfloat-abi=hard
/-mthumb/-mcpu=cortex-m0
nlocale.cpp is built once and is reused for all the variants.
This is incorrect as the same binary may not work on all target profiles - eg.
nlocale.x built for arm A-profile
may not work on M-profile targets. nlocale needs to be rebuilt for each
variant in site.exp. This patch fixes that.
Meanwhile, it updates all the usage of cached value with the new method.
This is similar to the recent change in gcc/testsuite/lib/target-support.exp
A global dictionary is used to store a property for a particular target,
instead of the target check and update approach.
This factors the common code out of each procedure, reduce the length of
libstdc++.exp file.
Tested on arm-none-eabi with the following variants in site.exp:
/-marm/-march=armv7-a/-mfpu=vfpv3-d16/-mfloat-abi=softfp
/-mthumb/-march=armv8-a/-mfpu=crypto-neon-fp-armv8/-mfloat-abi=hard
/-mthumb/-mcpu=cortex-m0
/-mthumb/-mcpu=cortex-m3
/-mthumb/-mcpu=cortex-m4
/-mthumb/-mcpu=cortex-m7
/-mthumb/-mcpu=cortex-m23
/-mthumb/-march=armv8-m.main
Tested on native x86_64,
make check-target-libstdc++-v3
with default unix variant. There is no change on the result.
Okay to commit?
Regards,
Renlin
gcc/libstdc++-v3/:
2018-11-16 Renlin Li
Tejas Belagod
testsuite/lib/libstdc++.exp (check_v3_target_prop_cached): New proc.
(check_v3_target): Use the check_v3_target_prop_cached.
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 79d8e0130dcefdd8ccb67ad45f81ff12a3703600..7047b8f7b2233911445abaed54337bc46b37b7e5 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -688,31 +688,38 @@ proc v3-build_support { } {
}
}
-proc check_v3_target_fileio { } {
-global et_fileio_saved
-global et_fileio_target_name
-global tool
-global srcdir
+# Implement an target check for property PROP by invoking
+# the Tcl command ARGS and seeing if it returns true.
-if { ![info exists et_fileio_target_name] } {
- set et_fileio_target_name ""
-}
+proc check_v3_target_prop_cached { prop args } {
+global et_cache
-# If the target has changed since we set the cached value, clear it.
-set current_target [current_target_name]
-if { $current_target != $et_fileio_target_name } {
- verbose "check_v3_target_fileio: `$et_fileio_target_name'" 2
- set et_fileio_target_name $current_target
- if [info exists et_fileio_saved] {
- verbose "check_v3_target_fileio: removing cached result" 2
- unset et_fileio_saved
+set target [current_target_name]
+if {![info exists et_cache($prop,$target)]} {
+ verbose "check_v3_target_prop_cached $prop: checking $target" 2
+ if {[string is true -strict $args] || [string is false -strict $args]} {
+ error {check_v3_target_prop_cached condition already evaluated; did you pass [...] instead of the expected {...}?}
+ } else {
+ set code [catch {uplevel eval $args} result]
+ if {$code != 0 && $code != 2} {
+ verbose "check_v3_target_prop_cached $prop: evaluation failed for $target" 2
+ return -code $code $result
+ }
+ set et_cache($prop,$target) $result
}
+} else {
+ verbose "check_v3_target_prop_cached $prop $target: using cached result" 2
}
-if [info exists et_fileio_saved] {
- verbose "check_v3_target_fileio: using cached result" 2
-} else {
- set et_fileio_saved 0
+set value $et_cache($prop,$target)
+verbose "check_v3_target_prop_cached $prop: returning $value for $target" 2
+return $value
+}
+
+proc check_v3_target_fileio { } {
+return [check_v3_target_prop_cached et_fileio {
+ global tool
+ global srcdir
# Set up, compile, and execute a C++ test program that tries to use
# the file functions
@@ -766,41 +773,19 @@ proc check_v3_target_fileio { } {
verbose "check_v3_target_fileio: status is <$status>" 2
if { $status == "pass" } {
- set et_fileio_saved 1
+ return 1
}
} else {
verbose "check_v3_target_fileio: compilation failed" 2
}
-}
-return $et_fileio_saved
+ return 0
+}]
}
# Eventually we want C90/C99 determining and switching from this.
proc check_v3_target_c_std { } {
-global et_c_std_saved
-global et_c_std_target_name
-global tool
-
-if { ![info exists et_c_std_target_name] } {
- set et_c_std_target_name ""
-}
-
-# If the target has changed since we set the cached value, clear it.
-set current_target [current_target_name]
-if { $current_target != $et_c_std_target_name } {
- verbose "check_v3_target_c