Re: HEADS UP: plan to switch many ports over to GCC 12 soon

"David H. Gutteridge" <[email protected]>
Newsgroups gmane.os.netbsd.devel.toolchain
Message-ID <[email protected]>
On Fri, 21 Jun 2024 at 15:07:41 -0400, Greg Troxel wrote:
> Christoph Badura <bad%bsd.de@localhost> writes:
> 
>> For me gcc/usr.bin/host-libcpp failed to build on macOS 12.7.
>> 
>> Stuff like:
>> src/external/gpl3/gcc/dist/libcpp/include/line-map.h:1677:44: warning: 
>> deleted function definitions are a C++11 extension 
>> [-Wc++11-extensions]
>> src/external/gpl3/gcc/dist/libcpp/include/cpplib.h:319:13: warning: 
>> commas at the end of enumerator lists are a C++11 extension 
>> [-Wc++11-extensions]
>> src/external/gpl3/gcc/dist/libcpp/include/cpplib.h:1144:6: warning: 
>> scoped enumerations are a C++11 extension [-Wc++11-extensions]
>> etc.
>> 
>> A patch similar what David Gutteridge did on r1.113 of 
>> src/tools/gcc/Makefile
>> fixed that.
>> 
>> diff --git a/external/gpl3/gcc/usr.bin/host-libcpp/Makefile 
>> b/external/gpl3/gcc/usr.bin/host-libcpp/Makefile
>> index 77ea9e0b2ba..e7968c85f55 100644
>> --- a/external/gpl3/gcc/usr.bin/host-libcpp/Makefile
>> +++ b/external/gpl3/gcc/usr.bin/host-libcpp/Makefile
>> @@ -1,5 +1,7 @@
>>  #	$NetBSD: Makefile,v 1.6 2023/05/19 10:42:34 lukem Exp $
>> 
>> +.include <bsd.init.mk>
>> +
>>  BUILD_ENV= \
>>  		AR=${HOST_AR:Q} \
>>  		AWK=${TOOL_AWK:Q} \
>> @@ -19,6 +21,12 @@ BUILD_ENV= \
>>  		RANLIB=${HOST_RANLIB:Q} \
>>  		YACC=${YACC:Q}
>> 
>> +# Force C++11 so builds succeed on hosts where this isn't the 
>> compiler
>> +# default, e.g., NetBSD 8.x with GCC 5.5.
>> +.if ${HAVE_GCC} > 10
>> +HOST_CXXFLAGS+=		-std=c++11
>> +.endif
>> +
>>  GMAKE_J_ARGS?=	${MAKEFLAGS:[*]:M*-j*:C/(^|.* )(-j 
>> ?[0-9][0-9]*).*/\2/W}
>>  BUILD_COMMAND=	/usr/bin/env -i ${BUILD_ENV} ${TOOL_GMAKE} 
>> ${GMAKE_J_ARGS} -e
>> 
>> I'll commit that if there are no objections.
> 
> I'm not really comfortable with this being conditional.   If the 
> program
> is in c++11, it makes sense to just always pass that -std.   If the
> default is c++11, it's a noop.  If the default is c++17, it asks that
> the sources be treated as c++11 and thus would catch if anyone added a
> c++17ism via an edit.

If you're referring here to ".if ${HAVE_GCC} > 10", that definitely
needs to be conditional. HAVE_GCC refers to the version of GCC being
built as a tool, not the version of the host compiler in use. Building
GCC < 11 does not require C++11 support from the host compiler, and
wouldn't be correct to pass (it would knock out older but still viable
host compilers in that context, at minimum).

Regards,

Dave
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.