Bug 212105

Summary: Building kernel with a language different from english will fails with LD error on 5.12.x
Product: Other Reporter: Marco Scardovi (scardracs) (mscardovi)
Component: ConfigurationAssignee: other_configuration (other_configuration)
Status: RESOLVED CODE_FIX    
Severity: blocking CC: andy.shevchenko, mscardovi, nicolas.werner
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 5.12.x Subsystem:
Regression: Yes Bisected commit-id:

Description Marco Scardovi (scardracs) 2021-03-07 14:07:30 UTC
If ld isn't ld GNU but, in my example, ld di GNU, it will fail to recognize as ld.

sudo genkernel all --loglevel=5
* CMD_LOGLEVEL: 5
* Gentoo Linux Genkernel; Version 4.1.2
* Using genkernel configuration from '/etc/genkernel.conf' ...
* Running with options: all --loglevel=5
* Resolving config file, command line, and arch default settings.
*   TMPDIR defaulted to "/var/tmp/genkernel".
*   LOGFILE set in config file to "/var/log/genkernel.log".
*   KERNEL_DIR defaulted to "/usr/src/linux".
*   KERNEL_MODULES_PREFIX not set.
*   KERNEL_SOURCES defaulted to "yes".
*   INITRAMFS_FILENAME defaulted to "initramfs-%%KV%%.img".
*   INITRAMFS_SYMLINK_NAME defaulted to "initramfs".
*   KERNEL_CONFIG_FILENAME defaulted to "kernel-config-%%KV%%".
*   KERNEL_FILENAME defaulted to "vmlinuz-%%KV%%".
*   KERNEL_SYMLINK_NAME defaulted to "kernel".
*   SYSTEMMAP_FILENAME defaulted to "System.map-%%KV%%".
*   SYSTEMMAP_SYMLINK_NAME defaulted to "System.map".
*   CHECK_FREE_DISK_SPACE_BOOTDIR not set.
*   CHECK_FREE_DISK_SPACE_KERNELOUTPUTDIR not set.
*   COMPRESS_INITRD set in config file to "yes".
*   COMPRESS_INITRD_TYPE set in config file to "best".
*   CHOST defaulted to "x86_64-pc-linux-gnu".
*   MAKEOPTS defaulted to " -j4".
*   NICE set in config file to "10".
*   KERNEL_AS defaulted to "as".
*   KERNEL_AR defaulted to "ar".
*   KERNEL_CC defaulted to "gcc".
*   KERNEL_CFLAGS not set.
*   KERNEL_CXX defaulted to "g++".
*   KERNEL_LD defaulted to "ld".
*   KERNEL_NM defaulted to "nm".
*   KERNEL_MAKE defaulted to "make".
*   KERNEL_OBJCOPY defaulted to "objcopy".
*   KERNEL_OBJDUMP defaulted to "objdump".
*   KERNEL_RANLIB defaulted to "ranlib".
*   KERNEL_READELF defaulted to "readelf".
*   KERNEL_STRIP defaulted to "strip".
*   UTILS_AS defaulted to "as".
*   UTILS_AR defaulted to "ar".
*   UTILS_CC defaulted to "gcc".
*   UTILS_CFLAGS defaulted to "-Os -pipe -fomit-frame-pointer".
*   UTILS_CXX defaulted to "g++".
*   UTILS_LD defaulted to "ld".
*   UTILS_NM defaulted to "nm".
*   UTILS_MAKE defaulted to "make".
*   UTILS_OBJCOPY defaulted to "objcopy".
*   UTILS_OBJDUMP defaulted to "objdump".
*   UTILS_RANLIB defaulted to "ranlib".
*   UTILS_READELF defaulted to "readelf".
*   UTILS_STRIP defaulted to "strip".
*   CROSS_COMPILE not set.
*   BOOTDIR defaulted to "/boot".
*   KERNEL_APPEND_LOCALVERSION not set.
*   KERNEL_LOCALVERSION defaulted to "-%%ARCH%%".
*   MODPROBEDIR defaulted to "/etc/modprobe.d".
*   SPLASH defaulted to "no".
*   CLEAR_CACHEDIR set in config file to "no".
*   POSTCLEAR set in config file to "no".
*   MRPROPER defaulted to "yes".
*   MENUCONFIG defaulted to "no".
*   GCONFIG defaulted to "no".
*   NCONFIG defaulted to "no".
*   XCONFIG defaulted to "no".
*   CLEAN set in config file to "yes".
*   MINKERNPACKAGE not set.
*   MODULESPACKAGE not set.
*   MODULEREBUILD defaulted to "yes".
*   MODULEREBUILD_CMD defaulted to "emerge --ignore-default-opts --buildpkg=n --usepkg=n --quiet-build=y @module-rebuild".
*   KERNCACHE not set.
*   RAMDISKMODULES defaulted to "yes".
*   ALLRAMDISKMODULES defaulted to "no".
*   INITRAMFS_OVERLAY not set.
*   LINUXRC not set.
*   MOUNTBOOT set in config file to "yes".
*   BUILD_STATIC defaulted to "no".
*   SAVE_CONFIG defaulted to "yes".
*   SYMLINK defaulted to "no".
*   OLDCONFIG defaulted to "yes".
*   SANDBOX defaulted to "yes".
*   SSH defaulted to "no".
*   SSH_AUTHORIZED_KEYS_FILE defaulted to "/etc/dropbear/authorized_keys".
*   SSH_HOST_KEYS defaulted to "create".
*   STRACE defaulted to "no".
*   BCACHE defaulted to "no".
*   LVM defaulted to "no".
*   DMRAID defaulted to "no".
*   ISCSI defaulted to "no".
*   HYPERV defaulted to "no".
*   BOOTFONT defaulted to "none".
*   BOOTLOADER set in config file to "grub2".
*   B2SUM defaulted to "no".
*   BUSYBOX defaulted to "yes".
*   BUSYBOX_CONFIG not set.
*   NFS defaulted to "yes".
*   MICROCODE set in config file to "amd".
*   MICROCODE_INITRAMFS defaulted to "no".
*   UNIONFS defaulted to "no".
*   NETBOOT defaulted to "no".
*   REAL_ROOT not set.
*   LUKS defaulted to "no".
*   GPG defaulted to "no".
*   MDADM defaulted to "no".
*   MDADM_CONFIG not set.
*   E2FSPROGS defaulted to "no".
*   XFSPROGS defaulted to "no".
*   ZFS defaulted to "no".
*   BTRFS set in config file to "yes".
*   VIRTIO defaulted to "no".
*   MULTIPATH defaulted to "no".
*   FIRMWARE defaulted to "no".
*   FIRMWARE_DIR defaulted to "/lib/firmware".
*   FIRMWARE_FILES not set.
*   FIRMWARE_INSTALL defaulted to "no".
*   INTEGRATED_INITRAMFS defaulted to "no".
*   WRAP_INITRD defaulted to "no".
*   GENZIMAGE defaulted to "no".
*   KEYMAP defaulted to "yes".
*   DOKEYMAPAUTO defaulted to "no".
*   STRIP_TYPE defaulted to "modules".
*   INSTALL defaulted to "yes".
*   CLEANUP defaulted to "yes".
*   KERNEL_OUTPUTDIR defaulted to "/usr/src/linux".
* Read 'x86_64' from 'uname -m' ...
* ARCH 'x86_64' detected ...
* CBUILD set to 'x86_64-pc-linux-gnu' ...
* CHOST set to 'x86_64-pc-linux-gnu' ...

* Sourcing default modules_load from '/usr/share/genkernel/defaults/modules_load' ...
* Sourcing arch-specific config.sh from '/usr/share/genkernel/arch/x86_64/config.sh' ...
* Sourcing arch-specific modules_load from '/usr/share/genkernel/arch/x86_64/modules_load' ...
* Unable to determine LOCALVERSION -- maybe cleaned/fresh sources?
* KERNEL_ARCH set to 'x86' ...

* GK_FILENAME_CONFIG set to 'kernel-config-5.12.0-rc2' (was: 'kernel-config-%%KV%%')
* GK_FILENAME_KERNEL set to 'vmlinuz-5.12.0-rc2' (was: 'vmlinuz-%%KV%%')
* GK_FILENAME_KERNEL_SYMLINK set to 'kernel' (was: 'kernel')
* GK_FILENAME_SYSTEMMAP set to 'System.map-5.12.0-rc2' (was: 'System.map-%%KV%%')
* GK_FILENAME_SYSTEMMAP_SYMLINK set to 'System.map' (was: 'System.map')
* GK_FILENAME_INITRAMFS set to 'initramfs-5.12.0-rc2.img' (was: 'initramfs-%%KV%%.img')
* GK_FILENAME_INITRAMFS_SYMLINK set to 'initramfs' (was: 'initramfs')
* Checking for suitable kernel configuration ...
*         - '/etc/kernels/kernel-config-5.12.0-rc2' not found; Skipping ...
*         - '/etc/kernels/kernel-config-5.12.0-rc2-x86_64' not found; Skipping ...
*         - '/etc/kernels/kernel-config-x86_64-5.12.0-rc2' not found; Skipping ...
*         - '/usr/share/genkernel/arch/x86_64/kernel-config-5.12.0-rc2' not found; Skipping ...
*         - '/usr/share/genkernel/arch/x86_64/kernel-config-5.12' not found; Skipping ...

* Working with Linux kernel 5.12.0-rc2 for x86_64
* Using kernel config file '/usr/share/genkernel/arch/x86_64/generated-config' ...
* 
* Note: The version above is subject to change (depends on config and status of kernel sources).

* mount: >> Boot partition is already mounted in read-write mode on '/boot'.

* kernel: >> Initializing ...
*         >> --mrproper is set; Skipping 'make clean' ...
*         >> Previous config backed up to .config--2021-03-07--12-23-34.bak
*         >> Running 'make mrproper' ...
COMMAND: nice -n10 make  -j4 ARCH='x86' AS='x86_64-pc-linux-gnu-as' AR='x86_64-pc-linux-gnu-ar' CC='x86_64-pc-linux-gnu-gcc' LD='x86_64-pc-linux-gnu-ld' NM='x86_64-pc-linux-gnu-nm' OBJCOPY='x86_64-pc-linux-gnu-objcopy' OBJDUMP='x86_64-pc-linux-gnu-objdump' READELF='x86_64-pc-linux-gnu-readelf' STRIP='x86_64-pc-linux-gnu-strip' HOSTAR='x86_64-pc-linux-gnu-ar' HOSTCC='x86_64-pc-linux-gnu-gcc' HOSTCXX='x86_64-pc-linux-gnu-g++' HOSTLD='x86_64-pc-linux-gnu-ld' mrproper
  CLEAN   scripts/basic
  CLEAN   scripts/kconfig
  CLEAN   .config
*         >> Copying '/usr/share/genkernel/arch/x86_64/generated-config' to '/usr/src/linux/.config' ...
*         >> Running 'make oldconfig' ...
COMMAND: nice -n10 make  -j4 ARCH='x86' AS='x86_64-pc-linux-gnu-as' AR='x86_64-pc-linux-gnu-ar' CC='x86_64-pc-linux-gnu-gcc' LD='x86_64-pc-linux-gnu-ld' NM='x86_64-pc-linux-gnu-nm' OBJCOPY='x86_64-pc-linux-gnu-objcopy' OBJDUMP='x86_64-pc-linux-gnu-objdump' READELF='x86_64-pc-linux-gnu-readelf' STRIP='x86_64-pc-linux-gnu-strip' HOSTAR='x86_64-pc-linux-gnu-ar' HOSTCC='x86_64-pc-linux-gnu-gcc' HOSTCXX='x86_64-pc-linux-gnu-g++' HOSTLD='x86_64-pc-linux-gnu-ld' oldconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/confdata.o
  HOSTCC  scripts/kconfig/expr.o
  LEX     scripts/kconfig/lexer.lex.c
  YACC    scripts/kconfig/parser.tab.[ch]
  HOSTCC  scripts/kconfig/preprocess.o
  HOSTCC  scripts/kconfig/symbol.o
  HOSTCC  scripts/kconfig/util.o
  HOSTCC  scripts/kconfig/lexer.lex.o
  HOSTCC  scripts/kconfig/parser.tab.o
  HOSTLD  scripts/kconfig/conf
x86_64-pc-linux-gnu-ld: unknown linker
scripts/Kconfig.include:50: Sorry, this linker is not supported.
make[1]: *** [scripts/kconfig/Makefile:63: oldconfig] Errore 1
make: *** [Makefile:600: oldconfig] Errore 2
*         >> Ensure that required kernel options for genkernel's initramfs usage are set ...
*                  - Option 'CONFIG_BLK_DEV_INITRD=y' already set in '/usr/src/linux/.config'; Skipping ...
*                  - Option 'CONFIG_MMU=y' already set in '/usr/src/linux/.config'; Skipping ...
*                  - Option 'CONFIG_SHMEM=y' already set in '/usr/src/linux/.config'; Skipping ...
*                  - Option 'CONFIG_TMPFS=y' already set in '/usr/src/linux/.config'; Skipping ...
*                  - Option 'CONFIG_TTY=y' already set in '/usr/src/linux/.config'; Skipping ...
*                  - Option 'CONFIG_UNIX98_PTYS=y' already set in '/usr/src/linux/.config'; Skipping ...
* Determining 'BEST' compression method for initramfs using kernel config '/usr/src/linux/.config' ...
* Checking if we can use 'XZ' compression ...
* Will use 'XZ' compression -- all requirements are met!
*                  - Option 'CONFIG_RD_XZ=y' already set in '/usr/src/linux/.config'; Skipping ...
*         >> Ensure that CONFIG_LOCALVERSION is set ...
*                  - Setting option 'CONFIG_LOCALVERSION' to '"-x86_64"' in '/usr/src/linux/.config'...
*         >> Ensure that required kernel options for early microcode loading support are set ...
*                  - Setting option 'CONFIG_MICROCODE' to 'y' in '/usr/src/linux/.config'...
*                  - Adding option 'CONFIG_MICROCODE_OLD_INTERFACE' with value 'y' to '/usr/src/linux/.config'...
*                  - Adding option 'CONFIG_MICROCODE_AMD' with value 'y' to '/usr/src/linux/.config'...
*         >> Re-running 'make oldconfig' due to changed kernel options ...
COMMAND: nice -n10 make  -j4 ARCH='x86' AS='x86_64-pc-linux-gnu-as' AR='x86_64-pc-linux-gnu-ar' CC='x86_64-pc-linux-gnu-gcc' LD='x86_64-pc-linux-gnu-ld' NM='x86_64-pc-linux-gnu-nm' OBJCOPY='x86_64-pc-linux-gnu-objcopy' OBJDUMP='x86_64-pc-linux-gnu-objdump' READELF='x86_64-pc-linux-gnu-readelf' STRIP='x86_64-pc-linux-gnu-strip' HOSTAR='x86_64-pc-linux-gnu-ar' HOSTCC='x86_64-pc-linux-gnu-gcc' HOSTCXX='x86_64-pc-linux-gnu-g++' HOSTLD='x86_64-pc-linux-gnu-ld' oldconfig
x86_64-pc-linux-gnu-ld: unknown linker
scripts/Kconfig.include:50: Sorry, this linker is not supported.
make[1]: *** [scripts/kconfig/Makefile:63: oldconfig] Errore 1
make: *** [Makefile:600: oldconfig] Errore 2
*         >> Checking if required kernel options are still present ...
*                  - 'CONFIG_TMPFS' is set to 'y'
*                  - 'CONFIG_TTY' is set to 'y'
*                  - 'CONFIG_UNIX98_PTYS' is set to 'y'
*                  - 'CONFIG_MICROCODE' is set to 'y'
*                  - 'CONFIG_MICROCODE_AMD' is set to 'y'
*                  - 'CONFIG_RD_XZ' is set to 'y'
COMMAND: nice -n10 make  -j4 ARCH='x86' AS='x86_64-pc-linux-gnu-as' AR='x86_64-pc-linux-gnu-ar' CC='x86_64-pc-linux-gnu-gcc' LD='x86_64-pc-linux-gnu-ld' NM='x86_64-pc-linux-gnu-nm' OBJCOPY='x86_64-pc-linux-gnu-objcopy' OBJDUMP='x86_64-pc-linux-gnu-objdump' READELF='x86_64-pc-linux-gnu-readelf' STRIP='x86_64-pc-linux-gnu-strip' HOSTAR='x86_64-pc-linux-gnu-ar' HOSTCC='x86_64-pc-linux-gnu-gcc' HOSTCXX='x86_64-pc-linux-gnu-g++' HOSTLD='x86_64-pc-linux-gnu-ld' prepare
  SYNC    include/config/auto.conf.cmd
x86_64-pc-linux-gnu-ld: unknown linker
scripts/Kconfig.include:50: Sorry, this linker is not supported.
make[2]: *** [scripts/kconfig/Makefile:63: syncconfig] Errore 1
make[1]: *** [Makefile:600: syncconfig] Errore 2
make: *** [Makefile:709: include/config/auto.conf.cmd] Errore 2
* Unable to determine LOCALVERSION -- maybe cleaned/fresh sources?
*         >> Kernel version has not changed since genkernel start
*         >> Compiling 5.12.0-rc2 bzImage ...
COMMAND: nice -n10 make  -j4 ARCH='x86' AS='x86_64-pc-linux-gnu-as' AR='x86_64-pc-linux-gnu-ar' CC='x86_64-pc-linux-gnu-gcc' LD='x86_64-pc-linux-gnu-ld' NM='x86_64-pc-linux-gnu-nm' OBJCOPY='x86_64-pc-linux-gnu-objcopy' OBJDUMP='x86_64-pc-linux-gnu-objdump' READELF='x86_64-pc-linux-gnu-readelf' STRIP='x86_64-pc-linux-gnu-strip' HOSTAR='x86_64-pc-linux-gnu-ar' HOSTCC='x86_64-pc-linux-gnu-gcc' HOSTCXX='x86_64-pc-linux-gnu-g++' HOSTLD='x86_64-pc-linux-gnu-ld' bzImage
  SYNC    include/config/auto.conf.cmd
x86_64-pc-linux-gnu-ld: unknown linker
scripts/Kconfig.include:50: Sorry, this linker is not supported.
make[2]: *** [scripts/kconfig/Makefile:63: syncconfig] Errore 1
make[1]: *** [Makefile:600: syncconfig] Errore 2
make: *** [Makefile:709: include/config/auto.conf.cmd] Errore 2
* ERROR: Failed to locate kernel binary 'arch/x86_64/boot/bzImage' in '/usr/src/linux'!
* Please consult '/var/log/genkernel.log' for more information and any
* errors that were reported above.
* 
* Report any genkernel bugs to bugs.gentoo.org and
* assign your bug to genkernel@gentoo.org. Please include
* as much information as you can in your bug report; attaching
* '/var/log/genkernel.log' so that your issue can be dealt with effectively.
* 
* Please do *not* report kernel compilation failures as genkernel bugs!
* 

* mount: >> Boot partition state on '/boot' was not changed; Skipping restore boot partition state ...
Comment 1 Marco Scardovi (scardracs) 2021-03-07 14:09:16 UTC
I'm building this on Gentoo. If I set LANG="en_US" then it works without any problem
Comment 2 Marco Scardovi (scardracs) 2021-03-07 14:23:52 UTC
Just to be clear:

if x86_64-pc-linux-gnu-ld --version is ld GNU it will works
if x86_64-pc-linux-gnu-ld --version is ld di GNU it will not works
Comment 3 Alfred Wingate 2021-03-07 14:29:46 UTC
I'd add to the issue that the issue is caused by (binutils) ld with localization like Italian (the one above is Italian), Finnish and Gaelic which differ from the English "GNU ld" output in `x86_64-pc-linux-gnu-ld --version`.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/ld-version.sh?h=v5.12-rc2#n38

```
if [ "$1" = GNU -a "$2" = ld ]; then
	shift $(($# - 1))
	version=$1
	min_version=$bfd_min_version
	name=BFD
	disp_name="GNU ld"
elif [ "$1" = GNU -a "$2" = gold ]; then
	echo "gold linker is not supported as it is not capable of linking the kernel proper." >&2
	exit 1
elif [ "$1" = LLD ]; then
	version=$2
	min_version=$lld_min_version
	name=LLD
	disp_name=LLD
else
	echo "$orig_args: unknown linker" >&2
	exit 1
fi
```

Which leads to this code to fail on output like
```
ld di GNU (Gentoo 2.35.2 p1) 2.35.2
Copyright (C) 2020 Free Software Foundation, Inc.
Questo programma è software libero; siete liberi di ridistribuirlo secondo i termini
della GNU General Public License versione 3 o (a scelta) una versione più recente.
Questo programma non ha assolutamente alcuna garanzia.
```
but not 
```
GNU ld (Gentoo 2.35.1 p2) 2.35.1
Copyright (C) 2020 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
```

This issue didnt come up because the linker checking code was like this:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/scripts/Kconfig.include?h=v5.11.4#n42
```
# Fail if the linker is gold as it's not capable of linking the kernel proper
$(error-if,$(success, $(LD) -v | grep -q gold), gold linker '$(LD)' not supported)

```

The commit that changed the linker checking behavior:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/scripts/ld-version.sh?h=v5.12-rc2&id=02aff85922043cf175ebbe5fc3430acfeaeb8393
Comment 4 Nicolas Werner 2021-03-07 14:30:40 UTC
Specifically the problem here is that 02aff85922043cf175ebbe5fc3430acfeaeb8393 changed the linker matching logic from checking for not being "gold" to it having to include "GNU ld". This does not work on all locales (most notably Finnish, Gaelic and Italien, I think), so the linker is marked as unsupported. The check should probably set the C locale or don't check for the string "GNU ld" at least.
Comment 7 Marco Scardovi (scardracs) 2021-03-13 20:01:35 UTC
(In reply to Andy Shevchenko from comment #6)
> https://git.kernel.org/pub/masahiroy/linux-kbuild/c/bcbcf50f5218

This link does not actually works
Comment 8 Andy Shevchenko 2021-03-14 10:24:10 UTC
(In reply to Marco Scardovi from comment #7)
> (In reply to Andy Shevchenko from comment #6)
> > https://git.kernel.org/pub/masahiroy/linux-kbuild/c/bcbcf50f5218
> 
> This link does not actually works

https://git.kernel.org/masahiroy/linux-kbuild/c/bcbcf50f5218
Comment 9 Marco Scardovi (scardracs) 2021-03-14 10:42:04 UTC
(In reply to Andy Shevchenko from comment #8)
> (In reply to Marco Scardovi from comment #7)
> > (In reply to Andy Shevchenko from comment #6)
> > > https://git.kernel.org/pub/masahiroy/linux-kbuild/c/bcbcf50f5218
> > 
> > This link does not actually works
> 
> https://git.kernel.org/masahiroy/linux-kbuild/c/bcbcf50f5218

Thanks