Opened 13 months ago

Last modified 3 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: hohle (Jonathan Hohle), cooljeanius (Eric Gallager)
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 (2)

main.log (417.5 KB) - added by nneonneo (Robert Xiao) 13 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
mips-elf-gcc.zip (7.2 KB) - added by nneonneo (Robert Xiao) 6 months ago.
new portfile and patches

Download all attachments as: .zip

Change History (11)

Changed 13 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 13 months ago by nneonneo (Robert Xiao)

Description: modified (diff)

comment:2 Changed 13 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 13 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)

comment:4 Changed 6 months ago by hohle (Jonathan Hohle)

Cc: hohle added

comment:5 in reply to:  2 Changed 6 months ago by hohle (Jonathan Hohle)

Replying to nneonneo:

Do you have a patched Portfile or did you build outside Macports?

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

I very hackily rebuilt it using the in-progress MacPorts build directory. Definitely not a long-term strategy, but it works for me.

I guess that a newer GCC might help, although 4.9.4 is still very old and will still probably suffer from some of these issues.

@ryandesign: for this port, -Werror=implicit-function-declaration straight up breaks the build because some files just use functions without including the appropriate header file. (It’s very old C code). So I don’t think there’s a good way around this besides disabling the warning/error.

comment:7 in reply to:  6 Changed 6 months ago by ryandesign (Ryan Carsten Schmidt)

Replying to nneonneo:

-Werror=implicit-function-declaration straight up breaks the build because some files just use functions without including the appropriate header file. (It’s very old C code).

I am aware of that. The correct way to fix it is described in the WimplicitFunctionDeclaration wiki page.

Changed 6 months ago by nneonneo (Robert Xiao)

Attachment: mips-elf-gcc.zip added

new portfile and patches

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

I've attached a modified Portfile and a set of patches which successfully builds mips-elf-gcc.

comment:9 Changed 3 months ago by cooljeanius (Eric Gallager)

Cc: cooljeanius added
Note: See TracTickets for help on using tickets.