# SOLVED building kernel on x86_64 arch results in x86 bzImage

## mno

Hi everyone,

I'm completely confused. I've built many kernels before, and am installing a brand new install and I'm completely stumped.  Can someone say what I'm missing?  I am trying to build a kernel image, and make keeps on giving me an x86 kernel, instead of an x86_64 one.  I even tried 

```
make ARCH=x86_64 menuconfig
```

without luck.  I can paste the entire config output, but a snippet that I think is most important:

```

CONFIG_GENTOO_LINUX_INIT_SCRIPT=y

# CONFIG_GENTOO_LINUX_INIT_SYSTEMD is not set

CONFIG_64BIT=y

CONFIG_X86_64=y

CONFIG_X86=y

CONFIG_INSTRUCTION_DECODER=y

CONFIG_PERF_EVENTS_INTEL_UNCORE=y

CONFIG_OUTPUT_FORMAT="elf64-x86-64"

CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig"

```

I have a 2x Core 2 Xeon board, my stage3 image is 

```
stage3-amd64-20150521.tar.bz2
```

make.conf:

```
CHOST="x86_64-pc-linux-gnu"

CFLAGS="-march=core2 -O2 -pipe"

CXXFLAGS="${CFLAGS}"

MAKEOPTS="-j5"

# These are the USE flags that were used in addition to what is provided by the

# profile used for building.

USE="amd64 bindist ipv6 mmx sse sse2 sse3 ssse3 sse4 sse4a sse4_1 -alsa -kde -gnome -gtk -X"

PORTDIR="/usr/portage"

DISTDIR="${PORTDIR}/distfiles"

PKGDIR="${PORTDIR}/packages"

```

emerge --info:

```

livecd linux # emerge --info

Portage 2.2.18 (python 2.7.9-final-0, default/linux/amd64/13.0, gcc-4.8.4, glibc-2.20-r2, 3.18.12-gentoo x86_64)

=================================================================

System uname: Linux-3.18.12-gentoo-x86_64-Intel-R-_Xeon-R-_CPU_E5520_@_2.27GHz-with-gentoo-2.2

KiB Mem:    12301576 total,   8263764 free

KiB Swap:   25165820 total,  25165820 free

Timestamp of repository gentoo: Thu, 21 May 2015 00:45:01 +0000

sh bash 4.2_p53

ld GNU ld (Gentoo 2.24 p1.4) 2.24

app-shells/bash:          4.2_p53::gentoo

dev-lang/perl:            5.20.2::gentoo

dev-lang/python:          2.7.9-r1::gentoo, 3.3.5-r1::gentoo

dev-util/pkgconfig:       0.28-r2::gentoo

sys-apps/baselayout:      2.2::gentoo

sys-apps/openrc:          0.13.11::gentoo

sys-apps/sandbox:         2.6-r1::gentoo

sys-devel/autoconf:       2.69::gentoo

sys-devel/automake:       1.14.1::gentoo

sys-devel/binutils:       2.24-r3::gentoo

sys-devel/gcc:            4.8.4::gentoo

sys-devel/gcc-config:     1.7.3::gentoo

sys-devel/libtool:        2.4.6::gentoo

sys-devel/make:           4.1-r1::gentoo

sys-kernel/linux-headers: 3.18::gentoo (virtual/os-headers)

sys-libs/glibc:           2.20-r2::gentoo

Repositories:

gentoo

    location: /usr/portage

    sync-type: rsync

    sync-uri: rsync://rsync.gentoo.org/gentoo-portage

    priority: -1000

ACCEPT_KEYWORDS="amd64"

ACCEPT_LICENSE="* -@EULA"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-march=core2 -O2 -pipe"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/sandbox.d /etc/terminfo"

CXXFLAGS="-march=core2 -O2 -pipe"

DISTDIR="/usr/portage/distfiles"

FCFLAGS="-O2 -pipe"

FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"

FFLAGS="-O2 -pipe"

GENTOO_MIRRORS="http://mirror.csclub.uwaterloo.ca/gentoo-distfiles/ http://gentoo.gossamerhost.com/ http://www.gtlib.gatech.edu/pub/gentoo http://gentoo.osuosl.org/"

LANG="en_US.utf8"

LDFLAGS="-Wl,-O1 -Wl,--as-needed"

MAKEOPTS="-j5"

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"

PORTAGE_TMPDIR="/var/tmp"

USE="acl amd64 berkdb bindist bzip2 cli cracklib crypt cxx dri fortran gdbm iconv ipv6 mmx mmxext modules multilib ncurses nls nptl openmp pam pcre readline session sse sse2 sse3 sse4 sse4_1 sse4a ssl ssse3 tcpd unicode 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" CAMERAS="ptp2" 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 itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="keyboard mouse evdev" 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-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3" RUBY_TARGETS="ruby19 ruby20" USERLAND="GNU" VIDEO_CARDS="fbdev glint intel mach64 mga nouveau nv r128 radeon savage sis tdfx trident vesa via vmware dummy v4l" 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:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON

```

Any help is greatly appreciated.  What am I missing?

----------

## Jaglover

Why you think your kernel is 32-bit? It will be in arch/x86/boot, yes. But it is 64-bit.

----------

## mno

Shouldn't a 64-bit kernel generate the files in arch/x86_64/bzImage?  When the make script runs, I only see 

```
arch/x86/[..]
```

being compiled, nothing for 

```
arch/x86_64/[..]
```

----------

## mno

Also, the top of make menuconfig results in:

```
 Linux/x86 3.18.12-gentoo Kernel Configuration
```

----------

## Jaglover

```
 ~ $ ls -l /usr/src/linux/arch/x86_64/boot/bzImage 

lrwxrwxrwx 1 root root 22 May  6 16:29 /usr/src/linux/arch/x86_64/boot/bzImage -> ../../x86/boot/bzImage

```

----------

## mno

So I'm just paranoid and this is as expected?

----------

## Jaglover

This is how it works, yes. Go ahead and boot it, you'll see it is 64-bit.

You miss CPU_FLAGS_X86 variable in your make.conf. (Yes, it is again X86 for 64-bit install.)

----------

## mno

Thanks Jaglover, I've been doing this for so many years and just never paid attention before.

Thx on the point of the CPU_FLAGS_X86, does it make sense to rebuild the kernel image with them added or doesn't really matter?

----------

## Jaglover

You are welcome!  :Smile: 

CPU_FLAGS_X86 are for packages, not for kernel build. Some packages expect it, but not all of them ... yet. 

app-portage/cpuinfo2cpuflags

----------

## 17salvador

 *mno wrote:*   

> Shouldn't a 64-bit kernel generate the files in arch/x86_64/bzImage?  When the make script runs, I only see 
> 
> ```
> arch/x86/[..]
> ```
> ...

 

If you have a Intel Xeon processor, Why you use kernel AMD in you instalation?

 This is possible?

----------

## mno

amd64 is the general arch for x86_64.  It is historically amd64 because AMD created the 64-bit first, Intel followed.

----------

