Re: official lang/gcc14 package builds are broken, at least for armv7: "error: attempt to use a poisoned identifier" and more

From: Mark Millard <marklmi_at_yahoo.com>
Date: Fri, 20 Sep 2024 03:29:25 UTC
On Sep 17, 2024, at 20:19, Mark Millard <marklmi@yahoo.com> wrote:

> On Sep 17, 2024, at 11:40, Dimitry Andric <dim@FreeBSD.org> wrote:
> 
>> This is because of gcc's weird identifier poisoning system, and them not correctly marking all used standard C++ headers for inclusion before the poisoning takes place.
>> 
>> Try the attached patch, which I have been using for a long time now (months, at least since the bootstrap options were deleted, but which I reverted locally).
>> 
>> -Dimitry
>> 
>> <lang__gcc14-devel-fix-plugins-1.diff>
>> 
>>> On 17 Sep 2024, at 16:24, Mark Millard <marklmi@yahoo.com> wrote:
>>> 
>>> Also: no member named 'fancy_abort' in namespace 'std'
>>> 
>>> Such is associated with not using STANDARD_BOOTSTRAP for armv7, given GCC's historic lack of keeping builds of everything working for just direct use of clang++/libc++ or the like.
>>> 
>>> The specific change that got back into this issue was:
>>> 
>>> -LANGUAGES:= c,c++,objc,fortran
>>> +LANGUAGES:= c,c++,objc,fortran,jit
>>> 
>>> It is the jit part of the build that fails to build as stands.
>>> 
>>> See:
>>> 
>>> https://pkg-status.freebsd.org/ampere2/data/main-armv7-default/p13f486017d78_s3df987c99/logs/errors/gcc14-14.2.0_1.log
>>> 
>>> Example:
>>> 
>>> In file included from /wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/gcc/jit/dummy-frontend.cc:23:
>>> In file included from /wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/gcc/jit/jit-playback.h:24:
>>> In file included from /usr/include/c++/v1/string:594:
>>> In file included from /usr/include/c++/v1/__memory_resource/polymorphic_allocator.h:20:
>>> In file included from /usr/include/c++/v1/tuple:1455:
>>> In file included from /usr/include/c++/v1/exception:82:
>>> /usr/include/c++/v1/__exception/exception_ptr.h:111:3: error: no member named 'fancy_abort' in namespace 'std'; did you mean simply 'fancy_abort'?
>>> 111 | std::abort();
>>> | ^~~~~
>>> /wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/gcc/system.h:808:13: note: 'fancy_abort' declared here
>>> 808 | extern void fancy_abort (const char *, int, const char *)
>>> | ^
>>> In file included from /wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/gcc/jit/dummy-frontend.cc:23:
>>> In file included from /wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/gcc/jit/jit-playback.h:26:
>>> In file included from /usr/include/c++/v1/vector:325:
>>> In file included from /usr/include/c++/v1/__format/formatter_bool.h:20:
>>> In file included from /usr/include/c++/v1/__format/formatter_integral.h:35:
>>> /usr/include/c++/v1/locale:288:32: error: attempt to use a poisoned identifier
>>> 288 | __status = (unsigned char*)malloc(__nkw);
>>> | ^
>>> /usr/include/c++/v1/locale:1385:24: error: attempt to use a poisoned identifier
>>> 1385 | __ob = (char_type*)malloc(2 * static_cast<size_t>(__nc) * sizeof(char_type));
>>> | ^
>>> /usr/include/c++/v1/locale:2429:31: error: attempt to use a poisoned identifier
>>> 2429 | _Tp* __t = (_Tp*)std::realloc(__owns ? __b.get() : 0, __new_cap);
>>> | ^
>>> /usr/include/c++/v1/locale:2632:24: error: attempt to use a poisoned identifier
>>> 2632 | __h.reset((char*)malloc(static_cast<size_t>(__wn - __wb.get() + 2)));
>>> | ^
>>> /usr/include/c++/v1/locale:2910:28: error: attempt to use a poisoned identifier
>>> 2910 | __hd.reset((char_type*)malloc(static_cast<size_t>(__n) * sizeof(char_type)));
>>> | ^
>>> /usr/include/c++/v1/locale:2936:28: error: attempt to use a poisoned identifier
>>> 2936 | __hw.reset((char_type*)malloc(__exn * sizeof(char_type)));
>>> | ^
>>> /usr/include/c++/v1/locale:2974:27: error: attempt to use a poisoned identifier
>>> 2974 | __h.reset((char_type*)malloc(__exn * sizeof(char_type)));
>>> | ^
>>> 
> 
> In my environment (that somewhat predates the change that made the
> ampere2 based build fail), I set up a poudriere-devel test for
> lang/gcc14 ( not lang/gcc14-devel ):
> 
> # poudriere ports -l
> PORTSTREE METHOD TIMESTAMP           PATH
> default   null   2021-04-18 02:05:47 /usr/ports
> 
> # ~/fbsd-based-on-what-commit.sh -C /usr/ports/
> d13cce06daa6 (HEAD -> main, freebsd/main, freebsd/HEAD) graphics/gmic-qt: Update to 3.4.1
> Author:     Jason E. Hale <jhale@FreeBSD.org>
> Commit:     Jason E. Hale <jhale@FreeBSD.org>
> CommitDate: 2024-09-02 04:05:53 +0000
> branch: main
> merge-base: d13cce06daa6361cdbd6b97b768ab80aa60b8677
> merge-base: CommitDate: 2024-09-02 04:05:53 +0000
> n675562 (--first-parent --count for merge-base)
> 
> (Note: I've made no commits.)
> 
> # git -C /usr/ports/ status lang/gcc14
> On branch main
> Your branch is up to date with 'freebsd/main'.
> 
> Changes not staged for commit:
>  (use "git add <file>..." to update what will be committed)
>  (use "git restore <file>..." to discard changes in working directory)
> modified:   lang/gcc14/Makefile
> 
> Untracked files:
>  (use "git add <file>..." to include in what will be committed)
> lang/gcc14/files/patch-gcc_jit_dummy-frontend.cc
> lang/gcc14/files/patch-gcc_jit_jit-builtins.cc
> lang/gcc14/files/patch-gcc_jit_jit-playback.cc
> lang/gcc14/files/patch-gcc_jit_jit-recording.cc
> lang/gcc14/files/patch-gcc_jit_libgccjit.cc
> 
> no changes added to commit (use "git add" and/or "git commit -a")
> 
> (Note, below the whitespace details might not be preserved,
> so the text is only suggestive.)
> 
> # git -C /usr/ports/ diff lang/gcc14
> diff --git a/lang/gcc14/Makefile b/lang/gcc14/Makefile
> index 53bac89a7f14..17029847fa7c 100644
> --- a/lang/gcc14/Makefile
> +++ b/lang/gcc14/Makefile
> @@ -73,7 +73,7 @@ CONFIGURE_TARGET=     x86_64-portbld-${OPSYS:tl}${OSREL}
> CONFIGURE_ARGS+=       --with-abi=elfv2
> .endif
> 
> -LANGUAGES:=    c,c++,objc,fortran
> +LANGUAGES:=    c,c++,objc,fortran,jit
> TARGLIB=       ${PREFIX}/lib/gcc${SUFFIX}
> TARGLIB32=     ${PREFIX}/lib32 # The version information is added later
> LIBEXEC=       ${PREFIX}/libexec/gcc${SUFFIX}
> 
> And, from the content of your patch:
> 
> # head -30 /usr/ports/lang/gcc14/files/patch-gcc_jit_*.cc
> ==> /usr/ports/lang/gcc14/files/patch-gcc_jit_dummy-frontend.cc <==
> --- gcc/jit/dummy-frontend.cc.orig 2024-01-14 22:32:46 UTC
> +++ gcc/jit/dummy-frontend.cc
> @@ -18,6 +18,8 @@ along with GCC; see the file COPYING3.  If not see
> <http://www.gnu.org/licenses/>.  */
> 
> #include "config.h"
> +#define INCLUDE_STRING
> +#define INCLUDE_VECTOR
> #include "system.h"
> 
> ==> /usr/ports/lang/gcc14/files/patch-gcc_jit_jit-builtins.cc <==
> --- gcc/jit/jit-builtins.cc.orig 2024-01-14 22:32:46 UTC
> +++ gcc/jit/jit-builtins.cc
> @@ -18,6 +18,8 @@ along with GCC; see the file COPYING3.  If not see
> <http://www.gnu.org/licenses/>.  */
> 
> #include "config.h"
> +#define INCLUDE_STRING
> +#define INCLUDE_VECTOR
> #include "system.h"
> #include "coretypes.h"
> #include "target.h"
> 
> ==> /usr/ports/lang/gcc14/files/patch-gcc_jit_jit-playback.cc <==
> --- gcc/jit/jit-playback.cc.orig 2024-01-14 22:32:46 UTC
> +++ gcc/jit/jit-playback.cc
> @@ -20,6 +20,8 @@ along with GCC; see the file COPYING3.  If not see
> 
> #include "config.h"
> #define INCLUDE_MUTEX
> +#define INCLUDE_STRING
> +#define INCLUDE_VECTOR
> #include "libgccjit.h"
> #include "system.h"
> #include "coretypes.h"
> 
> ==> /usr/ports/lang/gcc14/files/patch-gcc_jit_jit-recording.cc <==
> --- gcc/jit/jit-recording.cc.orig 2024-01-14 22:32:46 UTC
> +++ gcc/jit/jit-recording.cc
> @@ -20,6 +20,8 @@ along with GCC; see the file COPYING3.  If not see
> 
> #include "config.h"
> #define INCLUDE_SSTREAM
> +#define INCLUDE_STRING
> +#define INCLUDE_VECTOR
> #include "system.h"
> #include "coretypes.h"
> #include "tm.h"
> 
> ==> /usr/ports/lang/gcc14/files/patch-gcc_jit_libgccjit.cc <==
> /jit/libgccjit.cc.orig 2024-01-14 22:32:46 UTC
> +++ gcc/jit/libgccjit.cc
> @@ -20,6 +20,8 @@ along with GCC; see the file COPYING3.  If not see
> 
> #include "config.h"
> #define INCLUDE_MUTEX
> +#define INCLUDE_STRING
> +#define INCLUDE_VECTOR
> #include "system.h"
> #include "coretypes.h"
> #include "timevar.h"
> 
> The result for poudriere bulk lang/gcc14 was:
> 
> [00:06:55] [01] [00:00:00] Building   lang/gcc14 | gcc14-14.2.0
> [00:28:00] [01] [00:21:05] Finished   lang/gcc14 | gcc14-14.2.0: Success ending TMPFS: 1.61 GiB
> 
> So it looks like adding your files/patch-gcc_jit_*.cc
> files to lang/gcc14 would allow the ampere2 builds
> of lang/gcc14 for armv7 to work without use of
> STANDARD_BOOTSTRAP (at least for now).
> 
> 
> ( The "ending TMPFS: . . . GiB" is something I add to
> poudirere for helping to find packages that I might
> want to add to TMPFS_BLACKLIST .)
> 
> 
> The context has:
> 
> # poudriere jail -jmain-armv7 -i
> Jail name:         main-armv7
> Jail version:      15.0-CURRENT
> Jail arch:         armv7
> Jail method:       pkgbase
> Jail mount:        /usr/local/poudriere/jails/main-armv7-poud
> Jail fs:            Jail updated:      2024-08-27 21:47:56
> Jail pkgbase:      disabled
> 
> The pkgbase system for the jail is from the official
> materials at the time it was last updated. It is
> not my personal world build at all.
> 

I just fetched an update to my /usr/ports/ on amd64 and
tried to build my ports  for amd64. It is my odd personal
environment. But it got failures building jit materials.
For example:

In file included from /wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/libstdc++-v3/include/bits/basic_ios.h:37,
                 from /wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/libstdc++-v3/include/std/ios:46,
                 from /wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/libstdc++-v3/include/std/istream:40,
                 from /wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/libstdc++-v3/include/std/sstream:40,
                 from /wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/gcc/system.h:774,
                 from /wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/gcc/jit/jit-recording.cc:25:
/wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/libstdc++-v3/include/bits/locale_facets.h:250:53: error: macro "toupper" passed 2 arguments, but takes just 1
  250 |       toupper(char_type *__lo, const char_type* __hi) const
      |                                                     ^
In file included from /wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/gcc/system.h:235:
/wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/gcc/../include/safe-ctype.h:146:9: note: macro "toupper" defined here
  146 | #define toupper(c) do_not_use_toupper_with_safe_ctype
      |         ^~~~~~~
/wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/libstdc++-v3/include/bits/locale_facets.h:279:53: error: macro "tolower" passed 2 arguments, but takes just 1
  279 |       tolower(char_type* __lo, const char_type* __hi) const
      |                                                     ^
/wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/gcc/../include/safe-ctype.h:148:9: note: macro "tolower" defined here
  148 | #define tolower(c) do_not_use_tolower_with_safe_ctype
      |         ^~~~~~~
/wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/libstdc++-v3/include/bits/locale_facets.h:827:53: error: macro "toupper" passed 2 arguments, but takes just 1
  827 |       toupper(char_type *__lo, const char_type* __hi) const
      |                                                     ^
/wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/gcc/../include/safe-ctype.h:146:9: note: macro "toupper" defined here
  146 | #define toupper(c) do_not_use_toupper_with_safe_ctype
      |         ^~~~~~~
/wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/libstdc++-v3/include/bits/locale_facets.h:860:53: error: macro "tolower" passed 2 arguments, but takes just 1
  860 |       tolower(char_type* __lo, const char_type* __hi) const
      |                                                     ^
/wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/gcc/../include/safe-ctype.h:148:9: note: macro "tolower" defined here
  148 | #define tolower(c) do_not_use_tolower_with_safe_ctype
      |         ^~~~~~~


In file included from /wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/libstdc++-v3/include/bits/basic_ios.h:37,
                 from /wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/libstdc++-v3/include/std/ios:46,
                 from /wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/libstdc++-v3/include/std/istream:40,
                 from /wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/libstdc++-v3/include/std/sstream:40,
                 from /wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/gcc/system.h:774,
                 from /wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/gcc/jit/jit-recording.cc:25:
/wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/libstdc++-v3/include/bits/locale_facets.h:250:53: error: macro "toupper" passed 2 arguments, but takes just 1
  250 |       toupper(char_type *__lo, const char_type* __hi) const
      |                                                     ^
In file included from /wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/gcc/system.h:235:
/wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/gcc/../include/safe-ctype.h:146:9: note: macro "toupper" defined here
  146 | #define toupper(c) do_not_use_toupper_with_safe_ctype
      |         ^~~~~~~
/wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/libstdc++-v3/include/bits/locale_facets.h:279:53: error: macro "tolower" passed 2 arguments, but takes just 1
  279 |       tolower(char_type* __lo, const char_type* __hi) const
      |                                                     ^
/wrkdirs/usr/ports/lang/gcc14/work/gcc-14.2.0/gcc/../include/safe-ctype.h:148:9: note: macro "tolower" defined here
  148 | #define tolower(c) do_not_use_tolower_with_safe_ctype
      |         ^~~~~~~
. . .

The context has the:

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	lang/gcc14/files/patch-gcc_jit_dummy-frontend.cc
	lang/gcc14/files/patch-gcc_jit_jit-builtins.cc
	lang/gcc14/files/patch-gcc_jit_jit-playback.cc
	lang/gcc14/files/patch-gcc_jit_jit-recording.cc
	lang/gcc14/files/patch-gcc_jit_libgccjit.cc

So these from your patch proved insufficient for this context.

(It will be a while before the aarch64 context gets to the
lang/gcc14 and its jit.)

===
Mark Millard
marklmi at yahoo.com