File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ abs_path() {
123123 echo " $( cd " $( dirname " $1 " ) " && pwd) /$( basename " $1 " ) "
124124}
125125
126- # Set executable path and the extension to use for the libdoorstop shared object
126+ # Set executable path and the extension to use for the libdoorstop shared object as well as check whether we're running on Apple Silicon
127127os_type=" $( uname -s) "
128128case ${os_type} in
129129 Linux* )
@@ -148,6 +148,14 @@ case ${os_type} in
148148 ;;
149149 esac
150150 lib_extension=" dylib"
151+
152+ # CPUs for Apple Silicon are in the format "Apple M.."
153+ cpu_type=" $( sysctl -n machdep.cpu.brand_string) "
154+ case " ${cpu_type} " in
155+ Apple* )
156+ is_apple_silicon=1
157+ ;;
158+ esac
151159 ;;
152160 * )
153161 # alright whos running games on freebsd
@@ -309,4 +317,14 @@ else
309317 export DYLD_INSERT_LIBRARIES=" ${doorstop_name} :${DYLD_INSERT_LIBRARIES} "
310318fi
311319
312- exec " $executable_path " " $@ "
320+ if [ -n " ${is_apple_silicon} " ]; then
321+ export ARCHPREFERENCE=" arm64,x86_64"
322+
323+ # We need to use arch for Apple Silicon to allow the executable to be run natively as otherwise if
324+ # the executable is universal, supporting both x86_64 and arm64, MacOs will still run it as x86_64
325+ # if the parent process is running as x86.
326+ # arch also strips the DYLD_INSERT_LIBRARIES env var so we have to pass that in manually
327+ arch -e DYLD_INSERT_LIBRARIES=$DYLD_INSERT_LIBRARIES " $executable_path " " $@ "
328+ else
329+ exec " $executable_path " " $@ "
330+ fi
You can’t perform that action at this time.
0 commit comments