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

xmake error: cannot build elfutils #14

Open
fntlnz opened this issue May 4, 2023 · 3 comments · May be fixed by #15
Open

xmake error: cannot build elfutils #14

fntlnz opened this issue May 4, 2023 · 3 comments · May be fixed by #15

Comments

@fntlnz
Copy link
Collaborator

fntlnz commented May 4, 2023

I get this error while compiling traffico with xmake.

method 'fetch' is not callable (a nil value)

I made a repro xmake.lua for testing

-- xmake.lua
add_rules("mode.debug", "mode.release")
add_requires("elfutils")
target("my_app")
    set_kind("binary")
    set_languages("c99")
    add_files("main.c")
    add_packages("elfutils")

Same result, so it's not related to traffico per se.

@fntlnz
Copy link
Collaborator Author

fntlnz commented May 4, 2023

stack trace

error: @programdir/modules/package/tools/autoconf.lua:161: method 'fetch' is not callable (a nil value)
stack traceback:
    [@programdir/modules/package/tools/autoconf.lua:161]: in function '_get_cflags_from_packagedeps'
    [@programdir/modules/package/tools/autoconf.lua:215]: in function 'buildenvs'
    [@programdir/modules/package/tools/autoconf.lua:427]: in function 'configure'
    [@programdir/modules/package/tools/autoconf.lua:467]: in function 'build'
    [@programdir/modules/package/tools/autoconf.lua:496]: in function 'install'
    [...ke/repositories/xmake-repo/packages/e/elfutils/xmake.lua:70]: in function 'script'
    [...dir/modules/private/action/require/impl/utils/filter.lua:125]: in function 'call'
    [.../modules/private/action/require/impl/actions/install.lua:364]:

  => install elfutils 0.183 .. failed
error: @programdir/modules/private/async/runjobs.lua:256: .../modules/private/action/require/impl/actions/install.lua:469: install failed!
stack traceback:
    [C]: in function 'error'
    [@programdir/core/base/os.lua:913]:
    [.../modules/private/action/require/impl/actions/install.lua:469]: in function 'catch'
    [@programdir/core/sandbox/modules/try.lua:123]: in function 'try'
    [.../modules/private/action/require/impl/actions/install.lua:328]:
    [...modules/private/action/require/impl/install_packages.lua:479]: in function 'jobfunc'
    [@programdir/modules/private/async/runjobs.lua:232]:

stack traceback:
        [C]: in function 'error'
        @programdir/core/base/os.lua:913: in function 'os.raiselevel'
        (...tail calls...)
        @programdir/modules/private/async/runjobs.lua:256: in field 'catch'
        @programdir/core/sandbox/modules/try.lua:123: in global 'try'
        @programdir/modules/private/async/runjobs.lua:218: in upvalue 'cotask'
        @programdir/core/base/scheduler.lua:404: in function <@programdir/core/base/scheduler.lua:397>

@leodido
Copy link
Owner

leodido commented Jul 14, 2023

This xmake commit should solve the issue. Lemme look into it.

@leodido
Copy link
Owner

leodido commented Jul 14, 2023

I confirm, that commit solves the issue.

I've tested it with xmake v2.8.1+dev.a7d08d7. To install xmake from a branch containing that commit (eg., dev or master) you can do:

curl -fsSL https://xmake.io/shget.text | bash -s dev
source $HOME/.xmake/profile

Or otherwise, wait for xmake to release v2.8.2 😄

Output:

[vscode@codespaces-5a7c8f traffico]$ xmake f --generate-vmlinux=y
checking for platform ... linux
checking for architecture ... x86_64
updating repositories .. ok
note: install or modify (m) these packages (pass -y to skip confirm)?
in xmake-repo:
  -> cmake 3.26.4 [from:llvm,cjson]
  -> elfutils 0.183 [from:libbpf]
  -> cjson 1.7.15 
in l13o:
  -> libbpf v0.8.0 
  -> bats v1.7.0 
  -> mini_httpd 1.30 
please input: y (y/n/m)
y
  => download https://github.com/bats-core/bats-core/archive/refs/tags/v1.7.0.tar.gz .. ok
Installed Bats to /home/vscode/.xmake/packages/b/bats/v1.7.0/ccbbe97a924a460eb1cc8066487eb7d3/bin/bats
  => install bats v1.7.0 .. ok
  => download https://acme.com/software/mini_httpd/mini_httpd-1.30.tar.gz .. ok
  => downloading cmake, elfutils, installing mini_httpd .. (3/curl,make) mini_httpd/1.30 26Oct2018
  => install mini_httpd 1.30 .. ok
  => download https://sourceware.org/elfutils/ftp/0.183/elfutils-0.183.tar.bz2 .. ok
  => download https://cmake.org/files/v3.26/cmake-3.26.4-linux-x86_64.tar.gz .. ok
  => install cmake 3.26.4 .. ok
  => download https://github.com/DaveGamble/cJSON/archive/v1.7.15.zip .. ok
  => install cjson 1.7.15 .. ok
  => install elfutils 0.183 .. ok
  => download https://github.com/libbpf/libbpf/archive/v0.8.0.tar.gz .. ok
  => install libbpf v0.8.0 .. ok
generating /tmp/.xmake1000/230714/api.nop.h.in ... ok
generating /tmp/.xmake1000/230714/api.block_private_ipv4.h.in ... ok
generating /tmp/.xmake1000/230714/api.block_port.h.in ... ok
generating /tmp/.xmake1000/230714/api.block_ip.h.in ... ok
generating /workspaces/traffico/api/api.h.in ... ok
generating /tmp/.xmake1000/230714/api.block_private_ipv4.h.in ... cache
generating /tmp/.xmake1000/230714/api.block_port.h.in ... cache
generating /tmp/.xmake1000/230714/api.block_ip.h.in ... cache
generating /tmp/.xmake1000/230714/api.nop.h.in ... cache
generating /workspaces/traffico/api/api.h.in ... cache

Building tests now:

[vscode@codespaces-5a7c8f traffico]$ xmake -b test
generating /tmp/.xmake1000/230714/api.block_private_ipv4.h.in ... cache
generating /tmp/.xmake1000/230714/api.nop.h.in ... cache
generating /tmp/.xmake1000/230714/api.block_ip.h.in ... cache
generating /tmp/.xmake1000/230714/api.block_port.h.in ... cache
generating /tmp/.xmake1000/230714/api.nop.h.in ... cache
generating /tmp/.xmake1000/230714/api.block_ip.h.in ... cache
generating /tmp/.xmake1000/230714/api.block_private_ipv4.h.in ... cache
generating /tmp/.xmake1000/230714/api.block_port.h.in ... cache
generating /tmp/.xmake1000/230714/api.nop.h.in ... cache
generating /tmp/.xmake1000/230714/api.block_ip.h.in ... cache
generating /tmp/.xmake1000/230714/api.block_private_ipv4.h.in ... cache
generating /tmp/.xmake1000/230714/api.block_port.h.in ... cache
[ 10%]: providing.bpftool tools/bpftool
[ 20%]: generating.vmlinux vmlinux/vmlinux.h
[ 29%]: compiling.bpf bpf/block_ip.bpf.c
[ 29%]: compiling.bpf bpf/nop.bpf.c
[ 29%]: compiling.bpf bpf/block_port.bpf.c
[ 29%]: compiling.bpf bpf/block_private_ipv4.bpf.c
[ 29%]: compiling.bpf.o build/.gens/bpf/linux/x86_64/release/rules/bpf/block_port.bpf.o
[ 29%]: compiling.bpf.o build/.gens/bpf/linux/x86_64/release/rules/bpf/block_ip.bpf.o
[ 29%]: compiling.bpf.o build/.gens/bpf/linux/x86_64/release/rules/bpf/nop.bpf.o
[ 29%]: compiling.bpf.o build/.gens/bpf/linux/x86_64/release/rules/bpf/block_private_ipv4.bpf.o
[ 29%]: generating.skel.h build/.gens/bpf/linux/x86_64/release/rules/bpf/nop.skel.h
[ 29%]: generating.skel.h build/.gens/bpf/linux/x86_64/release/rules/bpf/block_port.skel.h
[ 29%]: generating.skel.h build/.gens/bpf/linux/x86_64/release/rules/bpf/block_ip.skel.h
[ 29%]: generating.skel.h build/.gens/bpf/linux/x86_64/release/rules/bpf/block_private_ipv4.skel.h
[ 70%]: cache compiling.release traffico.c
[ 70%]: cache compiling.release traffico-cni.c
[ 79%]: linking.release traffico
[ 79%]: linking.release traffico-cni
[100%]: build ok, spent 1.548s

Then, running those tests:

[vscode@codespaces-5a7c8f traffico]$ xmake run test
generating /tmp/.xmake1000/230714/api.block_port.h.in ... cache
generating /tmp/.xmake1000/230714/api.nop.h.in ... cache
generating /tmp/.xmake1000/230714/api.block_ip.h.in ... cache
generating /tmp/.xmake1000/230714/api.block_private_ipv4.h.in ... cache
generating /tmp/.xmake1000/230714/api.block_ip.h.in ... cache
generating /tmp/.xmake1000/230714/api.block_port.h.in ... cache
generating /tmp/.xmake1000/230714/api.block_private_ipv4.h.in ... cache
generating /tmp/.xmake1000/230714/api.nop.h.in ... cache
1..14
# setup:
# remove namespace ns9 (if it exists)
# create namespace ns9
# create veth link veth0 <-> peer0
# assign device peer0 to namespace ns9
# setup address of veth0
# setup address of peer0
# teardown:
# delete device veth0
# remove namespace ns9 (if it exists)
ok 1 cli: install nop program at egress
# setup:
# remove namespace ns9 (if it exists)
# create namespace ns9
# create veth link veth0 <-> peer0
# assign device peer0 to namespace ns9
# setup address of veth0
# setup address of peer0
# teardown:
# delete device veth0
# remove namespace ns9 (if it exists)
ok 2 cli: install nop program at ingress
# setup:
# remove namespace ns3 (if it exists)
# create namespace ns3
# create veth link veth0 <-> peer0
# assign device peer0 to namespace ns3
# setup address of veth0
# setup address of peer0
# traffico up at interface peer0
# traffico down
# tc qdisc still there
# BPF program still there
# teardown:
# delete device veth0
# remove namespace ns3 (if it exists)
ok 3 cli: --no-cleanup works
# setup:
# remove namespace ns4 (if it exists)
# create namespace ns4
# create veth link veth0 <-> peer0
# assign device peer0 to namespace ns4
# setup address of veth0
# setup address of peer0
# teardown:
# delete device veth0
# remove namespace ns4 (if it exists)
ok 4 cli: block_private_ipv4 blocks ICMP packets
ok 5 cli: help
ok 6 cli: usage
ok 7 cli: invalid option
ok 8 cli: unrecognized option
ok 9 cli: missing program
ok 10 cli: unavailable program
ok 11 cli: unavailable network interface
ok 12 cli: unavailable network interface (long)
ok 13 cli: unsupported attach point
# setup:
# remove namespace ns6 (if it exists)
# create namespace ns6
# create veth link veth0 <-> peer0
# assign device peer0 to namespace ns6
# setup address of veth0
# setup address of peer0
# serving /tmp at 8787
# can reach 10.22.1.1:8787
# can reach 10.22.1.1:8787 from the namespace
# installing block_private_ipv4 in the namespace
# attach ok
# qdisc ok
# cannot reach 10.22.1.1:8787 from the namespace
# teardown:
# delete device veth0
# remove namespace ns6 (if it exists)
# shutdown server
ok 14 cni: block_private_ipv4
[vscode@codespaces-5a7c8f traffico]$ echo $?
0

Verdict: it works! 🥳

@leodido leodido linked a pull request Jul 14, 2023 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants