Re: [Patch, libstdc++.exp]Update the usage of cached result, rebuild nlocale wrapper for each variant.

2019-04-10 Thread Jonathan Wakely

On 11/03/19 11:54 +, Jonathan Wakely wrote:

Hi, I've just noticed this in your r266209 change from November:

On 16/11/18 10:42 +, Renlin Li wrote:

+return [check_v3_target_prop_cached et_parallel_mode {
+   global cxxflags
+   global v3-libgomp
# If 'make check-parallel' is running the test succeeds.
if { ${v3-libgomp} == 1 && [regexp "libgomp" $cxxflags] } {
-   set et_parallel_mode 1
+   return1 1


Is this a typo? It should be "return 1" not "return1 1" right?



I've committed this fix to trunk.


commit 116f85727b49103ff3c8d4fb152c7a6047eb3546
Author: Jonathan Wakely 
Date:   Wed Apr 10 15:44:35 2019 +0100

Fix typo in effective-target check

* testsuite/lib/libstdc++.exp (check_v3_target_parallel_mode): Fix
typo.

diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 5a12ac0242d..d0efc90a1ba 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -1048,7 +1048,7 @@ proc check_v3_target_parallel_mode { } {
 	global v3-libgomp
 	# If 'make check-parallel' is running the test succeeds.
 	if { ${v3-libgomp} == 1 && [regexp "libgomp" $cxxflags] } {
-	return1 1
+	return 1
 	}
 	return 0
 }]


Re: [Patch, libstdc++.exp]Update the usage of cached result, rebuild nlocale wrapper for each variant.

2019-03-11 Thread Jonathan Wakely

Hi, I've just noticed this in your r266209 change from November:

On 16/11/18 10:42 +, Renlin Li wrote:

+return [check_v3_target_prop_cached et_parallel_mode {
+   global cxxflags
+   global v3-libgomp
# If 'make check-parallel' is running the test succeeds.
if { ${v3-libgomp} == 1 && [regexp "libgomp" $cxxflags] } {
-   set et_parallel_mode 1
+   return1 1


Is this a typo? It should be "return 1" not "return1 1" right?



Re: [Patch, libstdc++.exp]Update the usage of cached result, rebuild nlocale wrapper for each variant.

2018-11-16 Thread Renlin Li




On 11/16/2018 01:20 PM, Jonathan Wakely wrote:

On 16/11/18 10:42 +, Renlin Li wrote:

Hi all,


Please remember that all patches for libstdc++ must be sent to the
libstdc++ list, as documented at https://gcc.gnu.org/lists.html
Just CCing me is not enough.


Hi Jonathan,

I knew I missed something!
Thanks, committed.

Regards,
Renlin



Re: [Patch, libstdc++.exp]Update the usage of cached result, rebuild nlocale wrapper for each variant.

2018-11-16 Thread Jonathan Wakely

On 16/11/18 10:42 +, Renlin Li wrote:

Hi all,


Please remember that all patches for libstdc++ must be sent to the
libstdc++ list, as documented at https://gcc.gnu.org/lists.html
Just CCing me is not enough.


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.


This is great, thanks!


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?


OK, thanks.



[Patch, libstdc++.exp]Update the usage of cached result, rebuild nlocale wrapper for each variant.

2018-11-16 Thread Renlin Li

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