-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathbuild-rosetta.sh
executable file
·30 lines (25 loc) · 1.13 KB
/
build-rosetta.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh
# Builds retrowin32 as a x86_64 Darwin exe.
# Arguments passed through to the underlying linker.
linker_args=""
# - Shrink pagezero from 4gb to 4kb so we can use lower 32 bits of memory:
linker_args="$linker_args -segalign 0x1000 -pagezero_size 0x1000"
# - Put all our own content above 3gb:
linker_args="$linker_args -image_base 0xc0001000"
# - Disable PIE, required for moving image base:
linker_args="$linker_args -no_pie -no_fixup_chains"
# - Put our RESV32 section at 0x1000 to ensure nothing like malloc claims
# the now available lower memory:
linker_args="$linker_args -segaddr RESV32 0x1000"
# To pass the linker args through all the intermediate build layers,
# we want to end up with a RUSTFLAGS like
# -C link_arg=-Wl,-segalign,0x1000,etc
link_flag="-C link_arg=-Wl"
for arg in $linker_args; do
link_flag="$link_flag,$arg"
done
# relocation=model=dynamic-no-pic needed for disabling PIE as well.
# --print link-args
export RUSTFLAGS="$RUSTFLAGS -C relocation-model=dynamic-no-pic $link_flag"
# note: faster debug cycle if you remove 'sdl'
exec cargo build --target x86_64-apple-darwin -p retrowin32 --features x86-64,sdl "$@"