Skip to contentSkip to conversation

Kconfig olddefconfig nukes 32-bit

DISCUSSION Nicolas Schier 3 participants 5 messages Apr 12 – May 5 1 message not in the archive Kbuild

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Nicolas Schier

author maintainer
#1 lore raw
Cc linux-kbuild
Quoted 8 lines · Andrew Valencia

Hi,

I'm working over in the 6.19..12 world, and brought over a working .config which I updated with olddefconfig. Long story short, the config was converted to a x86 64-bit config.

The issue is the new config entry 64BIT, which has a default value of ARCH != "i386".

yes, there is a 64BIT Kconfig symbol defined at arch/x86/Kconfig which is true by default for non-i386 builds. According to my git tree, the corresponding lines did not change since v4.18 [1].

[1]: https://git.kernel.org/kbuild/c/104daea149c45

Quoted 3 lines

On my 32-bit x86 build machine with its 32-bit .config, the default Y is being selected. Is it possible i386 is not the correct name for ARCH on this target?

I guess, that you want to cross-build a 32bit-Linux on a 64bit-machine, right? How did you call olddefconfig (e.g. make ARCH=i386 olddefconfig)?

Kind regards

Signature · 1 line
Nicolas
#2 lore raw

(Re-sending for rejection of an HTML part by the list management SW.)

Hi,

This is for x86 32-bit target, built _on_ a x86 32-bit machine.

The issue appears to be:

config 64BIT

        bool "64-bit kernel" if "$(ARCH)" = "x86"
        default "$(ARCH)" != "i386"
        help
          Say yes to build a 64-bit kernel - formerly known as x86_64

Which appears to say this config item is only enabled if ARCH is x86. But this then makes the default value calculation invariant for any target with this config item--it is always true, and thus always 64-bit.

So things like CONFIG_X86_32 go away, and CONFIG_OUTPUT_FORMAT switch away from elf32-i386. Even if you're on a 32-bit build machine with a proper .config brought over from a previous 32-bit x86 build.

When 64BIT is being introduced in olddefconfig, I'd hope it would key off of CONFIG_X86_32 or something like it.

Thank you for giving this a look!
Andy

Quoted 18 lines · Nicolas Schier
Cc linux-kbuild
Quoted 8 lines · Andrew Valencia

Hi,

I'm working over in the 6.19..12 world, and brought over a working .config which I updated with olddefconfig. Long story short, the config was converted to a x86 64-bit config.

The issue is the new config entry 64BIT, which has a default value of ARCH != "i386".

yes, there is a 64BIT Kconfig symbol defined at arch/x86/Kconfig which is true by default for non-i386 builds. According to my git tree, the corresponding lines did not change since v4.18 [1].

[1]: https://git.kernel.org/kbuild/c/104daea149c45

Quoted 12 lines
Quoted 3 lines

On my 32-bit x86 build machine with its 32-bit .config, the default Y is being selected. Is it possible i386 is not the correct name for ARCH on this target?

I guess, that you want to cross-build a 32bit-Linux on a 64bit-machine, right? How did you call olddefconfig (e.g. make ARCH=i386 olddefconfig)?

Kind regards

Signature · 1 line
Nicolas

--------------------------------
Andy Valencia
https://vsta.org/andy/

#3 lore raw

[ CC: x86 (x86 arch specific olddefconfig behaviour) ]

Hi Andrew,

please reply in-line instead of top-posting.

Quoted 10 lines · Andrew Valencia

(Re-sending for rejection of an HTML part by the list management SW.)

Hi,

This is for x86 32-bit target, built _on_ a x86 32-bit machine.

The issue appears to be:

config 64BIT

        bool "64-bit kernel" if "$(ARCH)" = "x86"

This makes 64BIT interactively selectable only if ARCH=x86. When using ARCH=i386 or ARCH=x86_64, the "64-bit kernel" Kconfig option is not available in 'make oldconfig' or 'make menuconfig' etc.

Quoted 1 line
        default "$(ARCH)" != "i386"

This sets the default value for CONFIG_64BIT to 'y' if ARCH is not explicitly set to 'i386' -- thus for ARCH=x86 and ARCH=x86_64.

Quoted 8 lines

help
Say yes to build a 64-bit kernel - formerly known as x86_64

Which appears to say this config item is only enabled if ARCH is x86. But this then makes the default value calculation invariant for any target with this config item--it is always true, and thus always 64-bit.

Quoted 6 lines

So things like CONFIG_X86_32 go away, and CONFIG_OUTPUT_FORMAT switch away from elf32-i386. Even if you're on a 32-bit build machine with a proper .config brought over from a previous 32-bit x86 build.

When 64BIT is being introduced in olddefconfig, I'd hope it would key off of CONFIG_X86_32 or something like it.

Running 'make olddefconfig' (w/o a specific x86 arch) lets arch/x86/Makefile choose a defconfig file for reference (cp. head of arch/x86/Makefile). If ARCH=x86 (or unspecified on any x86 machine), the output of uname -m is evaluated. If ARCH=i386 is explicitly given, the 32bit defconfig will be chosen, no matter what kind of x86 the build host is; and the other way around for ARCH=x86_64.

Thus, if you build a 32bit kernel with your 32bit config file on a x86_64 host, you have to use

make ARCH=i386 olddefconfig

if you want to use 'olddefconfig' to let the config keep the CONFIG_64BIT=n setting.

Does that help?

Kind regards,
Nicolas

#4 lore raw
Quoted 1 line · Nicolas Schier

[ CC: x86 (x86 arch specific olddefconfig behaviour) ]

typo in [email protected], resending

Quoted 60 lines

Hi Andrew,

please reply in-line instead of top-posting.

Quoted 10 lines · Andrew Valencia

(Re-sending for rejection of an HTML part by the list management SW.)

Hi,

This is for x86 32-bit target, built _on_ a x86 32-bit machine.

The issue appears to be:

config 64BIT

        bool "64-bit kernel" if "$(ARCH)" = "x86"

This makes 64BIT interactively selectable only if ARCH=x86. When using ARCH=i386 or ARCH=x86_64, the "64-bit kernel" Kconfig option is not available in 'make oldconfig' or 'make menuconfig' etc.

Quoted 1 line
        default "$(ARCH)" != "i386"

This sets the default value for CONFIG_64BIT to 'y' if ARCH is not explicitly set to 'i386' -- thus for ARCH=x86 and ARCH=x86_64.

Quoted 8 lines

help
Say yes to build a 64-bit kernel - formerly known as x86_64

Which appears to say this config item is only enabled if ARCH is x86. But this then makes the default value calculation invariant for any target with this config item--it is always true, and thus always 64-bit.

Quoted 6 lines

So things like CONFIG_X86_32 go away, and CONFIG_OUTPUT_FORMAT switch away from elf32-i386. Even if you're on a 32-bit build machine with a proper .config brought over from a previous 32-bit x86 build.

When 64BIT is being introduced in olddefconfig, I'd hope it would key off of CONFIG_X86_32 or something like it.

Running 'make olddefconfig' (w/o a specific x86 arch) lets arch/x86/Makefile choose a defconfig file for reference (cp. head of arch/x86/Makefile). If ARCH=x86 (or unspecified on any x86 machine), the output of uname -m is evaluated. If ARCH=i386 is explicitly given, the 32bit defconfig will be chosen, no matter what kind of x86 the build host is; and the other way around for ARCH=x86_64.

Thus, if you build a 32bit kernel with your 32bit config file on a x86_64 host, you have to use

make ARCH=i386 olddefconfig

if you want to use 'olddefconfig' to let the config keep the CONFIG_64BIT=n setting.

Does that help?

Kind regards,
Nicolas

#5 lore raw

Hi, Nicolas. Thanks for your helpful comments, I went off and read code and tried many scenarios based on your comments.

Quoted 6 lines · Nicolas Schier
Quoted 6 lines

Running 'make olddefconfig' (w/o a specific x86 arch) lets arch/x86/Makefile choose a defconfig file for reference (cp. head of arch/x86/Makefile). If ARCH=x86 (or unspecified on any x86 machine), the output of uname -m is evaluated. If ARCH=i386 is explicitly given, the 32bit defconfig will be chosen, no matter what kind of x86 the build host is; and the other way around for ARCH=x86_64.

All my comments which follow are for an existing 32-bit config, a new kernel.org source tree, on a 32-bit build machine. The starting point config is from a Linux-libre project config, config-6.18.18-gnu:

https://linux486.org/pickup/olddefconfig/config-6.18.18-gnu.txt

"make olddefconfig" results in a config with CONFIG_64BIT=y. "make ARCH=i386 olddefconfig" results in a 32-bit config with no mention of CONFIG_64BIT at all. "make ARCH=x86_64 olddefconfig" results in the same config as "make olddefconfig", as does "make ARCH=x86 olddefconfig"

I propose to you that 64BIT be a proper config item for all x86en, 32-bit and 64-bit. For 64-bit, "CONFIG_64BIT-y" and for 32-bit "# CONFIG_64BIT is not set". This results in config files fully describing what they need to build--and guiding any future olddefconfig to stay with what has previously been selected.

Quoted 9 lines
Quoted 9 lines

Thus, if you build a 32bit kernel with your 32bit config file on a x86_64 host, you have to use

make ARCH=i386 olddefconfig

if you want to use 'olddefconfig' to let the config keep the CONFIG_64BIT=n setting.

Does that help?

Very much so. The remaining suggestion I make is that the default be selected so that an old 32-bit config, on a 32-bit build machine, by default (i.e., without explicitly setting ARCH) generate a 32-bit new config when olddefconfig is used. This obviously would depend on the "uname -m" value.

A small patch to (1) preserve the resolution of the 64BIT config item on all x86, plus (2) choose a default value guided by uname -m when ARCH is the general x86 value:

https://linux486.org/pickup/olddefconfig/uarch.diff.txt

Thank you for your help!
Andy