NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

toolchain/57405: clang build has been broken on aarch64 since binutils 2.39 update



>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
>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!



Home | Main Index | Thread Index | Old Index