尝试将GCC特定的asm goto移植到Clang [英] Trying to port GCC specific asm goto to Clang

查看:482
本文介绍了尝试将GCC特定的asm goto移植到Clang的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试将一些GNU扩展名转换为实际的标准C,因此它将在clang上运行,知道标准C而不是GNU扩展名,我有点茫然.

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););

我尝试将其转换为实际的asm,但尚未成功.

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

如果您好奇的话,这是我将要在clang上构建的内核的一部分,除了那一部分.

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.

您遇到的实现取决于gcc(v4.5 ),它添加了一个新的asm goto语句,该语句允许分支到标签.

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

Clang/LLVM< 9.0.0不支持 asm goto .

作为使您的Linux内核正确编译的快速解决方案,可以在内核配置中禁用CONFIG_JUMP_LABEL.当编译器不正确支持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.

更新:添加了对asm goto的初始支持到v9.0.0中的Clang .

Update: Initial support for asm goto was added to Clang in v9.0.0.

最初对asm goto语句(GNU C扩展)的支持 添加了用于从内联汇编到标签的控制流的功能.主要消费者 这个构造是Linux内核(CONFIG_JUMP_LABEL = y)和glib.有 在Clang的集成汇编器中,还有一些不受支持的极端情况 IfConverter.请针对您遇到的任何问题提交bug.

Initial support for asm goto statements (a GNU C extension) has been added for control flow from inline assembly to labels. The main consumers of this construct are the Linux kernel (CONFIG_JUMP_LABEL=y) and glib. There are still a few unsupported corner cases in Clang's integrated assembler and IfConverter. Please file bugs for any issues you run into.

这篇关于尝试将GCC特定的asm goto移植到Clang的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆