I’ve been trying to compile the latest Linux v4.8.9 kernel on Ubuntu 16.10 and this error keeps popping up after I’ve made the default .config, modified it with menuconfig and ran make by itself. I’ve also run make mrproper as soon as I untarred the file. This is the output right after I run make:
scripts/kconfig/conf --silentoldconfig Kconfig
SYSTBL arch/x86/entry/syscalls/../../include/generated/asm/syscalls_32.h
SYSHDR arch/x86/entry/syscalls/../../include/generated/asm/unistd_32_ia32.h
SYSHDR arch/x86/entry/syscalls/../../include/generated/asm/unistd_64_x32.h
SYSTBL arch/x86/entry/syscalls/../../include/generated/asm/syscalls_64.h
SYSHDR arch/x86/entry/syscalls/../../include/generated/uapi/asm/unistd_32.h
SYSHDR arch/x86/entry/syscalls/../../include/generated/uapi/asm/unistd_64.h
SYSHDR arch/x86/entry/syscalls/../../include/generated/uapi/asm/unistd_x32.h
HOSTCC arch/x86/tools/relocs_32.o
HOSTCC arch/x86/tools/relocs_64.o
HOSTCC arch/x86/tools/relocs_common.o
HOSTLD arch/x86/tools/relocs
CHK include/config/kernel.release
UPD include/config/kernel.release
WRAP arch/x86/include/generated/asm/clkdev.h
WRAP arch/x86/include/generated/asm/cputime.h
WRAP arch/x86/include/generated/asm/dma-contiguous.h
WRAP arch/x86/include/generated/asm/early_ioremap.h
WRAP arch/x86/include/generated/asm/mcs_spinlock.h
WRAP arch/x86/include/generated/asm/mm-arch-hooks.h
CHK include/generated/uapi/linux/version.h
UPD include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
UPD include/generated/utsrelease.h
CC kernel/bounds.s
kernel/bounds.c:1:0: error: code model kernel does not support PIC mode
/*
Kbuild:45: recipe for target 'kernel/bounds.s' failed
make[1]: *** [kernel/bounds.s] Error 1
Makefile:1015: recipe for target 'prepare0' failed
make: *** [prepare0] Error 2
I’ve also tried compiling with the -no-pie option after the make command but it renders a set of new errors, constantly saying that there are «missing targets». I have gcc version 6.2.0. I also have gcc-5 installed because I assumed in the beginning it might be because gcc was too new but the same problem persists in gcc-5. Someone in the mailing lists or another forum mentioned that the problem was resolved by directly cloning from git but that didn’t help in my scenario either.
I’m curious if anyone else has run into this problem and if so, what a possible fix might be?
NOTE:I’m running Ubuntu in Virtualbox on a Mac if that might be a possible source of problems.
asked Nov 20, 2016 at 6:45
John LongJohn Long
1631 gold badge1 silver badge7 bronze badges
The issue is with your gcc installation, in gcc 6+ versions PIE( position independent executables) is enabled by default. So in order to compile you need to disable it.
Even gcc 5 has the issue.
This is a known bug for gcc. Bug Link.
So far there is no official patch from gcc side, so the workaround is to patch the Makefile of kernel source.
If you are familiar with patching the source file use the codes from this link to create the patch file then try to compile.Patch File
Let me know if you are having difficulties installing the patch.
answered Nov 21, 2016 at 1:45
JoyJoy
1561 silver badge5 bronze badges
9
Open the Makefile, look for CFLAGS_EXTRA and add the following option to it -fno-pie
I had the line:
EXTRA_CFLAGS += $(CFLAGS_EXTRA)
I changed it for:
EXTRA_CFLAGS += $(CFLAGS_EXTRA) -fno-pie
For building kernel 4, above flag is: KBUILD_CFLAGS
.
And it started compiling again.
abu_bua
10.4k10 gold badges42 silver badges62 bronze badges
answered Jan 26, 2018 at 9:22
NatimNatim
88311 silver badges23 bronze badges
2
So I had the same issue while installing the latest 2.6 version of the driver on Ubuntu Server 18.04.4. Adding flags did help to pass through the original error message but then another popped up (asm related).
So then I thought maybe it’s a problem of the 2.6 version. So I switched the branch to sgx_driver_2.0
tag, made a fresh make clean
and make
again. And it compiled successfully. Interestingly, right after that I switched back to sgx_driver_2.6 tag and tried to compile again. It worked this time.
I have no idea what was the problem before.
2018-10-29, 12:47 |
||
|
||
code model kernel does not support PIC mode
Hello, When I’m building «make bin-x86_64-pcbios/ipxe.lkrn», I get this error: Code:
And when I build it in 32 bit, I get a different error: Code:
|
||
2018-10-29, 16:31 |
RE: code model kernel does not support PIC mode
I found a way to solve the «kernel does not support PIC mode». You just add «-fno-pie» at the end of this line in Makefile.housekeeping. Apparently it’s a bug with gcc v5+. link Code:
On both architecture, I get the lzma.h error. Does anybody have a clue? |
2018-10-29, 19:10 |
RE: code model kernel does not support PIC mode
Any particular reason you are building bin-x86_64-pcbios instead of bin-i386-pcbios ? Are you building from latest git master? or what is the git commit that you are using? Use GitHub Discussions |
|
2018-10-31, 11:19 |
RE: code model kernel does not support PIC mode
Just needed to reinstall the liblzma package. Don’t know why but now it works. Thanks! |
2019-04-26, 10:30 |
RE: code model kernel does not support PIC mode
Hello, anyone have an idea about this ? |
2019-04-26, 20:03 |
RE: code model kernel does not support PIC mode
Have you done as the OP did and make sure that you have liblzma headers installed? If so, what are you compiling on? (example Ubuntu 16 or similar) Use GitHub Discussions |
|
I have troubles recompiling my Kernel. Downloading the source package, decompress it and running
fakeroot make-kpkg kernel_image
leads me to the error
[...]
CHK include/generated/utsrelease.h
UPD include/generated/utsrelease.h
CHK include/generated/package.h
UPD include/generated/package.h
CC kernel/bounds.s
kernel/bounds.c:1:0: error: code model kernel does not support PIC mode
The issue may be solved by changing the Kernel configuration obtained with make menuconfig
.
How to get rid of this error and have successful compilation
- Печать
Страницы: [1] Вниз
Тема: Ошибка при компиляции cc1: error: code model kernel does not support PIC mode (Прочитано 3706 раз)
0 Пользователей и 1 Гость просматривают эту тему.
ConnaiSSant
Ubuntu 18.04 64x
Компилирую драйвер usb для преобразователя интерфейса RS485
Полный выхлоп команды make:
make:
make -C /lib/modules/4.15.0-20-generic/build M=/home/user/Загрузки/epsolar-tracer/xr_usb_serial_common-1a
make[1]: вход в каталог «/usr/src/linux-headers-4.15.0-20-generic»
CC [M] /home/user/Загрузки/epsolar-tracer/xr_usb_serial_common-1a/xr_usb_serial_common.o
cc1: error: code model kernel does not support PIC mode
scripts/Makefile.build:339: recipe for target '/home/user/Загрузки/epsolar-tracer/xr_usb_serial_common-1a/xr_usb_serial_common.o' failed
make[2]: *** [/home/user/Загрузки/epsolar-tracer/xr_usb_serial_common-1a/xr_usb_serial_common.o] Error 1
Makefile:1552: recipe for target '_module_/home/user/Загрузки/epsolar-tracer/xr_usb_serial_common-1a' failed
make[1]: *** [_module_/home/user/Загрузки/epsolar-tracer/xr_usb_serial_common-1a] Error 2
make[1]: выход из каталога «/usr/src/linux-headers-4.15.0-20-generic»
Makefile:9: recipe for target 'all' failed
make: *** [all] Error 2
В гугле предлагают какие то патчи
gcc —version
gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0
« Последнее редактирование: 15 Мая 2018, 22:15:45 от ConnaiSSant »
bezbo
Пояснение:
The issue is with your gcc installation, in gcc 6+ versions PIE( position independent executables) is enabled by default. So in order to compile you need to disable it. Even gcc 5 has the issue. This is a known bug for gcc.
Решение:
Open the Makefile, look for CFLAGS_EXTRA and add the following option to it -fno-pie
I had the line:
EXTRA_CFLAGS += $(CFLAGS_EXTRA)
I changed it for:
EXTRA_CFLAGS += $(CFLAGS_EXTRA) -fno-pie
And it started compiling again.
ConnaiSSant
Отсутствует CFLAGS_EXTRA
obj-m := xr_usb_serial_common.o
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
EXTRA_CFLAGS := -DDEBUG=0
all:
$(MAKE) -C $(KERNELDIR) M=$(PWD)
modules_install:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
clean:
rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions vtty
Пользователь добавил сообщение 16 Мая 2018, 08:31:37:
Или как вариант, собрать gcc без pie
Пользователь добавил сообщение 16 Мая 2018, 21:06:32:
Но это долгий способ. Давайте сначало, какой Makefile нужно изменить? То что собираемся компилировать или при сборке gcc имеется ввиду? Если компилируемый код, то можно просто добавить целиком строку из вышеперечисленного ответа?
« Последнее редактирование: 16 Мая 2018, 21:06:32 от ConnaiSSant »
- Печать
Страницы: [1] Вверх