[Bug c/84187] New: -O0 fails inline assembly compile
rong2.liu at intel dot com
gcc-bugzilla@gcc.gnu.org
Fri Feb 2 21:44:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84187
Bug ID: 84187
Summary: -O0 fails inline assembly compile
Product: gcc
Version: 5.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: rong2.liu at intel dot com
Target Milestone: ---
Hi,
When I use -O0 flag to compile a kernel module, compile fails with following
error message. The same code compiles fine if not using -O0 flag.
make -C /lib/modules/4.12.0+/build M=/home/bob/GccCompileError
make[1]: Entering directory '/home/bob/kernel/v4.12/linux'
CC [M] /home/bob/GccCompileError/GccCompileError.o
In file included from ./include/linux/compiler.h:62:0,
from ./include/linux/init.h:4,
from /home/bob/GccCompileError/GccCompileError.c:1:
./arch/x86/include/asm/cpufeature.h: In function ‘GccCompileError_init’:
./include/linux/compiler-gcc.h:264:38: warning: asm operand 0 probably doesn’t
match constraints
#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
^
./arch/x86/include/asm/cpufeature.h:146:3: note: in expansion of macro
‘asm_volatile_goto’
asm_volatile_goto("1: jmp 6f\n"
^
./include/linux/compiler-gcc.h:264:38: warning: asm operand 2 probably doesn’t
match constraints
#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
^
./arch/x86/include/asm/cpufeature.h:146:3: note: in expansion of macro
‘asm_volatile_goto’
asm_volatile_goto("1: jmp 6f\n"
^
./include/linux/compiler-gcc.h:264:38: error: impossible constraint in ‘asm’
#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)
^
./arch/x86/include/asm/cpufeature.h:146:3: note: in expansion of macro
‘asm_volatile_goto’
asm_volatile_goto("1: jmp 6f\n"
^
scripts/Makefile.build:308: recipe for target
'/home/bob/GccCompileError/GccCompileError.o' failed
make[2]: *** [/home/bob/GccCompileError/GccCompileError.o] Error 1
Makefile:1512: recipe for target '_module_/home/bob/GccCompileError' failed
make[1]: *** [_module_/home/bob/GccCompileError] Error 2
make[1]: Leaving directory '/home/bob/kernel/v4.12/linux'
Makefile:16: recipe for target 'all' failed
make: *** [all] Error 2
Here is the very simple source code to demonstrate the error:
1 #include <linux/init.h>
2 #include <linux/module.h>
3 #include <asm/cpufeature.h>
4 #include <asm/cpufeatures.h>
5
6 MODULE_LICENSE("Proprietary");
7
8 static int __init GccCompileError_init(void)
9 {
10 bool invPcid = false;
11
12 invPcid = static_cpu_has(X86_FEATURE_INVPCID);
13 printk(KERN_ERR "<1> INVPCID = %s\n", invPcid == true ? "true" :
"false");
14
15 //printk("GccCompileError: Hello, world!\n");
16 return 0;
17 }
18
19 static void __exit GccCompileError_exit(void)
20 {
21 printk("GccCompileError: Goodbye, world!\n");
22 }
23
24 module_init(GccCompileError_init);
25 module_exit(GccCompileError_exit);
And the following is Makefile:
1 KERNEL_MODULE_NAME := GccCompileError
2
3 KERNELDIR:=/lib/modules/$(shell uname -r)/build
4 PWD=$(shell pwd)
5
6 INCLUDES = -I.
7
8 ccflags-y += $(INCLUDES) -ggdb -O0
9 #ccflags-y += $(INCLUDES) -ggdb
10
11 obj-m += GccCompileError.o
12
13 switch-y := GccCompileError.o
14
15 all:
16 $(MAKE) -C $(KERNELDIR) M=$(PWD)
17
18 clean:
19 $(MAKE) -C $(KERNELDIR) M=$(PWD) clean
20
21 install:
22 $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
More information about the Gcc-bugs
mailing list