Skip to content

Avoid passing Linux-like flags on Windows distros #1095

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

Merged
merged 3 commits into from
Feb 16, 2024
Merged
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
72 changes: 39 additions & 33 deletions .evergreen/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export CMAKE_BUILD_PARALLEL_LEVEL
if command -V ccache 2>/dev/null; then
export CMAKE_CXX_COMPILER_LAUNCHER=ccache


# Allow reuse of ccache compilation results between different build directories.
export CCACHE_BASEDIR CCACHE_NOHASHDIR
CCACHE_BASEDIR="$(pwd)"
Expand Down Expand Up @@ -99,7 +98,7 @@ esac
: "${cmake_examples_target:?}"

# Create a VERSION_CURRENT file in the build directory to include in the dist tarball.
python ./etc/calc_release_version.py > ./build/VERSION_CURRENT
python ./etc/calc_release_version.py >./build/VERSION_CURRENT
cd build

cmake_flags=(
Expand All @@ -116,7 +115,7 @@ case "${OSTYPE:?}" in
cygwin)
case "${generator:-}" in
*2015*) cmake_flags+=("-DBOOST_ROOT=C:/local/boost_1_60_0") ;;
*2017*|*2019*) cmake_flags+=("-DCMAKE_CXX_STANDARD=17") ;;
*2017* | *2019*) cmake_flags+=("-DCMAKE_CXX_STANDARD=17") ;;
*)
echo "missing explicit CMake Generator on Windows distro" 1>&2
exit 1
Expand Down Expand Up @@ -147,7 +146,9 @@ cc_flags=()
cxx_flags=()

case "${OSTYPE:?}" in
cygwin) ;;
cygwin)
# Most compiler flags are not applicable to builds on Windows distros.
;;
darwin*)
cc_flags+=("${cc_flags_init[@]}")
cxx_flags+=("${cxx_flags_init[@]}" -stdlib=libc++)
Expand All @@ -162,35 +163,40 @@ linux*)
;;
esac

# Sanitizers overwrite the usual compiler flags.
if [[ "${USE_SANITIZER_ASAN:-}" == "ON" ]]; then
cxx_flags=(
"${cxx_flags_init[@]}"
-D_GLIBCXX_USE_CXX11_ABI=0
-fsanitize=address
-O1 -g -fno-omit-frame-pointer
)
fi
if [[ "${USE_SANITIZER_UBSAN:-}" == "ON" ]]; then
cxx_flags=(
"${cxx_flags_init[@]}"
-D_GLIBCXX_USE_CXX11_ABI=0
-fsanitize=undefined
-fsanitize-blacklist="$(pwd)/../etc/ubsan.ignorelist"
-fno-sanitize-recover=undefined
-O1 -g -fno-omit-frame-pointer
)
fi

# Ignore warnings generated by core::optional in mnmlstc/core.
if [[ "${OSTYPE:?}" == linux* && "${HOSTTYPE:?}" == powerpc64le ]]; then
cxx_flags+=(-Wno-error=maybe-uninitialized)
fi

# Ignore deprecation warnings when building on a release branch.
if [ "$(echo "${branch_name:?}" | cut -f2 -d'/')" != "${branch_name:?}" ]; then
cc_flags+=(-Wno-deprecated-declarations)
cxx_flags+=(-Wno-deprecated-declarations)
# Most compiler flags are not applicable to builds on Windows distros.
if [[ "${OSTYPE:?}" != cygwin ]]; then
# Sanitizers overwrite the usual compiler flags.
if [[ "${USE_SANITIZER_ASAN:-}" == "ON" ]]; then
cxx_flags=(
"${cxx_flags_init[@]}"
-D_GLIBCXX_USE_CXX11_ABI=0
-fsanitize=address
-O1 -g -fno-omit-frame-pointer
)
fi

# Sanitizers overwrite the usual compiler flags.
if [[ "${USE_SANITIZER_UBSAN:-}" == "ON" ]]; then
cxx_flags=(
"${cxx_flags_init[@]}"
-D_GLIBCXX_USE_CXX11_ABI=0
-fsanitize=undefined
-fsanitize-blacklist="$(pwd)/../etc/ubsan.ignorelist"
-fno-sanitize-recover=undefined
-O1 -g -fno-omit-frame-pointer
)
fi

# Ignore warnings generated by core::optional in mnmlstc/core.
if [[ "${OSTYPE:?}" == linux* && "${HOSTTYPE:?}" == powerpc64le ]]; then
cxx_flags+=(-Wno-error=maybe-uninitialized)
fi

# Ignore deprecation warnings when building on a release branch.
if [[ "$(echo "${branch_name:?}" | cut -f2 -d'/')" != "${branch_name:?}" ]]; then
cc_flags+=(-Wno-deprecated-declarations)
cxx_flags+=(-Wno-deprecated-declarations)
fi
fi

if [[ "${#cc_flags[@]}" -gt 0 ]]; then
Expand Down