@item @{ dg-lto-options @{ @{ @var{options} @} [@{ @var{options} @}] @} [@{ target @var{selector} @}]@}
This directive provides a list of one or more sets of compiler options
-to override @var{LTO_OPTIONS}. Each test will be compiled and run with
-each of these sets of options.
+to override @var{LTO_OPTIONS}. Every test file will be compiled and
+run once for each of these sets of options. Individual source files
+within a test may also use @code{dg-options} to specify additional
+options to include.
+
+@item @{ dg-lto-additional-options @{ @{ @var{options} @} [@{ @var{options} @}] @} [@{ target @var{selector} @}]@}
+This is similar to @code{dg-lto-options}, but rather than overriding
+@var{LTO_OPTIONS}, it appends the given options to each of the sets
+specified in @var{LTO_OPTIONS}. This can be used to add a given list
+of options to every compilation of all source files in the test,
+without otherwise changing which combinations of options are tested.
@item @{ dg-extra-ld-options @var{options} [@{ target @var{selector} @}]@}
This directive adds @var{options} to the linker options used.
* dg-lto-options - the equivalent of dg-options with additional syntax
to support different sets of options for different files compiled
as part of the same test case,
+ * dg-lto-additional-options - the equivalent of dg-additional-options;
+ adds to the default options instead of overwriting them
* dg-lto-warning - the equivalent of dg-warning for diagnostics expected
to be emitted at LTO link time,
* dg-lto-message - the equivakent of dg-message for informational notes
# dg-options sets a variable called dg-extra-tool-flags.
set dg-extra-tool-flags ""
+ set lto-additional-tool-flags ""
# dg-options sets a variable called tool_flags.
set tool_flags ""
unresolved "$src: $errmsg for \"$op\""
return
}
+ } elseif { [string match "dg-lto-additional-options" $cmd] } {
+ set op [lreplace $op 0 0 "dg-additional-options"]
+ set saved-dg-extra-tool-flags ${dg-extra-tool-flags}
+ set dg-extra-tool-flags ${lto-additional-tool-flags}
+ set status [catch "$op" errmsg]
+ if { $status != 0 } {
+ perror "src: $errmsg for \"$op\"\n"
+ unresolved "$src: $errmsg for \"$op\""
+ return
+ }
+ set lto-additional-tool-flags ${dg-extra-tool-flags}
+ set dg-extra-tool-flags ${saved-dg-extra-tool-flags}
} elseif { ![string compare "dg-xfail-if" $cmd] \
|| ![string compare "dg-options" $cmd] } {
warning "lto.exp does not support $cmd in primary source file"
# Return flags to use for compiling the primary source file and for
# linking.
verbose "dg-extra-tool-flags for main is ${dg-extra-tool-flags}"
- return ${dg-extra-tool-flags}
+ verbose "lto-additional-tool-flags for main is ${lto-additional-tool-flags}"
+ return [list ${dg-extra-tool-flags} ${lto-additional-tool-flags}]
}
set compile_type "run"
set dg-do-what [list ${dg-do-what-default} "" P]
array set dg-messages-by-file [list]
- set extra_flags(0) [lto-get-options-main $src1]
+ lassign [lto-get-options-main $src1] extra_flags(0) additional-flags
set compile_xfail(0) ""
# If the main file defines dg-options, those flags are used to
# Compile pieces with the compiler under test.
set i 0
foreach src $src_list obj $obj_list {
- lto-obj $src $obj $option $extra_flags($i) $option \
+ lto-obj $src $obj $option "$extra_flags($i) ${additional-flags}" $option \
$compile_xfail($i)
incr i
}
lto-link-and-maybe-run \
"[lindex $obj_list 0]-[lindex $obj_list end]" \
- $obj_list $execname $filtered ${dg-extra-ld-options} \
+ $obj_list $execname $filtered "${additional-flags} ${dg-extra-ld-options}" \
$filtered
if (![string compare "ar-link" $compile_type]) {