Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 875146

Summary: sys-libs/efivar-38 - clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
Product: Gentoo Linux Reporter: Toralf Förster <toralf>
Component: Current packagesAssignee: Mike Gilbert <floppym>
Status: CONFIRMED ---    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 870412    
Attachments: emerge-info.txt
clang.tar.bz2
emerge-history.txt
environment
etc.portage.tar.bz2
sys-libs:efivar-38:20221004-115759.log
temp.tar.bz2

Description Toralf Förster gentoo-dev 2022-10-04 16:50:17 UTC
too long lines were shrinked:

clang -pipe -march=native -fno-diagnostics-color -O2 -Werror=implicit-function-declaration -Werror=implicit-int -std=gnu11 -funsigned-char -fvisibility=hidden   -std=gnu11 -funsigned-char -fvisibility=hidden    -fPIC  -DLIBEFIVAR_VERSION=38 -D_GNU_SOURCE -I/var/tmp/portage/sys-libs/efivar-38/work/ef
clang -pipe -march=native -fno-diagnostics-color -O2 -Werror=implicit-function-declaration -Werror=implicit-int -std=gnu11 -funsigned-char -fvisibility=hidden   -std=gnu11 -funsigned-char -fvisibility=hidden    -fPIC  -DLIBEFIVAR_VERSION=38 -D_GNU_SOURCE -I/var/tmp/portage/sys-libs/efivar-38/work/ef
clang -pipe -march=native -fno-diagnostics-color -O2 -Werror=implicit-function-declaration -Werror=implicit-int -std=gnu11 -funsigned-char -fvisibility=hidden   -std=gnu11 -funsigned-char -fvisibility=hidden    -L.   -Wl,--add-needed -Wl,--build-id -Wl,--no-allow-shlib-undefined -Wl,-z,now -Wl,-z,mu
x86_64-pc-linux-gnu-ld: error: unknown argument '--add-needed'
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [/var/tmp/portage/sys-libs/efivar-38/work/efivar-38/src/include/rules.mk:32: makeguids] Error 1
make[1]: Leaving directory '/var/tmp/portage/sys-libs/efivar-38/work/efivar-38/src'

  -------------------------------------------------------------------

  This is an unstable amd64 chroot image at a tinderbox (==build bot)
  name: 17.1_desktop_gnome_systemd-j4-20221004-070004

  -------------------------------------------------------------------

gcc-config -l:
 [1] x86_64-pc-linux-gnu-12.2.0 *
clang/llvm (if any):
clang version 15.0.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/15/bin
/usr/lib/llvm/15
15.0.1
Python 3.10.7
Available Ruby profiles:
  [1]   ruby27 (with Rubygems)
  [2]   ruby30 (with Rubygems) *
Available Rust versions:
  [1]   rust-bin-1.64.0 *
The following VMs are available for generation-2:
*)	Eclipse Temurin JDK 17.0.4.1_p1 [openjdk-bin-17]
2)	Eclipse Temurin JDK 8.345_p01 [openjdk-bin-8]
Available Java Virtual Machines:
  [1]   openjdk-bin-8 
  [2]   openjdk-bin-17  system-vm

The Glorious Glasgow Haskell Compilation System, version 9.0.2
php cli (if any):
GNU Make 4.3

  HEAD of ::gentoo
commit 675cdae09d9011d3ea4e4fa2906da6236389898c
Author: Repository mirror & CI <repomirrorci@gentoo.org>
Date:   Tue Oct 4 11:47:56 2022 +0000

    2022-10-04 11:47:55 UTC

emerge -qpvO sys-libs/efivar
[ebuild  N    ] sys-libs/efivar-38  USE="-test"
Comment 1 Toralf Förster gentoo-dev 2022-10-04 16:50:18 UTC
Created attachment 820180 [details]
emerge-info.txt
Comment 2 Toralf Förster gentoo-dev 2022-10-04 16:50:19 UTC
Created attachment 820183 [details]
clang.tar.bz2
Comment 3 Toralf Förster gentoo-dev 2022-10-04 16:50:20 UTC
Created attachment 820186 [details]
emerge-history.txt
Comment 4 Toralf Förster gentoo-dev 2022-10-04 16:50:22 UTC
Created attachment 820189 [details]
environment
Comment 5 Toralf Förster gentoo-dev 2022-10-04 16:50:23 UTC
Created attachment 820192 [details]
etc.portage.tar.bz2
Comment 6 Toralf Förster gentoo-dev 2022-10-04 16:50:24 UTC
Created attachment 820195 [details]
sys-libs:efivar-38:20221004-115759.log
Comment 7 Toralf Förster gentoo-dev 2022-10-04 16:50:25 UTC
Created attachment 820198 [details]
temp.tar.bz2
Comment 8 toukoamg 2022-10-27 11:25:37 UTC
I've backported some patches (8695d256e98c1a79a64c69c60c5f07546c580b05, 1f247260c9b4bd6fcda30f3e4cc358852aeb9e4d) which fix build on clang.

diff --git a/src/include/defaults.mk b/src/include/defaults.mk
index ab8e9a8c..2c98e07d 100644
--- a/src/include/defaults.mk
+++ b/src/include/defaults.mk
@@ -51,7 +51,6 @@ LDFLAGS ?=
 override _CCLDFLAGS := $(CCLDFLAGS)
 override _LDFLAGS := $(LDFLAGS)
 override LDFLAGS = $(CFLAGS) -L. $(_LDFLAGS) $(_CCLDFLAGS) \
-		   -Wl,--add-needed \
 		   -Wl,--build-id \
 		   -Wl,--no-allow-shlib-undefined \
 		   -Wl,--no-undefined-version \
@@ -94,7 +93,6 @@ override _HOST_LDFLAGS := $(HOST_LDFLAGS)
 override _HOST_CCLDFLAGS := $(HOST_CCLDFLAGS)
 override HOST_LDFLAGS = $(HOST_CFLAGS) -L. \
 			$(_HOST_LDFLAGS) $(_HOST_CCLDFLAGS) \
-			-Wl,--add-needed \
 			-Wl,--build-id \
 			-Wl,--no-allow-shlib-undefined \
 			-Wl,-z,now \
--- a/src/include/gcc.specs	2022-10-27 12:15:09.106855980 +0100
+++ b/src/include/gcc.specs	2022-10-27 12:15:34.624091373 +0100
@@ -5,4 +5,4 @@
 + %{!shared:%{!static:%{!r:-pie}}} %{static:-Wl,-no-fatal-warnings -Wl,-static -static -Wl,-z,relro,-z,now} -grecord-gcc-switches
 
 *link:
-+ --no-undefined-version --no-allow-shlib-undefined --add-needed -z now --build-id %{!static:%{!shared:-pie}} %{shared:-z relro} %{static:%<pie}
++ --no-undefined-version --no-allow-shlib-undefined -z now --build-id %{!static:%{!shared:-pie}} %{shared:-z relro} %{static:%<pie}
--- a/src/include/workarounds.mk	2022-10-27 12:20:18.955858758 +0100
+++ a/src/include/workarounds.mk	2022-10-27 12:21:52.426101701 +0100
@@ -2,20 +2,20 @@
 #
 # workarounds.mk - workarounds for weird stuff behavior
 
-LD_FLAVOR := $(shell LC_ALL=C $(LD) --version | grep -E '^(LLD|GNU ld)'|sed 's/ .*//g')
-LD_VERSION := $(shell LC_ALL=C $(LD) --version | grep -E '^(LLD|GNU ld)'|sed 's/.* //')
+LD_FLAVOR := $(shell LC_ALL=C $(LD) --version | grep -E '^((.* )?LLD|GNU ld)'|sed 's/.* LLD/LLD/;s/ .*//g')
+LD_VERSION := $(shell LC_ALL=C $(LD) --version | grep -E '^((.* )?LLD|GNU ld)'|sed 's/.* LLD/LLD/;s/.* //')
 # 2.35 is definitely broken and 2.36 seems to work
 LD_DASH_T := $(shell \
 	if [ "x${LD_FLAVOR}" = xLLD ] ; then \
 		echo '-T' ; \
 	elif [ "x${LD_FLAVOR}" = xGNU ] ; then \
 		if echo "${LD_VERSION}" | grep -q -E '^2\.3[6789]|^2\.[456789]|^[3456789]|^[[:digit:]][[:digit:]]' ; then \
-			echo '-T' ; \
+			echo "" ; \
 		else \
 			echo "" ; \
 		fi ; \
 	else \
-		echo "Your linker is not supported" ; \
+		echo "Your linker ${LD_FLAVOR} version ${LD_VERSION} is not supported" ; \
 		exit 1 ; \
 	fi)