Page MenuHomeFreeBSD

Add LLVM BPF backend
ClosedPublic

Authored by yhayakawa3720_gmail.com on Jun 27 2018, 8:43 AM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 26 2024, 8:20 PM
Unknown Object (File)
Feb 15 2024, 2:56 PM
Unknown Object (File)
Dec 27 2023, 8:40 AM
Unknown Object (File)
Dec 26 2023, 8:03 PM
Unknown Object (File)
Dec 22 2023, 8:39 AM
Unknown Object (File)
Dec 21 2023, 3:47 PM
Unknown Object (File)
Dec 20 2023, 1:51 AM
Unknown Object (File)
Dec 9 2023, 3:37 PM

Details

Summary

This patch adds LLVM BPF backend to build target.

BPF (eBPF) is an independent instruction set architecture which is introduced in Linux a few years ago. Originally, eBPF execute environment was only inside Linux kernel. However, recent years there are some user space implementation (https://github.com/iovisor/ubpf, https://doc.dpdk.org/guides/prog_guide/bpf_lib.html) and kernel space implementation for FreeBSD is going on (https://github.com/YutaroHayakawa/generic-ebpf).

Since its backend source already included in FreeBSD base, just including it to build target makes these kind of things usable in FreeBSD.

Test Plan

Build test with latest revision.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

The patch previously uploaded was wrong one. Updated it.

Apart from the question whether to enable BPF by default, or not, LGTM. @yhayakawa3720_gmail.com, can you commit, or shall I do it?

share/mk/src.opts.mk
240 ↗(On Diff #44512)

I'm not sure if we want to enable this target by default? (I have another patch which adds *all* supported LLVM targets, but is does not enable them by default.)

I suppose it does not add too much build time, but still, I would rather avoid complaints of "yet another CPU cycle taken by LLVM's huge build". :)

@bdrewery @emaste what's your opinion on that?

This revision is now accepted and ready to land.Jun 27 2018, 4:18 PM
share/mk/src.opts.mk
240 ↗(On Diff #44512)

Good question. As @bdrewery is changing the bootstrap compiler to build only the needed target by default, and moving to one compiler for universe, I suppose it's not a big deal to add it by default... but perhaps we should leave it off by default until use cases are in the three or ready.

Please rebase for share/mk/src.opts.mk changes. You'll need to add bpf to the __LLVM_TARGETS list and remove LLVM_TARGET_BPF. Also note changes to the tools/build/options/ file with a suggestion to use LLVM_TARGET_ALL.

This revision now requires changes to proceed.Jun 27 2018, 6:46 PM
share/mk/src.opts.mk
257 ↗(On Diff #44572)

Actually now I'm not so sure if we should enable BPF by default.
I think it makes more sense to keep it off-by-default until there is a more compelling reason to enable it (like your kernel support is merged).
On the otherhand this is only adding a handful of files so the complaints may not come if it is on-by-default.

tools/build/options/WITH_LLVM_TARGET_BPF
2 ↗(On Diff #44572)

I think an extra blurb here about what BPF backend support is for is warranted.

share/mk/src.opts.mk
257 ↗(On Diff #44572)

Let's add it now, but disabled by default, and we can enable it later on when it is needed.

tools/build/options/WITH_LLVM_TARGET_BPF
2 ↗(On Diff #44572)

Well in fact all the LLVM_TARGET descriptions are rather short, but I'm not sure what kind of other information you would want to give here? That it is specifically meant for kernel BPF ?

I completely agree with disabling it by default, but it seems removing bpf from the __LLVM_TARGETS list ends up to the error like this.

$ sudo make buildworld
...

make[3]: "/usr/src/lib/clang/llvm.build.mk" line 57: Malformed conditional (${MK_LLVM_TARGET_BPF} != "no")

...

Any idea to solve this?

I completely agree with disabling it by default, but it seems removing bpf from the __LLVM_TARGETS list ends up to the error like this.

$ sudo make buildworld
...

make[3]: "/usr/src/lib/clang/llvm.build.mk" line 57: Malformed conditional (${MK_LLVM_TARGET_BPF} != "no")

...

Any idea to solve this?

Add LLVM_TARGET_BPF to __DEFAULT_NO_OPTIONS, maybe just after the ​.for __llt in ${__LLVM_TARGETS} loop. It's a bit unfortunate that it has to be done this way, though. That for loop has obfuscated the settings a little bit. :)

Thank you for your help Dim. I fixed the patch to disable BPF backend by default.

Actually, I have nothing to say in the configuration description. My project is going on, but its not guaranteed to land to FreeBSD. If the community allow me to do that, I'm happy to write it.

If we need some general description about (e)BPF, I can write it.

Hello. Is there any opportunity to this changes get merged into 12?

Remove my blocker - I think it's fine in general if off-by-default

This revision is now accepted and ready to land.Aug 9 2018, 7:12 PM
This revision was automatically updated to reflect the committed changes.

Sorry for late response. Thank you for your help!