Giter Site home page Giter Site logo

Comments (12)

joelagnel avatar joelagnel commented on September 26, 2024 1

@iotcg thanks for sharing your header build script. Could you send me a pull-request to add out-of-tree kernel header build support to --kernelsrc option? I think we will also need additional options maybe: --kernelsrc and --kernelout ?

from adeb.

rongqianfeng avatar rongqianfeng commented on September 26, 2024

Hi,
I try the methods of @Linuxuser4 provide as follows,the bcc compilation on target board success.

  1. A softlink to stdc++ was required since compilation complained of missing stdc++ library.
    ln -s /usr/lib/gcc/aarch64-linux-gnu/7/libstdc++.so /usr/lib/libstdc++.so

  2. Two include paths needed to be provided to avoid missing header error. These were added in CMakeLists.txt in the base folder:
    include_directories(/usr/include/c++/7/)
    include_directories(/usr/include/aarch64-linux-gnu/c++/7/)

When run the command "funclatency do_sys_open" generate Issue 1: Headers are missing on the target device, but I don't know how to solve this problem.
root@localhost:/# funclatency do_sys_open
In file included from :2:
In file included from /virtual/include/bcc/bpf.h:12:
In file included from include/linux/types.h:5:
include/uapi/linux/types.h:4:10: fatal error: 'asm/types.h' file not found
#include <asm/types.h>
^~~~~~~~~~~~~
1 error generated.
Traceback (most recent call last):
File "/usr/share/bcc/tools/funclatency", line 206, in
b = BPF(text=bpf_text)
File "/usr/lib/python2.7/dist-packages/bcc/init.py", line 318, in init
raise Exception("Failed to compile BPF text")
Exception: Failed to compile BPF text

from adeb.

changchengx avatar changchengx commented on September 26, 2024

I enabled adeb on x86 android platform. The issue is resolved in:
https://github.com/iotcg/adeb/tree/develop.
You can check the git log to find how to set the right environment variable to resolve these issues.

from adeb.

rongqianfeng avatar rongqianfeng commented on September 26, 2024

Yes, I have changed the source code in bashrc.common as follow:

#WA for library link issue
LIBRARY_PATH=${LIBRARY_PATH}:/usr/lib/gcc/aarch64-linux-gnu/7/
export LIBRARY_PATH=${LIBRARY_PATH}:/usr/lib/aarch64-linux-gnu/

#WA for include path issue
CPATH=${CPATH}:/usr/include/c++/7
export CPATH=${CPATH}:/usr/include/aarch64-linux-gnu/c++/7

#WA for kernel include files on arm64 device
export CPATH=${CPATH}:/kernel-headers/include
cat /proc/cpuinfo | grep -q aarch64 2>/dev/null
rst=$?
if [ $rst -eq 0 ]
then
CPATH=${CPATH}:/kernel-headers/arch/arm64/include/generated
export CPATH=${CPATH}:/kernel-headers/arch/arm64/include/generated/uapi
fi

The bcc compilation also failed, is my kernel config issue?

-- Configuring done
-- Generating done
-- Build files have been written to: /bcc-master/build
Scanning dependencies of target bpf-static
Scanning dependencies of target bpf-shared
Scanning dependencies of target bcc-loader-static
[ 1%] Building C object src/cc/CMakeFiles/bpf-static.dir/libbpf.c.o
[ 1%] Building C object src/cc/CMakeFiles/bpf-shared.dir/libbpf.c.o
[ 2%] Building CXX object src/cc/CMakeFiles/bcc-loader-static.dir/bcc_syms.cc.o
In file included from /bcc-master/src/cc/libbpf.c:22:
In file included from /usr/include/fcntl.h:35:
In file included from /usr/include/aarch64-linux-gnu/bits/fcntl.h:61:
In file included from /usr/include/aarch64-linux-gnu/bits/fcntl-linux.h:346:
/kernel-headers/include/linux/falloc.h:12:2: error: unknown type name '__s16'
__s16 l_type;
In file included from /bcc-master/src/cc/libbpf.c:22:
In file included from /usr/include/fcntl.h:35:
In file included from /usr/include/aarch64-linux-gnu/bits/fcntl.h:61:
^In file included from /usr/include/aarch64-linux-gnu/bits/fcntl-linux.h
:346:
/kernel-headers/include/linux/falloc.h:12:2: error: unknown type name '__s16'
__s16 l_type;
^
/kernel-headers/include/linux/falloc.h/kernel-headers/include/linux/falloc.h:13:2: :error: unknown type name '__s16'
__s16 l_whence;13:2: error: unknown type name '__s16'
__s16 l_whence;
...
fatal error: too many errors emitted, stopping now [-ferror-limit=]
13 warnings and 20 errors generated.
make[2]: *** [src/cc/CMakeFiles/bpf-shared.dir/build.make:63: src/cc/CMakeFiles/bpf-shared.dir/libbpf.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:158: src/cc/CMakeFiles/bpf-shared.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

from adeb.

changchengx avatar changchengx commented on September 26, 2024

It's kernel head file issues.
Two suspect points:

  1. Some kernel head files are not copied into kernel-headers.
  2. Need more specific CPATH to include the directory to tell gcc/clang to find the header file.

BTW, you can refer to below file to generate kernel-headers:
https://github.com/iotcg/adeb/blob/develop/kernel-headers.sh
As you know, we often build kernel out of kernel source directory, e.g. build_kernel.
You can put kernel-header.sh under build_kernel and run the script, it will generate kernel-headers directory which includes all the required kernel head files.

from adeb.

joelagnel avatar joelagnel commented on September 26, 2024

from adeb.

changchengx avatar changchengx commented on September 26, 2024

@joelagnel Glad to see your fix, waiting for PR. I also want to know how to resolve "library link issue" & "include head file issue" besides my method.

from adeb.

joelagnel avatar joelagnel commented on September 26, 2024

Actually, the issue I was talking about is different. Your compilation could be failing because of incorrect 'kernel-headers' as you pointed:

/kernel-headers/include/linux/falloc.h:12:2: error: unknown type name '__s16'

Erick is working on removing dependency on kernel headers. His prototype is already working but it has to be merged. It will be merged either today or tomorrow. After that the following command should work:
“adeb prepare --build --bcc`

We will update you today or tomorrow. Thanks for the patience and for your help in making Androdeb better.

from adeb.

joelagnel avatar joelagnel commented on September 26, 2024

CC @ErickReyesR

from adeb.

joelagnel avatar joelagnel commented on September 26, 2024

Also as I was saying, we will also provide "backup" kernel headers incase --kernelsrc option is skipped which @ErickReyesR is working on.

from adeb.

changchengx avatar changchengx commented on September 26, 2024

@joelagnel Per your request, PR: #13
This PR has been verified on local host and target device. It supports extract kernel headers when building kernel out-of-tree.

from adeb.

joelagnel avatar joelagnel commented on September 26, 2024

At the moment, I feel out-of-tree header building will complicate the flow too much. Also we have eliminated the need for kernel version as long as you are running a recent LTS kernel (headers will be automatically downloaded). For that reason, I am closing this. Thanks

from adeb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.