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.1k10 gold badges41 silver badges60 bronze badges
answered Jan 26, 2018 at 9:22
NatimNatim
88311 silver badges23 bronze badges
2
- Печать
Страницы: [1] Вниз
Тема: Ошибка при компиляции cc1: error: code model kernel does not support PIC mode (Прочитано 3528 раз)
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] Вверх
GamingAori
Registered Member
- Posts
- 5
- Karma
- 0
cc1: error: code model kernel does not support PIC mode
Fri Mar 15, 2019 8:02 am
Hey,
I bought me a new WIFI USB Adapter the dootoper AC1200 which use the RTL88x2B according to the driver documentation. When I try compile the driver for installing it I get the error cc1: error: code model kernel does not support PIC mode. How can I solve this problem?
NoNameNoBlame
- Karma
- 0
Re: cc1: error: code model kernel does not support PIC mode
Fri Mar 15, 2019 11:34 am
First of all:
Plug your device in.
Then use:
$ ubuntu-drivers —help
Did You do this?
GamingAori
Registered Member
- Posts
- 5
- Karma
- 0
Re: cc1: error: code model kernel does not support PIC mode
Fri Mar 15, 2019 12:06 pm
NoNameNoBlame wrote:First of all:
Plug your device in.
Then use:
$ ubuntu-drivers —help
Did You do this?
No, I didn’t. What does that?
NoNameNoBlame
- Karma
- 0
Re: cc1: error: code model kernel does not support PIC mode
Fri Mar 15, 2019 12:21 pm
It installs the driver from Ubuntu,
if one exists.
—
If You don’t know what PIC
(position independent code)
as a compile-option does, and
whether Your kernel supports it
and if yes, how it does, then:
Please ask at the Ubuntu-Forum.
They provide KDE neon’s kernels and drivers.
—
But, if this doesn’t satisfy You, say so.
GamingAori
Registered Member
- Posts
- 5
- Karma
- 0
Re: cc1: error: code model kernel does not support PIC mode
Fri Mar 15, 2019 1:28 pm
NoNameNoBlame wrote:It installs the driver from Ubuntu,
if one exists.—
If You don’t know what PIC
(position independent code)
as a compile-option does, and
whether Your kernel supports it
and if yes, how it does, then:Please ask at the Ubuntu-Forum.
They provide KDE neon’s kernels and drivers.—
But, if this doesn’t satisfy You, say so.
Okay just try it with ubuntu-drivers and it didn’t work. So how exactly do I compile and install the driver?
NoNameNoBlame
- Karma
- 0
Re: cc1: error: code model kernel does not support PIC mode
Fri Mar 15, 2019 1:50 pm
I don’t know.
The last Linux-kernel, I compiled was over 15 years ago.
The last kernel I compiled myself, was a BSD-kernel. Also,
many years ago.
—
Follow my hint and go to the Ubuntu-forums.
And provide necessary details:
Where did You download the driver-source?
Give full location!
Did You follow the compile-instructions of the
driver’s included README files? Etc.
NoNameNoBlame
- Karma
- 0
Re: cc1: error: code model kernel does not support PIC mode
Fri Mar 15, 2019 2:25 pm
And don’t forget to provide hardware info.
Like this:
- Code: Select all
$ lspci -vvv | grep 11
03:00.0 Network controller: Broadcom Inc. and subsidiaries BCM4322 802.11a/b/g/n Wireless LAN Controller (rev 01)
$ lspci -vvv -n | grep -A1 03:00.0
03:00.0 0280: 14e4:432b (rev 01)
Subsystem: 106b:008e
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
© Copyright 2012 KDE Community Forum Team. All rights reserved.
KDE Community Forums has no liability for any content or post. All messages belong to and are the opinion of their respective authors.
KDE and K Desktop Environment are trademarks of KDE e.V. • For more details, contact the Forum Administrators.
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 |
|
View previous topic :: View next topic | |||||||||
Author | Message | ||||||||
---|---|---|---|---|---|---|---|---|---|
grellyd n00b Joined: 11 Oct 2016 |
|
||||||||
Back to top |
|
||||||||
fedeliallalinea Administrator Joined: 08 Mar 2003 |
|
||||||||
Back to top |
|
||||||||
NeddySeagoon Administrator Joined: 05 Jul 2003 |
|
||||||||
Back to top |
|
||||||||
fedeliallalinea Administrator Joined: 08 Mar 2003 |
|
||||||||
Back to top |
|
||||||||
grellyd n00b Joined: 11 Oct 2016 |
|
||||||||
Back to top |
|
||||||||
grellyd n00b Joined: 11 Oct 2016 |
|
||||||||
Back to top |
|
||||||||
grellyd n00b Joined: 11 Oct 2016 |
|
||||||||
Back to top |
|
||||||||
Jaglover Watchman Joined: 29 May 2005 |
|
||||||||
Back to top |
|
||||||||
grellyd n00b Joined: 11 Oct 2016 |
|
||||||||
Back to top |
|
||||||||
grellyd n00b Joined: 11 Oct 2016 |
|
||||||||
Back to top |
|
||||||||
|
You cannot post new topics in this forum |
- Forum
- The Ubuntu Forum Community
- Ubuntu Specialised Support
- Development & Programming
- Packaging and Compiling Programs
- CC1 ERROR after running the make command
-
CC1 ERROR after running the make command
Hey, im building a kernel module and for some reason after a few times that it worked i get the following error:
«cc1: error: code model kernel does not support PIC mode.»
i looked around tried all kinds of things and nothing seems to work, even installed ubuntu again because i thought i courrupted some files, help please! thank you.
-
Re: CC1 ERROR after running the make command
-
Re: CC1 ERROR after running the make command
i tried to add the EXTRA_FLAGS line it didnt work.
about the comment with the patch — i didnt understand so idk ..i wierd stuff that i already build modules before and it suddenly happend.
thanks for the quick replay!
-
Re: CC1 ERROR after running the make command
Can you paste the contents of Makefile at paste.ubuntu.com and post a link?
-
Re: CC1 ERROR after running the make command
its the simplest module ever:
obj-m += x.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modulesclean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules————————————————————————————
-
Re: CC1 ERROR after running the make command
What kernel and Ubuntu version? Also check
Code:
cat /usr/src/linux-headers-$(uname -r)/Makefile | grep -i pie
-
Re: CC1 ERROR after running the make command
ok i have no idea how it happend but it fixed itself, thank for the help!