Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing support for asm_inline in Linux 5.4 #2546

Closed
bobrik opened this issue Oct 10, 2019 · 2 comments
Closed

Missing support for asm_inline in Linux 5.4 #2546

bobrik opened this issue Oct 10, 2019 · 2 comments

Comments

@bobrik
Copy link
Contributor

bobrik commented Oct 10, 2019

I'm observing the following issue:

$ 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'
#define asm_inline asm __inline
                       ^

The cause appears to be this commit landed in 5.4.0-rc1:

If I replace asm_inline with asm in the kernel headers, it works just fine.

I do have CONFIG_CC_HAS_ASM_INLINE=y:

The kernel is compiled with GCC 9.2.0, BCC is using LLVM9.

@bobrik
Copy link
Contributor Author

bobrik commented Oct 10, 2019

Adding the following at the very top of opensnoop C code also works:

#ifdef asm_inline
#undef asm_inline
#define asm_inline asm
#endif

Should I make a PR to insert this in BFrontendAction::DoMiscWorkAround() or is there a better way?

@yonghong-song
Copy link
Collaborator

yonghong-song commented Oct 10, 2019

Could you add the workaround to helpers.h? There is already asm_volatile_goto workaround there?
Yes, please do help submit a pull request. Thanks!

bobrik added a commit to bobrik/bcc that referenced this issue Oct 10, 2019
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'
                       ^
```
CrackerCat pushed a commit to CrackerCat/bcc that referenced this issue Jul 31, 2024
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'
                       ^
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants