简体   繁体   中英

Trying to port GCC specific asm goto to Clang

I've been trying to turn a bit of GNU extensions in to actual standard C so it'll run on clang, knowing standard C and not GNU extensions, I'm at a bit of a loss.

    __asm__ (goto("1:"
            STATIC_KEY_INITIAL_NOP
            ".pushsection __jump_table,  \"aw\" \n\t"
            _ASM_ALIGN "\n\t"
            _ASM_PTR "1b, %l[l_yes], %c0 \n\t"
            ".popsection \n\t"
            : :  "i" (key) : : l_yes););

I've tried to turn this in to actual asm, but have yet to be successful.

If you're curious, this is part of a kernel I've just about got to build on clang, besides that one section.

You seem to be having a problem compiling arch/x86/include/asm/jump_label.h . The entire code-snippet is to enable support for "jump label patching". A new feature quite useful to allow debugging(print logs etc.) with have near-zero overhead when debugging is disabled.

The implementation you encounter depends on gcc(v4.5) which adds a new asm goto statement that allows branching to a label.

It appears that Clang/LLVM does NOT support asm goto .

As a quick fix to get your Linux kernel compiling properly, you can disable CONFIG_JUMP_LABEL in your kernel configuration. This config option is used to disable the optimisation when the compiler does NOT support asm goto properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM