NetBSD Problem Report #57014

From cjep@netbsd.org  Sat Sep 17 11:35:37 2022
Return-Path: <cjep@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 C02C31A9248
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 17 Sep 2022 11:35:37 +0000 (UTC)
Message-Id: <20220917111850.6CCE61A924A@mollari.NetBSD.org>
Date: Sat, 17 Sep 2022 11:18:50 +0000 (UTC)
From: cjep@netbsd.org
Reply-To: cjep@netbsd.org
To: gnats-bugs@NetBSD.org
Subject: Cross-build of NetBSD fails on OpenBSD 7.1 due to gcc generators
X-Send-Pr-Version: 3.95

>Number:         57014
>Category:       toolchain
>Synopsis:       Cross-build of NetBSD fails on OpenBSD 7.1 due to gcc generators
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    toolchain-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Sep 17 11:40:00 +0000 2022
>Closed-Date:    Sun May 21 08:09:33 +0000 2023
>Last-Modified:  Sat Jun 03 14:25:01 +0000 2023
>Originator:     Chris Pinnock
>Release:        NetBSD-current as of today
>Organization:
Very little
>Environment:
OpenBSD blowfish.home 7.1 GENERIC.MP#3 amd64
OpenBSD clang version 13.0.0
Target: amd64-unknown-openbsd7.1
Thread model: posix

>Description:
The cross-build fails during the compilation of the target gcc compiler
due to problems linking the GCC generator backend. The generator is build
with the host compiler because it needs to run on the host to output.

--- gencondmd ---
#      link  backend/gencondmd
c++ -std=gnu++98 -I/home/cjep/src/NetBSD/current/src/../objects/amd64/external/gpl3/gcc/usr.bin/backend -I/home/cjep/src/NetBSD/current/src/../objects/amd64/external/gpl3/gcc/usr.bin/host-libiberty/libiberty -I. -I/home/cjep/src/NetBSD/current/src/external/gpl3/gcc/usr.bin/backend/../gcc/arch/x86_64 -DIN_GCC -DHAVE_CONFIG_H -I/home/cjep/src/NetBSD/current/src/external/gpl3/gcc/dist/gcc -I/home/cjep/src/NetBSD/current/src/external/gpl3/gcc/dist/gcc/. -I/home/cjep/src/NetBSD/current/src/external/gpl3/gcc/dist/gcc/../include -I/home/cjep/src/NetBSD/current/src/external/gpl3/gcc/dist/gcc/../libcpp/include -I/home/cjep/src/NetBSD/current/src/external/gpl3/gcc/dist/gcc/../libdecnumber -I/home/cjep/src/NetBSD/current/src/external/gpl3/gcc/dist/gcc/../libdecnumber/dpd -I/home/cjep/src/NetBSD/current/src/external/gpl3/gcc/dist/gcc/../libbacktrace -DGENERATOR_FILE -I/home/cjep/src/NetBSD/current/src/external/gpl3/gcc/usr.bin/backend/..  -o gencondmd gencondmd.lo build-rtl.lo read-rtl.lo build-
 ggc-none.lo vec.lo min-insn-modes.lo gensupport.lo build-print-rtl.lo hash-table.lo sort.lo read-md.lo build-errors.lo -L/home/cjep/src/NetBSD/current/src/../objects/amd64/tooldir.OpenBSD-7.1-amd64/lib -lnbcompat /home/cjep/src/NetBSD/current/src/../objects/amd64/external/gpl3/gcc/usr.bin/host-libiberty/libiberty/libiberty.a  build-sort.lo
ld: error: undefined symbol: ix86_isa_flags
 referenced by gencondmd.c
               gencondmd.lo:(__cxx_global_var_init.101)
 referenced by gencondmd.c
               gencondmd.lo:(__cxx_global_var_init.101)
 referenced by gencondmd.c
               gencondmd.lo:(__cxx_global_var_init.101)
 referenced 2268 more times
(etc)

The tools target builds fine (i.e. clang is able to build nbgcc and friends 
ok). It is when the target compiler is being built by the tools that there is a 
problem (although note that the host compiler is at work here because the
generator needs to run on the host)..

This also affects macOS Monterey builds using the Xcode clang compiler 
(at least for me). Does not seem to be a problem with FreeBSD's clang (yet).

>How-To-Repeat:
On an OpenBSD 7.1 box (or a macOS Monterey box with Xcode tools):
./build.sh -U -u build

>Fix:
Commenting out line 29 of external/gpl3/gcc/usr.bin/backend/Makefile
#HOST_CXXFLAGS+=        -std=gnu++98
results in a successful build. Perhaps we should not include this flag when
a. building the target compiler (i.e. when we are not building tools)
b. the host compiler is clang.
or somehow not use it for the GCC generators that need to compile on the host

(This change also allows me to build again on macOS Monterey, although
there CTF tools are not working properly during the build for me. On the
relevant platforms i386, amd64, arm the nbctfmerge tool seg faults - will
look at this separately and file a different PR when I have time)

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->feedback
State-Changed-By: lukem@NetBSD.org
State-Changed-When: Fri, 19 May 2023 23:30:05 +0000
State-Changed-Why:
I think I've fixed this in -current.
At least, it now works on macOS with clang++ as the host compiler.

Has this fixed the problem for you on your OpenBSD and macOS builds?


From: "Luke Mewburn" <lukem@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57014 CVS commit: src/external/gpl3
Date: Fri, 19 May 2023 23:28:22 +0000

 Module Name:	src
 Committed By:	lukem
 Date:		Fri May 19 23:28:22 UTC 2023

 Modified Files:
 	src/external/gpl3/gcc.old/usr.bin/backend: Makefile
 	src/external/gpl3/gcc.old/usr.bin/common: Makefile
 	src/external/gpl3/gcc.old/usr.bin/common-target: Makefile
 	src/external/gpl3/gcc.old/usr.bin/frontend: Makefile
 	src/external/gpl3/gcc.old/usr.bin/libcpp: Makefile
 	src/external/gpl3/gcc.old/usr.bin/libdecnumber: Makefile
 	src/external/gpl3/gcc/usr.bin/backend: Makefile
 	src/external/gpl3/gcc/usr.bin/common: Makefile
 	src/external/gpl3/gcc/usr.bin/common-target: Makefile
 	src/external/gpl3/gcc/usr.bin/frontend: Makefile
 	src/external/gpl3/gcc/usr.bin/libcpp: Makefile
 	src/external/gpl3/gcc/usr.bin/libdecnumber: Makefile

 Log Message:
 gcc: fix build with clang++ HOST_CXX

 Define HOSTPROG_CXX before .include anything that brings in bsd.own.mk.
 This ensures that HOST_DBG (etc) gets assigned before HOST_CFLAGS
 and HOST_CXXFLAGS is created.

 backend: .include <bsd.init.mk> much earlier, as per the other directories.
 Fixes backend build when using clang++ as the host compiler (e.g., macOS),
 because backend host tools are now built with -O.
 Inspired by https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=255760

 Note that gcc.old/Makefile.prog may be mis-used because it defines HOSTPROG_CXX
 and this Makefile fragment is included after bsd.*.mk in other Makefiles,
 but they seem to build ok so leaving it alone for now.

 Fixes PR toolchain/57014


 To generate a diff of this commit:
 cvs rdiff -u -r1.16 -r1.17 src/external/gpl3/gcc.old/usr.bin/backend/Makefile
 cvs rdiff -u -r1.10 -r1.11 src/external/gpl3/gcc.old/usr.bin/common/Makefile
 cvs rdiff -u -r1.9 -r1.10 \
     src/external/gpl3/gcc.old/usr.bin/common-target/Makefile
 cvs rdiff -u -r1.12 -r1.13 \
     src/external/gpl3/gcc.old/usr.bin/frontend/Makefile
 cvs rdiff -u -r1.11 -r1.12 src/external/gpl3/gcc.old/usr.bin/libcpp/Makefile
 cvs rdiff -u -r1.11 -r1.12 \
     src/external/gpl3/gcc.old/usr.bin/libdecnumber/Makefile
 cvs rdiff -u -r1.66 -r1.67 src/external/gpl3/gcc/usr.bin/backend/Makefile
 cvs rdiff -u -r1.11 -r1.12 src/external/gpl3/gcc/usr.bin/common/Makefile
 cvs rdiff -u -r1.11 -r1.12 \
     src/external/gpl3/gcc/usr.bin/common-target/Makefile
 cvs rdiff -u -r1.14 -r1.15 src/external/gpl3/gcc/usr.bin/frontend/Makefile
 cvs rdiff -u -r1.9 -r1.10 src/external/gpl3/gcc/usr.bin/libcpp/Makefile
 cvs rdiff -u -r1.8 -r1.9 src/external/gpl3/gcc/usr.bin/libdecnumber/Makefile

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: feedback->closed
State-Changed-By: cjep@NetBSD.org
State-Changed-When: Sun, 21 May 2023 08:09:33 +0000
State-Changed-Why:
The patch fixes the problem and OpenBSD builds are back. Also MacOS builds
work again on Monterey on arm64 & x86.


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57014 CVS commit: [netbsd-10] src/external/gpl3/gcc/usr.bin
Date: Sun, 28 May 2023 09:47:28 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sun May 28 09:47:28 UTC 2023

 Modified Files:
 	src/external/gpl3/gcc/usr.bin/backend [netbsd-10]: Makefile
 	src/external/gpl3/gcc/usr.bin/common [netbsd-10]: Makefile
 	src/external/gpl3/gcc/usr.bin/common-target [netbsd-10]: Makefile
 	src/external/gpl3/gcc/usr.bin/frontend [netbsd-10]: Makefile
 	src/external/gpl3/gcc/usr.bin/libcpp [netbsd-10]: Makefile
 	src/external/gpl3/gcc/usr.bin/libdecnumber [netbsd-10]: Makefile

 Log Message:
 Pull up following revision(s) (requested by lukem in ticket #176):

 	external/gpl3/gcc/usr.bin/libdecnumber/Makefile: revision 1.9
 	external/gpl3/gcc/usr.bin/common/Makefile: revision 1.12
 	external/gpl3/gcc/usr.bin/backend/Makefile: revision 1.67
 	external/gpl3/gcc/usr.bin/common-target/Makefile: revision 1.12
 	external/gpl3/gcc/usr.bin/frontend/Makefile: revision 1.15
 	external/gpl3/gcc/usr.bin/libcpp/Makefile: revision 1.10

 gcc: fix build with clang++ HOST_CXX

 Define HOSTPROG_CXX before .include anything that brings in bsd.own.mk.

 This ensures that HOST_DBG (etc) gets assigned before HOST_CFLAGS
 and HOST_CXXFLAGS is created.

 backend: .include <bsd.init.mk> much earlier, as per the other directories.

 Fixes backend build when using clang++ as the host compiler (e.g., macOS),
 because backend host tools are now built with -O.

 Inspired by https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=255760

 Note that gcc.old/Makefile.prog may be mis-used because it defines HOSTPROG_CXX
 and this Makefile fragment is included after bsd.*.mk in other Makefiles,
 but they seem to build ok so leaving it alone for now.

 Fixes PR toolchain/57014


 To generate a diff of this commit:
 cvs rdiff -u -r1.66 -r1.66.2.1 src/external/gpl3/gcc/usr.bin/backend/Makefile
 cvs rdiff -u -r1.11 -r1.11.2.1 src/external/gpl3/gcc/usr.bin/common/Makefile
 cvs rdiff -u -r1.11 -r1.11.2.1 \
     src/external/gpl3/gcc/usr.bin/common-target/Makefile
 cvs rdiff -u -r1.14 -r1.14.2.1 \
     src/external/gpl3/gcc/usr.bin/frontend/Makefile
 cvs rdiff -u -r1.9 -r1.9.2.1 src/external/gpl3/gcc/usr.bin/libcpp/Makefile
 cvs rdiff -u -r1.8 -r1.8.2.1 \
     src/external/gpl3/gcc/usr.bin/libdecnumber/Makefile

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57014 CVS commit: [netbsd-9] src/external/gpl3/gcc/usr.bin
Date: Sat, 3 Jun 2023 14:24:26 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sat Jun  3 14:24:25 UTC 2023

 Modified Files:
 	src/external/gpl3/gcc/usr.bin/backend [netbsd-9]: Makefile
 	src/external/gpl3/gcc/usr.bin/common [netbsd-9]: Makefile
 	src/external/gpl3/gcc/usr.bin/common-target [netbsd-9]: Makefile
 	src/external/gpl3/gcc/usr.bin/frontend [netbsd-9]: Makefile
 	src/external/gpl3/gcc/usr.bin/libcpp [netbsd-9]: Makefile
 	src/external/gpl3/gcc/usr.bin/libdecnumber [netbsd-9]: Makefile

 Log Message:
 Pull up following revision(s) (requested by lukem in ticket #1635):

 	external/gpl3/gcc/usr.bin/libdecnumber/Makefile: revision 1.9
 	external/gpl3/gcc/usr.bin/common/Makefile: revision 1.12
 	external/gpl3/gcc/usr.bin/backend/Makefile: revision 1.67
 	external/gpl3/gcc/usr.bin/common-target/Makefile: revision 1.12
 	external/gpl3/gcc/usr.bin/frontend/Makefile: revision 1.15
 	external/gpl3/gcc/usr.bin/libcpp/Makefile: revision 1.10

 gcc: fix build with clang++ HOST_CXX

 Define HOSTPROG_CXX before .include anything that brings in bsd.own.mk.

 This ensures that HOST_DBG (etc) gets assigned before HOST_CFLAGS
 and HOST_CXXFLAGS is created.
 backend: .include <bsd.init.mk> much earlier, as per the other directories.

 Fixes backend build when using clang++ as the host compiler (e.g., macOS),
 because backend host tools are now built with -O.
 Inspired by https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=255760

 Fixes PR toolchain/57014


 To generate a diff of this commit:
 cvs rdiff -u -r1.55 -r1.55.2.1 src/external/gpl3/gcc/usr.bin/backend/Makefile
 cvs rdiff -u -r1.9 -r1.9.2.1 src/external/gpl3/gcc/usr.bin/common/Makefile
 cvs rdiff -u -r1.8 -r1.8.2.1 \
     src/external/gpl3/gcc/usr.bin/common-target/Makefile
 cvs rdiff -u -r1.13 -r1.13.2.1 \
     src/external/gpl3/gcc/usr.bin/frontend/Makefile
 cvs rdiff -u -r1.8 -r1.8.6.1 src/external/gpl3/gcc/usr.bin/libcpp/Makefile
 cvs rdiff -u -r1.7 -r1.7.6.1 \
     src/external/gpl3/gcc/usr.bin/libdecnumber/Makefile

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

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