llvm / llvm/llvm-project

[libc] poll alias conflict: system sys/poll.h is leaked into src/poll/linux/poll.cpp on Ubuntu 24.04

Open
#177,757 2 comments 0 reactions 0 assignees View on GitHub
libc
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

When building libc on Ubuntu 24.04 with GCC 13.3.0, the build fails in poll.cpp. The preprocessor output reveals that the system header /usr/include/x86_64-linux-gnu/sys/poll.h is being included, which declares extern int poll.

When LLVM_LIBC_FUNCTION subsequently tries to define poll with a [[gnu::alias]] attribute, the compiler rejects it because the name poll is already occupied by the external system declaration.

Preprocessor Output:
extern "C" {
54 "/usr/include/x86_64-linux-gnu/sys/poll.h" 3 4
extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout)

This leads to the following error during compilation:

llvm-project/libc/src/poll/linux/poll.cpp:23:25: error: ‘int __llvm_libc_23_0_0_git::poll(pollfd*, nfds_t, int)’ aliased to external symbol ‘poll’
23 | LLVM_LIBC_FUNCTION(int, poll, (pollfd * fds, nfds_t nfds, int timeout)) {

Environment

OS: Ubuntu 24.04 LTS (Noble Numbat)

Compiler: g++ (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0

Build Command: cmake -G Ninja ../llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=libc

Steps to reproduce:
Clean build of llvm-project/libc on Ubuntu 24.04 using the system GCC.
Build will fail when building poll.cpp

This issue does not happen when compiling on Clang

Contributor guide

Open the contributing guide

Research direction

Reproduce the clean libc build on Ubuntu 24.04 with the stated CMake and Ninja command, then inspect llvm-project/libc/src/poll/linux/poll.cpp and the preprocessor output around sys/poll.h. Done means the GCC build no longer fails with the poll alias conflict, while the existing Clang behavior remains unaffected.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, ubuntu
Domain
compilers, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.