Skip to content

Commit 7e59b69

Browse files
authored
Try run on apple silicon. (#77)
1 parent be09a98 commit 7e59b69

5 files changed

Lines changed: 913 additions & 275 deletions

File tree

.github/workflows/cmake.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@ jobs:
1010
build:
1111
strategy:
1212
matrix:
13-
os: [ubuntu-latest, windows-latest, macOS-latest]
13+
os: [ubuntu-latest, windows-latest, macos-11, macos-14]
1414
type: [Debug, RelWithDebInfo, MinSizeRel, Release]
15-
compiler: [default, clang, gcc]
15+
compiler: [default, clang, gcc, tcc]
1616
exclude:
17-
- {os: "macOS-latest", compiler: "clang"}
18-
- {os: "macOS-latest", compiler: "gcc"}
17+
- {os: "macos-11", compiler: "clang"}
18+
- {os: "macos-11", compiler: "gcc"}
19+
- {os: "macos-11", compiler: "tcc"}
20+
- {os: "macos-14", compiler: "clang"}
21+
- {os: "macos-14", compiler: "gcc"}
22+
- {os: "macos-14", compiler: "tcc"}
1923
- {os: "ubuntu-latest", compiler: "default"}
2024
- {os: "ubuntu-latest", compiler: "default"}
25+
- {os: "windows-latest", compiler: "gcc"}
26+
- {os: "windows-latest", compiler: "tcc"}
2127
runs-on: ${{ matrix.os }}
2228

2329
steps:
@@ -28,7 +34,7 @@ jobs:
2834

2935
- name: Setup dependencies (Ubuntu)
3036
if: startsWith(matrix.os, 'ubuntu')
31-
run: sudo apt-get install -y gcc-10 g++-10 clang
37+
run: sudo apt-get install -y gcc-10 g++-10 clang tcc
3238

3339
- name: Setup dependencies (MinGW)
3440
if: matrix.compiler == 'gcc' && startsWith(matrix.os, 'windows')
@@ -46,6 +52,12 @@ jobs:
4652
working-directory: ${{github.workspace}}/build
4753
run: cmake $GITHUB_WORKSPACE/test -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10
4854

55+
- name: Configure CMake with TCC (Ubuntu)
56+
shell: bash
57+
if: matrix.compiler == 'tcc' && startsWith(matrix.os, 'ubuntu')
58+
working-directory: ${{github.workspace}}/build
59+
run: cmake $GITHUB_WORKSPACE/test -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DCMAKE_C_COMPILER=tcc -DCMAKE_CXX_COMPILER=g++-10
60+
4961
- name: Configure CMake with MinGW
5062
shell: bash
5163
if: matrix.compiler == 'gcc' && startsWith(matrix.os, 'windows')

subprocess.h

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,23 @@
4848
#pragma warning(pop)
4949
#endif
5050

51+
#if defined(__TINYC__)
52+
#define SUBPROCESS_ATTRIBUTE(a) __attribute((a))
53+
#else
54+
#define SUBPROCESS_ATTRIBUTE(a) __attribute__((a))
55+
#endif
56+
5157
#if defined(_MSC_VER)
5258
#define subprocess_pure
5359
#define subprocess_weak __inline
5460
#define subprocess_tls __declspec(thread)
5561
#elif defined(__MINGW32__)
56-
#define subprocess_pure __attribute__((pure))
57-
#define subprocess_weak static __attribute__((used))
62+
#define subprocess_pure SUBPROCESS_ATTRIBUTE(pure)
63+
#define subprocess_weak static SUBPROCESS_ATTRIBUTE(used)
5864
#define subprocess_tls __thread
59-
#elif defined(__clang__) || defined(__GNUC__)
60-
#define subprocess_pure __attribute__((pure))
61-
#define subprocess_weak __attribute__((weak))
65+
#elif defined(__clang__) || defined(__GNUC__) || defined(__TINYC__)
66+
#define subprocess_pure SUBPROCESS_ATTRIBUTE(pure)
67+
#define subprocess_weak SUBPROCESS_ATTRIBUTE(weak)
6268
#define subprocess_tls __thread
6369
#else
6470
#error Non clang, non gcc, non MSVC compiler found!
@@ -414,6 +420,13 @@ struct subprocess_s {
414420
#pragma clang diagnostic pop
415421
#endif
416422

423+
#if defined(__clang__)
424+
#if __has_warning("-Wunsafe-buffer-usage")
425+
#pragma clang diagnostic push
426+
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
427+
#endif
428+
#endif
429+
417430
#if defined(_WIN32)
418431
subprocess_weak int subprocess_create_named_pipe_helper(void **rd, void **wr);
419432
int subprocess_create_named_pipe_helper(void **rd, void **wr) {
@@ -1173,6 +1186,12 @@ int subprocess_alive(struct subprocess_s *const process) {
11731186
return is_alive;
11741187
}
11751188

1189+
#if defined(__clang__)
1190+
#if __has_warning("-Wunsafe-buffer-usage")
1191+
#pragma clang diagnostic pop
1192+
#endif
1193+
#endif
1194+
11761195
#if defined(__cplusplus)
11771196
} // extern "C"
11781197
#endif

test/main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ __declspec(dllimport) int __stdcall SetEnvironmentVariableA(const char *,
3535

3636
#include "subprocess.h"
3737

38+
#if defined(__clang__)
39+
#if __has_warning("-Wunsafe-buffer-usage")
40+
#pragma clang diagnostic push
41+
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
42+
#endif
43+
#endif
44+
3845
UTEST(create, subprocess_destroy_is_idempotent) {
3946
const char *const commandLine[] = {"./process_return_zero", 0};
4047
struct subprocess_s process;

test/process_call_return_argc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
// For more information, please refer to <http://unlicense.org/>
2525

2626
#include <subprocess.h>
27-
#ifdef __MINGW32__
27+
28+
#if defined(_MSC_VER)
29+
#include <direct.h>
30+
#define chdir(x) _chdir(x)
31+
#elif defined(__MINGW32__)
2832
#include <unistd.h> // chdir
2933
#endif
3034

0 commit comments

Comments
 (0)