Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved]Kernel Build Fails: Kbuild does not support PIC mode
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
grellyd
n00b
n00b


Joined: 11 Oct 2016
Posts: 21

PostPosted: Wed Mar 14, 2018 6:34 am    Post subject: [solved]Kernel Build Fails: Kbuild does not support PIC mode Reply with quote

Hi all,

I am having some troubles after the 17.0 upgrade. In particular with the -PIC flag on the new gcc 6+ compiler and building the kernel.

I am experiencing the same symptoms from https://bugs.gentoo.org/621848.

I have corrected all emerge errors and every package has been rebuilt successfully on my system. However the problem comes when attempting to add new kernel flags.

After doing `make menuconfig` and selecting a few new options, when I go to do `make` I get:

Code:

  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CC      kernel/bounds.s
kernel/bounds.c:1:0: error: code model kernel does not support PIC mode
 /*
 
make[1]: *** [Kbuild:45: kernel/bounds.s] Error 1
make: *** [Makefile:986: prepare0] Error 2


After extensive searching and trying the fixes suggested in various forum threads and the above bug thread, nothing has resolved my issue.

I also noted the bug thread was marked as 'Fixed and Resolved', yet I did not see where or how. Thinking it may just be in the most recent Linux tree, I re-emerged the Linux sources and tried to upgrade to Linux-4.9, but to no avail.

Any help would be highly appreciated.

---Grellyd

_______________________

My emerge -info as suggested in: https://forums.gentoo.org/viewtopic-t-1071006-highlight-kbuild.html

Code:

Portage 2.3.24 (python 3.6.3-final-0, default/linux/amd64/17.0/desktop, gcc-6.4.0, glibc-2.25-r10, 4.4.6-gentoo x86_64)
=================================================================
System uname: Linux-4.4.6-gentoo-x86_64-Intel-R-_Core-TM-_i7-4600U_CPU_@_2.10GHz-with-gentoo-2.4.1
KiB Mem:     8114852 total,    800900 free
KiB Swap:    8388604 total,   8386084 free
Timestamp of repository gentoo: Tue, 13 Mar 2018 22:30:01 +0000
Head commit of repository gentoo: 3f923ae8e40a95c604621adb4a25d5f23ceb5f93
sh bash 4.4_p12
ld GNU ld (Gentoo 2.29.1 p3) 2.29.1
app-shells/bash:          4.4_p12::gentoo
dev-java/java-config:     2.2.0-r3::gentoo
dev-lang/perl:            5.24.3::gentoo
dev-lang/python:          2.7.14-r1::gentoo, 3.5.4-r1::gentoo, 3.6.3-r1::gentoo
dev-util/cmake:           3.9.6::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.4.1-r2::gentoo
sys-apps/openrc:          0.34.11::gentoo
sys-apps/sandbox:         2.12::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69-r4::gentoo
sys-devel/automake:       1.11.6-r3::gentoo, 1.15.1-r2::gentoo
sys-devel/binutils:       2.29.1-r1::gentoo
sys-devel/gcc:            6.4.0-r1::gentoo
sys-devel/gcc-config:     1.8-r1::gentoo
sys-devel/libtool:        2.4.6-r3::gentoo
sys-devel/make:           4.2.1::gentoo
sys-kernel/linux-headers: 4.13::gentoo (virtual/os-headers)
sys-libs/glibc:           2.25-r10::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-extra-opts:
    sync-rsync-verify-metamanifest: no

haskell
    location: /var/lib/layman/haskell
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=haswell -mavx2"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O2 -pipe -march=haswell -mavx2"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync multilib-strict news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="rsync://gentoo.gossamerhost.com/gentoo-distfiles/ http://gentoo.gossamerhost.com http://mirror.csclub.uwaterloo.ca/gentoo-distfiles/ ftp://mirror.csclub.uwaterloo.ca/gentoo-distfiles/ http://ftp.ucsb.edu/pub/mirrors/linux/gentoo/ ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/"
LANG="en_CA.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j8"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="X a52 aac acl acpi alsa amd64 berkdb bluetooth branding bzip2 cairo cdda cdr cli consolekit crypt cups cxx dbus dri dts dvd dvdr emboss encode exif fam flac fortran gdbm gif git glamor google gpm gtk hscolour iconv ipv6 jit jpeg lcms ldap libnotify mad mmx mng modules mp3 mp4 mpeg multilib ncurses nls nptl nsplugin ogg opengl openmp pam pango pcre pdf png policykit ppds python qt3support qt5 readline sdl seccomp smp sound spell sse sse2 ssl startup-notification svg tcpd tiff truetype udev udisks unicode upower usb vim-syntax vorbis wxwidgets x264 xattr xcb xml xv xvid zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6 php7-0" POSTGRES_TARGETS="postgres9_5" PYTHON_SINGLE_TARGET="python3_6" PYTHON_TARGETS="python2_7 python3_6 python3_5" RUBY_TARGETS="ruby22 ruby23" USERLAND="GNU" VIDEO_CARDS="intel" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS


Last edited by grellyd on Wed Mar 14, 2018 10:37 pm; edited 1 time in total
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 30894
Location: here

PostPosted: Wed Mar 14, 2018 6:59 am    Post subject: Reply with quote

It seems a gcc 6 bug, you have two workaround

_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54220
Location: 56N 3W

PostPosted: Wed Mar 14, 2018 9:36 am    Post subject: Reply with quote

grellyd,

4.4.6-gentoo is an old kernel. Update it. Current stable is 4.9.76-r1
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 30894
Location: here

PostPosted: Wed Mar 14, 2018 9:46 am    Post subject: Reply with quote

NeddySeagoon wrote:
4.4.6-gentoo is an old kernel. Update it. Current stable is 4.9.76-r1

Mmm I don't see that, thanks NeddySeagoon.
grellyd probably changing with a newest kernel is the best solution, forgets my workarounds
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
grellyd
n00b
n00b


Joined: 11 Oct 2016
Posts: 21

PostPosted: Wed Mar 14, 2018 7:51 pm    Post subject: Reply with quote

Quote:
4.4.6-gentoo is an old kernel. Update it. Current stable is 4.9.76-r1


Thanks for the replies you two. The kernel upgrade was one of the last things that I tried. That also doesn't build.

Currently I get:

Code:

/usr/src/linux # eselect kernel list
Available kernel symlink targets:
  [1]   linux-4.4.6-gentoo
  [2]   linux-4.9.76-gentoo-r1 *

/usr/src/linux # make silentoldconfig
scripts/kconfig/conf  --silentoldconfig Kconfig

/usr/src/linux # make -j4
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  HOSTCC  scripts/kallsyms
  CC      scripts/mod/empty.o
scripts/mod/empty.c:1:0: error: code model kernel does not support PIC mode
 /* empty file to figure out endianness / word size */
 
  HOSTCC  scripts/selinux/genheaders/genheaders
make[2]: *** [scripts/Makefile.build:259: scripts/mod/empty.o] Error 1
make[1]: *** [scripts/Makefile.build:403: scripts/mod] Error 2
make[1]: *** Waiting for unfinished jobs....
  HOSTCC  scripts/selinux/mdp/mdp
make: *** [Makefile:545: scripts] Error 2
make: *** Waiting for unfinished jobs....



which seems to be the same error as before?

The one thing I have not tried yet is nuking the directory as suggested in https://wiki.gentoo.org/wiki/Kernel/Upgrade#Solving_build_problems. I'll try that next.
Back to top
View user's profile Send private message
grellyd
n00b
n00b


Joined: 11 Oct 2016
Posts: 21

PostPosted: Wed Mar 14, 2018 7:56 pm    Post subject: Reply with quote

Quote:
The one thing I have not tried yet is nuking the directory as suggested in https://wiki.gentoo.org/wiki/Kernel/Upgrade#Solving_build_problems. I'll try that next.


That got a bit farther, but same produced the same result:

Code:

/usr/src/linux # cp .config /usr/src/kernel_config_bk

/usr/src/linux # ls /usr/src
kernel_config_bk  linux  linux-4.12.12-gentoo  linux-4.12.5-gentoo  linux-4.4.6-gentoo  linux-4.9.76-gentoo-r1

/usr/src/linux # make distclean
  CLEAN   .
  CLEAN   arch/x86/entry/vdso
  CLEAN   arch/x86/kernel/cpu
  CLEAN   arch/x86/kernel
  CLEAN   arch/x86/realmode/rm
  CLEAN   arch/x86/lib
  CLEAN   drivers/firmware/efi/libstub
  CLEAN   drivers/tty/vt
  CLEAN   drivers/video/logo
  CLEAN   firmware
  CLEAN   lib
  CLEAN   security/selinux
  CLEAN   usr
  CLEAN   arch/x86/boot/compressed
  CLEAN   arch/x86/boot
  CLEAN   arch/x86/tools
  CLEAN   .tmp_versions
  CLEAN   scripts/basic
  CLEAN   scripts/kconfig
  CLEAN   scripts/mod
  CLEAN   scripts/selinux/genheaders
  CLEAN   scripts/selinux/mdp
  CLEAN   scripts
  CLEAN   include/config include/generated arch/x86/include/generated
  CLEAN   .config .config.old .version Module.symvers

/usr/src/linux # mv /usr/src/kernel_config_bk .config

/usr/src/linux # make -j9
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/zconf.lex.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf  --silentoldconfig Kconfig
  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_32.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
  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
  HOSTCC  scripts/kallsyms
  HOSTCC  scripts/conmakehash
  HOSTCC  scripts/pnmtologo
  HOSTCC  scripts/sortextable
  CC      scripts/mod/empty.o
  HOSTCC  scripts/selinux/genheaders/genheaders
scripts/mod/empty.c:1:0: error: code model kernel does not support PIC mode
 /* empty file to figure out endianness / word size */
 
make[2]: *** [scripts/Makefile.build:259: scripts/mod/empty.o] Error 1
make[1]: *** [scripts/Makefile.build:403: scripts/mod] Error 2
make[1]: *** Waiting for unfinished jobs....
  HOSTCC  scripts/selinux/mdp/mdp
make: *** [Makefile:545: scripts] Error 2
make: *** Waiting for unfinished jobs....

Back to top
View user's profile Send private message
grellyd
n00b
n00b


Joined: 11 Oct 2016
Posts: 21

PostPosted: Wed Mar 14, 2018 9:22 pm    Post subject: Reply with quote

While looking back at your comment @fedeliallalinea
Quote:
Remove CONFIG_CC_STACKPROTECTOR_STRONG from kernel config
I wanted to see if it was set, and how I could remove it. So I grepped the file.
Code:
/usr/src/linux # grep STACKPROTECTOR .config
CONFIG_HAVE_CC_STACKPROTECTOR=y
# CONFIG_CC_STACKPROTECTOR is not set
CONFIG_CC_STACKPROTECTOR_NONE=y
# CONFIG_CC_STACKPROTECTOR_REGULAR is not set
# CONFIG_CC_STACKPROTECTOR_STRONG is not set


Does this look correct for a 4.9 Kernel? 'STRONG' does not appear to be set.

Could I have made an error while upgrading my kernel?
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 8291
Location: Saint Amant, Acadiana

PostPosted: Wed Mar 14, 2018 9:40 pm    Post subject: Reply with quote

After setting the symlink with eselect you need to do:
Code:
cd ../linux

_________________
My Gentoo installation notes.
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
grellyd
n00b
n00b


Joined: 11 Oct 2016
Posts: 21

PostPosted: Wed Mar 14, 2018 9:59 pm    Post subject: Reply with quote

Jaglover wrote:
After setting the symlink with eselect you need to do:
Code:
cd ../linux


Ah that makes sense. Otherwise I'm still in the wrong directory.

I'll try that now. It seems promising.

I missed that on https://wiki.gentoo.org/wiki/Kernel/Upgrade I'll put in a wiki edit.
Back to top
View user's profile Send private message
grellyd
n00b
n00b


Joined: 11 Oct 2016
Posts: 21

PostPosted: Wed Mar 14, 2018 10:26 pm    Post subject: Reply with quote

My kernel compile is now running well.

Thanks for the help everyone.

My wiki edit to hopefully stop someone making the same mistake in the future: https://wiki.gentoo.org/wiki/Kernel/Upgrade#Moving_to_the_new_folder
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum