Skip to content
137 changes: 137 additions & 0 deletions .github/workflows/portability.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: Portability

# Dimensions cmake.yml does not reach: capability paths, 32-bit, non-x86, BSD.

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:

capability-paths:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: fork instead of posix_spawn
defs: -DSUBPROCESS_SPAWN_VIA_FORK=1
- name: no chdir file action, no exec error reporting
defs: -DSUBPROCESS_HAVE_CWD=0 -DSUBPROCESS_SPAWN_REPORTS_EXEC_ERRORS=0
- name: no chdir file action only
defs: -DSUBPROCESS_HAVE_CWD=0
name: ${{ matrix.name }}
steps:
- uses: actions/checkout@v4
- name: Build and test
run: |
cmake -S test -B build \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_C_FLAGS="${{ matrix.defs }}" \
-DCMAKE_CXX_FLAGS="${{ matrix.defs }}"
cmake --build build -j
ctest --test-dir build --output-on-failure

linux-32-bit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install multilib
run: sudo apt-get update && sudo apt-get install -y gcc-multilib g++-multilib
- name: Build and test
run: |
cmake -S test -B build \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_C_FLAGS=-m32 \
-DCMAKE_CXX_FLAGS=-m32 \
-DCMAKE_EXE_LINKER_FLAGS=-m32
cmake --build build -j
ctest --test-dir build --output-on-failure

windows-x86:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- run: cmake -S test -B build -A Win32
- run: cmake --build build --config RelWithDebInfo
- run: ctest --test-dir build -C RelWithDebInfo --output-on-failure

musl:
runs-on: ubuntu-latest
container: alpine:3
steps:
- name: Install toolchain
run: apk add --no-cache gcc g++ musl-dev cmake make linux-headers git
- uses: actions/checkout@v4
- name: Build and test
run: |
cmake -S test -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build -j
ctest --test-dir build --output-on-failure

# Builds everything, runs only *divzero: qemu-user does not propagate the
# errno posix_spawn reports a failed exec with, so the rest fails here on
# every architecture regardless of target.
foreign-arch:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: [ppc64le, riscv64, s390x, armv7]
name: linux ${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
- uses: uraimo/run-on-arch-action@v3
with:
arch: ${{ matrix.arch }}
distro: ubuntu_latest
install: |
apt-get update -q
apt-get install -q -y build-essential cmake
run: |
cmake -S test -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build -j
cd build && ./subprocess_test '--filter=*divzero'

# NetBSD twice on purpose: addchdir arrived in 10.0, so 9.x takes another path.
bsd:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- { os: freebsd, version: "14.3", pkg: "sudo pkg install -y cmake" }
- { os: netbsd, version: "9.4", pkg: "sudo pkgin -y install cmake" }
- { os: netbsd, version: "10.1", pkg: "sudo pkgin -y install cmake" }
- { os: openbsd, version: "7.9", pkg: "sudo pkg_add cmake" }
name: ${{ matrix.os }} ${{ matrix.version }}
steps:
- uses: actions/checkout@v4
- uses: cross-platform-actions/action@v1.4.0
with:
operating_system: ${{ matrix.os }}
version: ${{ matrix.version }}
run: |
${{ matrix.pkg }}
cmake -S test -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build
ctest --test-dir build --output-on-failure

macos-deployment-target:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
target: ["10.14", "10.15", "11.0"]
name: macOS deployment target ${{ matrix.target }}
steps:
- uses: actions/checkout@v4
- name: Build and test
run: |
cmake -S test -B build \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${{ matrix.target }}
cmake --build build -j
ctest --test-dir build --output-on-failure
5 changes: 5 additions & 0 deletions subprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ subprocess_weak int subprocess_alive(struct subprocess_s *const process);
#endif

#if defined(__NetBSD__)
/* <sys/param.h> pulls in <sys/inttypes.h>, which hides the PRI macros from C++
before C++11 behind an include guard, so this has to be set before it. */
#if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS)
#define __STDC_FORMAT_MACROS 1
#endif
#include <sys/param.h>
#endif

Expand Down
8 changes: 6 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,17 @@ subprocess_set_cxx_flags(test98.cpp "-std=gnu++98")
subprocess_set_cxx_flags(test11.cpp "-std=c++11" "-Wno-c++98-compat")
subprocess_set_cxx_flags(test14.cpp "-std=c++14" "-Wno-c++98-compat")
subprocess_set_cxx_flags(test17.cpp "-std=c++17" "-Wno-c++98-compat")
# GCC 8 and clang 9 only accept the pre-release spelling -std=c++2a.
# GCC 8 and clang 9 only accept the pre-release spelling -std=c++2a, and GCC 7
# and older accept neither, so the file falls back to the compiler default.
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++20" SUBPROCESS_CXX_HAS_STD_CXX20)
check_cxx_compiler_flag("-std=c++2a" SUBPROCESS_CXX_HAS_STD_CXX2A)
if(SUBPROCESS_CXX_HAS_STD_CXX20)
subprocess_set_cxx_flags(test20.cpp "-std=c++20" "-Wno-c++98-compat")
else()
elseif(SUBPROCESS_CXX_HAS_STD_CXX2A)
subprocess_set_cxx_flags(test20.cpp "-std=c++2a" "-Wno-c++98-compat")
else()
subprocess_set_cxx_flags(test20.cpp "" "-Wno-c++98-compat")
endif()
subprocess_set_cxx_flags(pre_windows.cpp "" "-Wno-c++98-compat")
subprocess_set_cxx_flags(post_windows.cpp "" "-Wno-c++98-compat")
Expand Down
Loading
Loading