I have been able to build every gcc release from 8 to 12.2 on both CentOS6 and CentOS 7 w/o problem including 12.1. However, 12.2 fails to compile libiberty/objdump.c due to "PTR" not being defined. I tried compiling with 10.2, 11.3 and 12.1 w/o success However, a big change was recently checked into libiberty that eliminates the PTR macro, but 12.2 does not include it. I can confirm that this diff works correctly https://github.com/gcc-mirror/gcc/commit/50b009c5daef92bc60fc26fcc4c495e117667387.patch
filename is likely wrong - I did this 2 days ago and lost the log output. 100% consistent on 2 different build systems/OS though
Without seeing a build log on what exactly fails there is nothing we can do about it, applying the [PATCH] libiberty: stop using PTR macro change is not the right fix if anything needs to be fixed at all. Note, there were no changes whatsoever in include/ or libiberty/ directories except for a 12.2.0 release added ChangeLog entry, so I somehow can't believe 12.1 worked fine and 12.2 doesn't if nothing else changed.
We have been using the same build setup for the last 20 years and this is the 1st gcc failure :) We build EVERYTHING in a self contained fashion and don't rely on any OS libraries except libc.so. I don't know what file normally defines PTR, but someone else must have run into this for the patch to have been checked in Below log is from a CentOS 7 compile using gcc 12.1 /tools/arch/Linux_3.10.0-x86_64/gcc-12.1.0-bootstrap/bin/gcc -c -DHAVE_CONFIG_H -fPIC -pipe -DNDEBUG -Wno-error=unused-value -Wno-unused-variable -I/tools/arch/Linux_3.10.0-x86_64/gcc-12.1.0-bootstrap//include -I. -I/var/tmp/gcc-12.2.0-bootstrap/gcc-12.2.0/libiberty/../include -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic -D_GNU_SOURCE -fcf-protection /var/tmp/gcc-12.2.0-bootstrap/gcc-12.2.0/libiberty/objalloc.c -o objalloc.o /var/tmp/gcc-12.2.0-bootstrap/gcc-12.2.0/libiberty/objalloc.c: In function ‘objalloc_create’: /var/tmp/gcc-12.2.0-bootstrap/gcc-12.2.0/libiberty/objalloc.c:95:18: error: ‘PT’ undeclared (first use in this function) 95 | ret->chunks = (PTR) malloc (CHUNK_SIZE); | ^~~ /var/tmp/gcc-12.2.0-bootstrap/gcc-12.2.0/libiberty/objalloc.c:95:18: note: each undeclared identifier is reported only once for each function it appears in /var/tmp/gcc-12.2.0-bootstrap/gcc-12.2.0/libiberty/objalloc.c:95:22: error: expected ‘;’ before ‘malloc’ 95 | ret->chunks = (PTR) malloc (CHUNK_SIZE); | ^~~~~~~ | ; /var/tmp/gcc-12.2.0-bootstrap/gcc-12.2.0/libiberty/objalloc.c: At top level: /var/tmp/gcc-12.2.0-bootstrap/gcc-12.2.0/libiberty/objalloc.c:114:1: error: unknown type name ‘PTR’ 114 | PTR | ^~~ /var/tmp/gcc-12.2.0-bootstrap/gcc-12.2.0/libiberty/objalloc.c:115:1: error: conflicting types for ‘_objalloc_alloc’; have ‘int(struct objalloc *, long unsigned int)’ 115 | _objalloc_alloc (struct objalloc *o, unsigned long original_len) | ^~~~~~~~~~~~~~~
one other comment. all the gcc prereqs are the latest available releases - every 3rd party package is built by us from the most up-to-date versions
include/ansidecl.h has: #if defined (__STDC__) || defined(__cplusplus) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32) ... #define PTR void * ... #else /* Not ANSI C. */ #define PTR char * ... #endif So, can you rerun the above command line with -E -dD instead of -c and -o objalloc.i instead of -o objalloc.o ?
Where does the: -I/tools/arch/Linux_3.10.0-x86_64/gcc-12.1.0-bootstrap//include come there? If it e.g. contains glibc fixincluded ansidecl.h, then that could explain why it breaks. But you don't want to use your build compiler's include directories in preference over the build tree ones.
i was playing w/ cmdline and had deleted an extra arg. the 12.2 path is before the 12.1 path. However, our build scripts include the correct gcc header dir to all configure lines to ensure we don't pull in the system gcc headers. This causes 12.2 to include the source include dir (var/tmp...) last instead of first It is strange that this only fails for 12.2. I rebuilt 12.1 yesterday w/o issue so did something change in Makefile.in or a configure script that changed the include order? I can confirm that removing the original gcc include paths from the compile works correctly fail: /tools/arch/Linux_3.10.0-x86_64/gcc-12.1.0-bootstrap/bin/gcc -c -DHAVE_CONFIG_H -fPIC -O3 -pipe -DNDEBUG -Wno-error=unused-value -Wno-unused-variable -I/tools/arch/Linux_3.10.0-x86_64/gcc-12.2.0-bootstrap/include -I/tools/arch/Linux_3.10.0-x86_64/gcc-12.1.0-bootstrap//include -I. -I/var/tmp/gcc-12.2.0-bootstrap/gcc-12.2.0/libiberty/../include -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic -D_GNU_SOURCE -fcf-protection /var/tmp/gcc-12.2.0-bootstrap/gcc-12.2.0/libiberty/objalloc.c -o objalloc.o succeed: /tools/arch/Linux_3.10.0-x86_64/gcc-12.1.0-bootstrap/bin/gcc -c -DHAVE_CONFIG_H -fPIC -O3 -pipe -ffunction-sections -fdata-sections -march=nehalem -mtune=broadwell -DNDEBUG -Wno-error=unused-value -Wno-unused-variable -I. -I/var/tmp/gcc-12.2.0-bootstrap/gcc-12.2.0/libiberty/../include -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic -D_GNU_SOURCE -fcf-protection /var/tmp/gcc-12.2.0-bootstrap/gcc-12.2.0/libiberty/objalloc.c -o objalloc.o
(In reply to Todd Richmond from comment #0) > I have been able to build every gcc release from 8 to 12.2 on both CentOS6 > and CentOS 7 w/o problem including 12.1. However, 12.2 fails to compile > libiberty/objdump.c due to "PTR" not being defined. I tried compiling with > 10.2, 11.3 and 12.1 w/o success > > However, a big change was recently checked into libiberty that eliminates > the PTR macro, but 12.2 does not include it. I can confirm that this diff > works correctly > > https://github.com/gcc-mirror/gcc/commit/ > 50b009c5daef92bc60fc26fcc4c495e117667387.patch cc-ing author of this patch
So this is a clear bug in your build scripts then. You just can't add -I options that to configure/make variables where it will override -I paths added during the build, the build compilers paths need to always come after the other paths (and that is what happens by default, compiler always searches its own paths unless -nostdinc or -nostdinc++). Don't do it and it will build fine.