mbox series

[bpf-next,v3,0/3] selftests/bpf: Improve building with extra

Message ID cover.1730449390.git.vmalik@redhat.com (mailing list archive)
Headers show
Series selftests/bpf: Improve building with extra | expand

Message

Viktor Malik Nov. 1, 2024, 8:27 a.m. UTC
When trying to build BPF selftests with additional compiler and linker
flags, we're running into multiple problems. This series addresses all
of them:

- CFLAGS are not passed to sub-makes of bpftool and libbpf. This is a
  problem when compiling with PIE as libbpf.a ends up being non-PIE and
  cannot be linked with other binaries (patch #1).

- bpftool Makefile runs `llvm-config --cflags` and appends the result to
  CFLAGS. The result typically contains `-D_GNU_SOURCE` which may be
  already set in CFLAGS. That causes a compilation error (patch #2).

- Some GCC flags are not supported by Clang but there are binaries which
  are always built with Clang but reuse user-defined CFLAGS. When CFLAGS
  contain such flags, compilation fails (patch #3).

Changelog:
----------
v2 -> v3:
- resolve conflicts between patch #1 and 4192bb294f80 ("selftests/bpf:
  Provide a generic [un]load_module helper")
- add Quentin's and Jiri's acks for patches #2 and #3

v1 -> v2:
- cover forgotten case in patch#1 (noted by Eduard)
- remove -D_GNU_SOURCE unconditionally in patch#2 (suggested by Andrii)
- rewrite patch#3 to just add -Wno-unused-command-line-argument
  (suggested by Andrii)

Viktor Malik (3):
  selftests/bpf: Allow building with extra flags
  bpftool: Prevent setting duplicate _GNU_SOURCE in Makefile
  selftests/bpf: Disable warnings on unused flags for Clang builds

 tools/bpf/bpftool/Makefile           |  6 ++++-
 tools/testing/selftests/bpf/Makefile | 36 +++++++++++++++++++---------
 2 files changed, 30 insertions(+), 12 deletions(-)

Comments

Andrii Nakryiko Nov. 1, 2024, 7:46 p.m. UTC | #1
On Fri, Nov 1, 2024 at 1:38 AM Viktor Malik <vmalik@redhat.com> wrote:
>
> When trying to build BPF selftests with additional compiler and linker
> flags, we're running into multiple problems. This series addresses all
> of them:
>
> - CFLAGS are not passed to sub-makes of bpftool and libbpf. This is a
>   problem when compiling with PIE as libbpf.a ends up being non-PIE and
>   cannot be linked with other binaries (patch #1).
>
> - bpftool Makefile runs `llvm-config --cflags` and appends the result to
>   CFLAGS. The result typically contains `-D_GNU_SOURCE` which may be
>   already set in CFLAGS. That causes a compilation error (patch #2).
>
> - Some GCC flags are not supported by Clang but there are binaries which
>   are always built with Clang but reuse user-defined CFLAGS. When CFLAGS
>   contain such flags, compilation fails (patch #3).
>
> Changelog:
> ----------
> v2 -> v3:
> - resolve conflicts between patch #1 and 4192bb294f80 ("selftests/bpf:
>   Provide a generic [un]load_module helper")
> - add Quentin's and Jiri's acks for patches #2 and #3
>
> v1 -> v2:
> - cover forgotten case in patch#1 (noted by Eduard)
> - remove -D_GNU_SOURCE unconditionally in patch#2 (suggested by Andrii)
> - rewrite patch#3 to just add -Wno-unused-command-line-argument
>   (suggested by Andrii)
>
> Viktor Malik (3):
>   selftests/bpf: Allow building with extra flags
>   bpftool: Prevent setting duplicate _GNU_SOURCE in Makefile
>   selftests/bpf: Disable warnings on unused flags for Clang builds
>

I've applied the last two patches, they seem to be independent from
the first, right?


>  tools/bpf/bpftool/Makefile           |  6 ++++-
>  tools/testing/selftests/bpf/Makefile | 36 +++++++++++++++++++---------
>  2 files changed, 30 insertions(+), 12 deletions(-)
>
> --
> 2.47.0
>
>
patchwork-bot+netdevbpf@kernel.org Nov. 1, 2024, 7:50 p.m. UTC | #2
Hello:

This series was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Fri,  1 Nov 2024 09:27:10 +0100 you wrote:
> When trying to build BPF selftests with additional compiler and linker
> flags, we're running into multiple problems. This series addresses all
> of them:
> 
> - CFLAGS are not passed to sub-makes of bpftool and libbpf. This is a
>   problem when compiling with PIE as libbpf.a ends up being non-PIE and
>   cannot be linked with other binaries (patch #1).
> 
> [...]

Here is the summary with links:
  - [bpf-next,v3,1/3] selftests/bpf: Allow building with extra flags
    (no matching commit)
  - [bpf-next,v3,2/3] bpftool: Prevent setting duplicate _GNU_SOURCE in Makefile
    https://git.kernel.org/bpf/bpf-next/c/0513eeee86d6
  - [bpf-next,v3,3/3] selftests/bpf: Disable warnings on unused flags for Clang builds
    https://git.kernel.org/bpf/bpf-next/c/77017b9c4682

You are awesome, thank you!
Viktor Malik Nov. 4, 2024, 11:34 a.m. UTC | #3
On 11/1/24 20:46, Andrii Nakryiko wrote:
> On Fri, Nov 1, 2024 at 1:38 AM Viktor Malik <vmalik@redhat.com> wrote:
>>
>> When trying to build BPF selftests with additional compiler and linker
>> flags, we're running into multiple problems. This series addresses all
>> of them:
>>
>> - CFLAGS are not passed to sub-makes of bpftool and libbpf. This is a
>>   problem when compiling with PIE as libbpf.a ends up being non-PIE and
>>   cannot be linked with other binaries (patch #1).
>>
>> - bpftool Makefile runs `llvm-config --cflags` and appends the result to
>>   CFLAGS. The result typically contains `-D_GNU_SOURCE` which may be
>>   already set in CFLAGS. That causes a compilation error (patch #2).
>>
>> - Some GCC flags are not supported by Clang but there are binaries which
>>   are always built with Clang but reuse user-defined CFLAGS. When CFLAGS
>>   contain such flags, compilation fails (patch #3).
>>
>> Changelog:
>> ----------
>> v2 -> v3:
>> - resolve conflicts between patch #1 and 4192bb294f80 ("selftests/bpf:
>>   Provide a generic [un]load_module helper")
>> - add Quentin's and Jiri's acks for patches #2 and #3
>>
>> v1 -> v2:
>> - cover forgotten case in patch#1 (noted by Eduard)
>> - remove -D_GNU_SOURCE unconditionally in patch#2 (suggested by Andrii)
>> - rewrite patch#3 to just add -Wno-unused-command-line-argument
>>   (suggested by Andrii)
>>
>> Viktor Malik (3):
>>   selftests/bpf: Allow building with extra flags
>>   bpftool: Prevent setting duplicate _GNU_SOURCE in Makefile
>>   selftests/bpf: Disable warnings on unused flags for Clang builds
>>
> 
> I've applied the last two patches, they seem to be independent from
> the first, right?

Yes, they are independent, thanks. I'll sync with Toke on the first one.

Viktor

> 
> 
>>  tools/bpf/bpftool/Makefile           |  6 ++++-
>>  tools/testing/selftests/bpf/Makefile | 36 +++++++++++++++++++---------
>>  2 files changed, 30 insertions(+), 12 deletions(-)
>>
>> --
>> 2.47.0
>>
>>
>
patchwork-bot+netdevbpf@kernel.org Nov. 6, 2024, 8:40 p.m. UTC | #4
Hello:

This series was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Fri,  1 Nov 2024 09:27:10 +0100 you wrote:
> When trying to build BPF selftests with additional compiler and linker
> flags, we're running into multiple problems. This series addresses all
> of them:
> 
> - CFLAGS are not passed to sub-makes of bpftool and libbpf. This is a
>   problem when compiling with PIE as libbpf.a ends up being non-PIE and
>   cannot be linked with other binaries (patch #1).
> 
> [...]

Here is the summary with links:
  - [bpf-next,v3,1/3] selftests/bpf: Allow building with extra flags
    https://git.kernel.org/bpf/bpf-next/c/9a28559932d2
  - [bpf-next,v3,2/3] bpftool: Prevent setting duplicate _GNU_SOURCE in Makefile
    (no matching commit)
  - [bpf-next,v3,3/3] selftests/bpf: Disable warnings on unused flags for Clang builds
    (no matching commit)

You are awesome, thank you!