NetBSD Problem Report #58437

From www@netbsd.org  Wed Jul 17 20:22:54 2024
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)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id A113C1A9239
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 17 Jul 2024 20:22:54 +0000 (UTC)
Message-Id: <20240717202252.F3D6B1A923A@mollari.NetBSD.org>
Date: Wed, 17 Jul 2024 20:22:52 +0000 (UTC)
From: palle@lyckegaard.dk
Reply-To: palle@lyckegaard.dk
To: gnats-bugs@NetBSD.org
Subject: Building tools/gcc on a Solaris 11.4 host after GCC has been switched to GCC 12 fails
X-Send-Pr-Version: www-1.0

>Number:         58437
>Category:       toolchain
>Synopsis:       Building tools/gcc on a Solaris 11.4 host after GCC has been switched to GCC 12 fails
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jul 17 20:25:00 +0000 2024
>Last-Modified:  Mon Jul 22 17:35:00 +0000 2024
>Originator:     Palle Lyckegaard
>Release:        current
>Organization:
NetBSD
>Environment:
SunOS s11-sparc.cfarm 5.11 11.4.71.170.2 sun4v sparc sun4v logical-domain

>Description:
After the switch to GCC 12 building tools/gcc on a Solaris 11.4 host system has started to fail.

build.sh tools fails with:

...
/usr/bin/bash ./libtool --tag=CC --tag=disable-static  --mode=link /usr/bin/gcc -Wall  -O -Wc,-static-libgcc  -module -avoid-version -bindir /home/palle/netbsd/build/sparc64/tooldir/libexec/gcc/sparc64--netbsd/12.4.0 -export-symbols-regex onload    -o liblto_plugin.la -rpath /home/palle/netbsd/build/sparc64/tooldir/libexec/gcc/sparc64--netbsd/12.4.0 lto-plugin.lo  -Wc,../libiberty/pic/libiberty.a 
libtool: link: nm  .libs/lto-plugin.o   |  | /usr/bin/gsed 's/.* //' | sort | uniq > .libs/liblto_plugin.exp
./libtool: eval: line 1116: syntax error near unexpected token `|'
./libtool: eval: line 1116: `nm  .libs/lto-plugin.o   |  | /usr/bin/gsed 's/.* //' | sort | uniq > .libs/liblto_plugin.exp'
nbgmake[2]: *** [liblto_plugin.la] Error 2
nbgmake[2]: Leaving directory `/home/palle/netbsd/build/sparc64/objdir/tools/gcc/build/lto-plugin'
nbgmake[1]: *** [all] Error 2
nbgmake[1]: Leaving directory `/home/palle/netbsd/build/sparc64/objdir/tools/gcc/build/lto-plugin'
:
...


Investigating tools/gcc/lto-plugin configure:

...
configure:7527: checking command to parse nm output from /usr/bin/gcc object
configure:7645: /usr/bin/gcc -c -O   -DNETBSD_TOOLS -DTARGET_SYSTEM_ROOT=0  -DTARGET_SYSTEM_ROOT_RELOCATABLE conftest.c >&5
configure:7648: $? = 0
configure:7652: nm conftest.o \| sed -n -e 's/^.*[ ]\([BDRT][BDRT]*\)[ ][ ]*\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2 \2/p' \> conftest.nm
configure:7655: $? = 0
cannot run sed -n -e 's/^.*[     ]\([BDRT][BDRT]*\)[     ][      ]*\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2 \2/p'
configure:7645: /usr/bin/gcc -c -O   -DNETBSD_TOOLS -DTARGET_SYSTEM_ROOT=0  -DTARGET_SYSTEM_ROOT_RELOCATABLE conftest.c >&5
configure:7648: $? = 0
configure:7652: nm conftest.o \| sed -n -e 's/^.*[ ]\([BDRT][BDRT]*\)[ ][ ]*_\([_A-Za-z][_A-Za-z0-9]*\)$/\1 _\2 \2/p' \> conftest.nm
configure:7655: $? = 0
cannot run sed -n -e 's/^.*[     ]\([BDRT][BDRT]*\)[     ][      ]*_\([_A-Za-z][_A-Za-z0-9]*\)$/\1 _\2 \2/p'
configure:7747: result: failed
configure:7957: /usr/bin/gcc -c -O   -DNETBSD_TOOLS -DTARGET_SYSTEM_ROOT=0  -DTARGET_SYSTEM_ROOT_RELOCATABLE conftest.c >&5
configure:7960: $? = 0
...

Solaris nm is not usable here as show below:


conftest.c

#ifdef __cplusplus
extern "C" {
#endif
char nm_test_var;
void nm_test_func(void);
void nm_test_func(void){}
#ifdef __cplusplus
}
#endif
int main(){nm_test_var='a';nm_test_func();return(0);}


nm contest.o output on a system with GNU nm:

                 U
0000000000000008 T main
0000000000000000 T nm_test_func
0000000000000000 B nm_test_var


nm outout on a Solaris 11.4 system:

conftest.o:

[Index]   Value                Size                Type  Bind  Other Shndx   Name

[5]     |                   0|                   0|SECT |LOCL |0    |5      |
[2]     |                   0|                   0|SECT |LOCL |0    |1      |
[3]     |                   0|                   0|SECT |LOCL |0    |3      |
[4]     |                   0|                   0|SECT |LOCL |0    |4      |
[8]     |                   2|                   0|REGI |GLOB |0    |UNDEF  |
[7]     |                   8|                  28|FUNC |GLOB |0    |1      |main
[6]     |                   0|                   8|FUNC |GLOB |0    |1      |nm_test_func
[9]     |                   0|                   1|OBJT |GLOB |0    |4      |nm_test_var
[1]     |                   0|                   0|FILE |LOCL |0    |ABS    |conftest.c



So the output from the GNU nm and Solaris nm commands obviously differs, so the configure script fails.







>How-To-Repeat:
Issue a build.sh tools command on a Solaris 11.4 system.

>Fix:
Simple patch to tools/gcc/Makefile so the tool/nm version is used as NM.

Verified on a Solaris 11.4 host and GNU host (Ubuntu Linux) - assumes no issues on a NetBSD host.


diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
index 8b9797992d7b..223d84a047c4 100644
--- a/tools/gcc/Makefile
+++ b/tools/gcc/Makefile
@@ -95,7 +95,7 @@ GCC_CPPFLAGS+=        -DNB_FIX_VAX_BACKEND
 MAKE_ARGS=     MACHINE= MAKEINFO=${TOOL_MAKEINFO:Q} \
                LIBGCC= LIBGCC1= LIBGCC1_TEST= LIBGCC2= INSTALL_LIBGCC= \
                EXTRA_PARTS= CPPFLAGS=${GCC_CPPFLAGS:Q} \
-               AR=${HOST_AR:Q} RANLIB=${HOST_RANLIB:Q}
+               AR=${HOST_AR:Q} RANLIB=${HOST_RANLIB:Q} NM=${NM:Q}

 CONFIGURE_ENV+= gcc_cv_libc_provides_ssp=yes \
                gcc_cv_as_sparc_gotdata_op=no

>Audit-Trail:
From: Palle Lyckegaard <palle@lyckegaard.dk>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: toolchain/58437: Building tools/gcc on a Solaris 11.4 host after
 GCC has been switched to GCC 12 fails
Date: Mon, 22 Jul 2024 17:30:51 +0000 (UTC)

 On Wed, 17 Jul 2024, gnats-admin@netbsd.org wrote:

 > Date: Wed, 17 Jul 2024 20:25:00 +0000 (UTC)
 > From: gnats-admin@netbsd.org
 > Reply-To: gnats-bugs@netbsd.org
 > To: palle@lyckegaard.dk
 > Subject: Re: toolchain/58437: Building tools/gcc on a Solaris 11.4 host after
 >     GCC has been switched to GCC 12 fails
 > 
 > Thank you very much for your problem report.
 > It has the internal identification `toolchain/58437'.
 > The individual assigned to look at your
 > report is: toolchain-manager.
 >
 >> Category:       toolchain
 >> Responsible:    toolchain-manager
 >> Synopsis:       Building tools/gcc on a Solaris 11.4 host after GCC has been switched to GCC 12 fails
 >> Arrival-Date:   Wed Jul 17 20:25:00 +0000 2024
 >
 >

 Could someone with knowledge of the toolchain/gcc building process have a 
 look at the issue - I can commit the fix myself (verified on Linux, NetBSD 
 and Solaris host systems now)

NetBSD Home
NetBSD PR Database Search

(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-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.