Em Mon, Aug 03, 2015 at 01:11:16PM -0300, Arnaldo Carvalho de Melo escreveu:
> > >  ERROR:    unable to compile ./foo.c
> > >  Hint:    Check error message shown above.
> > >         LLVM 3.7 or newer is required. Which can be found from 
> > > http://llvm.org
> > >         You may want to try git trunk:
> > >             git clone http://llvm.org/git/llvm.git
> > >                  and
<SNIP>
> > >      or: perf record [<options>] -- <command> [<options>]

> > >      -e, --event <event>   event selector. use 'perf list' to list 
> > > available events
> > >  [root@felicio ~]#

> > > Now to find a hello.c BPF scriptlet...

So, we do not need to provide all this LLVM environment installation
hints when we get to any error, i.e. the one above was just becasuse
"./foo.c" doesn't exist, clang ran successfully, so no need for telling
the user how to install it.

The following error also shouldn't emit those hints:

  [root@felicio ~]# perf record -e ./lock_page.bpf.c sleep 1
  /root/./lock_page.bpf.c:1:5: error: expected parameter declarator
  SEC("lock_page=__lock_page page->flags")
      ^
  /root/./lock_page.bpf.c:1:5: error: expected ')'
  /root/./lock_page.bpf.c:1:4: note: to match this '('
  SEC("lock_page=__lock_page page->flags")
     ^
  /root/./lock_page.bpf.c:1:1: warning: type specifier missing, defaults to 
'int' [-Wimplicit-int]
  SEC("lock_page=__lock_page page->flags")
  ^
  /root/./lock_page.bpf.c:1:41: error: expected ';' after top level declarator
  SEC("lock_page=__lock_page page->flags")
                                          ^
                                          ;
  /root/./lock_page.bpf.c:2:22: warning: declaration of 'struct pt_regs' will 
not be visible outside of this function [-Wvisibility]
  int lock_page(struct pt_regs *ctx, int err, unsigned long flags)
                     ^
  2 warnings and 3 errors generated.
  ERROR:        unable to compile ./lock_page.bpf.c
  Hint: Check error message shown above.
        LLVM 3.7 or newer is required. Which can be found from http://llvm.org
        You may want to try git trunk:
                git clone http://llvm.org/git/llvm.git
                     and
                git clone http://llvm.org/git/clang.git

        Or fetch the latest clang/llvm 3.7 from pre-built llvm packages for
        debian/ubuntu:
                http://llvm.org/apt

        If you are using old version of clang, change 'clang-bpf-cmd-template'
        option in [llvm] section of ~/.perfconfig to:

          "$CLANG_EXEC $CLANG_OPTIONS $KERNEL_INC_OPTIONS \
             -working-directory $WORKING_DIR -c $CLANG_SOURCE \
             -emit-llvm -o - | /path/to/llc -march=bpf -filetype=obj -o -"
        (Replace /path/to/llc with path to your llc)

  Hint: You can also pre-compile it into .o
  invalid or unsupported event: './lock_page.bpf.c'
  Run 'perf list' for a list of valid events

   usage: perf record [<options>] [<command>]
      or: perf record [<options>] -- <command> [<options>]

      -e, --event <event>   event selector. use 'perf list' to list available 
events
  [root@felicio ~]# 

And I am interested in that "Hint: You can also pre-compile it into .o", seems
like a useful one, if it  was on the screen, i.e. how can I pre-compile this
into a .o, its some random piece of eBPF "scriptlet" I found in one of your
csets, after this cset in your patchkit:

  [root@felicio ~]# cat lock_page.bpf.c 
  SEC("lock_page=__lock_page page->flags")
  int lock_page(struct pt_regs *ctx, int err, unsigned long flags)
  {
        return 1;
  }
  [root@felicio ~]#

Also it would be nice to tell the user, when compilation fails, where to look
for a eBPF scriptlet primer, i.e. where can I find some documentation on how
to write such scriptlets?

At this point I expect it to build the .c into a .o, then, as the wiring up is
not there, tell the user that all went well, but more infrastructure is needed,
apply the following patches from Wang Nan! 8-)

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to