[MacPorts] #70331: gcc14 (c++) can not compile trivial program

MacPorts noreply at macports.org
Sun Jul 7 03:33:16 UTC 2024


#70331: gcc14 (c++) can not compile trivial program
----------------------+--------------------
  Reporter:  acmaggs  |      Owner:  (none)
      Type:  defect   |     Status:  new
  Priority:  Normal   |  Milestone:
 Component:  ports    |    Version:
Resolution:           |   Keywords:
      Port:  gcc14    |
----------------------+--------------------

Comment (by mouse07410):

 Also, GCC (starting with v12?) stopped working correctly (at least on
 more-or-less complex inputs) when {{{-stdlib=libc++}}} flag is given.

 {{{
 $ g++ -I/opt/local/include -std=c++20 -o t bs-main.cpp -L/opt/local/lib
 -lntl
 bs-main.cpp: In function 'HASHLIST* htNewExponent(int)':
 bs-main.cpp:81:39: warning: NULL used in arithmetic [-Wpointer-arith]
    81 |     if( ( newList->value = value ) == NULL ) {
       |                                       ^~~~
 Undefined symbols for architecture arm64:
   "NTL::operator>>(std::istream&, NTL::ZZ&)", referenced from:
 __ZN3NTL4convINS_2ZZEPKcEEN14_ntl_enable_ifIXsr20_ntl_is_char_pointerIT0_E5valueEvE4typeERT_S6_
 in ccGysLbd.o
 ld: symbol(s) not found for architecture arm64
 collect2: error: ld returned 1 exit status
 $ g++ -stdlib=libc++ -I/opt/local/include -std=c++20 -o t bs-main.cpp
 -L/opt/local/lib -lntl
 In file included from
 /opt/local/libexec/gcc12/libc++/include/c++/v1/new:99,
                  from /opt/local/include/NTL/new.h:5,
                  from /opt/local/include/NTL/tools.h:11,
                  from /opt/local/include/NTL/ZZ.h:19,
                  from bs-main.cpp:7:
 /opt/local/libexec/gcc12/libc++/include/c++/v1/cstdlib:144:9: error:
 'at_quick_exit' has not been declared in '::'
   144 | using ::at_quick_exit _LIBCPP_USING_IF_EXISTS;
       |         ^~~~~~~~~~~~~
 /opt/local/libexec/gcc12/libc++/include/c++/v1/cstdlib:145:9: error:
 'quick_exit' has not been declared in ::'
   145 | using ::quick_exit _LIBCPP_USING_IF_EXISTS;
       |         ^~~~~~~~~~
 bs-main.cpp: In function 'HASHLIST* htNewExponent(int)':
 bs-main.cpp:81:39: warning: NULL used in arithmetic [-Wpointer-arith]
    81 |     if( ( newList->value = value ) == NULL ) {
       |                                       ^~~~
 $
 $ g++ -v
 Using built-in specs.
 COLLECT_GCC=g++
 COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/arm64-apple-darwin23/12.4.0
 /lto-wrapper
 Target: arm64-apple-darwin23
 Configured with:
 /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_gcc12/gcc12/work/gcc-12.4.0/configure
 --prefix=/opt/local --build=arm64-apple-darwin23 --enable-
 languages=c,c++,objc,obj-c++,lto,fortran,jit --libdir=/opt/local/lib/gcc12
 --includedir=/opt/local/include/gcc12 --infodir=/opt/local/share/info
 --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-12
 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-
 suffix=-mp-12 --with-gxx-include-dir=/opt/local/include/gcc12/c++/ --with-
 gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-
 isl=/opt/local --with-zstd=/opt/local --enable-checking=release --disable-
 multilib --enable-lto --enable-libstdcxx-time --with-build-config
 =bootstrap-debug --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld-
 classic --with-ar=/opt/local/bin/ar --with-
 bugurl=https://trac.macports.org/newticket --enable-host-shared --with-
 darwin-extra-rpath=/opt/local/lib/libgcc --with-libiconv-prefix=/opt/local
 --disable-tls --with-gxx-libcxx-include-
 dir=/opt/local/libexec/gcc12/libc++/include/c++/v1 --with-
 pkgversion='MacPorts gcc12 12.4.0_0+stdlib_flag' --with-
 sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk
 Thread model: posix
 Supported LTO compression algorithms: zlib zstd
 gcc version 12.4.0 (MacPorts gcc12 12.4.0_0+stdlib_flag)
 $
 }}}

 Since all the Macports-installed libraries (like NTL in this case) are in
 libc++ format, inability to support it is a show-stopper for GCC use.

 Needless to say, Clang++ works fine:
 {{{
 $ clang++ -I/opt/local/include -std=c++20 -o t bs-main.cpp
 -L/opt/local/lib -lntl
 bs-main.cpp:81:36: warning: comparison between NULL and non-pointer ('int'
 and NULL) [-Wnull-arithmetic]
     if( ( newList->value = value ) == NULL ) {
         ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~
 1 warning generated.
 $ ./t
 Building hashtable...

 Collisions:11695

 Time: 0.327223 sec
 Searching for collision...
 715969 * B + 262758 = x

 Time: 0.252635 sec
 ^C
 $
 }}}

-- 
Ticket URL: <https://trac.macports.org/ticket/70331#comment:14>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list