NetBSD Problem Report #57405
From www@netbsd.org Sat May 13 10:28:48 2023
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 522E31A923C
for <gnats-bugs@gnats.NetBSD.org>; Sat, 13 May 2023 10:28:48 +0000 (UTC)
Message-Id: <20230513102846.627D11A923D@mollari.NetBSD.org>
Date: Sat, 13 May 2023 10:28:46 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: clang build has been broken on aarch64 since binutils 2.39 update
X-Send-Pr-Version: www-1.0
>Number: 57405
>Category: toolchain
>Synopsis: clang build has been broken on aarch64 since binutils 2.39 update
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: toolchain-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat May 13 10:30:01 +0000 2023
>Last-Modified: Sat May 13 11:00:05 +0000 2023
>Originator: Taylor R Campbell
>Release: current
>Organization:
The NetLD Foundation
>Environment:
>Description:
build_install ===> compat (with: BOOTSTRAP_SUBDIRS=../../../lib)
build_install ===> compat/dirshack
build_install ===> compat/arm/eabi
build_install ===> compat/arm/eabi/../../../lib
dependall-csu ===> compat/arm/eabi/../../../lib
dependall ===> compat/arm/eabi/../../../lib/csu
install-csu ===> compat/arm/eabi/../../../lib
install ===> compat/arm/eabi/../../../lib/csu
dependall-libc ===> compat/arm/eabi/../../../lib
dependall ===> compat/arm/eabi/../../../lib/libc
build libc/libc.so.12.220.link
/home/riastradh/netbsd/current/src/../obj.arm64-clang/tooldir/aarch64--netbsd/bin/ld: warning: -z relro ignored
aarch64--netbsd-clang: error: linker command failed with exit code 1 (use -v to see invocation)
This warning appears to be new, arising from this change to ignore the `-z relro' option:
http://cvsweb.netbsd.org/bsdweb.cgi/src/external/gpl3/binutils/dist/ld/emultempl/elf.em.diff?r1=1.2&r2=1.3&only_with_tag=MAIN
else if (strcmp (optarg, "nocopyreloc") == 0)
- link_info.nocopyreloc = TRUE;
+ link_info.nocopyreloc = true;
+EOF
+if test -n "$COMMONPAGESIZE"; then
+fragment <<EOF
else if (strcmp (optarg, "relro") == 0)
- link_info.relro = TRUE;
+ link_info.relro = true;
else if (strcmp (optarg, "norelro") == 0)
- link_info.relro = FALSE;
+ link_info.relro = false;
+EOF
+fi
+fragment <<EOF
else if (strcmp (optarg, "separate-code") == 0)
I'm not sure if relro is expected to work, now or ever, on 32-bit arm, but `-z relro' is passed only if MKRELRO is not `no':
https://nxr.netbsd.org/xref/src/share/mk/bsd.sys.mk?r=1.313#140
140 .if ${MKRELRO:Uno} != "no"
141 LDFLAGS+= -Wl,-z,relro
142 .endif
And bsd.own.mk enables MKRELRO by default on aarch64 and disables it by default on 32-bit arm:
https://nxr.netbsd.org/xref/src/share/mk/bsd.own.mk?r=1.1318#1138
1137 #
1138 # RELRO is enabled on i386, amd64, and aarch64 by default
1139 #
1140 .if ${MACHINE} == "i386" || \
1141 ${MACHINE} == "amd64" || \
1142 ${MACHINE_ARCH:Maarch64*}
1143 MKRELRO?= partial
1144 .else
1145 MKRELRO?= no
1146 .endif
So presumably relro should be disabled during the 32-bit compat library builds. But it must be enabled if the build fails this way. Perhaps we need to manually override it somewhere in the makefile magic under src/compat.
>How-To-Repeat:
./build.sh -c clang -m evbarm64 release
>Fix:
Yes, please!
>Audit-Trail:
From: Taylor R Campbell <campbell+netbsd@mumble.net>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: toolchain/57405: clang build has been broken on aarch64 since binutils 2.39 update
Date: Sat, 13 May 2023 10:39:51 +0000
And this only happens in the clang build because 32-bit compat
libraries are only enabled in the clang build for now:
https://nxr.netbsd.org/xref/src/compat/archdirs.mk?r=1.14#31
31 .if ${ACTIVE_CC} == "clang"
32 .if (${MACHINE_ARCH} == "aarch64")
33 ARCHDIR_SUBDIR+= arm/eabi
34 ARCHDIR_SUBDIR+= arm/eabihf
35 .elif (${MACHINE_ARCH} == "aarch64eb")
36 ARCHDIR_SUBDIR+= arm/eabi
37 .endif
38 .endif
(That they have to be disabled in the gcc build is a different bug for
other reasons I don't remember; someone should file a separate PR for
that.)
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/57405 CVS commit: src
Date: Sat, 13 May 2023 10:56:55 +0000
Module Name: src
Committed By: riastradh
Date: Sat May 13 10:56:55 UTC 2023
Modified Files:
src/compat/arm/eabi: bsd.eabi.mk
src/compat/arm/eabihf: bsd.eabihf.mk
src/share/mk: bsd.own.mk
Log Message:
compat: Disable relro in 32-bit arm compat.
Not supported by binutils:
ld: warning: -z relro ignored
PR toolchain/57405
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/compat/arm/eabi/bsd.eabi.mk
cvs rdiff -u -r1.4 -r1.5 src/compat/arm/eabihf/bsd.eabihf.mk
cvs rdiff -u -r1.1318 -r1.1319 src/share/mk/bsd.own.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.