tech-toolchain archive

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

Re: (GNU) tools with GCC 14 and Clang-{15,16}



So I managed to foil GDB into building (fully on macos with Clang-15,
and all the way to the link on FreeBSD with Clang-16 where static
linking failed due to an undefined symbol:  _libmd_SHA256_Init because
in FreeBSD these functions are of course in libmd, not libc).

GDB's build is horribly overly complex and obtuse and abuses many
Autoconf features and invents many new non-standard configure flags, all
for code that shouldn't really be so unportable.  But by using these
flags to turn off "developer" features, and by overloading one of the
otherwise unused environment variables that ends up on the tail of the
list of CFLAGS I managed to get rid of the warnings.

GCC is now failing on macos with what look like some real errors
(attached below my sig).  I'll retry the FreeBSD build without
static-linking and see how far it gets with GCC.

BTW, I have confirmed that GCC ignores "-Wno-*" options where the option
is unknown or invalid, so unconditionally giving "-Wno-everything" is
safe for it.

Anyway I was able to get it to work with the following patches:

Index: external/gpl3/gdb/dist/bfd/development.sh
===================================================================
RCS file: /cvs/master/m-NetBSD/main/src/external/gpl3/gdb/dist/bfd/development.sh,v
retrieving revision 1.1.1.5
diff -u -r1.1.1.5 development.sh
--- external/gpl3/gdb/dist/bfd/development.sh	15 Sep 2020 01:41:57 -0000	1.1.1.5
+++ external/gpl3/gdb/dist/bfd/development.sh	9 Sep 2024 05:01:27 -0000
@@ -16,7 +16,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.

 # Controls whether to enable development-mode features by default.
-development=true
+development=false

 # Indicate whether this is a release branch.
-experimental=true
+experimental=false
Index: tools/Makefile.gnuhost
===================================================================
RCS file: /cvs/master/m-NetBSD/main/src/tools/Makefile.gnuhost,v
retrieving revision 1.53
diff -u -r1.53 Makefile.gnuhost
--- tools/Makefile.gnuhost	13 Jun 2020 10:49:17 -0000	1.53
+++ tools/Makefile.gnuhost	9 Sep 2024 05:58:34 -0000
@@ -51,6 +51,14 @@
 .MAKEOVERRIDES+= _GNU_CFGSRC
 .endif

+.if defined(HOST_LDFLAGS) && defined(HOST_LDSTATIC)
+. if empty(HOST_LDFLAGS:M*${HOST_LDSTATIC}*)
+HOST_LDFLAGS+=		${HOST_LDSTATIC}
+. endif
+.elif !defined(HOST_LDFLAGS) && defined(HOST_LDSTATIC)
+HOST_LDFLAGS=		${HOST_LDSTATIC}
+.endif
+
 CONFIGURE_ENV+= \
 		AR=${HOST_AR:Q} \
 		AWK=${TOOL_AWK:Q} \
@@ -62,6 +70,7 @@
 		CXXFLAGS=${HOST_CXXFLAGS:Q} \
 		INSTALL=${HOST_INSTALL_FILE:Q} \
 		LDFLAGS=${HOST_LDFLAGS:Q} \
+		LDSTATIC=${HOST_LDSTATIC:Q} \
 		LEX=${LEX:Q} \
 		FLEX=${LEX:Q} \
 		M4=${TOOL_M4:Q} \
@@ -74,7 +83,39 @@

 CONFIGURE_ARGS+=--prefix=${TOOLDIR}
 .if ${MKPIC} == "no"
-CONFIGURE_ARGS+=--disable-shared
+CONFIGURE_ARGS+= --disable-shared
+.endif
+
+CONFIGURE_ARGS+=--disable-maintainer-mode
+CONFIGURE_ARGS+=--disable-werror
+CONFIGURE_ARGS+=--disable-build-warnings
+CONFIGURE_ENV+=	ERROR_ON_WARNING=no
+
+# XXX need some way to inject -Wno-everything!
+#
+# this configure args is actually tested against the compiler with the current
+# conftest.c as '-Weverything' which causes so many errors the compiler gives up
+# and so configure thinks it doesn't accept the option at all!
+#
+#		--enable-build-warnings=-Wno-everything
+#
+# Maybe:
+CONFIGURE_ENV+=	DEBUGINFOD_CFLAGS=-Wno-everything
+
+.if defined(HOST_LDSTATIC) && !empty(HOST_LDSTATIC)
+CONFIGURE_ARGS+= --enable-static
+.endif
+
+MAKE_ENV+=		CFLAGS=${HOST_CFLAGS:Q}
+MAKE_ENV+=		CPPFLAGS=${HOST_CPPFLAGS:Q}
+MAKE_ENV+=		CXXFLAGS=${HOST_CXXFLAGS:Q}
+MAKE_ENV+=		LDFLAGS=${HOST_LDFLAGS:Q}
+MAKE_ENV+=		LDSTATIC=${HOST_LDLDSTATIC:Q}
+
+.if defined(HOST_LDSTATIC) && !empty(HOST_LDSTATIC) && defined(USE_LIBTOOL)
+# work around libtool brain-damage
+# xxx this doesn't always work very well....  (see also src/tools/binutils/Makefile which uses "--static", two hyphens)
+MAKE_ARGS+=	LDFLAGS="${HOST_LDSTATIC} -all-static"
 .endif

 .if ${MAKEVERBOSE} == 0
Index: share/mk/bsd.host.mk
===================================================================
RCS file: /cvs/master/m-NetBSD/main/src/share/mk/bsd.host.mk,v
retrieving revision 1.5
diff -u -r1.5 bsd.host.mk
--- share/mk/bsd.host.mk	9 Aug 2020 21:13:38 -0000	1.5
+++ share/mk/bsd.host.mk	8 Sep 2024 23:27:44 -0000
@@ -16,18 +16,18 @@

 # Helpers for cross-compiling
 HOST_CC?=	cc
-HOST_CFLAGS?=	${HOST_DBG}
+HOST_CFLAGS?=	${HOST_DBG} -std=gnu99 -Wno-everything
 HOST_COMPILE.c?=${HOST_CC} ${HOST_CFLAGS} ${HOST_DTRACE_OPTS} ${HOST_CPPFLAGS} -c
 HOST_COMPILE.cc?=      ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_DTRACE_OPTS} ${HOST_CPPFLAGS} -c
 HOST_LINK.cc?=  ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS}
 .if defined(HOSTPROG_CXX)
 HOST_LINK.c?=   ${HOST_LINK.cc}
 .else
-HOST_LINK.c?=	${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS}
+HOST_LINK.c?=	${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} ${HOST_LDSTATIC} ${HOST_LDFLAGS}
 .endif

 HOST_CXX?=	c++
-HOST_CXXFLAGS?=	${HOST_DBG}
+HOST_CXXFLAGS?=	${HOST_DBG} -std=gnu++14 -Wno-everything

 HOST_CPP?=	cpp
 HOST_CPPFLAGS?=


--
					Greg A. Woods <gwoods%acm.org@localhost>

Kelowna, BC     +1 250 762-7675           RoboHack <woods%robohack.ca@localhost>
Planix, Inc. <woods%planix.com@localhost>     Avoncote Farms <woods%avoncote.ca@localhost>

c++ -fno-PIE -c   -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -fno-strict-aliasing -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings   -DHAVE_CONFIG_H -I. -I. -I/Volumes/work/woods/m-NetBSD-current/tools/gcc/../../external/gpl3/gcc/dist/gcc -I/Volumes/work/woods/m-NetBSD-current/tools/gcc/../../external/gpl3/gcc/dist/gcc/. -I/Volumes/work/woods/m-NetBSD-current/tools/gcc/../../external/gpl3/gcc/dist/gcc/../include -I/Volumes/work/woods/m-NetBSD-current/tools/gcc/../../external/gpl3/gcc/dist/gcc/../libcpp/include -I/Users/woods/build/woods/very.local/current-x86_64-amd64-tools/include -I/Users/woods/build/woods/very.local/current-x86_64-amd64-tools/include -I/Users/woods/build/woods/very.local/current-x86_64-amd64-tools/include  -I/Volumes/work/woods/m-NetBSD-current/tools/gcc/../../external/gpl3/gcc/dist/gcc/.
 ./libdecnumber -I/Volumes/work/woods/m-NetBSD-current/tools/gcc/../../external/gpl3/gcc/dist/gcc/../libdecnumber/dpd -I../libdecnumber -I/Volumes/work/woods/m-NetBSD-current/tools/gcc/../../external/gpl3/gcc/dist/gcc/../libbacktrace  -DNETBSD_TOOLS -DTARGET_SYSTEM_ROOT=0  -DTARGET_SYSTEM_ROOT_RELOCATABLE -o gcov.o -MT gcov.o -MMD -MP -MF ./.deps/gcov.TPo /Volumes/work/woods/m-NetBSD-current/tools/gcc/../../external/gpl3/gcc/dist/gcc/gcov.c
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
In file included from /Volumes/work/woods/m-NetBSD-current/tools/gcc/../../external/gpl3/gcc/dist/gcc/gcov.c:39:
In file included from /Volumes/work/woods/m-NetBSD-current/tools/gcc/../../external/gpl3/gcc/dist/gcc/system.h:233:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/map:2529:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:526:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/boyer_moore_searcher.h:27:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/vector:321:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__format/formatter_bool.h:20:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__format/formatter_integral.h:32:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/locale:202:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__locale:550:5: error: '__abi_tag__' attribute only applies to structs, variables, functions, and namespaces
    _LIBCPP_INLINE_VISIBILITY
    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:891:37: note: expanded from macro '_LIBCPP_INLINE_VISIBILITY'
#  define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
                                    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:870:26: note: expanded from macro '_LIBCPP_HIDE_FROM_ABI'
          __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE))))
                         ^
In file included from /Volumes/work/woods/m-NetBSD-current/tools/gcc/../../external/gpl3/gcc/dist/gcc/gcov.c:39:
In file included from /Volumes/work/woods/m-NetBSD-current/tools/gcc/../../external/gpl3/gcc/dist/gcc/system.h:233:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/map:2529:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:526:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/boyer_moore_searcher.h:27:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/vector:321:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__format/formatter_bool.h:20:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__format/formatter_integral.h:32:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/locale:202:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__locale:551:37: error: expected ';' at end of declaration list
    char_type toupper(char_type __c) const
                                    ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__locale:557:48: error: too many arguments provided to function-like macro invocation
    const char_type* toupper(char_type* __low, const char_type* __high) const
                                               ^
/Volumes/work/woods/m-NetBSD-current/tools/gcc/../../external/gpl3/gcc/dist/gcc/../include/safe-ctype.h:146:9: note: macro 'toupper' defined here
#define toupper(c) do_not_use_toupper_with_safe_ctype
        ^

Attachment: pgpj0GZpxxqxR.pgp
Description: OpenPGP Digital Signature



Home | Main Index | Thread Index | Old Index