Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-86898

Bazel with Ubsan is passing a series of sanitize options to Clang instead of -fsanitize=undefined

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Build
    • ALL
    • 131

      When adding -fsanitize=undefined to a bazel target's copt, it invokes clang with a series of options instead of -fsanitize=undefined:

       /home/ubuntu/mongo/build/bazelisk build --//bazel/config:compiler_type=clang --//bazel/config:build_mode=opt_debug --//bazel/config:separate_debug=False --//bazel/config:libunwind=auto --//bazel/config:use_gdbserver=False --//bazel/config:spider_monkey_dbg=False --//bazel/config:allocator=system --//bazel/config:use_lldbserver=False --//bazel/config:use_wait_for_debugger=False --//bazel/config:use_ocsp_stapling=True --//bazel/config:use_disable_ref_track=False --//bazel/config:use_wiredtiger=True --//bazel/config:use_glibcxx_debug=False --//bazel/config:build_grpc=False --//bazel/config:use_libcxx=False --//bazel/config:detect_odr_violations=False --//bazel/config:linkstatic=True --//bazel/config:use_diagnostic_latches=False --//bazel/config:shared_archive=False --//bazel/config:linker=lld --//bazel/config:streams_release_build=True --//bazel/config:build_enterprise=False --//bazel/config:visibility_support=auto --platforms=//bazel/platforms:linux_arm64_clang --host_platform=//bazel/platforms:linux_arm64_clang --compilation_mode=dbg --//bazel/config:http_client=True --//bazel/config:ubsan=True --//bazel/config:asan=False //src/mongo/platform:visibility_test1 --config=local
      
      -fsanitize=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound,vptr
      

      It's possible there's logic in bazel's internals to perform this switch, but it's unclear why it's doing it and if it is actually equivalent to -fsanitize=undefined.

            Assignee:
            udita.bose@mongodb.com Udita Bose
            Reporter:
            zack.winter@mongodb.com Zack Winter
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: