Skip to content

Add csafe and cppsafe executables with sanitizers support #1878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sql/files/defaultdata/cppsafe/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
# nothing to compile
22 changes: 22 additions & 0 deletions sql/files/defaultdata/cppsafe/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

# C++ compile wrapper-script for 'compile.sh'.
# See that script for syntax and more info.

DEST="$1" ; shift
MEMLIMIT="$1" ; shift

# Add -DONLINE_JUDGE or -DDOMJUDGE below if you want it make easier for teams
# to do local debugging.

# -x c++: Explicitly set compile language to C++ (no object files or
# other languages autodetected by extension)
# -Wall: Report all warnings
# -fsanitize: Enable the specified Sanitizers, see https://github.com/google/sanitizers for the full documentation
# -fPIE -pie -fno-omit-frame-pointer -fno-optimize-sibling-calls: Make code position independent and disable optimizations that may obfuscate the info provided by the
sanitizers
# -g: Include debugging/symbol information in the executable, improves sanitizers output if an error is detected
# -O2: Level 2 optimizations (default for speed)
# -pipe: Use pipes for communication between stages of compilation
g++ -x c++ -Wall -fsanitize=address,undefined -fPIE -pie -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -O2 -pipe -o "$DEST" "$@"
exit $?
2 changes: 2 additions & 0 deletions sql/files/defaultdata/csafe/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
# nothing to compile
24 changes: 24 additions & 0 deletions sql/files/defaultdata/csafe/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

# C compile wrapper-script for 'compile.sh'.
# See that script for syntax and more info.

DEST="$1" ; shift
MEMLIMIT="$1" ; shift

# Add -DONLINE_JUDGE or -DDOMJUDGE below if you want it make easier for teams
# to do local debugging.

# -x c: Explicitly set compile language to C (no C++ nor object files
# autodetected by extension)
# -Wall: Report all warnings
# -fsanitize: Enable the specified Sanitizers, see https://github.com/google/sanitizers for the full documentation
# -fPIE -pie -fno-omit-frame-pointer -fno-optimize-sibling-calls: make code position independent and disable optimizations that may obfuscate the info provided by the
sanitizers
# -g: Include debugging/symbol information in the executable, improves sanitizers output if an error is detected
# -O2: Level 2 optimizations (default for speed)
# -g have file names and line numbers included in warning messages
# -pipe: Use pipes for communication between stages of compilation
# -lm: Link with math-library (has to be last argument!)
gcc -x c -Wall -fsanitize=address,undefined -fPIE -pie -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -O2 -pipe -o "$DEST" "$@" -lm
exit $?