-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·23 lines (18 loc) · 844 Bytes
/
build.sh
File metadata and controls
executable file
·23 lines (18 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
DIR=$1
TARGET=$2
case $TARGET in
"aarch64-unknown-linux-gnu")
DL_LOADER="\"/lib/ld-linux-aarch64.so.1\""
;;
"x86_64-unknown-linux-gnu")
DL_LOADER="\"/lib64/ld-linux-x86-64.so.2\""
;;
esac
mkdir -p $DIR
cargo build --target $TARGET
# gcc -fPIC -pie -Wl,-E -Iself-executable-dynlib/header -Ltarget/$TARGET/debug self-executable-dynlib/shim.c -o build/libself_executable_dynlib.so -lself_executable_dynlib -lpthread -lrt -ldl
gcc -fPIC -shared -DDL_LOADER=$DL_LOADER -Wl,-e,lib_entry -Iself-executable-dynlib/header -o build/libself_executable_dynlib.so -Ltarget/$TARGET/debug self-executable-dynlib/shim.c -lself_executable_dynlib -lpthread -lrt -ldl
gcc -Iself-executable-dynlib/header main_bin/main.c -o build/main_bin -Lbuild -lself_executable_dynlib