kraj / meta-clang

Clang C/C++ cross compiler and runtime for OpenEmbedded/Yocto Project
MIT License
151 stars 192 forks source link

bcc: remove LUAJIT setting and related examples #921

Closed sandy-lcq closed 3 months ago

sandy-lcq commented 3 months ago

Current LUAJIT actually not works, below is snip of src/lua/CMakeLists.txt [snip] find_package(LuaJIT) find_program(LUAJIT luajit)

if (LUAJIT_LIBRARIES AND LUAJIT) FILE(GLOB_RECURSE SRC_LUA ${CMAKE_CURRENT_SOURCE_DIR}/bcc/.lua ${CMAKE_CURRENT_SOURCE_DIR}/bcc/vendor/.lua ${CMAKE_CURRENT_SOURCE_DIR}/bpf/*.lua)

ADD_CUSTOM_COMMAND(
    OUTPUT bcc.lua
    COMMAND ${LUAJIT} ${CMAKE_CURRENT_SOURCE_DIR}/src/squish.lua ${CMAKE_CURRENT_SOURCE_DIR}
    DEPENDS ${SRC_LUA} ${CMAKE_CURRENT_SOURCE_DIR}/squishy
)

ADD_CUSTOM_COMMAND(
    OUTPUT bcc.o
    COMMAND ${LUAJIT} -bg bcc.lua bcc.o
    DEPENDS bcc.lua
)

[snip]

LUAJIT will be set when luajit is found. For oe, maybe we need to DEPENDS on luajit-native. But there are still 2 problems after I change DEPENDS from luajit to luajit-native and export LUA_PATH="${RECIPE_SYSROOT_NATIVE}/usr/share/luajit-2.1/?.lua"

  1. luajit seems not support cross compile, if our target arch is different with build host, from above snip, luajit will compile out bcc.o with host arch, int this way, compile will failed with below error: "error adding symbols: file in wrong format".

Refer [1], seems like option "-a" can used to generate other arch object. But luajit-native don't have this option: cortexa57-wrs-linux/bcc/0.29.1/recipe-sysroot-native/usr/bin/luajit [options]... [script [args]...]. Available options are: -e chunk Execute string 'chunk'. -l name Require library 'name'. -b ... Save or list bytecode. -j cmd Perform LuaJIT control command. -O[opt] Control LuaJIT optimizations. -i Enter interactive mode after executing 'script'. -v Show version information. -E Ignore environment variables. – Stop handling options.

  1. if target arch is the same as build host(my test env is x86-64), bcc-lua is built out, but still have 2 problems, first, "bcc-lua /usr/share/bcc/examples/lua/bashreadline.lua" has a runtime error [2]. second, bcc-lua may try to find modules on host path:

root@qemux86-64:/usr/share/bcc/examples/lua# bcc-lua ./kprobe-latency.lua bcc-lua: bcc.lua:3052: module 'syscall' not found: no field package.preload['syscall'] no file './syscall.lua' no file '/build/tmp-glibc/work/x86_64-linux/luajit-native/2.1/recipe-sysroot-native/usr/share/luaj' no file '/usr/local/share/lua/5.1/syscall.lua' no file '/usr/local/share/lua/5.1/syscall/init.lua' no file '/build/tmp-glibc/work/x86_64-linux/luajit-native/2.1/recipe-sysroot-native/usr/share/lua/' no file '/build/tmp-glibc/work/x86_64-linux/luajit-native/2.1/recipe-sysroot-native/usr/share/lua/' no file './syscall.so' no file '/usr/local/lib/lua/5.1/syscall.so' no file '/build/tmp-glibc/work/x86_64-linux/luajit-native/2.1/recipe-sysroot-native/usr/lib/lua/5.' no file '/usr/local/lib/lua/5.1/loadall.so'

so remove LUAJIT setting and related examples first

[1] https://luajit.org/running.html [2] https://github.com/iovisor/bcc/issues/1621

sandy-lcq commented 3 months ago

This is an RFC patch, according to current state, I think maybe no one need this luajit for now, so maybe we could remove it.

sandy-lcq commented 3 months ago

The build check failed since minicom do_configure failed. But I can build minicom successfully with both gcc and clang. I don't see why my change will cause this failure, seems not related.

sandy-lcq commented 3 months ago

Just find that the build out executable bcc-lua for x86-64 maybe try to found modules on host path. According to the offical webpage luajit, I cannot found how to cross compile out an target arch object by luajit, I need to confirm with luajit upstream.

root@qemux86-64:/usr/share/bcc/examples/lua# bcc-lua ./kprobe-latency.lua bcc-lua: bcc.lua:3052: module 'syscall' not found: no field package.preload['syscall'] no file './syscall.lua' no file '/build/tmp-glibc/work/x86_64-linux/luajit-native/2.1/recipe-sysroot-native/usr/share/luaj' no file '/usr/local/share/lua/5.1/syscall.lua' no file '/usr/local/share/lua/5.1/syscall/init.lua' no file '/build/tmp-glibc/work/x86_64-linux/luajit-native/2.1/recipe-sysroot-native/usr/share/lua/' no file '/build/tmp-glibc/work/x86_64-linux/luajit-native/2.1/recipe-sysroot-native/usr/share/lua/' no file './syscall.so' no file '/usr/local/lib/lua/5.1/syscall.so' no file '/build/tmp-glibc/work/x86_64-linux/luajit-native/2.1/recipe-sysroot-native/usr/lib/lua/5.' no file '/usr/local/lib/lua/5.1/loadall.so' stack traceback: [C]: in function 'require' bcc.lua:3052: in function [C]: at 0x00454840 [C]: in function 'require' ./kprobe-latency.lua:21: in main chunk [C]: in function 'dofile' bcc.lua:6332: in function [C]: at 0x00404b50

kraj commented 3 months ago

The build check failed since minicom do_configure failed. But I can build minicom successfully with both gcc and clang. I don't see why my change will cause this failure, seems not related.

Just rebase your branch and push again it will rerun the CI loop