Skip to content

Commit 5c52b96

Browse files
authored
Support platform macosx/arm64 (#62)
* Clarify error message in src/nix/entrypoint.c * Support Mac Apple Silicon; improve debug logging * Fix CI/CD build errors for Linux and macOS - Fix Linux build: conditionally compile platform-specific plthook files - Linux now only compiles plthook_elf.c - macOS now only compiles plthook_osx.c - Fix macOS build: ensure .doorstop_version files are created for all targets - Add after_build to doorstop_x86_64 target - Enhanced doorstop_arm64 after_build to create version files and properly handle universal binary creation - Ensures compatibility with GitHub Actions workflow expectations
1 parent 226bd1d commit 5c52b96

File tree

6 files changed

+841
-290
lines changed

6 files changed

+841
-290
lines changed

.github/workflows/build-be.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,25 +115,25 @@ jobs:
115115
uses: actions/checkout@v4
116116
- name: Configure paths
117117
run: |
118-
mkdir -p artifacts/{verbose,release,debug}/x64
118+
mkdir -p artifacts/{verbose,release,debug}/universal
119119
- name: Build Release
120120
run: |
121121
./build.sh
122-
cp build/macosx/x86_64/release/libdoorstop.dylib artifacts/release/x64/libdoorstop.dylib
123-
cp build/macosx/x86_64/release/.doorstop_version artifacts/release/x64/.doorstop_version
124-
cp assets/nix/run.sh artifacts/release/x64/run.sh
122+
cp build/macosx/universal/release/libdoorstop.dylib artifacts/release/universal/libdoorstop.dylib
123+
cp build/macosx/universal/release/.doorstop_version artifacts/release/universal/.doorstop_version
124+
cp assets/nix/run.sh artifacts/release/universal/run.sh
125125
- name: Build Verbose
126126
run: |
127127
./build.sh -with_logging
128-
cp build/macosx/x86_64/release/libdoorstop.dylib artifacts/verbose/x64/libdoorstop.dylib
129-
cp build/macosx/x86_64/release/.doorstop_version artifacts/verbose/x64/.doorstop_version
130-
cp assets/nix/run.sh artifacts/verbose/x64/run.sh
128+
cp build/macosx/universal/release/libdoorstop.dylib artifacts/verbose/universal/libdoorstop.dylib
129+
cp build/macosx/universal/release/.doorstop_version artifacts/verbose/universal/.doorstop_version
130+
cp assets/nix/run.sh artifacts/verbose/universal/run.sh
131131
- name: Build Debug
132132
run: |
133133
./build.sh -with_logging -debug
134-
cp build/macosx/x86_64/debug/libdoorstop.dylib artifacts/debug/x64/libdoorstop.dylib
135-
cp build/macosx/x86_64/debug/.doorstop_version artifacts/debug/x64/.doorstop_version
136-
cp assets/nix/run.sh artifacts/debug/x64/run.sh
134+
cp build/macosx/universal/debug/libdoorstop.dylib artifacts/debug/universal/libdoorstop.dylib
135+
cp build/macosx/universal/debug/.doorstop_version artifacts/debug/universal/.doorstop_version
136+
cp assets/nix/run.sh artifacts/debug/universal/run.sh
137137
- name: Upload Release
138138
uses: actions/upload-artifact@v4
139139
with:

build.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ if [[ ! -d "$XMAKE_DIR" ]] || [[ ! -x "$xmake" ]]; then
239239
curl -fSL "https://github.com/xmake-io/xmake/releases/download/v$XMAKE_VERSION/xmake-v$XMAKE_VERSION.$pack.run" > "$TOOLS_DIR/xmake.run"
240240
log-8601-local "Downloading xmake maybe..."
241241
sh "$TOOLS_DIR/xmake.run" --noexec --target "$XMAKE_BUILD_DIR"
242-
log-8601-local "Buinding and installing xmake..."
242+
log-8601-local "Building and installing xmake..."
243243
if (cd "$XMAKE_BUILD_DIR" && ./configure && DESTDIR="$TOOLS_DIR" PREFIX="xmake" $make install); then
244244
msg-success "xmake installed successfully"
245245
else
@@ -248,10 +248,16 @@ if [[ ! -d "$XMAKE_DIR" ]] || [[ ! -x "$xmake" ]]; then
248248
fi
249249
fi
250250

251-
# Build projects for each arch
252-
for arch in "${ARCHS[@]}"
253-
do
254-
log-8601-local "Building for $arch..."
255-
"$xmake" f -a $arch -m $PROFILE --include_logging=$WITH_LOGGING
256-
"$xmake" "$@"
257-
done
251+
if [[ "$(uname)" == "Darwin" ]]; then
252+
log-8601-local "Building for macOS universal binary..."
253+
"$xmake" f -m $PROFILE --include_logging=$WITH_LOGGING
254+
"$xmake" "$@"
255+
else
256+
# Build projects for each arch
257+
for arch in "${ARCHS[@]}"
258+
do
259+
log-8601-local "Building for $arch..."
260+
"$xmake" f -a $arch -m $PROFILE --include_logging=$WITH_LOGGING
261+
"$xmake" "$@"
262+
done
263+
fi

src/nix/config.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "../config/config.h"
2+
#include "../util/logging.h"
23
#include "../crt.h"
34

45
void get_env_bool(const char_t *name, bool_t *target) {
@@ -43,4 +44,18 @@ void load_config() {
4344
get_env_path("DOORSTOP_CLR_RUNTIME_CORECLR_PATH",
4445
&config.clr_runtime_coreclr_path);
4546
get_env_path("DOORSTOP_CLR_CORLIB_DIR", &config.clr_corlib_dir);
47+
48+
//Print out all the relevant configuration settings using LOG()
49+
LOG("DOORSTOP_ENABLED: %d", config.enabled);
50+
LOG("DOORSTOP_REDIRECT_OUTPUT_LOG: %d", config.redirect_output_log);
51+
LOG("DOORSTOP_IGNORE_DISABLED_ENV: %d", config.ignore_disabled_env);
52+
LOG("DOORSTOP_MONO_DEBUG_ENABLED: %d", config.mono_debug_enabled);
53+
LOG("DOORSTOP_MONO_DEBUG_SUSPEND: %d", config.mono_debug_suspend);
54+
LOG("DOORSTOP_MONO_DEBUG_ADDRESS: %s", config.mono_debug_address);
55+
LOG("DOORSTOP_TARGET_ASSEMBLY: %s", config.target_assembly);
56+
LOG("DOORSTOP_BOOT_CONFIG_OVERRIDE: %s", config.boot_config_override);
57+
LOG("DOORSTOP_MONO_DLL_SEARCH_PATH_OVERRIDE: %s",
58+
config.mono_dll_search_path_override);
59+
LOG("DOORSTOP_CLR_RUNTIME_CORECLR_PATH: %s", config.clr_runtime_coreclr_path);
60+
LOG("DOORSTOP_CLR_CORLIB_DIR: %s", config.clr_corlib_dir);
4661
}

src/nix/entrypoint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ __attribute__((constructor)) void doorstop_ctor() {
162162
void *mono_handle = plthook_handle_by_name("libmono");
163163

164164
if (plthook_replace(hook, "mono_jit_init_version", &init_mono, NULL) != 0)
165-
printf("Failed to hook jit_init_version, ignoring it. Error: %s\n",
165+
printf("Failed to hook jit_init_version, ignoring it. This is probably fine unless you see other errors. Error: %s\n",
166166
plthook_error());
167167
else if (mono_handle)
168168
load_mono_funcs(mono_handle);

0 commit comments

Comments
 (0)