Skip to content

Commit

Permalink
Redefine asm_inline for Linux 5.4+, Fixes #2546 (#2547) (#5)
Browse files Browse the repository at this point in the history
Here's the upstream commit that introduced `asm_inline`:

* torvalds/linux@eb11186

Without this patch BCC fails with the following:

```
$ sudo /usr/share/bcc/tools/opensnoop
In file included from /virtual/main.c:2:
In file included from include/uapi/linux/ptrace.h:142:
In file included from ./arch/x86/include/asm/ptrace.h:5:
./arch/x86/include/asm/segment.h:254:2: error: expected '(' after 'asm'
        alternative_io ("lsl %[seg],%[p]",
        ^
./arch/x86/include/asm/alternative.h:240:2: note: expanded from macro 'alternative_io'
        asm_inline volatile (ALTERNATIVE(oldinstr, newinstr, feature)   \
        ^
include/linux/compiler_types.h:210:24: note: expanded from macro 'asm_inline'
                       ^
```

Co-authored-by: Ivan Babrou <[email protected]>
  • Loading branch information
Prakash Surya and bobrik authored Oct 21, 2020
1 parent 7e71ead commit ef9a7c7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/cc/export/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ R"********(
#ifndef __BPF_HELPERS_H
#define __BPF_HELPERS_H

/* In Linux 5.4 asm_inline was introduced, but it's not supported by clang.
* Redefine it to just asm to enable successful compilation.
*/
#ifdef asm_inline
#undef asm_inline
#define asm_inline asm
#endif

/* Before bpf_helpers.h is included, uapi bpf.h has been
* included, which references linux/types.h. This will bring
* in asm_volatile_goto definition if permitted based on
Expand Down

0 comments on commit ef9a7c7

Please sign in to comment.