Re: [PATCH bpf-next] bpf: add a few more options for GCC_BPF in selftests/bpf/Makefile

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 4/24/24 14:24, Jose E. Marchesi wrote:
> 
> Hi Yonghong.
> 
>> On 4/24/24 1:41 AM, Jose E. Marchesi wrote:
>>> This little patch modifies selftests/bpf/Makefile so it passes the
>>> following extra options when invoking gcc-bpf:
>>>
>>>   -gbtf
>>>     This makes GCC to emit BTF debug info in .BTF and .BTF.ext.
>>
>> Could we do if '-g' is specified, for bpf program,
>> btf will be automatically generated?
> 
> Hmm, in principle I wouldn't oppose for -g to mean -gbtf instead of
> -gdwarf.  DWARF can always be generated by using -gdwarf.
> 
> Faust, Indu, WDYT?

I agree it makes sense. Will need to look for the appropriate way
to set this in gcc, but I am happy to prepare a patch.

> 
>>>
>>>   -mco-re
>>>     This tells GCC to generate CO-RE relocations in .BTF.ext.
>>
>> Can we make this default? That is, remove -mco-re option. I
>> can imagine for any serious bpf program, co-re is a must.
> 
> CO-RE depends on BTF.  So I understand the above as making -mco-re the
> default if BTF is generated, i.e. if -gbtf (or -g with the modification
> above) are specified.  Isn't that what clang does?  Am I interpreting
> correctly?

This is already the default. We enable -mco-re automatically in the BPF
backend if also generating BTF, unless user explicitly disables via
-mno-co-re.

This should work the same way with plain -g, once -g means BTF for the
target.

> 
>>>
>>>   -masm=pseudoc
>>>     This tells GCC to emit BPF assembler using the pseudo-c syntax.
>>
>> Can we make it the other way round such that -masm=pseudoc is
>> the default? You can have an option e.g., -masm=non-pseudoc,
>> for the other format?
> 
> We could add a configure-time build option:
> 
>   --with-bpf-default-asm-syntax={pseudoc,normal}
> 
> so that GCC can be built to use whatever selected syntax as default.
> Distros and people can then decide what to do.
> 
>>>
>>> Tested in bpf-next master.
>>> No regressions.
>>>
>>> Signed-off-by: Jose E. Marchesi <jose.marchesi@xxxxxxxxxx>
>>> Cc: Yonghong Song <yhs@xxxxxxxx>
>>> Cc: Eduard Zingerman <eddyz87@xxxxxxxxx>
>>> Cc: david.faust@xxxxxxxxxx
>>> Cc: cupertino.miranda@xxxxxxxxxx
>>> ---
>>>   tools/testing/selftests/bpf/Makefile | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
>>> index edc73f8f5aef..702428021132 100644
>>> --- a/tools/testing/selftests/bpf/Makefile
>>> +++ b/tools/testing/selftests/bpf/Makefile
>>> @@ -442,7 +442,7 @@ endef
>>>   # Build BPF object using GCC
>>>   define GCC_BPF_BUILD_RULE
>>>   	$(call msg,GCC-BPF,$(TRUNNER_BINARY),$2)
>>> -	$(Q)$(BPF_GCC) $3 -O2 -c $1 -o $2
>>> +	$(Q)$(BPF_GCC) $3 -O2 -gbtf -mco-re -masm=pseudoc -c $1 -o $2
>>>   endef
>>>     SKEL_BLACKLIST := btf__% test_pinning_invalid.c test_sk_assign.c




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux