Skip to content

bug(cmake): makeHeader target references deleted file src/misc/makeHeader.cpp - breaks musl/Alpine builds #9122

Description

@satwareAG-ironMike

Problem

Firebird v5.0.4 src/CMakeLists.txt:997 contains:

add_executable(makeHeader misc/makeHeader.cpp)

But src/misc/makeHeader.cpp was deleted in commit 45d5e3aa7a ("Refactor public include files (#205)"). The add_executable call was not removed, leaving a dangling reference to a non-existent source file.

On glibc systems (Debian, Fedora, AlmaLinux), CMake apparently tolerates this (the makeHeader target is behind if (NOT CMAKE_CROSSCOMPILING) and may never be evaluated). On musl libc (Alpine Linux), CMake validates source file existence at configure time and fails with:

CMake Error at src/CMakeLists.txt:997 (add_executable):
  No SOURCES given to target: makeHeader

CMake Generate step failed. Build files cannot be regenerated correctly.

Reproduction

docker run --rm alpine:3.21 sh -c '
  apk add --no-cache cmake ninja build-base git
  git clone --depth 1 --branch v5.0.4 https://github.com/FirebirdSQL/firebird.git /fbsrc
  mkdir -p /fbsrc/build && cd /fbsrc/build
  cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release
'
# Fails: No SOURCES given to target: makeHeader

Root Cause

Commit 45d5e3aa7a refactored public include file generation and deleted src/misc/makeHeader.cpp (83 lines removed) but did not remove the corresponding add_executable and set_output_directory calls in src/CMakeLists.txt:997-998.

The makeHeader binary was a helper that generated ibase.h from public headers (ibase.h, types_pub.h, consts_pub.h, etc.) by concatenating them. Post-refactor, ibase.h is generated or managed differently, making this target dead code.

Proposed Fix

Option A (minimal): Guard with file existence check:

if (NOT CMAKE_CROSSCOMPILING)
    if (EXISTS ${CMAKE_SOURCE_DIR}/src/misc/makeHeader.cpp)
        add_executable          (makeHeader misc/makeHeader.cpp)
        set_output_directory    (makeHeader . CURRENT_DIR)
        # ... rest of makeHeader block ...
    endif()
endif()

Option B (clean): Remove the entire makeHeader block (lines 997-1018) since the source file was deleted and the functionality was refactored away. The add_custom_command at line 1016 that calls makeHeader should also be removed.

Impact

  • Alpine Linux / musl libc: Cannot build Firebird client library from source
  • php-firebird: APK packaging blocked (issue satwareAG/php-firebird Locally exploitable stack overflow [CORE167] #496)
  • Downstream: Any distribution using musl libc cannot build Firebird from source

Environment

  • Firebird: v5.0.4 (latest stable, released 2026-04-17)
  • CMake: 3.31.1 (Alpine 3.21)
  • OS: Alpine Linux 3.21 (musl libc 1.2.5)
  • GCC: 14.2.0

Context

This was discovered during CI validation of php-firebird's Alpine APK packaging (packaging/apk/APKBUILD), which builds libfbclient from source for musl libc. The official FB5 client tarball is glibc-linked and cannot be used on Alpine without building from source.

The makeHeader target is behind if (NOT CMAKE_CROSSCOMPILING) — on glibc systems, CMake appears to skip evaluation of source existence for targets that are never built. On musl, CMake validates all add_executable calls at configure time regardless of whether the target will be built.

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