Skip to content

GCC 15 from Homebrew fails to compile C++ code on Ubuntu 25.04 (glibc 2.41) - __GTHREAD_COND_INIT error #261062

@yuki2006

Description

@yuki2006

brew config output

HOMEBREW_VERSION: 4.5.2
ORIGIN: https://github.com/Homebrew/brew
HEAD: xxx
Last commit: xxx
Core tap JSON: xxx
Core tap origin: https://github.com/Homebrew/homebrew-core
Core tap HEAD: xxx
Core tap branch: master
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 2
Homebrew Ruby: 3.3.6
CPU: Generic x86_64
Clang: N/A
Git: 2.48.1
Curl: 8.12.1
Kernel: Linux 6.14.x x86_64
OS: Ubuntu 25.04 (plucky)
Host glibc: 2.41
/usr/bin/gcc: 14.2.0
glibc: N/A

brew doctor output

Your system is ready to brew.

What you tried to do

Compile a simple C++ program using Homebrew's GCC 15 on Ubuntu 25.04

What happened (include command output)

$ /home/linuxbrew/.linuxbrew/bin/g++-15 -std=c++23 main.cpp

In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0/include/c++/15/x86_64-pc-linux-gnu/bits/gthr-default.h:35,
...
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0/include/c++/15/ext/concurrence.h:257:32: error: cannot convert '<brace-enclosed initializer list>' to 'unsigned int' in initialization
  257 |     __gthread_cond_t _M_cond = __GTHREAD_COND_INIT;
      |                                ^~~~~~~~~~~~~~~~~~~

What you expected to happen

The program should compile successfully.

Environment

  • OS: Ubuntu 25.04 (Plucky Puffin)
  • glibc: 2.41
  • Homebrew GCC: 15.2.0 (installed via brew install gcc)
  • System GCC: 15.0.1 (from apt)

Root Cause

Homebrew's GCC 15 was built against a different version of glibc. The __GTHREAD_COND_INIT macro (which expands to PTHREAD_COND_INITIALIZER) in Homebrew's GCC headers is incompatible with glibc 2.41's pthread_cond_t structure.

Minimal Reproduction

docker run --rm ubuntu:25.04 bash -c '
  apt-get update -qq && apt-get install -y -qq curl git build-essential

  # Install Homebrew
  NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

  # Install GCC from Homebrew
  brew install gcc

  # Create test file
  echo "#include <bits/stdc++.h>
int main() { return 0; }" > main.cpp

  # This fails
  /home/linuxbrew/.linuxbrew/bin/g++-15 -std=c++23 main.cpp
'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions