From 7c459bf90c11f1e589f5518522a48a92c2b93de0 Mon Sep 17 00:00:00 2001 From: Neo-Desktop <321592+Neo-Desktop@users.noreply.github.com> Date: Sun, 29 Nov 2026 18:11:03 +0000 Subject: [PATCH] ci: build for Mac OS X 10.4 with the SDK of clang-retro/macosx-sdk The macosx10.4 sysroot of dos-sdk no longer comes with Apple's MacOSX10.4u.sdk. It now has MacOSX10.4.sdk, the 10.4 SDK of clang-retro/macosx-sdk. cmake/macosx-legacy.cmake uses MACOSX_LEGACY_SDK, which is MACOSX_LEGACY_SYSROOT/MacOSX10.4.sdk by default, and stops if the SDK has no crt1.o. CI builds the SDK from the main branch of macosx-sdk and uses it. Haiku: link libmedia and libtranslation. The sound of clang-retro MFC (port/src/audio_haiku.cpp) uses the Media Kit, and its images use the Translation Kit. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01B82eRVSwCR74jLBgo41Zbc Signed-off-by: Neo-Desktop <321592+Neo-Desktop@users.noreply.github.com> --- .github/workflows/build.yml | 19 +++++++++++++++---- cmake/macosx-legacy.cmake | 21 ++++++++++++++++++--- docs/building.md | 11 ++++++++--- winport/CMakeLists.txt | 10 ++++++---- 4 files changed, 47 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 65286e3..b6c8302 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -300,9 +300,10 @@ jobs: # clang-retro MFC (cmake/macosx-legacy.cmake). All of it builds on # Linux: clang of clang-retro/llvm (its llvm-prebuilt release, which # has emulated TLS for 10.4), the macosx10.4 sysroot of dos-sdk (libc++ - # and Apple's MacOSX10.4u.sdk, under Apple's license), and Apple's ld64 - # and ar for PowerPC (dos-sdk's scripts/build-cctools-ppc.sh, kept in - # the cache). + # and the builtins), the Mac OS X 10.4 SDK of clang-retro/macosx-sdk + # (built from its main branch: stub libraries, start files and + # headers, with no file from Apple), and ld64 and ar for PowerPC + # (dos-sdk's scripts/build-cctools-ppc.sh, kept in the cache). winport-macosx-legacy: name: Windows app on Mac OS X 10.4 and later (PowerPC and i386), the modem built in runs-on: ubuntu-24.04 @@ -321,6 +322,10 @@ jobs: with: repository: clang-retro/dos-sdk path: dos-sdk + - uses: actions/checkout@v4 + with: + repository: clang-retro/macosx-sdk + path: macosx-sdk - name: Packages run: | sudo apt-get update @@ -337,7 +342,7 @@ jobs: rm llvm.tar.zst "$RUNNER_TEMP/llvm/bin/clang" --version | head -1 echo "MACOSX_LEGACY_LLVM=$RUNNER_TEMP/llvm" >> "$GITHUB_ENV" - - name: The macosx10.4 sysroot (libc++ and MacOSX10.4u.sdk) + - name: The macosx10.4 sysroot (libc++ and the builtins) run: | sh dos-sdk/packaging/get-toolchain.sh -s macosx10.4 "$RUNNER_TEMP/sysroots" echo "MACOSX_LEGACY_SYSROOT=$RUNNER_TEMP/sysroots/macosx10.4" >> "$GITHUB_ENV" @@ -351,6 +356,12 @@ jobs: run: | PREFIX="$RUNNER_TEMP/cctools-ppc" SRC="$RUNNER_TEMP/cctools-port" \ sh dos-sdk/scripts/build-cctools-ppc.sh > cctools.log 2>&1 || { tail -50 cctools.log; exit 1; } + - name: The Mac OS X 10.4 SDK (clang-retro/macosx-sdk) + run: | + PATH="$RUNNER_TEMP/cctools-ppc/bin:$PATH" CLANG="$MACOSX_LEGACY_LLVM/bin/clang" \ + OUT="$RUNNER_TEMP/macosx-sdk" sh macosx-sdk/build-sysroot.sh 10.4 + test -f "$RUNNER_TEMP/macosx-sdk/macosx10.4/usr/lib/crt1.o" + echo "MACOSX_LEGACY_SDK=$RUNNER_TEMP/macosx-sdk/macosx10.4" >> "$GITHUB_ENV" - name: Build (PowerPC and i386) run: | export MACOSX_LEGACY_CCTOOLS="$RUNNER_TEMP/cctools-ppc" diff --git a/cmake/macosx-legacy.cmake b/cmake/macosx-legacy.cmake index ab54095..84b1459 100644 --- a/cmake/macosx-legacy.cmake +++ b/cmake/macosx-legacy.cmake @@ -14,9 +14,13 @@ # release), with emulated TLS for Mac OS X 10.4 # MACOSX_LEGACY_SYSROOT the macosx10.4 sysroot of clang-retro/dos-sdk # (packaging/get-toolchain.sh -s macosx10.4): libc++, -# and MacOSX10.4u.sdk in it +# the builtins, and MacOSX10.4.sdk in it # MACOSX_LEGACY_CCTOOLS Apple's ld64 and ar for PowerPC # (dos-sdk's scripts/build-cctools-ppc.sh) +# This is optional: +# MACOSX_LEGACY_SDK the Mac OS X 10.4 SDK: a 10.4 sysroot of +# clang-retro/macosx-sdk (build-sysroot.sh 10.4). +# Default: MACOSX_LEGACY_SYSROOT/MacOSX10.4.sdk. # The environment variables of the same names also set them. set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_VERSION 8.0) @@ -33,12 +37,23 @@ foreach(_v ARCH LLVM SYSROOT CCTOOLS) set(ENV{MACOSX_LEGACY_${_v}} "${MACOSX_LEGACY_${_v}}") endforeach() # (try_compile projects see these) +if(NOT MACOSX_LEGACY_SDK AND DEFINED ENV{MACOSX_LEGACY_SDK}) + set(MACOSX_LEGACY_SDK "$ENV{MACOSX_LEGACY_SDK}") +endif() +if(NOT MACOSX_LEGACY_SDK) + set(MACOSX_LEGACY_SDK "${MACOSX_LEGACY_SYSROOT}/MacOSX10.4.sdk") +endif() +if(NOT EXISTS "${MACOSX_LEGACY_SDK}/usr/lib/crt1.o") + message(FATAL_ERROR "MACOSX_LEGACY_SDK (${MACOSX_LEGACY_SDK}) is not a Mac OS X 10.4 SDK: it has no usr/lib/crt1.o") +endif() +set(MACOSX_LEGACY_SDK "${MACOSX_LEGACY_SDK}" CACHE STRING "" FORCE) +set(ENV{MACOSX_LEGACY_SDK} "${MACOSX_LEGACY_SDK}") list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES - MACOSX_LEGACY_ARCH MACOSX_LEGACY_LLVM MACOSX_LEGACY_SYSROOT MACOSX_LEGACY_CCTOOLS) + MACOSX_LEGACY_ARCH MACOSX_LEGACY_LLVM MACOSX_LEGACY_SYSROOT MACOSX_LEGACY_CCTOOLS + MACOSX_LEGACY_SDK) set(CMAKE_SYSTEM_PROCESSOR ${MACOSX_LEGACY_ARCH}) set(MACOSX_LEGACY_TARGET "${MACOSX_LEGACY_ARCH}-apple-macosx10.4") -set(MACOSX_LEGACY_SDK "${MACOSX_LEGACY_SYSROOT}/MacOSX10.4u.sdk") set(_cct "${MACOSX_LEGACY_CCTOOLS}/bin/powerpc-apple-darwin8-") set(CMAKE_OSX_SYSROOT "${MACOSX_LEGACY_SDK}") diff --git a/docs/building.md b/docs/building.md index c7feec7..2f23dfe 100644 --- a/docs/building.md +++ b/docs/building.md @@ -67,9 +67,14 @@ Mac OS X 10.0-10.5 port of clang-retro MFC and the toolchain file `llvm-prebuilt` release). The clang of the clang-dos package can be too old: it must have emulated TLS for Mac OS X 10.4. - The `macosx10.4` sysroot of [clang-retro/dos-sdk](https://github.com/clang-retro/dos-sdk): - `sh packaging/get-toolchain.sh -s macosx10.4 DIR`. It has libc++ and - the builtins, and the script also gets Apple's `MacOSX10.4u.sdk`. - Apple's license applies to the SDK. + `sh packaging/get-toolchain.sh -s macosx10.4 DIR`. It has libc++, the + builtins and `MacOSX10.4.sdk`, the 10.4 SDK of + [clang-retro/macosx-sdk](https://github.com/clang-retro/macosx-sdk). + No file from Apple is in it. +- Optional: a newer 10.4 SDK from a macosx-sdk checkout. Run + `OUT=DIR sh build-sysroot.sh 10.4` in macosx-sdk, then set + `MACOSX_LEGACY_SDK=DIR/macosx10.4`. CI does this, so that it uses the + latest headers of macosx-sdk. - Apple's `ld64` and `ar` for PowerPC: `PREFIX=DIR sh scripts/build-cctools-ppc.sh` in dos-sdk. This `ld64` also links for i386. diff --git a/winport/CMakeLists.txt b/winport/CMakeLists.txt index 9cd118b..06b9ff7 100644 --- a/winport/CMakeLists.txt +++ b/winport/CMakeLists.txt @@ -137,10 +137,12 @@ elseif(HAIKU) # (the USB devices for Look for a modem, from the USB Kit: # windows/src/ports_haiku.cpp, with Haiku's headers only) target_sources(dmodem-win32 PRIVATE "${_win}/src/ports_haiku.cpp") - # (libbe: the Interface Kit; libdevice: the USB Kit; libnetwork: the - # sockets; libbsd: dl_iterate_phdr. libroot has the rest, dlopen and - # the threads too.) - target_link_libraries(dmodem-win32 PRIVATE be device network bsd) + # (libbe: the Interface Kit; libmedia: the Media Kit, for the sound of + # clang-retro MFC (port/src/audio_haiku.cpp); libtranslation: the + # Translation Kit, for its images; libdevice: the USB Kit; libnetwork: + # the sockets; libbsd: dl_iterate_phdr. libroot has the rest, dlopen + # and the threads too.) + target_link_libraries(dmodem-win32 PRIVATE be media translation device network bsd) else() target_link_libraries(dmodem-win32 PRIVATE dl pthread) endif()