[SERVER-49197] Prevent build failures with --sanitize=* and icecc Created: 30/Jun/20  Updated: 06/Dec/22  Resolved: 17/Jul/20

Status: Closed
Project: Core Server
Component/s: Build
Affects Version/s: 4.5 Required
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Ryan Egesdahl (Inactive) Assignee: [DO NOT ASSIGN] Backlog - Server Development Platform Team (SDP) (Inactive)
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Server Development Platform
Operating System: ALL
Sprint: Dev Platform 2020-07-27
Participants:

 Description   

Icecream as deployed in our fleet currently does not work with sanitizer blacklist files. We have a workaround in place that is supposed to prevent errors such as this:
```
ccache /opt/mongodbtoolchain/v3/bin/clang++ -o build/optdebug/mongo/db/storage/flow_control_parameters_gen.dyn.o -c -Woverloaded-virtual -Werror=unused-result -Wpessimizing-move -Wredundant-move -Wno-undefined-var-template -Wno-instantiation-after-specialization -fsized-deallocation -Wunused-exception-parameter -std=c++17 -gsplit-dwarf -fno-omit-frame-pointer -fno-strict-aliasing -fasynchronous-unwind-tables -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch -Werror -O2 -Wno-unused-local-typedefs -Wno-unused-function -Wno-unused-private-field -Wno-deprecated-declarations -Wno-tautological-constant-out-of-range-compare -Wno-tautological-constant-compare -Wno-tautological-unsigned-zero-compare -Wno-tautological-unsigned-enum-zero-compare -Wno-unused-const-variable -Wno-missing-braces -Wno-inconsistent-missing-override -Wno-potentially-evaluated-expression -Wno-unused-lambda-capture -Wno-exceptions -fstack-protector-strong -fsanitize=thread -fno-omit-frame-pointer -fsanitize-blacklist=etc/tsan.blacklist -fno-builtin-memcmp -Qunused-arguments -frewrite-includes -fPIC -DSAFEINT_USE_INTRINSICS=0 -DPCRE_STATIC -D_XOPEN_SOURCE=700 -D_GNU_SOURCE -DTHREAD_SANITIZER -DBOOST_THREAD_VERSION=5 -DBOOST_THREAD_USES_DATETIME -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS -DBOOST_ENABLE_ASSERT_DEBUG_HANDLER -DBOOST_LOG_NO_SHORTHAND_NAMES -DBOOST_LOG_USE_NATIVE_SYSLOG -DBOOST_LOG_WITHOUT_THREAD_ATTR -DABSL_FORCE_ALIGNED_ACCESS -DBOOST_LOG_DYN_LINK -Isrc/third_party/s2 -Isrc/third_party/variant-1.4.0/include -Isrc/third_party/SafeInt -Isrc/third_party/pcre-8.42 -Isrc/third_party/fmt/dist/include -Isrc/third_party/boost-1.70.0 -Isrc/third_party/abseil-cpp-master/abseil-cpp -Ibuild/optdebug -Isrc build/optdebug/mongo/db/storage/flow_control_parameters_gen.cpp
clang: error: no such file or directory: 'etc/tsan.blacklist'
clang: error: no such file or directory: 'etc/tsan.blacklist'
```

However, if you have icecream enabled, those errors show up regardless of our workaround. It's apparent that the workaround is not working.

Based on a review of the relevant code, it looks like the reason the workaround is not operating is because it's looking for sanitizer blacklist files in the command line:
```

  1. We can't handle sanitizer blacklist files, so disable icecc then, and just flow through
  2. icerun to prevent slamming the local system with a huge -j value.
    if any(
    f.startswith("-fsanitize-blacklist=")
    for fs in ["CCFLAGS", "CFLAGS", "CXXFLAGS"]
    for f in env[fs]
    ):
    env["ICECC"] = "$ICERUN" # We can't handle sanitizer blacklist files, so disable icecc then, and just flow through
  3. icerun to prevent slamming the local system with a huge -j value.
    if any(
    f.startswith("-fsanitize-blacklist=")
    for fs in ["CCFLAGS", "CFLAGS", "CXXFLAGS"]
    for f in env[fs]
    ):
    env["ICECC"] = "$ICERUN"
    ```

Unfortunately, we are using a SCons builder to replace those command-line options at compile time because we have made the blacklist files a dependency so we can force a rebuild whenever the blacklist files have changed. This means the workaround never sees what it's expecting and is effectively non-operational.

Implement a better workaround that disables remote builds when a sanitizer blacklist file is in use.



 Comments   
Comment by Ryan Egesdahl (Inactive) [ 17/Jul/20 ]

With the work done in SERVER-48041 and SERVER-47598, this will be effectively resolved.

Generated at Thu Feb 08 05:19:12 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.