[Click] Click Kernel Packages and Library Linking . . .
Eddie Kohler
kohler at cs.ucla.edu
Sun Oct 17 01:25:22 EDT 2010
Hi John,
Yeah, this sounds like a problem, and one the Click makefiles are not built to
handle.
With support for "provisions", you can ask Click to build & link with things
that are not elements. Although you mention wanting to maintain the code
separately, I think it is much better to do one of two things:
1. Don't explicitly link with the library, just make the library export its
symbols (as any linux module would). The library becomes a separate module
which must be installed for Click to load.
2. Shift the library's source into Click using ELEMENT_PROVIDES.
I worry about linking with a .a file. The two methods above ensure that Click
and the library are compiled for the same kernel version, using the correct
kernel compile options. A .a file might be out of sync.
Eddie
On 10/07/2010 07:31 PM, John Russell Lane wrote:
> Hello!
>
> I have a question related to Click package building, which I haven't
> seen on the mailing list or FAQ:
>
> Is there a well-accepted method for getting static, kernel-ready
> libraries linked to a Click kernel module?
>
> Background:
>
> I have a Click package (we'll call it "mypackage") which, for
> userlevel Click, I link with with an external library (call it
> "libmylib.so"). To tell Click that the external library is required,
> I use something like ELEMENT_LIBS("-L ../mylib -lmylib") in one or
> more of my Click package source files; all builds quite nicely and
> links at runtime.
>
> However, I'd like to move part of this into the kernel (i.e., build
> "mypackage.ko"). I modified my the "mylib" source to add precisely
> the same compile options Click adds for building source files (i.e.,
> it basically does a make in the Linux kernel source tree for a
> non-existent source file, has make dump the options used, parses them
> via sed and adds them to the build). I then built an ar archive
> library (call it "libmylib.a") out of the subset of source files from
> "mylib" which I've modified to run in the Linux kernel.
>
> Now, initially, I thought there might be an easy way to get this
> static library ("libmylib.a") linked with my Click package
> ("mypackage.ko"), but ELEMENT_LIBS definitely seems to be a
> userlevel-only option and I haven't seen anything in the docs related
> to getting external libraries linked into Click-built kernel modules.
>
> For the moment, what I'm doing is having Click build "mypackage.ko",
> rerunning the final linker call to include my "-L ../mylib -lmylib"
> and then installing. This builds, loads fine (via click-install) and
> is working for the moment, but I'm hoping there's a more automated
> method for doing this. Ideally, something like an ELEMENT_KLIBS might
> exist to add such libraries to the final linker call. One option is
> to fully integrate the "mylib" source into the "mypackage" source, but
> since they're maintained separately, this is not really desirable. A
> similar option is to create symlinks in the "mypackage" source to the
> "mylib" source files. But I'm hoping there's something that can be
> more easily maintained.
>
> Has anyone else run into this issue? Any suggestions, workarounds or
> solutions would be greatly appreciated.
>
> Thanks!
>
> jrl.
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
More information about the click
mailing list