Tested x86_64-pc-linux-gnu, OK for trunk?

-- 8< --

To run library tests with modules we need to compile them; this patch makes
us build a header unit for bits/stdc++.h and module interface units for std
and std.compat, if v3_std_list includes "modules".  So this doesn't happen
by default without a further change.

libstdc++-v3/ChangeLog:

        * testsuite/lib/libstdc++.exp (v3-build_support): Build
        gcms for bits/stdc++.h, std, and std.compat.
---
 libstdc++-v3/testsuite/lib/libstdc++.exp | 33 ++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp 
b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 15b052d941b..62aa53d251c 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -746,6 +746,7 @@ proc v3_target_compile_as_c { source dest type options } {
 proc v3-build_support { } {
     global env
     global srcdir
+    global blddir
     global v3-wchar_t
     global v3-threads
     global v3-symver
@@ -755,6 +756,7 @@ proc v3-build_support { } {
     set v3-wchar_t 0
     set v3-threads 0
     set v3-symver 0
+    set v3-modules 0
     set libtest_objs ""
 
     set config_src "config.cc"
@@ -794,6 +796,37 @@ proc v3-build_support { } {
        }
     }
 
+    global v3_std_list
+    global v3_modules_std
+    if { "modules" in $v3_std_list } {
+       verbose -log "modules testing requested"
+       set v3-modules 1
+    }
+
+    # Rebuild module std iff needed, i.e. if we don't have an object for
+    # libtestc++ or import fails.
+    if { ${v3-modules} == 1 } {
+       set std_file "$blddir/include/bits/std.cc"
+       set std_compat_file "$blddir/include/bits/std.compat.cc"
+
+       if { ([v3_target_compile bits/stdc++.h /dev/null object \
+                  [list "additional_flags=-std=gnu++$v3_modules_std -fmodules 
-g -w -fsearch-include-path"]]
+             != "") } {
+           error "could not compile bits/stdc++.h"
+       }
+       if { ([v3_target_compile $std_file std.o object \
+                  [list "additional_flags=-std=gnu++$v3_modules_std -fmodules 
-g -w"]]
+             != "") } {
+           error "could not compile std.cc"
+       }
+       if { ([v3_target_compile $std_compat_file std.compat.o object \
+                  [list "additional_flags=-std=gnu++$v3_modules_std -fmodules 
-g -w"]]
+             != "") } {
+           error "could not compile std.compat.cc"
+       }
+       append libtest_objs "std.o std.compat.o "
+    }
+
     # Build the support objects.
     set source_files [list testsuite_abi.cc testsuite_allocator.cc \
                          testsuite_character.cc testsuite_hooks.cc \

base-commit: 52a24bcecd388ab6e7d4e6500809fc761f6e7ca5
-- 
2.51.0

Reply via email to