NetBSD Problem Report #58668
From www@netbsd.org Mon Sep 9 06:43:10 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 296311A923B
for <gnats-bugs@gnats.NetBSD.org>; Mon, 9 Sep 2024 06:43:10 +0000 (UTC)
Message-Id: <20240909064308.BFC811A9242@mollari.NetBSD.org>
Date: Mon, 9 Sep 2024 06:43:08 +0000 (UTC)
From: devel.v9zjk@slmail.me
Reply-To: devel.v9zjk@slmail.me
To: gnats-bugs@NetBSD.org
Subject: gettext fails to build if base compiler is clang
X-Send-Pr-Version: www-1.0
>Number: 58668
>Category: pkg
>Synopsis: gettext fails to build if base compiler is clang
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: pkg-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Sep 09 06:45:00 +0000 2024
>Last-Modified: Sat Sep 14 15:25:01 +0000 2024
>Originator: Luca De Pandis
>Release: NetBSD 10_STABLE/pkgsrc HEAD
>Organization:
>Environment:
NetBSD netbsd.ldep.local 10.0_STABLE NetBSD 10.0_STABLE (GENERIC64.20240908181017Z) #0: Mon Sep 9 01:40:40 CEST 2024 ldepandis@Lucas-MacBook-Air.local:/Users/ldepandis/netbsd/build/obj/sys/arch/evbarm/compile/GENERIC64 evbarm
>Description:
When the base compiler is clang, gettext-lib fails to build when it tries to run configure for libasprintf, because it tries to check for the C/C++ preprocessor.
It tries to search for /usr/bin/cpp, but it isn't installed as the preprocessor in a base environement built with clang is /usr/bin/clang-cpp.
I tried to set CPP and CXXCPP in /etc/mk.conf but it sorts not effect.
Patching devel/gettext Makefile.common fixed the problem.
>How-To-Repeat:
Compile NetBSD with clang as the base compiler, set /etc/mk.conf with the following parameters:
PKGSRC_COMPILER=clang
CLANGBASE= /usr
and then try to compile devel/gettext-lib.
>Fix:
Index: ./devel/gettext/Makefile.common
===================================================================
RCS file: /cvsroot/pkgsrc/devel/gettext/Makefile.common,v
retrieving revision 1.27
diff -u -r1.27 Makefile.common
--- ./devel/gettext/Makefile.common 25 Feb 2024 15:42:05 -0000 1.27
+++ ./devel/gettext/Makefile.common 9 Sep 2024 06:41:59 -0000
@@ -33,3 +33,12 @@
CPPFLAGS+= -D_UCONTEXT_T=1
CPPFLAGS+= -D_UCONTEXT64_T=1
.endif
+
+# When base compiler is clang, gettext fails to build
+# because it tries to use /usr/bin/cpp as the system
+# preprocessor, but there is no cpp in base as clang
+# uses /usr/bin/clang-cpp
+.if ${PKGSRC_COMPILER} == "clang"
+CPP= /usr/bin/clang-cpp
+CXXCPP= /usr/bin/clang-cpp
+.endif
>Audit-Trail:
From: devel.v9zjk@slmail.me
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: pkg/58668: gettext fails to build if base compiler is clang
Date: Mon, 09 Sep 2024 09:06:40 +0000
Hi,
even www/nghttp2 has the same problem.
Here the log:
=3D=3D=3D> Configuring for nghttp2-1.63.0
=3D> Generating pkg-config files for builtin xz package.
=3D> Modifying GNU configure scripts to avoid --recheck
=3D> Replacing config-guess with pkgsrc versions
=3D> Replacing config-sub with pkgsrc versions
=3D> Replacing install-sh with pkgsrc version
=3D> Adding run-time search paths to pkg-config files.
INFO: [subst.mk:_pkgconfig] Ignoring nonexistent file "src/libnghttp2_asio.=
pc.in".
checking for aarch64--netbsd-gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... checking whether we are cross compil=
ing... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for wchar.h... yes
checking for minix/config.h... no
checking for vfork.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking whether _XOPEN_SOURCE should be defined... no
checking build system type... aarch64--netbsd
checking host system type... aarch64--netbsd
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... (cached) /usr/bin/grep
checking for egrep... (cached) /usr/bin/egrep
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... (cached) 262144
checking how to convert aarch64--netbsd file names to aarch64--netbsd forma=
t... func_convert_file_noop
checking how to convert aarch64--netbsd file names to toolchain format... f=
unc_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for aarch64--netbsd-objdump... no
checking for objdump... objdump
checking how to recognize dependent libraries... match_pattern /lib[^/]+(\.=
so|_pic\.a)$
checking for aarch64--netbsd-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for aarch64--netbsd-ar... no
checking for ar... ar
checking for archiver @FILE support... @
checking for aarch64--netbsd-strip... no
checking for strip... strip
checking for aarch64--netbsd-ranlib... no
checking for ranlib... ranlib
checking for gawk... /usr/bin/awk
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=3D4096 count=3D1
checking for aarch64--netbsd-mt... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... yes
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... rm: conftest*: No such file or dir=
ectory
yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... =
yes
checking whether -lc should be explicitly linked in... rm: conftest*: No su=
ch file or directory
no
checking dynamic linker characteristics... NetBSD ld.elf_so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking target system type... aarch64--netbsd
checking for a BSD-compatible install... /usr/bin/install -c -o root -g whe=
el
checking whether build environment is sane... yes
checking for a race-free mkdir -p... ././install-sh -c -d
checking whether make sets $(MAKE)... yes
checking whether make supports the include directive... yes (GNU style)
checking whether make supports nested variables... yes
checking how to create a pax tar archive... gnutar
checking dependency style of gcc... gcc3
checking whether make supports nested variables... (cached) yes
checking for aarch64--netbsd-gcc... (cached) gcc
checking whether the compiler supports GNU C... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to enable C11 features... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking whether the compiler supports GNU C++... no
checking whether c++ accepts -g... no
checking for c++ option to enable C++11 features... none needed
checking how to run the C++ preprocessor... /usr/bin/cpp
configure: error: in `/usr/pkgsrc/www/nghttp2/work/nghttp2-1.63.0':
configure: error: C++ preprocessor "/usr/bin/cpp" fails sanity check
See `config.log' for more details
*** Error code 1
Stop.
make[7]: stopped in /usr/pkgsrc/www/nghttp2
WARNING: *** Please consider adding c++ to USE_LANGUAGES in the package Mak=
efile.
*** Error code 1
Stop.
make[6]: stopped in /usr/pkgsrc/www/nghttp2
*** Error code 1
Stop.
make[5]: stopped in /usr/pkgsrc/www/curl
*** Error code 1
Stop.
make[4]: stopped in /usr/pkgsrc/devel/cmake
*** Error code 1
Stop.
make[3]: stopped in /usr/pkgsrc/archivers/brotli
*** Error code 1
Stop.
make[2]: stopped in /usr/pkgsrc/graphics/freetype2
*** Error code 1
Stop.
make[1]: stopped in /usr/pkgsrc/x11/libXfont2
*** Error code 1
Stop.
make: stopped in /usr/pkgsrc/x11/modular-xorg-server
I made a patch for it as well, but I think at this point it would be more u=
seful to fix this issue by adding a check in some mk macro file (mk/compile=
r.mk?).
What do you think?
Index: ./www/nghttp2/Makefile.common
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/pkgsrc/www/nghttp2/Makefile.common,v
retrieving revision 1.26
diff -u -r1.26 Makefile.common
--- ./www/nghttp2/Makefile.common 29 Aug 2024 10:52:16 -0000 1.26
+++ ./www/nghttp2/Makefile.common 9 Sep 2024 09:00:01 -0000
@@ -14,3 +14,10 @@
DISTINFO_FILE=3D ${.CURDIR}/../../www/nghttp2/distinfo
PATCHDIR=3D ${.CURDIR}/../../www/nghttp2/patches
+
+.include "../../mk/compiler.mk"
+
+.if ${PKGSRC_COMPILER} =3D=3D "clang"
+CPP=3D /usr/bin/clang-cpp
+CXXCPP=3D /usr/bin/clang-cpp
+.endif
Luca De Pandis
> On 9 Sep 2024, at 08:45, gnats-admin at netbsd.org <gnats-admin@netbsd.or=
g> wrote:
>=20
> Thank you very much for your problem report.
> It has the internal identification `pkg/58668'.
> The individual assigned to look at your
> report is: pkg-manager.
>=20
>> Category: pkg
>> Responsible: pkg-manager
>> Synopsis: gettext fails to build if base compiler is clang
>> Arrival-Date: Mon Sep 09 06:45:00 +0000 2024
>=20
>=20
From: Tobias Nygren <tnn@NetBSD.org>
To: gnats-bugs@netbsd.org
Cc: devel.v9zjk@slmail.me
Subject: Re: pkg/58668: gettext fails to build if base compiler is clang
Date: Wed, 11 Sep 2024 12:00:06 +0200
Hi,
I don't think the patch is is correct. Rather I suspect this is a
problem due to interaction between pkgsrc and /usr/share/mk on NetBSD.
On a NetBSD system with clang as the base compiler you should explicitly
set these options in mk.conf:
HAVE_LLVM=yes
MKLLVM=yes
MKGCC=no
The last two might be optional but they will be required also for
rebuilding your userland with ./build.sh so it's best to set them.
Please let us know if this solves the issue.
-Tobias
From: devel.v9zjk@slmail.me
To: Tobias Nygren <tnn@netbsd.org>
Cc: gnats-bugs@netbsd.org
Subject: Re: pkg/58668: gettext fails to build if base compiler is clang
Date: Wed, 11 Sep 2024 10:11:34 +0000
Hi Tobias,
sorry for the malformed patch. It seems like it was corrupted from Apple Ma=
il despite setting the plain-text format.
About the missing keywords in /etc/mk.conf, I set them in another mk.conf I=
used when I cross-built the image of NetBSD.
The system where I'm running pkgsrc was installed with sysinst from the ISO=
image that build.sh made.
I faced the problem about a wrong CPP detected with the following packages,=
when I was trying to build modular-xorg-server:
- gettext-lib
- nghttp2
- libva
Other dependencies of that package that were built with GNU Autotools didn'=
t show this behavior.
Best regards,
Luca De Pandis
> On 11 Sep 2024, at 12:00, Tobias Nygren - tnn at netbsd.org <tnn@netbsd.o=
rg> wrote:
>=20
> Hi,
>=20
> I don't think the patch is is correct. Rather I suspect this is a
> problem due to interaction between pkgsrc and /usr/share/mk on NetBSD.
>=20
> On a NetBSD system with clang as the base compiler you should explicitly
> set these options in mk.conf:
>=20
> HAVE_LLVM=3Dyes
> MKLLVM=3Dyes
> MKGCC=3Dno
>=20
> The last two might be optional but they will be required also for
> rebuilding your userland with ./build.sh so it's best to set them.
> Please let us know if this solves the issue.
>=20
> -Tobias
>=20
From: devel.v9zjk@slmail.me
To: Tobias Nygren <tnn@netbsd.org>
Cc: gnats-bugs@netbsd.org
Subject: Re: pkg/58668: gettext fails to build if base compiler is clang
Date: Sat, 14 Sep 2024 15:21:51 +0000
Hi Tobias,
sorry for the late answer but I couldn't try again with your suggestions.
Yes, setting those options solved the problem.
That said, in the documentation I think this requirements it's not that
clear.
Here what is documented:
(source: https://wiki.netbsd.org/tutorials/clang/)
MKGCC=3Dno needed as building GCC alongside is not maintained
MKLLVM=3Dyes builds LLVM libraries
HAVE_LLVM=3Dyes controls clang being built
PKGSRC_COMPILER=3Dclang instructs pkgsrc it's clang
CLANGBASE=3D/usr instructs pkgsrc where to look for the compiler
As you can see, HAVE_LLVM is considered something to set just to build
clang and not to set the latter also as the default compiler for pkgsrc.
I think it would be better to describe such option as mandatory in the
wiki, since it's not always true that the compilation environment for
the base is the same of pkgsrc's.
Anyway, thank you very much for your help.
Best regards,
Luca De Pandis
On Wednesday, September 11th, 2024 at 12:00, Tobias Nygren - tnn at netbsd.=
org <tnn@netbsd.org> wrote:
> Hi,
>=20
> I don't think the patch is is correct. Rather I suspect this is a
> problem due to interaction between pkgsrc and /usr/share/mk on NetBSD.
>=20
> On a NetBSD system with clang as the base compiler you should explicitly
> set these options in mk.conf:
>=20
> HAVE_LLVM=3Dyes
> MKLLVM=3Dyes
> MKGCC=3Dno
>=20
> The last two might be optional but they will be required also for
> rebuilding your userland with ./build.sh so it's best to set them.
> Please let us know if this solves the issue.
>=20
> -Tobias
(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.