Skip to content

Commit

Permalink
Add a helper script for compiling C++ programs locally
Browse files Browse the repository at this point in the history
  • Loading branch information
fwsGonzo committed Sep 15, 2024
1 parent 779dd5b commit 7357155
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions program/cpp/test_local_compiler.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
FILE="$1"
OUT="$2"
API="api/*.cpp"
INCLUDES="-Iapi"
VERSION=6

echo "Compiling $FILES into $OUT"

WARN="-Wall"
OPTS="-std=gnu++23 -fno-stack-protector -fno-threadsafe-statics $INCLUDES"
MEMOPS=-Wl,--wrap=memcpy,--wrap=memset,--wrap=memcmp,--wrap=memmove
STROPS=-Wl,--wrap=strlen,--wrap=strcmp,--wrap=strncmp
HEAPOPS=-Wl,--wrap=malloc,--wrap=calloc,--wrap=realloc,--wrap=free
LINKEROPS="$MEMOPS $STROPS $HEAPOPS"

set -v -x
riscv64-unknown-elf-g++ -DVERSION=$VERSION -g -O2 $OPTS $WARN $API "$FILE" -o "$OUT"

0 comments on commit 7357155

Please sign in to comment.