Skip to content

Commit 9c289a1

Browse files
committed
make linux ASAN compile actually work
1 parent 3b271fe commit 9c289a1

File tree

3 files changed

+92
-10
lines changed

3 files changed

+92
-10
lines changed

.ci-scripts/build-qtox-linux.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ fi
6464
SRCDIR=/qtox
6565
export CTEST_OUTPUT_ON_FAILURE=1
6666

67+
echo "SANITIZE_ARGS: ""$SANITIZE_ARGS"
68+
6769
if [ $MINIMAL -eq 1 ]; then
6870
cmake "$SRCDIR" \
6971
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \

.localrun/docker_it_asan.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#! /bin/bash
2+
3+
_HOME2_=$(dirname $0)
4+
export _HOME2_
5+
_HOME_=$(cd $_HOME2_;pwd)
6+
export _HOME_
7+
8+
echo $_HOME_
9+
cd $_HOME_
10+
11+
12+
if [ "$1""x" == "buildx" ]; then
13+
cp -a ../buildscripts .
14+
docker build -f Dockerfile -t qtox_push_002 .
15+
exit 0
16+
fi
17+
18+
cp -a ../.ci-scripts/build-qtox-linux.sh .
19+
20+
build_for='
21+
ubuntu:18.04
22+
'
23+
24+
for system_to_build_for in $build_for ; do
25+
26+
system_to_build_for_orig="$system_to_build_for"
27+
system_to_build_for=$(echo "$system_to_build_for_orig" 2>/dev/null|tr ':' '_' 2>/dev/null)
28+
29+
cd $_HOME_/
30+
mkdir -p $_HOME_/"$system_to_build_for"/
31+
32+
mkdir -p $_HOME_/"$system_to_build_for"/artefacts
33+
mkdir -p $_HOME_/"$system_to_build_for"/script
34+
mkdir -p $_HOME_/"$system_to_build_for"/workspace
35+
36+
ls -al $_HOME_/"$system_to_build_for"/
37+
38+
rsync -a ../ --exclude=.localrun $_HOME_/"$system_to_build_for"/workspace/build
39+
chmod a+rwx -R $_HOME_/"$system_to_build_for"/workspace/build
40+
41+
echo '#! /bin/bash
42+
43+
cp -av /workspace/build/* /qtox/
44+
cp -av /workspace/build/.??* /qtox/
45+
cd /qtox/.ci-scripts/
46+
47+
# disable tests
48+
sed -i -e "s#^include(Testing)##" /qtox/CMakeLists.txt
49+
cat /qtox/CMakeLists.txt|grep -i test
50+
51+
./build-qtox-linux.sh --sanitize --full --build-type Release
52+
53+
ls -hal /qtox/.ci-scripts/qtox
54+
55+
cp -av /qtox/.ci-scripts/qtox /artefacts/
56+
cp -av /usr/lib/x86_64-linux-gnu/libsnore* /artefacts/
57+
cp -av /usr/local/lib/libtoxcore* /artefacts/
58+
59+
chmod a+rwx /artefacts/*
60+
61+
' > $_HOME_/"$system_to_build_for"/script/run.sh
62+
63+
docker run -ti --rm \
64+
-v $_HOME_/"$system_to_build_for"/artefacts:/artefacts \
65+
-v $_HOME_/"$system_to_build_for"/script:/script \
66+
-v $_HOME_/"$system_to_build_for"/workspace:/workspace \
67+
--net=host \
68+
"qtox_push_002" \
69+
/bin/sh -c "apk add bash >/dev/null 2>/dev/null; /bin/bash /script/run.sh"
70+
if [ $? -ne 0 ]; then
71+
echo "** ERROR **:$system_to_build_for_orig"
72+
exit 1
73+
else
74+
echo "--SUCCESS--:$system_to_build_for_orig"
75+
fi
76+
77+
done
78+
79+

CMakeLists.txt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,6 @@ if(NOT CMAKE_BUILD_TYPE)
4242
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Options are: None, Debug, Release, RelWithDebInfo, MinSizeRel." FORCE)
4343
endif()
4444

45-
if(ASAN)
46-
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
47-
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
48-
endif()
49-
50-
if(TSAN)
51-
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=thread")
52-
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=thread")
53-
endif()
54-
5545
set(ENV{PKG_CONFIG_PATH}
5646
${CMAKE_SOURCE_DIR}/libs/lib/pkgconfig:/opt/ffmpeg/lib/pkgconfig:$ENV{PKG_CONFIG_PATH})
5747

@@ -97,6 +87,17 @@ if (NOT WIN32 AND NOT HAIKU)
9787
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all")
9888
endif()
9989

90+
if(ASAN)
91+
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
92+
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
93+
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
94+
endif()
95+
96+
if(TSAN)
97+
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=thread")
98+
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=thread")
99+
endif()
100+
100101
if (UNIX AND NOT APPLE)
101102
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,now")
102103
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,relro")

0 commit comments

Comments
 (0)