Skip to content

erts/configure does not detect poll() correctly when gcc 14 is used #9211

@lukebakken

Description

@lukebakken

Describe the bug
When using gcc version 14, several classes of warning are now considered errors, by default. The erts/configure script fails to detect poll because of missing include statements and return type for main:

https://github.com/erlang/otp/blob/master/erts/configure.ac#L3127-L3166

On Alpine Linux 3.21, which uses gcc 14.2.0, that check mistakenly fails due to these new compiler errors. Here is the complete erts/config.log from my Alpine 3.21 environment: https://github.com/lukebakken/docker-library-rabbitmq-749/blob/main/config.log

erts/config.log output
configure:25889: gcc -o conftest -fno-strict-aliasing -fno-common -g -O2 -Wl,-rpath=/opt/openssl/lib -I/usr/local/src/otp-27.2/erts/x86_64-pc-linux-musl   -D_GNU_SOURCE  conftest.c -lutil -ldl -lm   >&5
conftest.c:258:1: error: return type defaults to 'int' [-Wimplicit-int]
  258 | main()
      | ^~~~
conftest.c: In function 'main':
conftest.c:265:8: error: implicit declaration of function 'open' [-Wimplicit-function-declaration]
  265 |   fd = open("/dev/null", 1);
      |        ^~~~
conftest.c:270:5: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration]
  270 |     exit(1);  /* Does not work for devices -- fail */
      |     ^~~~
conftest.c:258:1: note: include '<stdlib.h>' or provide a declaration of 'exit'
  257 | #include <poll.h>
  +++ |+#include <stdlib.h>
  258 | main()
conftest.c:270:5: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
  270 |     exit(1);  /* Does not work for devices -- fail */
      |     ^~~~
conftest.c:270:5: note: include '<stdlib.h>' or provide a declaration of 'exit'
conftest.c:272:3: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
  272 |   exit(0);
      |   ^~~~
conftest.c:272:3: note: include '<stdlib.h>' or provide a declaration of 'exit'
configure:25889: $? = 1
configure: program exited with status 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define ASSUMED_CACHE_LINE_SIZE 64
| #define ERTS_ENABLE_MSACC 2
| #define ERTS_NO_RETPOLINE 
| #define HAVE_STDIO_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_SYS_TIME_H 1
| #define STDC_HEADERS 1
| #define SIZEOF_TIME_T 8
| #define SIZEOF_VOID_P 8
| #define HAVE_LIBM 1
| #define HAVE_LIBDL 1
| #define HAVE_LIBUTIL 1
| #define ETHR_TRUST_GCC_ATOMIC_BUILTINS_MEMORY_BARRIERS 0
| #define SIZEOF_VOID_P 8
| #define HAVE_PTHREAD_H 1
| #define HAVE_CLOCK_GETRES 1
| #define ETHR_HAVE_CLOCK_GETTIME_MONOTONIC 1
| #define ETHR_MONOTONIC_CLOCK_ID CLOCK_MONOTONIC
| #define ETHR_PTHREADS 1
| #define ETHR_HAVE_PTHREAD_H 1
| #define ETHR_HAVE_SCHED_H 1
| #define ETHR_HAVE_SYS_TIME_H 1
| #define ETHR_HAVE_USABLE_PTHREAD_STACK_MIN 1
| #define ETHR_HAVE_PTHREAD_SPIN_LOCK 1
| #define ETHR_HAVE_SCHED_YIELD 1
| #define ETHR_SCHED_YIELD_RET_INT 1
| #define ETHR_HAVE_PTHREAD_ATTR_SETGUARDSIZE 1
| #define ETHR_HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC 1
| #define ETHR_HAVE_LINUX_FUTEX 1
| #define ETHR_HAVE_PTHREAD_SETNAME_NP_2 1
| #define ETHR_HAVE_PTHREAD_GETNAME_NP_3 1
| #define SIZEOF_SHORT 2
| #define SIZEOF_INT 4
| #define SIZEOF_LONG 8
| #define SIZEOF_LONG_LONG 8
| #define SIZEOF___INT128_T 16
| #define ETHR_HAVE___sync_synchronize ~0
| #define ETHR_HAVE___sync_add_and_fetch 12
| #define ETHR_HAVE___sync_fetch_and_and 12
| #define ETHR_HAVE___sync_fetch_and_or 12
| #define ETHR_HAVE___sync_val_compare_and_swap 12
| #define ETHR_HAVE___atomic_store_n 12
| #define ETHR_HAVE___atomic_load_n 12
| #define ETHR_HAVE___atomic_add_fetch 12
| #define ETHR_HAVE___atomic_fetch_and 12
| #define ETHR_HAVE___atomic_fetch_or 12
| #define ETHR_HAVE___atomic_compare_exchange_n 12
| #define ETHR_HAVE_GCC_ASM_ARM_DMB_INSTRUCTION 0
| #define ETHR_HAVE_GCC_ASM_ARM_DMB_ST_INSTRUCTION 0
| #define ETHR_HAVE_GCC_ASM_ARM_DMB_LD_INSTRUCTION 0
| #define ETHR_HAVE_GCC_ASM_ARM_ISB_SY_INSTRUCTION 0
| #define ETHR_HAVE_GCC_ASM_ARM_DC_CVAU_INSTRUCTION 0
| #define ETHR_HAVE_GCC_ASM_ARM_IC_IVAU_INSTRUCTION 0
| #define ETHR_HAVE_GCC___ATOMIC_BUILTINS 1
| #define SIZEOF_VOID_P 8
| #define ETHR_SIZEOF_PTR 8
| #define SIZEOF_INT 4
| #define ETHR_SIZEOF_INT 4
| #define SIZEOF_LONG 8
| #define ETHR_SIZEOF_LONG 8
| #define SIZEOF_LONG_LONG 8
| #define ETHR_SIZEOF_LONG_LONG 8
| #define SIZEOF___INT64 0
| #define ETHR_SIZEOF___INT64 0
| #define SIZEOF___INT128_T 16
| #define ETHR_SIZEOF___INT128_T 16
| #define ETHR_GCC_HAVE_DW_CMPXCHG_ASM_SUPPORT 1
| #define ETHR_HAVE_ETHREAD_DEFINES 1
| #define ETHR_SMP_REQUIRE_NATIVE_IMPLS 1
| #define HAVE_POSIX_FADVISE 1
| #define HAVE_LINUX_FALLOC_H 1
| #define HAVE_FALLOCATE 1
| #define HAVE_POSIX_FALLOCATE /**/
| #define ERTS_NEED_DLOPEN_BEFORE_DLERROR 1
| #define HAVE_TERMCAP_H 1
| #define HAVE_CURSES_H 1
| #define HAVE_TERM_H 1
| #define HAVE_TERMCAP 1
| #define HAVE_WCWIDTH 1
| #define HAVE_ZLIB_INFLATEGETDICTIONARY 1
| #define ESOCK_ENABLE 1
| #define HAVE_LOCALTIME_R 1
| #define HAVE_STRFTIME 1
| #define HAVE_GETPROTOENT 1
| #define HAVE_SETPROTOENT 1
| #define HAVE_ENDPROTOENT 1
| #define ESOCK_USE_EXTENDED_ERROR_INFO 1
| #define ESOCK_COUNTER_SIZE 64
| #define HAVE_IF_NAMETOINDEX 1
| #define HAVE_IF_INDEXTONAME 1
| #define HAVE_IF_NAMEINDEX 1
| #define HAVE_IF_FREENAMEINDEX 1
| #define HAVE_GETHOSTNAME 1
| #define ESOCK_USE_SOCKET_REGISTRY 1
| #define HAVE_STRUCT_IFREQ_IFR_MAP 1
| #define ESOCK_USE_IFMAP /**/
| #define HAVE_STRUCT_IFREQ_IFR_HWADDR 1
| #define ESOCK_USE_HWADDR /**/
| #define HAVE_STRUCT_IFREQ_IFR_IFINDEX 1
| #define ESOCK_USE_IFINDEX /**/
| #define HAVE_WORKING_POSIX_OPENPT 1
| #define NETDB_H_NEEDS_IN_H 1
| #define HAVE_SOCKLEN_T 1
| #define H_ERRNO_DECLARED 1
| #define HAVE_DIRENT_H 1
| #define HAVE_SYS_WAIT_H 1
| #define HAVE_FCNTL_H 1
| #define HAVE_LIMITS_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_SYSLOG_H 1
| #define HAVE_DLFCN_H 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STROPTS_H 1
| #define HAVE_SYS_IOCTL_H 1
| #define HAVE_SYS_TIME_H 1
| #define HAVE_SYS_UIO_H 1
| #define HAVE_SYS_MMAN_H 1
| #define HAVE_SYS_SOCKET_H 1
| #define HAVE_MALLOC_H 1
| #define HAVE_ARPA_NAMESER_H 1
| #define HAVE_PTY_H 1
| #define HAVE_UTMP_H 1
| #define HAVE_LANGINFO_H 1
| #define HAVE_POLL_H 1
| #define HAVE_ELF_H 1
| #define HAVE_STRUCT_IFREQ_IFR_HWADDR 1
| #define HAVE_STRUCT_IP_MREQN 1
| #define HAVE_SYS_RESOURCE_H 1
| #define HAVE_DECL_GETRLIMIT 1
| #define HAVE_DECL_SETRLIMIT 1
| #define HAVE_DECL_RLIMIT_STACK 1
| #define HAVE_GETRUSAGE 1
| #define HAVE_SYS_TIMERFD_H 1
| #define HAVE_NETPACKET_PACKET_H 1
| #define HAVE_SCHED_H 1
| #define HAVE_SETNS 1
| #define HAVE_LINUX_TYPES_H 1
| #define HAVE_LINUX_ERRQUEUE_H 1
| #define HAVE_SO_BSDCOMPAT /**/
| #define NO_SA_LEN 1
| #define SIZEOF_CHAR 1
| #define SIZEOF_SHORT 2
| #define SIZEOF_INT 4
| #define SIZEOF_LONG 8
| #define SIZEOF_VOID_P 8
| #define SIZEOF_LONG_LONG 8
| #define SIZEOF_SIZE_T 8
| #define SIZEOF_OFF_T 8
| #define SIZEOF_TIME_T 8
| #define SIZEOF_SUSECONDS_T 8
| #define SIZEOF__FLOAT16 2
| #define ERTS_RESTRICT restrict
| #define ERTS_ENDIANNESS -1
| #define HAVE_FDATASYNC 1
| #define HAVE_SENDFILE 1
| #define HAVE_GETADDRINFO 1
| #define HAVE_GETNAMEINFO 1
| #define HAVE_GETHOSTBYNAME2 1
| #define HAVE_FINITE 1
| #define HAVE_DLOPEN 1
| #define HAVE_PREAD 1
| #define HAVE_PWRITE 1
| #define HAVE_MEMMOVE 1
| #define HAVE_STRERROR 1
| #define HAVE_STRERROR_R 1
| #define HAVE_STRNCASECMP 1
| #define HAVE_LOCALTIME_R 1
| #define HAVE_GMTIME_R 1
| #define HAVE_MPROTECT 1
| #define HAVE_MADVISE 1
| #define HAVE_POSIX_MADVISE 1
| #define HAVE_MMAP 1
| #define HAVE_MREMAP 1
| #define HAVE_MEMCPY 1
| #define HAVE_MEMRCHR 1
| #define HAVE_SBRK 1
| #define HAVE_BRK 1
| #define HAVE_FLOCKFILE 1
| #define HAVE_FSTAT 1
| #define HAVE_STRLCPY 1
| #define HAVE_STRLCAT 1
| #define HAVE_SETSID 1
| #define HAVE_SETLOCALE 1
| #define HAVE_NL_LANGINFO 1
| #define HAVE_POLL 1
| #define HAVE_MLOCKALL 1
| #define HAVE_PPOLL 1
| #define HAVE_VSYSLOG 1
| #define HAVE_INET_PTON 1
| #define HAVE_ISFINITE 1
| #define HAVE_POSIX_MEMALIGN 1
| #define HAVE_WRITEV 1
| #define HAVE_DECL_POSIX2TIME 0
| #define HAVE_DECL_TIME2POSIX 0
| #define HAVE_VPRINTF 1
| #define HAVE_CONFLICTING_FREAD_DECLARATION 1
| #define HAVE_PUTC_UNLOCKED 1
| #define HAVE_FWRITE_UNLOCKED 1
| #define HAVE_OPENPTY 1
| #define HAVE_IFADDRS_H 1
| #define HAVE_NETPACKET_PACKET_H 1
| #define HAVE_SYS_UN_H 1
| #define HAVE_GETIFADDRS 1
| #define HAVE_STRUCT_SOCKADDR_UN_SUN_PATH 1
| #define HAVE_IN6ADDR_ANY 1
| #define HAVE_IN6ADDR_LOOPBACK 1
| #define HAVE_DECL_IN6ADDR_ANY_INIT 1
| #define HAVE_DECL_IN6ADDR_LOOPBACK_INIT 1
| #define HAVE_DECL_IPV6_V6ONLY 1
| #define HAVE_SCHED_xETAFFINITY 1
| #define HAVE_END_SYMBOL 1
| #define HAVE__END_SYMBOL 1
| #define SBRK_RET_TYPE void *
| #define SBRK_ARG_TYPE intptr_t
| #define BRK_RET_TYPE int
| #define BRK_ARG_TYPE void *
| #define ERTS_STRUCTURE_ALIGNED_ALLOC 1
| #define HAVE_IN6 1
| #define HAVE_MULTICAST_SUPPORT 1
| #define HAVE_CLOCK_GETRES 1
| #define HAVE_GETTIMEOFDAY 1
| #define OS_SYSTEM_TIME_USING_CLOCK_GETTIME 1
| #define WALL_CLOCK_ID_STR "CLOCK_REALTIME"
| #define WALL_CLOCK_ID CLOCK_REALTIME
| #define HAVE_CLOCK_GETRES 1
| #define OS_MONOTONIC_TIME_USING_CLOCK_GETTIME 1
| #define ERTS_HAVE_CORRECTED_OS_MONOTONIC_TIME 1
| #define MONOTONIC_CLOCK_ID_STR "CLOCK_MONOTONIC"
| #define MONOTONIC_CLOCK_ID CLOCK_MONOTONIC
| #define HAVE_CLOCK_GETTIME_MONOTONIC_RAW 1
| #define HAVE_CLOCK_GETRES 1
| #define SYS_HRTIME_USING_CLOCK_GETTIME 1
| #define HAVE_MONOTONIC_ERTS_SYS_HRTIME 1
| #define HRTIME_CLOCK_ID_STR "CLOCK_MONOTONIC"
| #define HRTIME_CLOCK_ID CLOCK_MONOTONIC
| #define HAVE_CLOCK_GETTIME_CPU_TIME /**/
| #define NATIVE_ERLANG_STACK /**/
| #define ERLANG_FRAME_POINTERS /**/
| #define HAVE_LINUX_PERF_SUPPORT 1
| #define HAVE_LINUX_THP 1
| /* end confdefs.h.  */
| 
| #include <poll.h>
| main()
| {
| #ifdef _POLL_EMUL_H_
|   exit(1); /* Implemented using select() -- fail */
| #else
|   struct pollfd fds[1];
|   int fd;
|   fd = open("/dev/null", 1);
|   fds[0].fd = fd;
|   fds[0].events = POLLIN;
|   fds[0].revents = 0;
|   if (poll(fds, 1, 0) < 0 || (fds[0].revents & POLLNVAL) != 0) {
|     exit(1);  /* Does not work for devices -- fail */
|   }
|   exit(0);
| #endif
| }
| 
configure:25921: result: no; non-existing, broken, or based on select()

To Reproduce

git clone https://github.com/lukebakken/docker-library-rabbitmq-749.git
docker build --no-cache --pull --tag=docker-library-rabbitmq-749-repro .
docker run --rm --name dlr-749-repro docker-library-rabbitmq-749-repro /bin/sh -c 'sleep 600'

# in another terminal
docker cp dlr-749-repro:/usr/local/src/otp-27.2/erts/config.log .

# clean up
docker kill dlr-749-repro

Expected behavior
The check for a working poll(), and other checks that could possibly fail, work correctly using gcc 14.

Affected versions
Tested using OTP 27.2 source code.

Additional context
Originally reported here: docker-library/rabbitmq#749

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue is reported as a bugteam:VMAssigned to OTP team VM

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions