diff mbox series

[Testsuite,libgomp] – Fix check_effective_target_offload_target_nvptx for remote execution

Message ID 855cab27-5e33-dce0-3560-3b223b7e8b1a@codesourcery.com
State New
Headers show
Series [Testsuite,libgomp] – Fix check_effective_target_offload_target_nvptx for remote execution | expand

Commit Message

Tobias Burnus Feb. 4, 2020, 3:49 p.m. UTC
DejaGNU uses in lib/target.exp's
    proc default_target_compile {source destfile type options}
uses the following.

When running locally, $source is simply used
as argument. However, when run remotely, it is tried to be uploaded
on the remote host – and otherwise skipped. That's fine if the
argument is an actual file – but not if it is a flag.

Hence, flags should be passed as $options not as $source.
Quoting now from DejaGNU's default_target_compile#:

     set sources ""
     if {[isremote host]} {
         foreach x $source {
             set file [remote_download host $x]
             if { $file eq "" } {
                 warning "Unable to download $x to host."
                 return "Unable to download $x to host."
             } else {
                 append sources " $file"
             }
         }
     } else {
         set sources $source
     }

  * * *

FIRST, I think that affects the following calls, but I have not
checked. — I assume that moving it from the first to the last
argument should work and fix the "isremote" issue.

gcc/testsuite/gcc.target/arm/multilib.exp:    set gcc_output [${tool}_target_compile "--print-multi-directory $gcc_opts" "" "none" ""]
gcc/testsuite/lib/target-supports.exp:    set gcc_output [${tool}_target_compile "-v" "" "none" ""]
gcc/testsuite/lib/target-supports.exp:  set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=ld" "" "none" ""] 0]
gcc/testsuite/lib/target-supports.exp:  set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
gcc/testsuite/lib/target-supports.exp:  set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=ld" "" "none" ""] 0]

TODO: One should probably change this.


SECONDLY: I hit a very similar issue in libgomp, which I actually did debug.

In check_effective_target_offload_target_nvptx, one has something similar, namely:
   set gcc_output [libgomp_target_compile "-v $options" "" "none" ""]
This currently tries (w/o success) to upload the flags to the remote host and then
fails as the required "-v" flag fails (i.e. no input).

However, using "-v" as options argument does not work as seemingly only additional_flags=
arguments are passed on. Additionally, if one does not only want to pass on the first
argument, curly braces are needed.

PATCH: The attached patch does this – and have successfully tested it both with local
runs and with remote runs. (RUNTESTFLAGS="-v -v -v" did help a lot for studying the
behavior in both cases.)

OK for the trunk?

Cheers,

Tobias

Comments

Richard Sandiford Feb. 5, 2020, 4:31 p.m. UTC | #1
Tobias Burnus <tobias@codesourcery.com> writes:
> diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
> index 7e94527c7ca..cb7757b6a91 100644
> --- a/libgomp/testsuite/lib/libgomp.exp
> +++ b/libgomp/testsuite/lib/libgomp.exp
> @@ -346,11 +346,11 @@ proc check_effective_target_offload_target_nvptx { } {
>      # files; in particular, '-foffload', 'libgomp.oacc-*/*.exp'), which don't
>      # get passed on to 'check_effective_target_*' functions.  (Not caching the
>      # result due to that.)
> -    set options [current_compiler_flags]
> +    set options [concat "{additional_flags=-v" [current_compiler_flags] "}"]

Using:

    set options [list "additional_flags=[concat "-v" [current_compiler_flags]]"]

is maybe more obvious, and should get the { ... } quoting right for
unusual cases.

LGTM otherwise.

Thanks,
Richard
diff mbox series

Patch

	libgomp/
	* testsuite/lib/libgomp.exp
	(check_effective_target_offload_target_nvptx): Pass flags as 'options'
	and not as 'source' argument to libgomp_target_compile.

diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index 7e94527c7ca..cb7757b6a91 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -346,11 +346,11 @@  proc check_effective_target_offload_target_nvptx { } {
     # files; in particular, '-foffload', 'libgomp.oacc-*/*.exp'), which don't
     # get passed on to 'check_effective_target_*' functions.  (Not caching the
     # result due to that.)
-    set options [current_compiler_flags]
+    set options [concat "{additional_flags=-v" [current_compiler_flags] "}"]
     # Instead of inspecting command-line options, look what the compiler driver
     # decides.  This is somewhat modelled after
     # 'gcc/testsuite/lib/target-supports.exp:check_configured_with'.
-    set gcc_output [libgomp_target_compile "-v $options" "" "none" ""]
+    set gcc_output [libgomp_target_compile "" "" "none" $options]
     if [regexp "(?n)^OFFLOAD_TARGET_NAMES=(.*)" $gcc_output dummy offload_targets] {
 	verbose "compiling for offload targets: $offload_targets"
 	return [string match "*:nvptx*:*" ":$offload_targets:"]