Specify additional files, other than source files, that must be copied
to the system where the compiler runs.
-@item @{ dg-additional-sources "@var{filelist}" @}
+@item @{ dg-additional-sources "@var{filelist}" [@{ target @var{selector} @}] @}
Specify additional source files to appear in the compile line
following the main test file.
+If the directive includes the optional @samp{@{ @var{selector} @}}
+then the additional sources are only added if the target system
+matches the @var{selector}.
+Additional sources are generally used only in @samp{link} and @samp{run}
+tests; they are reported as unsupported and discarded in other kinds of
+tests that direct the compiler to output to a single file.
@end table
@subsubsection Add checks at the end of a test
append board_info($tboard,multilib_flags) " $flags_to_postpone"
}
- set options [dg-additional-files-options $options $source]
+ set options [dg-additional-files-options $options $source $dest $type]
if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
lappend options "libs=${gluefile}"
proc dg-additional-sources { args } {
global additional_sources
- set additional_sources [lindex $args 1]
+
+ if { [llength $args] > 3 } {
+ error "[lindex $args 0]: too many arguments"
+ return
+ }
+
+ if { [llength $args] >= 3 } {
+ switch [dg-process-target [lindex $args 2]] {
+ "S" { append additional_sources " [lindex $args 1]" }
+ "N" { }
+ "F" { error "[lindex $args 0]: `xfail' not allowed here" }
+ "P" { error "[lindex $args 0]: `xfail' not allowed here" }
+ }
+ } else {
+ append additional_sources " [lindex $args 1]"
+ }
}
# Record additional files -- other than source files -- that must be
# Return an updated version of OPTIONS that mentions any additional
# source files registered with dg-additional-sources. SOURCE is the
-# name of the test case.
+# name of the test case. If DEST is given and TYPE does not require
+# linking, additional sources are noted as unsupported rather than
+# added, because the compiler rejects a single output for multiple
+# sources.
-proc dg-additional-files-options { options source } {
+proc dg-additional-files-options { options source dest type } {
gcc_adjust_linker_flags
global additional_sources
global additional_sources_used
global additional_files
set to_download [list]
- if { $additional_sources != "" } then {
+ if { $additional_sources == "" } then {
+ } elseif { $type != "executable" && $dest != "" } then {
+ foreach s $additional_sources {
+ unsupported "$s: additional-source will not be used to build $dest"
+ }
+ set additional_sources_used ""
+ set additional_sources ""
+ } else {
if [is_remote host] {
lappend options "additional_flags=$additional_sources"
}
- regsub -all "^| " $additional_sources " [file dirname $source]/" additional_sources
+ regsub -all {^ *| *} $additional_sources " [file dirname $source]/" additional_sources
if ![is_remote host] {
lappend options "additional_flags=$additional_sources"
}
lappend options "timeout=[timeout_value]"
lappend options "compiler=$GCC_UNDER_TEST"
- set options [dg-additional-files-options $options $source]
+ set options [dg-additional-files-options $options $source $dest $type]
if {[target_info needs_status_wrapper] != "" && \
[target_info needs_status_wrapper] != "0" && \
lappend options "compiler=$GDC_UNDER_TEST"
set options [concat "$always_dflags" $options]
- set options [dg-additional-files-options $options $source]
+ set options [dg-additional-files-options $options $source $dest $type]
return [target_compile $source $dest $type $options]
}
lappend options "timeout=[timeout_value]"
set options [concat "$ALWAYS_GFORTRANFLAGS" $options]
- set options [dg-additional-files-options $options $source]
+ set options [dg-additional-files-options $options $source $dest $type]
set return_val [target_compile $source $dest $type $options]
if {[board_info $tboard exists multilib_flags]} {
lappend options "compiler=$GOC_UNDER_TEST"
set options [concat "$ALWAYS_GOCFLAGS" $options]
- set options [dg-additional-files-options $options $source]
+ set options [dg-additional-files-options $options $source $dest $type]
return [target_compile $source $dest $type $options]
}
set options [concat "$ALWAYS_OBJCXXFLAGS" $options];
- set options [dg-additional-files-options $options $source]
+ set options [dg-additional-files-options $options $source $dest $type]
set result [target_compile $source $dest $type $options]
set_ld_library_path_env_vars
- set options [dg-additional-files-options $options $source]
+ set options [dg-additional-files-options $options $source $dest $type]
return [target_compile $source $dest $type $options]
}
# schedule removal of dump files et al
# Do this before the call below destroys additional_sources..
append use_final_code [schedule-cleanups "$option $extra_flags"]
- set extra_options [dg-additional-files-options "" "$src"]
+ set extra_options [dg-additional-files-options "" "$src" $execname1 "executable"]
# Remove old profiling data files. Make sure additional_sources_used is
# valid, by running it after dg-additional-files-options.
lappend options "compiler=$RUST_UNDER_TEST"
set options [concat "$ALWAYS_RUSTFLAGS" $options]
- set options [dg-additional-files-options $options $source]
+ set options [dg-additional-files-options $options $source $dest $type]
return [target_compile $source $dest $type $options]
}