Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation fails, when system bpftool is used #1055

Open
ptr1337 opened this issue Dec 6, 2024 · 25 comments
Open

Compilation fails, when system bpftool is used #1055

ptr1337 opened this issue Dec 6, 2024 · 25 comments
Assignees
Labels
bug Something isn't working build Build related issues

Comments

@ptr1337
Copy link
Contributor

ptr1337 commented Dec 6, 2024

Reproducer:

  1. Archlinux enviroment
  2. paru -G scx-scheds-git && cd scx-scheds-git
  3. makepkg -si

Log:

INFO: autodetecting backend as ninja                                                                                                                                                                                                        
INFO: calculating backend command to run: /usr/bin/ninja -C /tmp/makepkg/scx-scheds-git/src/scx/build
ninja: Entering directory `/tmp/makepkg/scx-scheds-git/src/scx/build'
[1/50] Generating bpftool_target with a custom command

[11/50] Generating from 'scx_sdt.bpf.o'
FAILED: scheds/c/scx_sdt.p/scx_sdt.bpf.skel.h scheds/c/scx_sdt.p/scx_sdt.bpf.subskel.h 
/tmp/makepkg/scx-scheds-git/src/scx/meson-scripts/bpftool_build_skel /usr/bin/bpftool scheds/c/scx_sdt.p/scx_sdt.bpf.o scheds/c/scx_sdt.p/scx_sdt.bpf.skel.h scheds/c/scx_sdt.p/scx_sdt.bpf.subskel.h /tmp/makepkg/scx-scheds-git/src/scx/build/lib/lib
libbpf: failed to open file '/tmp/makepkg/scx-scheds-git/src/scx/build/lib/lib.bpf.o': -2
Error: failed to link '/tmp/makepkg/scx-scheds-git/src/scx/build/lib/lib.bpf.o': No such file or directory (2)
[12/50] Generating from 'scx_simple.bpf.o'
FAILED: scheds/c/scx_simple.p/scx_simple.bpf.skel.h scheds/c/scx_simple.p/scx_simple.bpf.subskel.h 
/tmp/makepkg/scx-scheds-git/src/scx/meson-scripts/bpftool_build_skel /usr/bin/bpftool scheds/c/scx_simple.p/scx_simple.bpf.o scheds/c/scx_simple.p/scx_simple.bpf.skel.h scheds/c/scx_simple.p/scx_simple.bpf.subskel.h /tmp/makepkg/scx-scheds-git/src/scx/build/lib/lib
libbpf: failed to open file '/tmp/makepkg/scx-scheds-git/src/scx/build/lib/lib.bpf.o': -2
Error: failed to link '/tmp/makepkg/scx-scheds-git/src/scx/build/lib/lib.bpf.o': No such file or directory (2)
[14/50] Generating from 'scx_userland.bpf.o'
FAILED: scheds/c/scx_userland.p/scx_userland.bpf.skel.h scheds/c/scx_userland.p/scx_userland.bpf.subskel.h 
/tmp/makepkg/scx-scheds-git/src/scx/meson-scripts/bpftool_build_skel /usr/bin/bpftool scheds/c/scx_userland.p/scx_userland.bpf.o scheds/c/scx_userland.p/scx_userland.bpf.skel.h scheds/c/scx_userland.p/scx_userland.bpf.subskel.h /tmp/makepkg/scx-scheds-git/src/scx/build/lib/lib
libbpf: failed to open file '/tmp/makepkg/scx-scheds-git/src/scx/build/lib/lib.bpf.o': -2
Error: failed to link '/tmp/makepkg/scx-scheds-git/src/scx/build/lib/lib.bpf.o': No such file or directory (2)

Removing the usage of system bpftool fixes the issue.
Issue can not be reproduced on latest release.

@etsal etsal self-assigned this Dec 6, 2024
@etsal
Copy link
Contributor

etsal commented Dec 6, 2024

Thanks for reporting this. Could you please post the version of the system bpftool that breaks this, and that of the latest bpftool? I am assuming one is <=7.5.0 and the other is 7.6.0?

There seems to be an issue we are investigating with libbpf <-= 1.5.0 that causes bpftool gen object to fail when provided with multiple input objects. This would explain why the library fails to build above. As a note, Rust schedulers should be unaffected by this change.

If that is the case, we can make linking with the library for C functions opt-in. This would prevent us from compiling scx_sdt when using the system bpftool, but that should not really be an issue. considering scx_sdt is only used for testing the arena allocator.

@ptr1337
Copy link
Contributor Author

ptr1337 commented Dec 6, 2024

Thanks for reporting this. Could you please post the version of the system bpftool that breaks this, and that of the latest bpftool? I am assuming one is <=7.5.0 and the other is 7.6.0?

Archlinux currently ships currently 7.5.0 provided by the bpf packages in linux-tools 6.12.

There seems to be an issue we are investigating with libbpf <-= 1.5.0 that causes bpftool gen object to fail when provided with multiple input objects. This would explain why the library fails to build above.

Yes, we are using on archlinux libbpf 1.5.0.

As a note, Rust schedulers should be unaffected by this change.

We are currently shipping in archlinux all sched-ext schedulers, and likely would keep doing so also in future releases.

@etsal
Copy link
Contributor

etsal commented Dec 6, 2024

In that case, I will turn off library linking for now if our bpftool gets overridden by the build option. This will also disable building scx_sdt since there is no way to do so without the most recent bpftool. Once bpftool 1.6 comes out, I will be removing this limitation. Let me know if that would work for Arch.

@etsal
Copy link
Contributor

etsal commented Dec 6, 2024

Can you send me the exact commit of the system bpftool used in the failing release? The commit that fixes the possible bug is libbpf/libbpf@ecf998e, but that should be included in the tagged release.

@etsal
Copy link
Contributor

etsal commented Dec 6, 2024

#1061

@ptr1337
Copy link
Contributor Author

ptr1337 commented Dec 6, 2024

Can you send me the exact commit of the system bpftool used in the failing release? The commit that fixes the possible bug is libbpf/libbpf@ecf998e, but that should be included in the tagged release.

https://archlinux.org/packages/core/x86_64/libbpf/
https://archlinux.org/packages/extra/x86_64/bpf/

Its using each just the latest release.

#1061

Gonna test the MR.

@etsal
Copy link
Contributor

etsal commented Dec 6, 2024

Sounds good, please make sure to use a75b865 which is the most recent version of the pull request (I just updated it).

@sirlucjan
Copy link
Contributor

Run-time dependency threads found: YES
Dependency threads found: YES unknown (cached)
Dependency threads found: YES unknown (cached)
Dependency threads found: YES unknown (cached)
Dependency threads found: YES unknown (cached)
Dependency threads found: YES unknown (cached)
Dependency threads found: YES unknown (cached)
Dependency threads found: YES unknown (cached)
Dependency threads found: YES unknown (cached)
Found pkg-config: YES (/usr/bin/pkg-config) 2.3.0
Run-time dependency systemd found: YES 256
Dependency openrc skipped: feature openrc disabled
Run-time dependency libalpm found: YES 15.0.0
Build targets in project: 59
WARNING: Deprecated features used:
 * 0.60.0: {'install_subdir with empty directory'}

Some warnings are there, but it seems to be building correctly.

@etsal
Copy link
Contributor

etsal commented Dec 6, 2024

Sounds good, in that case I will be merging the patch. I will keep this issue open, if the problem persists please let me know and I will take a look.

@anh0516
Copy link
Contributor

anh0516 commented Dec 7, 2024

After trying the LLVM 19 fix from #1051, my bpftool segfaulted:


[2/36] Generating bpftool_target with a custom command

[3/36] Generating from 'scx_sdt.bpf.o'
FAILED: scheds/c/scx_sdt.p/scx_sdt.bpf.skel.h scheds/c/scx_sdt.p/scx_sdt.bpf.subskel.h 
/home/avraham/Documents/scx/meson-scripts/bpftool_build_skel /usr/bin/bpftool scheds/c/scx_sdt.p/scx_sdt.bpf.o scheds/c/scx_sdt.p/scx_sdt.bpf.skel.h scheds/c/scx_sdt.p/scx_sdt.bpf.subskel.h /home/avraham/Documents/scx/build/lib/lib
libbpf: failed to get ELF header for /home/avraham/Documents/scx/build/lib/lib.bpf.o: invalid `Elf' handle
/home/avraham/Documents/scx/meson-scripts/bpftool_build_skel: line 25: 11524 Segmentation fault      "$bpftool" gen object "$stem".l1o "$input" "$lib".bpf.o
[4/36] Generating from 'scx_pair.bpf.o'
FAILED: scheds/c/scx_pair.p/scx_pair.bpf.skel.h scheds/c/scx_pair.p/scx_pair.bpf.subskel.h 
/home/avraham/Documents/scx/meson-scripts/bpftool_build_skel /usr/bin/bpftool scheds/c/scx_pair.p/scx_pair.bpf.o scheds/c/scx_pair.p/scx_pair.bpf.skel.h scheds/c/scx_pair.p/scx_pair.bpf.subskel.h /home/avraham/Documents/scx/build/lib/lib
libbpf: failed to get ELF header for /home/avraham/Documents/scx/build/lib/lib.bpf.o: invalid `Elf' handle
/home/avraham/Documents/scx/meson-scripts/bpftool_build_skel: line 25: 11523 Segmentation fault      "$bpftool" gen object "$stem".l1o "$input" "$lib".bpf.o
[5/36] Generating from 'scx_userland.bpf.o'
FAILED: scheds/c/scx_userland.p/scx_userland.bpf.skel.h scheds/c/scx_userland.p/scx_userland.bpf.subskel.h 
/home/avraham/Documents/scx/meson-scripts/bpftool_build_skel /usr/bin/bpftool scheds/c/scx_userland.p/scx_userland.bpf.o scheds/c/scx_userland.p/scx_userland.bpf.skel.h scheds/c/scx_userland.p/scx_userland.bpf.subskel.h /home/avraham/Documents/scx/build/lib/lib
libbpf: failed to get ELF header for /home/avraham/Documents/scx/build/lib/lib.bpf.o: invalid `Elf' handle
/home/avraham/Documents/scx/meson-scripts/bpftool_build_skel: line 25: 11525 Segmentation fault      "$bpftool" gen object "$stem".l1o "$input" "$lib".bpf.o
[6/36] Generating from 'scx_simple.bpf.o'
FAILED: scheds/c/scx_simple.p/scx_simple.bpf.skel.h scheds/c/scx_simple.p/scx_simple.bpf.subskel.h 
/home/avraham/Documents/scx/meson-scripts/bpftool_build_skel /usr/bin/bpftool scheds/c/scx_simple.p/scx_simple.bpf.o scheds/c/scx_simple.p/scx_simple.bpf.skel.h scheds/c/scx_simple.p/scx_simple.bpf.subskel.h /home/avraham/Documents/scx/build/lib/lib
libbpf: failed to get ELF header for /home/avraham/Documents/scx/build/lib/lib.bpf.o: invalid `Elf' handle
/home/avraham/Documents/scx/meson-scripts/bpftool_build_skel: line 25: 11516 Segmentation fault      "$bpftool" gen object "$stem".l1o "$input" "$lib".bpf.o
[7/36] Generating from 'scx_central.bpf.o'
FAILED: scheds/c/scx_central.p/scx_central.bpf.skel.h scheds/c/scx_central.p/scx_central.bpf.subskel.h 
/home/avraham/Documents/scx/meson-scripts/bpftool_build_skel /usr/bin/bpftool scheds/c/scx_central.p/scx_central.bpf.o scheds/c/scx_central.p/scx_central.bpf.skel.h scheds/c/scx_central.p/scx_central.bpf.subskel.h /home/avraham/Documents/scx/build/lib/lib
libbpf: failed to get ELF header for /home/avraham/Documents/scx/build/lib/lib.bpf.o: invalid `Elf' handle
/home/avraham/Documents/scx/meson-scripts/bpftool_build_skel: line 25: 11518 Segmentation fault      "$bpftool" gen object "$stem".l1o "$input" "$lib".bpf.o
[8/36] Generating from 'scx_flatcg.bpf.o'
FAILED: scheds/c/scx_flatcg.p/scx_flatcg.bpf.skel.h scheds/c/scx_flatcg.p/scx_flatcg.bpf.subskel.h 
/home/avraham/Documents/scx/meson-scripts/bpftool_build_skel /usr/bin/bpftool scheds/c/scx_flatcg.p/scx_flatcg.bpf.o scheds/c/scx_flatcg.p/scx_flatcg.bpf.skel.h scheds/c/scx_flatcg.p/scx_flatcg.bpf.subskel.h /home/avraham/Documents/scx/build/lib/lib
libbpf: failed to get ELF header for /home/avraham/Documents/scx/build/lib/lib.bpf.o: invalid `Elf' handle
/home/avraham/Documents/scx/meson-scripts/bpftool_build_skel: line 25: 11522 Segmentation fault      "$bpftool" gen object "$stem".l1o "$input" "$lib".bpf.o
[12/36] Generating rust_all with a custom command (wrapped by meson to set env)
ninja: build stopped: subcommand failed.

dmesg verifies the segfault is coming from bpftool itself. I rebuilt bpftool (Gentoo) and now it's happy. Maybe some symbols changed between LLVM 19.1.4 and 19.1.5 and it made bpftool unhappy until it was rebuilt against the new one? Not sure what else would have caused it.

@etsal
Copy link
Contributor

etsal commented Dec 7, 2024

Can you post the bpftool version/repo commit? It might be that the bpftool is not built out of the most recent tree. Also, is the project compiling when using the bpftool downloaded by scx?

@anh0516
Copy link
Contributor

anh0516 commented Dec 7, 2024

I'm building against the system dev-util/bpftool-7.5.0 USE="caps clang -llvm and the system `dev-libs/libbpf-1.5.0 USE="-static-libs".

Thinking more it wasn't because of a library it was linked against; dmesg said it was in bpftool itself:

bpftool[11523]: segfault at 28 ip 0000000000410820 sp 00007ffc177ab820 error 4 in bpftool[10820,404000+7a000] likely on CPU 0 (core 0, socket 0)
Code: 24 50 39 c8 0f 8c bc fe ff ff 4c 8b 6c 24 38 b8 06 00 00 00 31 d2 be 04 00 00 00 c4 e2 f9 f7 84 24 c0 00 00 00 4d 8d 44 05 00 <49> 8b 48 28 49 8b 40 30 4c 89 44 24 50 4c 8b 20 48 8b 41 20 4c 63
bpftool[11524]: segfault at 28 ip 0000000000410820 sp 00007ffe01c76e80 error 4 in bpftool[10820,404000+7a000] likely on CPU 4 (core 0, socket 0)
Code: 24 50 39 c8 0f 8c bc fe ff ff 4c 8b 6c 24 38 b8 06 00 00 00 31 d2 be 04 00 00 00 c4 e2 f9 f7 84 24 c0 00 00 00 4d 8d 44 05 00 <49> 8b 48 28 49 8b 40 30 4c 89 44 24 50 4c 8b 20 48 8b 41 20 4c 63
bpftool[11525]: segfault at 28 ip 0000000000410820 sp 00007ffedb1ebda0 error 4 in bpftool[10820,404000+7a000] likely on CPU 6 (core 2, socket 0)
Code: 24 50 39 c8 0f 8c bc fe ff ff 4c 8b 6c 24 38 b8 06 00 00 00 31 d2 be 04 00 00 00 c4 e2 f9 f7 84 24 c0 00 00 00 4d 8d 44 05 00 <49> 8b 48 28 49 8b 40 30 4c 89 44 24 50 4c 8b 20 48 8b 41 20 4c 63
bpftool[11516]: segfault at 28 ip 0000000000410820 sp 00007fff868e8340 error 4 in bpftool[10820,404000+7a000] likely on CPU 2 (core 2, socket 0)
Code: 24 50 39 c8 0f 8c bc fe ff ff 4c 8b 6c 24 38 b8 06 00 00 00 31 d2 be 04 00 00 00 c4 e2 f9 f7 84 24 c0 00 00 00 4d 8d 44 05 00 <49> 8b 48 28 49 8b 40 30 4c 89 44 24 50 4c 8b 20 48 8b 41 20 4c 63
bpftool[11518]: segfault at 28 ip 0000000000410820 sp 00007ffddc7ecb80 error 4 in bpftool[10820,404000+7a000] likely on CPU 0 (core 0, socket 0)
Code: 24 50 39 c8 0f 8c bc fe ff ff 4c 8b 6c 24 38 b8 06 00 00 00 31 d2 be 04 00 00 00 c4 e2 f9 f7 84 24 c0 00 00 00 4d 8d 44 05 00 <49> 8b 48 28 49 8b 40 30 4c 89 44 24 50 4c 8b 20 48 8b 41 20 4c 63
bpftool[11522]: segfault at 28 ip 0000000000410820 sp 00007ffc248cec20 error 4 in bpftool[10820,404000+7a000] likely on CPU 1 (core 1, socket 0)
Code: 24 50 39 c8 0f 8c bc fe ff ff 4c 8b 6c 24 38 b8 06 00 00 00 31 d2 be 04 00 00 00 c4 e2 f9 f7 84 24 c0 00 00 00 4d 8d 44 05 00 <49> 8b 48 28 49 8b 40 30 4c 89 44 24 50 4c 8b 20 48 8b 41 20 4c 63

I rebuilt dev-util/bpftool and it's working again every time. So something was screwy with it, who knows what.

I wasn't sure if this was useful information or not but I figured I'd post it anyways.

@ptr1337
Copy link
Contributor Author

ptr1337 commented Dec 7, 2024

@htejun @etsal
Compiling the 1.0.7 release still runs into the issue:

[11/50] Generating from 'scx_sdt.bpf.o'
FAILED: scheds/c/scx_sdt.p/scx_sdt.bpf.skel.h scheds/c/scx_sdt.p/scx_sdt.bpf.subskel.h 
/build/scx-scheds/src/scx/meson-scripts/bpftool_build_skel /usr/bin/bpftool scheds/c/scx_sdt.p/scx_sdt.bpf.o scheds/c/scx_sdt.p/scx_sdt.bpf.skel.h scheds/c/scx_sdt.p/scx_sdt.bpf.subskel.h /build/scx-scheds/src/scx/build/lib/lib
libbpf: failed to open file '/build/scx-scheds/src/scx/build/lib/lib.bpf.o': -2
Error: failed to link '/build/scx-scheds/src/scx/build/lib/lib.bpf.o': No such file or directory (2)
[12/50] Generating from 'scx_simple.bpf.o'
FAILED: scheds/c/scx_simple.p/scx_simple.bpf.skel.h scheds/c/scx_simple.p/scx_simple.bpf.subskel.h 
/build/scx-scheds/src/scx/meson-scripts/bpftool_build_skel /usr/bin/bpftool scheds/c/scx_simple.p/scx_simple.bpf.o scheds/c/scx_simple.p/scx_simple.bpf.skel.h scheds/c/scx_simple.p/scx_simple.bpf.subskel.h /build/scx-scheds/src/scx/build/lib/lib
libbpf: failed to open file '/build/scx-scheds/src/scx/build/lib/lib.bpf.o': -2
Error: failed to link '/build/scx-scheds/src/scx/build/lib/lib.bpf.o': No such file or directory (2)
[13/50] Generating from 'scx_userland.bpf.o'
FAILED: scheds/c/scx_userland.p/scx_userland.bpf.skel.h scheds/c/scx_userland.p/scx_userland.bpf.subskel.h 
/build/scx-scheds/src/scx/meson-scripts/bpftool_build_skel /usr/bin/bpftool scheds/c/scx_userland.p/scx_userland.bpf.o scheds/c/scx_userland.p/scx_userland.bpf.skel.h scheds/c/scx_userland.p/scx_userland.bpf.subskel.h /build/scx-scheds/src/scx/build/lib/lib
libbpf: failed to open file '/build/scx-scheds/src/scx/build/lib/lib.bpf.o': -2
Error: failed to link '/build/scx-scheds/src/scx/build/lib/lib.bpf.o': No such file or directory (2)

Reproducer in archlinux env:
sudo pacman -S devtools nvchecker
pkgctl repo clone --protocol=https scx-scheds
cd scx-scheds
pkgctl version upgrade
pkgctl build

@arighi
Copy link
Contributor

arighi commented Dec 8, 2024

Same problem in Ubuntu if you don't have a system bpftool installed. Installing the system bpftool seems to fix it, but I guess it's not using the fetched bpftool anymore (even if it's still fetching it). BTW, this is only for the C schedulers.

@arighi
Copy link
Contributor

arighi commented Dec 8, 2024

#1071 seems to fix the build issue on Ubuntu, but I think it's a different one....

@etsal
Copy link
Contributor

etsal commented Dec 8, 2024

@htejun @etsal Compiling the 1.0.7 release still runs into the issue:

[11/50] Generating from 'scx_sdt.bpf.o'
FAILED: scheds/c/scx_sdt.p/scx_sdt.bpf.skel.h scheds/c/scx_sdt.p/scx_sdt.bpf.subskel.h 
/build/scx-scheds/src/scx/meson-scripts/bpftool_build_skel /usr/bin/bpftool scheds/c/scx_sdt.p/scx_sdt.bpf.o scheds/c/scx_sdt.p/scx_sdt.bpf.skel.h scheds/c/scx_sdt.p/scx_sdt.bpf.subskel.h /build/scx-scheds/src/scx/build/lib/lib
libbpf: failed to open file '/build/scx-scheds/src/scx/build/lib/lib.bpf.o': -2
Error: failed to link '/build/scx-scheds/src/scx/build/lib/lib.bpf.o': No such file or directory (2)
[12/50] Generating from 'scx_simple.bpf.o'
FAILED: scheds/c/scx_simple.p/scx_simple.bpf.skel.h scheds/c/scx_simple.p/scx_simple.bpf.subskel.h 
/build/scx-scheds/src/scx/meson-scripts/bpftool_build_skel /usr/bin/bpftool scheds/c/scx_simple.p/scx_simple.bpf.o scheds/c/scx_simple.p/scx_simple.bpf.skel.h scheds/c/scx_simple.p/scx_simple.bpf.subskel.h /build/scx-scheds/src/scx/build/lib/lib
libbpf: failed to open file '/build/scx-scheds/src/scx/build/lib/lib.bpf.o': -2
Error: failed to link '/build/scx-scheds/src/scx/build/lib/lib.bpf.o': No such file or directory (2)
[13/50] Generating from 'scx_userland.bpf.o'
FAILED: scheds/c/scx_userland.p/scx_userland.bpf.skel.h scheds/c/scx_userland.p/scx_userland.bpf.subskel.h 
/build/scx-scheds/src/scx/meson-scripts/bpftool_build_skel /usr/bin/bpftool scheds/c/scx_userland.p/scx_userland.bpf.o scheds/c/scx_userland.p/scx_userland.bpf.skel.h scheds/c/scx_userland.p/scx_userland.bpf.subskel.h /build/scx-scheds/src/scx/build/lib/lib
libbpf: failed to open file '/build/scx-scheds/src/scx/build/lib/lib.bpf.o': -2
Error: failed to link '/build/scx-scheds/src/scx/build/lib/lib.bpf.o': No such file or directory (2)

Reproducer in archlinux env: sudo pacman -S devtools nvchecker pkgctl repo clone --protocol=https scx-scheds cd scx-scheds pkgctl version upgrade pkgctl build

The commands succeed on up-to-date arch system, so maybe #1071 fixed this?

@ptr1337
Copy link
Contributor Author

ptr1337 commented Dec 9, 2024

@arighi
I have build scx-scheds-git with system bpftool enabled:

Found ninja-1.12.1 at /usr/bin/ninja
INFO: autodetecting backend as ninja                                                                                                                                                                                                        
INFO: calculating backend command to run: /usr/bin/ninja -C /tmp/makepkg/scx-scheds-git/src/scx/build
ninja: Entering directory `/tmp/makepkg/scx-scheds-git/src/scx/build'
[1/50] Generating libbpf with a custom command

[2/50] Generating bpftool_target with a custom command

[22/50] Generating from 'scx_userland.bpf.o'
FAILED: scheds/c/scx_userland.p/scx_userland.bpf.skel.h scheds/c/scx_userland.p/scx_userland.bpf.subskel.h 
/tmp/makepkg/scx-scheds-git/src/scx/meson-scripts/bpftool_build_skel /usr/bin/bpftool scheds/c/scx_userland.p/scx_userland.bpf.o scheds/c/scx_userland.p/scx_userland.bpf.skel.h scheds/c/scx_userland.p/scx_userland.bpf.subskel.h /tmp/makepkg/scx-scheds-git/src/scx/build/lib/lib
libbpf: global 'scx_bpf_error_bstr': failed to resolve size of underlying type: -22
Error: failed to link '/tmp/makepkg/scx-scheds-git/src/scx/build/lib/lib.bpf.o': Invalid argument (22)
[23/50] Generating from 'scx_sdt.bpf.o'
FAILED: scheds/c/scx_sdt.p/scx_sdt.bpf.skel.h scheds/c/scx_sdt.p/scx_sdt.bpf.subskel.h 
/tmp/makepkg/scx-scheds-git/src/scx/meson-scripts/bpftool_build_skel /usr/bin/bpftool scheds/c/scx_sdt.p/scx_sdt.bpf.o scheds/c/scx_sdt.p/scx_sdt.bpf.skel.h scheds/c/scx_sdt.p/scx_sdt.bpf.subskel.h /tmp/makepkg/scx-scheds-git/src/scx/build/lib/lib
libbpf: global 'scx_bpf_error_bstr': failed to resolve size of underlying type: -22
Error: failed to link '/tmp/makepkg/scx-scheds-git/src/scx/build/lib/lib.bpf.o': Invalid argument (22)
[24/50] Generating from 'scx_central.bpf.o'
FAILED: scheds/c/scx_central.p/scx_central.bpf.skel.h scheds/c/scx_central.p/scx_central.bpf.subskel.h 
/tmp/makepkg/scx-scheds-git/src/scx/meson-scripts/bpftool_build_skel /usr/bin/bpftool scheds/c/scx_central.p/scx_central.bpf.o scheds/c/scx_central.p/scx_central.bpf.skel.h scheds/c/scx_central.p/scx_central.bpf.subskel.h /tmp/makepkg/scx-scheds-git/src/scx/build/lib/lib
libbpf: global 'scx_bpf_error_bstr': failed to resolve size of underlying type: -22
Error: failed to link '/tmp/makepkg/scx-scheds-git/src/scx/build/lib/lib.bpf.o': Invalid argument (22)
[29/50] Generating 'scheds/c/scx_flatcg.p/scx_flatcg.bpf.o'^C

@arighi
Copy link
Contributor

arighi commented Dec 9, 2024

@arighi I have build scx-scheds-git with system bpftool enabled:

Ok, but does it work also with the non-system bpftool?

@ptr1337
Copy link
Contributor Author

ptr1337 commented Dec 9, 2024

When removing -D bpftool=disabled the compilation from scx-scheds-git is succesful.

@anh0516
Copy link
Contributor

anh0516 commented Dec 9, 2024

I just did some experimenting.

I made a brand new Arch Linux installation. I then cloned and built scx-scheds 1.0.7 with pkgctl, which worked just fine, which we already knew.

I then cloned scx-scheds-git from the AUR and used pkgctl build (instead of the usual makepkg). That worked just fine too.

Then I realized that neither PKGBUILD is actually specifying -D bpftool=disabled. So I added it to both scx-scheds as well as scx-scheds-git and it does indeed fail with the errors we've already seen.

So then I wanted to build a new bpftool, and see if it solves the issue like it did for me on Gentoo. Took me a moment to realize that I had to clone linux-tools and not bpf.

This time I used makepkg to build both scx-scheds and scx-scheds-git so I could use the newly built bpftool instead of what got downloaded to the chroot. I'm sure there's a way around this but I'm not familiar with the tooling. They both still failed.

Checking dmesg, bpftool isn't segfaulting like it was for me.

Conclusion: My issue here was unrelated, both the latest release and latest git are still broken when building on Arch Linux with the system bpftool.

@etsal
Copy link
Contributor

etsal commented Dec 9, 2024

Can you try #1080? It should avoid the codepath that triggers the error.

@anh0516
Copy link
Contributor

anh0516 commented Dec 9, 2024

if bpftool_maj < 7 or (bpftool_maj == 7 and bpftool_min >= 5)

So it will only attempt to build it if bpftool is older than 7.0 or at least 7.5. Arch Linux is using bpftool 7.5, which satisfies this check. So it still tries to build and still fails.

If I change the condition to bpftool_min > 5, then it actually returns false, and results in a configure failure:

meson.build:308:40: ERROR: Unknown variable "scx_lib".

I'm building just fine on my Gentoo system with bpftool 7.5. So I'm doubtful that the bpftool version is the problem here. I also tried using system or downloaded libbpf and it didn't make a difference.

@etsal
Copy link
Contributor

etsal commented Dec 9, 2024

Sorry about that. Can you try changing the condition to bpftool_min < 5? This is what the intended check was.

@anh0516
Copy link
Contributor

anh0516 commented Dec 9, 2024

Oh I meant to say I changed it to < 5 but I used the wrong symbol in my comment here. I am getting

meson.build:308:40: ERROR: Unknown variable "scx_lib".

I tried commenting/removing references to it in meson.build, lib/meson.build, but it's still unhappy.

@etsal
Copy link
Contributor

etsal commented Dec 9, 2024

This is weird, for older bpftool versions line 308 should never be triggering. I will look into it.

@hodgesds hodgesds added bug Something isn't working build Build related issues labels Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working build Build related issues
Projects
None yet
Development

No branches or pull requests

6 participants