Skip to content

lang/gcc*: Darwin binary packages ship compilers broken by baked-in build-machine SDK path and stale fixincludes headers #423

Description

@Suyun114

Summary

The Darwin binary packages of lang/gcc15 ship a compiler that cannot compile even a trivial program using the C/C++ standard library on any machine whose macOS SDK path or version differs from the bulk build machine's. The same pattern exists in gcc10gcc16 (all use --with-sysroot=${OSX_SDK_PATH} in their Makefile.common).

Reproduction

Binary package gcc15-15.3.0nb1 from pkgsrc.smartos.org (Darwin/arm64), installed on a macOS 26 machine that has only the Command Line Tools (no Xcode):

$ /opt/pkg/gcc15/bin/g++ hello.cpp    # just #include <iostream>
/opt/pkg/gcc15/include/c++/cwchar:49:10: fatal error: wchar.h: No such file or directory

Plain C fails as well:

$ /opt/pkg/gcc15/bin/gcc h.c          # just #include <stdio.h>
.../include-fixed/stdio.h:73:10: fatal error: _stdio.h: No such file or directory

Root cause — two stacked issues

1. The build machine's SDK path is baked into the binaries.

CONFIGURE_ARGS.Darwin += --with-sysroot=${OSX_SDK_PATH} resolves via mk/platform/Darwin.mk to an absolute path on the build machine. The published binaries were configured with

--with-sysroot=/Applications/Xcode-15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk

which does not exist on install machines (different Xcode location/version, or no Xcode at all). gcc -v -E then shows an empty system header search list, so no system header can be found.

2. The packaged include-fixed/ headers are stale for any other SDK version.

fixincludes runs at package build time against the build machine's SDK (14.5), and the output is shipped verbatim. On machines with a newer SDK these headers shadow the real system headers and are structurally incompatible with them. Concretely, on macOS 26: the packaged include-fixed/stdio.h uses the include guard _STDIO_H_, which collides with the guard of the current SDK's _stdio.h (where FILE is now defined). _stdio.h is therefore skipped entirely and compilation fails with 'FILE' does not name a type. Passing --sysroot manually does not help, because include-fixed is searched before the sysroot include directory.

Note that builds within pkgsrc are unaffected because the cwrappers inject -isysroot ${OSX_SDK_PATH} (mk/platform/Darwin.mk); only direct use of the installed compiler breaks.

Request

Opening this for discussion on how this should be addressed for the Darwin packages (and whether the same change should be applied across lang/gcc10lang/gcc16). Happy to help test any approach on affected machines.

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