Skip to content

Commit

Permalink
asan: centos default disable asan, and refine asan_static asan_log au…
Browse files Browse the repository at this point in the history
…to check
  • Loading branch information
chen-guanghua committed Jan 2, 2023
1 parent fff8d98 commit 7a40db9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion trunk/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ WORKDIR /srs/trunk
# Build and install SRS.
# Note that SRT is enabled by default, so we configure without --srt=on.
# Note that we have copied all files by make install.
RUN ./configure --gb28181=on --h265=on --sanitizer-static=on ${CONFARGS} && make ${MAKEARGS} && make install
RUN ./configure --gb28181=on --h265=on ${CONFARGS} && make ${MAKEARGS} && make install

############################################################
# dist
Expand Down
13 changes: 12 additions & 1 deletion trunk/auto/depends.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,18 @@ if [[ $SRS_SANITIZER == YES && $OS_IS_X86_64 == YES ]]; then
fi
fi

if [[ $SRS_SANITIZER == YES && $OS_IS_X86_64 == YES ]]; then
if [[ $SRS_SANITIZER == YES && $OS_IS_X86_64 == YES && $SRS_SANITIZER_STATIC==RESERVED ]]; then
echo 'int main() { return 0; }' > ${SRS_OBJS}/test_sanitizer.c &&
gcc -fsanitize=address -fno-omit-frame-pointer -static-libasan -g -O0 ${SRS_OBJS}/test_sanitizer.c \
-o ${SRS_OBJS}/test_sanitizer 1>/dev/null 2>&1;
ret=$?; rm -rf ${SRS_OBJS}/test_sanitizer*
if [[ $ret -eq 0 ]]; then
echo "link static-libasan"
SRS_SANITIZER_STATIC=YES
fi
fi

if [[ $SRS_SANITIZER == YES && $OS_IS_X86_64 == YES && SRS_SANITIZER_LOG == RESERVED ]]; then
echo "#include <sanitizer/asan_interface.h>" > ${SRS_OBJS}/test_sanitizer.c &&
echo "int main() { return 0; }" >> ${SRS_OBJS}/test_sanitizer.c &&
gcc -fsanitize=address -fno-omit-frame-pointer -g -O0 ${SRS_OBJS}/test_sanitizer.c \
Expand Down
13 changes: 10 additions & 3 deletions trunk/auto/options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ SRS_LOG_LEVEL_V2=YES
# Experts options.
SRS_USE_SYS_SSL=NO # Use system ssl(-lssl) if required.
SRS_VALGRIND=NO
SRS_SANITIZER=YES
SRS_SANITIZER_STATIC=NO
SRS_SANITIZER_LOG=NO
SRS_SANITIZER=RESERVED
SRS_SANITIZER_STATIC=RESERVED
SRS_SANITIZER_LOG=RESERVED
SRS_BUILD_TAG= # Set the object files tag name.
SRS_CLEAN=YES # Whether do "make clean" when configure.
SRS_SIMULATOR=NO # Whether enable RTC simulate API.
Expand Down Expand Up @@ -512,6 +512,13 @@ function apply_auto_options() {
SRS_SANITIZER=NO
fi

# For centos, default disable asan
# @see https://github.com/ossrs/srs/issues/3347
if [[ $SRS_SANITIZER == RESERVED && $OS_IS_CENTOS != YES && $OS_IS_X86_64 == YES ]]; then
echo "Disable asan for Centos"
SRS_SANITIZER=YES
fi

# if transcode/ingest specified, requires the ffmpeg stub classes.
SRS_FFMPEG_STUB=NO
if [[ $SRS_TRANSCODE == YES ]]; then SRS_FFMPEG_STUB=YES; fi
Expand Down
5 changes: 0 additions & 5 deletions trunk/configure
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,6 @@ if [[ $SRS_STATIC == YES ]]; then
SrsLinkOptions="${SrsLinkOptions} -static-libstdc++";
fi

# For asan(Google Address Sanitizer)
if [[ $SRS_SANITIZER == YES && $OS_IS_X86_64 == YES && $SRS_SANITIZER_STATIC == YES ]]; then
SrsLinkOptions="${SrsLinkOptions} -static-libasan";
fi

# For coverage.
if [[ $SRS_GCOV == YES ]]; then
SrsLinkOptions="${SrsLinkOptions} ${SrsGcov}";
Expand Down

0 comments on commit 7a40db9

Please sign in to comment.