Skip to content

Commit

Permalink
Merge pull request #3028 from MirServer/cleanup-sanitizers
Browse files Browse the repository at this point in the history
sanitizers: clean things up for sanitizers, spread: simpler dependency install
  • Loading branch information
AlanGriffiths authored Aug 31, 2023
2 parents a67f858 + 32c2f13 commit b835713
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 52 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/spread.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@ jobs:
echo "max_size = 800M" > ${CCACHE_DIR}/ccache.conf
- name: Run Spread task
run: snap run spread-mir-ci.spread -v ${{ matrix.spread-task }}
run: snap run spread-mir-ci.spread -reuse -v ${{ matrix.spread-task }}

- name: CCache stats
run: cat ${CCACHE_DIR}/ccache.stats

- if: ${{ failure() && runner.debug }}
name: Setup upterm session
uses: lhotari/action-upterm@v1
with:
limit-access-to-actor: true
45 changes: 8 additions & 37 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,51 +144,22 @@ if(cmake_build_type_lower MATCHES "coverage")
endif()

if(cmake_build_type_lower MATCHES "addresssanitizer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=address")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address")
if (CMAKE_COMPILER_IS_GNUCXX)
# Work around GCC bug. It should automatically link to asan when
# -fsanitize=address is used, but doesn't.
#
# Linking everything with asan is harmless and simple, so do that.
link_libraries(asan) # Workaround for LP:1413474
endif()
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
add_link_options(-fsanitize=address)
elseif(cmake_build_type_lower MATCHES "threadsanitizer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=thread")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=thread")
if (CMAKE_COMPILER_IS_GNUCXX)
# Work around GCC bug. It should automatically link to tsan when
# -fsanitize=thread is used, but doesn't.
#
# Linking everything with tsan is harmless and simple, so do that.
link_libraries(tsan) # Workaround for LP:1413474
endif()
add_compile_options(-fsanitize=thread -fno-omit-frame-pointer)
add_link_options(-fsanitize=thread)
elseif(cmake_build_type_lower MATCHES "ubsanitizer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=undefined")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=undefined")
add_compile_options(-fsanitize=undefined -fno-omit-frame-pointer)
add_link_options(-fsanitize=undefined)
# "Symbol already defined" errors occur with pre-compiled headers
SET(MIR_USE_PRECOMPILED_HEADERS OFF CACHE BOOL "Use precompiled headers" FORCE)
if (CMAKE_COMPILER_IS_GNUCXX)
# Work around GCC bug. It should automatically link to asan when
# -fsanitize=undefined is used, but doesn't.
#
# Linking everything with ubsan is harmless and simple, so do that.
link_libraries(ubsan) # Workaround for LP:1413474
endif()
# We have inline classes as interfaces used by .so's and implemented elsewhere.
# This results in multiple trivial implementations. So let's not warn about that.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize=vptr")
add_compile_options(-fno-sanitize=vptr)
else()
# AddressSanitizer builds fail if we disallow undefined symbols
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined")
add_link_options(-Wl,--no-undefined)
endif()

enable_testing()
Expand Down
5 changes: 3 additions & 2 deletions spread.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ environment:
BUILD_TYPE/asan,asan_clang: AddressSanitizer
BUILD_TYPE/tsan,tsan_clang: ThreadSanitizer
BUILD_TYPE/ubsan,ubsan_clang: UBSanitizer
NOCHECK: ""
NOCHECK/asan,tsan,asan_clang,tsan_clang: nocheck
DEB_BUILD_EXTRA:
DEB_BUILD_EXTRA/ubsan,ubsan_clang: nostrip
DEB_BUILD_EXTRA/asan,asan_clang,tsan,tsan_clang: nostrip nocheck
CTEST_OUTPUT_ON_FAILURE: 1
CCACHE_DIR: /root/.ccache
# Needed for precompiled headers (https://ccache.dev/manual/latest.html#_precompiled_headers)
Expand Down
2 changes: 1 addition & 1 deletion spread/build/sbuild/task.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
environment:
DEB_BUILD_OPTIONS: "${NOCHECK}"
DEB_BUILD_OPTIONS: "${DEB_BUILD_EXTRA}"
NO_PKG_MANGLE: 1

systems: [ubuntu-*]
Expand Down
16 changes: 5 additions & 11 deletions spread/build/ubuntu/task.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
environment:
DEB_BUILD_OPTIONS: "parallel=$( nproc ) noopt ${NOCHECK}"
DEB_BUILD_OPTIONS: "parallel=$( nproc ) noopt ${DEB_BUILD_EXTRA}"
NO_PKG_MANGLE: 1

systems: [ubuntu-*]
Expand All @@ -12,20 +12,19 @@ summary: Build Ubuntu packages
execute: |
cd $SPREAD_PATH
apt-get install --yes software-properties-common
NODBG=$( [[ "${DEB_BUILD_OPTIONS}" != *nostrip* ]] && echo true || echo false )
# Add Mir dev PPA for any out-of-archive packages needed
# (Currently: a newer version of WLCS)
add-apt-repository ppa:mir-team/dev
add-apt-repository ppa:mir-team/dev --component "main $( $NODBG || echo main/debug )"
# to get dpkg-architecture and mk-build-deps
apt-get install \
--yes \
--no-install-recommends \
ccache \
devscripts \
dpkg-dev \
equivs
$( $NODBG || echo wlcs-dbgsym )
# set host and build environment up
source <( dpkg-architecture --print-set --host-arch ${ARCH} )
Expand Down Expand Up @@ -59,18 +58,13 @@ execute: |
apt-get update
apt-get --yes install qemu-user-static binfmt-support
# Quirk for the eglexternalplatform-dev build dependency
sed -i 's/\(eglexternalplatform-dev\)/\1:all/' debian/control
fi
# Mark the "release" in the changelog
debchange --release "CI release"
# install dependencies
mk-build-deps \
--install \
--tool "apt-get --yes -o Debug::pkgProblemResolver=yes -o APT::Immediate-Configure=0"
apt-get build-dep --yes ./
# use clang
if [ "${CLANG}" -eq 1 ]; then
Expand Down

0 comments on commit b835713

Please sign in to comment.