[V2,5/8] bpf: make target-supports.exp aware of eBPF
diff mbox series

Message ID 20190817005056.15749-6-jose.marchesi@oracle.com
State New
Headers show
Series
  • eBPF support for GCC
Related show

Commit Message

Jose E. Marchesi Aug. 17, 2019, 12:50 a.m. UTC
This patch makes the several effective target checks in
target-supports.exp to be aware of eBPF targets.

gcc/testsuite/ChangeLog:

	* lib/target-supports.exp (check_effective_target_malloc): New
	function.
	(check_effective_target_trampolines): Adapt to eBPF.
	(check_effective_target_stack_size): Likewise.
	(dg-effective-target-value): Likewise.
	(check_effective_target_indirect_jumps): Likewise.
	(check_effective_target_nonlocal_goto): Likewise.
	(check_effective_target_global_constructor): Likewise.
	(check_effective_target_return_address): Likewise.
---
 gcc/testsuite/ChangeLog               | 11 +++++++++++
 gcc/testsuite/lib/target-supports.exp | 27 +++++++++++++++++++--------
 2 files changed, 30 insertions(+), 8 deletions(-)

Comments

Jeff Law Aug. 19, 2019, 1:23 a.m. UTC | #1
On 8/16/19 6:50 PM, Jose E. Marchesi wrote:
> This patch makes the several effective target checks in
> target-supports.exp to be aware of eBPF targets.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* lib/target-supports.exp (check_effective_target_malloc): New
> 	function.
> 	(check_effective_target_trampolines): Adapt to eBPF.
> 	(check_effective_target_stack_size): Likewise.
> 	(dg-effective-target-value): Likewise.
> 	(check_effective_target_indirect_jumps): Likewise.
> 	(check_effective_target_nonlocal_goto): Likewise.
> 	(check_effective_target_global_constructor): Likewise.
> 	(check_effective_target_return_address): Likewise.
> ---
>  gcc/testsuite/ChangeLog               | 11 +++++++++++
>  gcc/testsuite/lib/target-supports.exp | 27 +++++++++++++++++++--------
>  2 files changed, 30 insertions(+), 8 deletions(-)
> 
> diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
> index 300d22a2d65..8b6168626d8 100644
> --- a/gcc/testsuite/lib/target-supports.exp
> +++ b/gcc/testsuite/lib/target-supports.exp
>  
> @@ -546,7 +550,11 @@ proc check_effective_target_stack_size { } {
>  proc dg-effective-target-value { effective_target } {
>      if { "$effective_target" == "stack_size" } {
>  	if [check_effective_target_stack_size] {
> -	    return [target_info gcc,stack_size]
> +	    if [istarget bpf-*-*] {
> +		return "512"
> +	    } else {
> +		return [target_info gcc,stack_size]
> +	    }
>  	}
>      }
Shouldn't the BPF stack size be defined be in your target files?


The ChangeLog mentions check_effective_target_malloc, but I don't see it
in the patch itself.  Note that it needs to be documented in
gcc/doc/sourcebuild.texi as well if you are adding a new
check_effective_target_<whatever>

jeff
Segher Boessenkool Aug. 19, 2019, 10:28 a.m. UTC | #2
Hi Jose,

On Sat, Aug 17, 2019 at 02:50:53AM +0200, Jose E. Marchesi wrote:
> --- a/gcc/testsuite/lib/target-supports.exp
> +++ b/gcc/testsuite/lib/target-supports.exp
> @@ -526,7 +526,8 @@ proc check_effective_target_trampolines { } {
>  	 || [istarget nvptx-*-*]
>  	 || [istarget hppa2.0w-hp-hpux11.23]
>  	 || [istarget hppa64-hp-hpux11.23]
> -	 || [istarget pru-*-*] } {
> +	 || [istarget pru-*-*]
> +         || [istarget bpf-*-*] } {

There is some whitespace damage here.

> @@ -538,6 +539,9 @@ proc check_effective_target_stack_size { } {
>      if [target_info exists gcc,stack_size] {
>  	return 1
>      }
> +    if [istarget bpf-*-*] {
> +	return 1
> +    }

You should still set the proper stack size in your board file, so does
this help you at all?

> @@ -546,7 +550,11 @@ proc check_effective_target_stack_size { } {
>  proc dg-effective-target-value { effective_target } {
>      if { "$effective_target" == "stack_size" } {
>  	if [check_effective_target_stack_size] {
> -	    return [target_info gcc,stack_size]
> +	    if [istarget bpf-*-*] {
> +		return "512"
> +	    } else {
> +		return [target_info gcc,stack_size]
> +	    }

Yeah okay...  Can't you directly override the gcc,stack_size setting,
instead of doing that in every(?) place it is checked?


Segher
Jose E. Marchesi Aug. 19, 2019, 2:01 p.m. UTC | #3
> --- a/gcc/testsuite/lib/target-supports.exp
    > +++ b/gcc/testsuite/lib/target-supports.exp
    >  
    > @@ -546,7 +550,11 @@ proc check_effective_target_stack_size { } {
    >  proc dg-effective-target-value { effective_target } {
    >      if { "$effective_target" == "stack_size" } {
    >  	if [check_effective_target_stack_size] {
    > -	    return [target_info gcc,stack_size]
    > +	    if [istarget bpf-*-*] {
    > +		return "512"
    > +	    } else {
    > +		return [target_info gcc,stack_size]
    > +	    }
    >  	}
    >      }
    Shouldn't the BPF stack size be defined be in your target files?

Yes, definitely.  I am adding a board description to dejagnu.  Will
set_board_info gcc,stack_size 512 there and remove this nasty overwrite
in dg-effective-target-value.

    The ChangeLog mentions check_effective_target_malloc, but I don't see it
    in the patch itself.  Note that it needs to be documented in
    gcc/doc/sourcebuild.texi as well if you are adding a new
    check_effective_target_<whatever>

Oh at some point I introduced a check_effective_target_malloc, then
removed it.  What you saw is a stale reference in the ChangeLog.  Will
get rid of it.

Thanks!
Jose E. Marchesi Aug. 19, 2019, 2:06 p.m. UTC | #4
Hi Seguer!  Thanks for reviewing :)
    
    > @@ -538,6 +539,9 @@ proc check_effective_target_stack_size { } {
    >      if [target_info exists gcc,stack_size] {
    >  	return 1
    >      }
    > +    if [istarget bpf-*-*] {
    > +	return 1
    > +    }
    
    You should still set the proper stack size in your board file, so does
    this help you at all?
    
    > @@ -546,7 +550,11 @@ proc check_effective_target_stack_size { } {
    >  proc dg-effective-target-value { effective_target } {
    >      if { "$effective_target" == "stack_size" } {
    >  	if [check_effective_target_stack_size] {
    > -	    return [target_info gcc,stack_size]
    > +	    if [istarget bpf-*-*] {
    > +		return "512"
    > +	    } else {
    > +		return [target_info gcc,stack_size]
    > +	    }
    
    Yeah okay...  Can't you directly override the gcc,stack_size setting,
    instead of doing that in every(?) place it is checked?
    
Yes I agree these things belong to the board configuration files, so I
will remove that ad-hoc logic from the patch.

Patch
diff mbox series

diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 300d22a2d65..8b6168626d8 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -526,7 +526,8 @@  proc check_effective_target_trampolines { } {
 	 || [istarget nvptx-*-*]
 	 || [istarget hppa2.0w-hp-hpux11.23]
 	 || [istarget hppa64-hp-hpux11.23]
-	 || [istarget pru-*-*] } {
+	 || [istarget pru-*-*]
+         || [istarget bpf-*-*] } {
 	return 0;
     }
     return 1
@@ -538,6 +539,9 @@  proc check_effective_target_stack_size { } {
     if [target_info exists gcc,stack_size] {
 	return 1
     }
+    if [istarget bpf-*-*] {
+	return 1
+    }
     return 0
 }
 
@@ -546,7 +550,11 @@  proc check_effective_target_stack_size { } {
 proc dg-effective-target-value { effective_target } {
     if { "$effective_target" == "stack_size" } {
 	if [check_effective_target_stack_size] {
-	    return [target_info gcc,stack_size]
+	    if [istarget bpf-*-*] {
+		return "512"
+	    } else {
+		return [target_info gcc,stack_size]
+	    }
 	}
     }
 
@@ -781,7 +789,7 @@  proc add_options_for_tls { flags } {
 # Return 1 if indirect jumps are supported, 0 otherwise.
 
 proc check_effective_target_indirect_jumps {} {
-    if { [istarget nvptx-*-*] } {
+    if { [istarget nvptx-*-*] || [istarget bpf-*-*] } {
 	return 0
     }
     return 1
@@ -790,7 +798,7 @@  proc check_effective_target_indirect_jumps {} {
 # Return 1 if nonlocal goto is supported, 0 otherwise.
 
 proc check_effective_target_nonlocal_goto {} {
-    if { [istarget nvptx-*-*] } {
+    if { [istarget nvptx-*-*] || [istarget bpf-*-*] } {
 	return 0
     }
     return 1
@@ -799,10 +807,9 @@  proc check_effective_target_nonlocal_goto {} {
 # Return 1 if global constructors are supported, 0 otherwise.
 
 proc check_effective_target_global_constructor {} {
-    if { [istarget nvptx-*-*] } {
-	return 0
-    }
-    if { [istarget amdgcn-*-*] } {
+    if { [istarget nvptx-*-*]
+	 || [istarget amdgcn-*-*]
+	 || [istarget bpf-*-*] } {
 	return 0
     }
     return 1
@@ -825,6 +832,10 @@  proc check_effective_target_return_address {} {
     if { [istarget nvptx-*-*] } {
 	return 0
     }
+    # No notion of return address in eBPF.
+    if { [istarget bpf-*-*] } {
+	return 0
+    }
     # It could be supported on amdgcn, but isn't yet.
     if { [istarget amdgcn*-*-*] } {
 	return 0