Opened 8 months ago
Last modified 8 months ago
#69631 new defect
gcc-devel does not build on Sonoma: error: call to undeclared function 'dup2'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
Reported by: | barracuda156 | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.9.1 |
Keywords: | sonoma | Cc: | |
Port: | gcc-devel |
Description
/usr/bin/clang -arch arm64 -c -DHAVE_CONFIG_H -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -I. -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_gcc-devel/libgcc-devel/work/gcc-14-20240303/libiberty/../include -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic -D_GNU_SOURCE /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_gcc-devel/libgcc-devel/work/gcc-14-20240303/libiberty/fibheap.c -o fibheap.o yes checking whether /usr/bin/clang -arch arm64 supports -Wold-style-definition... /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_gcc-devel/libgcc-devel/work/gcc-14-20240303/libiberty/filedescriptor.c:45:10: error: call to undeclared function 'dup2'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] return dup2 (fd, fd) < 0; ^ 1 warning and 1 error generated. make[3]: *** [filedescriptor.o] Error 1 make[3]: *** Waiting for unfinished jobs.... warning: unknown warning option '-Wshadow=local' [-Wunknown-warning-option] 1 warning generated. yes checking whether /usr/bin/clang -arch arm64 supports -Wc++-compat... 1 warning generated. make[3]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_gcc-devel/libgcc-devel/work/build/build-arm64-apple-darwin23/libiberty' make[2]: *** [all-build-libiberty] Error 2
Same error with the latest snapshot of gcc14:
opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_lang_gcc-devel/libgcc-devel/work/gcc-14-20240324/libiberty/filedescriptor.c:45:10: error: call to undeclared function 'dup2'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] return dup2 (fd, fd) < 0; ^ 1 warning and 1 error generated. make[3]: *** [filedescriptor.o] Error 1 make[3]: *** Waiting for unfinished jobs.... 1 warning generated.
Change History (2)
comment:1 Changed 8 months ago by ryandesign (Ryan Carsten Schmidt)
comment:2 Changed 8 months ago by ryandesign (Ryan Carsten Schmidt)
In addition, the problem may be that the earlier #elif defined(F_GETFD)
path isn't being taken. On my macOS 12 SDK I see F_GETFD
is defined in <fcntl.h> which filedescriptor.c does include but only if HAVE_FCNTL_H
is defined. Maybe there is a bug in the configure script test and HAVE_FCNTL_H
isn't getting defined; check your config.log.
Note: See
TracTickets for help on using
tickets.
POSIX says
dup2
is in <unistd.h> but I don't see that header included by libiberty/filedescriptor.c. You could try adding that#include
and see if it solves the problem. It looks like this code was moved to filedescriptor.c from another file 4.5 years ago, and that other file did include <unistd.h>. In any case, it's probably an upstream problem that needs to be reported the developers of gcc.