Opened 6 months ago

Last modified 6 months ago

#68659 new defect

mips-elf-gcc @3.4.6_0: fails to build due to implicit declaration of abort()

Reported by: nneonneo (Robert Xiao) Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.8.1
Keywords: catalina bigsur monterey ventura sonoma Cc:
Port: mips-elf-gcc

Description (last modified by nneonneo (Robert Xiao))

mips-elf-gcc fails to build on macOS 13.6.1 (Xcode 15.0.1), x86-64. The problem is an implicit declaration of abort:

In file included from /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_cross_mips-elf-gcc/mips-elf-gcc/work/gcc-3.4.6/libiberty/regex.c:649:
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_cross_mips-elf-gcc/mips-elf-gcc/work/gcc-3.4.6/libiberty/regex.c:4898:11: error: call to undeclared library function 'abort' with type 'void (void) __attribute__((noreturn))'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
          abort (); /* We have listed all the cases.  */
          ^
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_cross_mips-elf-gcc/mips-elf-gcc/work/gcc-3.4.6/libiberty/regex.c:4898:11: note: include the header <stdlib.h> or explicitly provide a declaration for 'abort'

The header stdlib.h is not being included because STDC_HEADERS is not defined, and abort is not prototyped for some reason.

Easy fix is probably to define STDC_HEADERS in config.h.

Full build log attached.

Attachments (1)

main.log (417.5 KB) - added by nneonneo (Robert Xiao) 6 months ago.
main.log from building mips-elf-gcc: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_cross_mips-elf-gcc/mips-elf-gcc/main.log

Download all attachments as: .zip

Change History (4)

Changed 6 months ago by nneonneo (Robert Xiao)

Attachment: main.log added

main.log from building mips-elf-gcc: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_cross_mips-elf-gcc/mips-elf-gcc/main.log

comment:1 Changed 6 months ago by nneonneo (Robert Xiao)

Description: modified (diff)

comment:2 Changed 6 months ago by nneonneo (Robert Xiao)

Got a successful build with the following changes:

  • Configure with CC='/usr/bin/clang -Wno-error=implicit-function-declaration' and with CXXFLAGS='-Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk' (note: *no* -stdlib=libc++ in CXXFLAGS!)
  • Build with CPATH unset
  • I made a few other small changes, but those shouldn't have been required to actually make things work.

We need -Wno-error=implicit-function-declaration to get STDC_HEADERS defined and fix many errors while building this old GCC; notably, we cannot put the flag in CFLAGS because otherwise it would be picked up while cross-compiling the target libraries, and the target GCC doesn't understand this flag. Similarly, we cannot have -stdlib=libc++ (and probably shouldn't even have -isysroot) in CXXFLAGS as the target GCC doesn't understand -stdlib. More generally, we should probably be configuring the host and target separately so we can have different CFLAGS/CXXFLAGS for them.

We also need to unset CPATH because it gets picked up during cross-compilation, and will cause the compiler to look for target headers in /opt/local/include which breaks the build.

comment:3 Changed 6 months ago by ryandesign (Ryan Carsten Schmidt)

Keywords: catalina bigsur monterey ventura sonoma added
Port: mips-elf-gcc added

See WimplicitFunctionDeclaration. Using -Wno-error=implicit-function-declaration is not recommended. If no other solution is possible, then you probably also want to set supported_archs to a value that does not include arm64.

Can these problems be fixed by upgrading the port to a newer version? Livecheck seems to think one is available:

% port livecheck mips-elf-gcc
mips-elf-gcc seems to have been updated (port version: 3.4.6, new version: 4.9.4)
Note: See TracTickets for help on using tickets.