This is an archive of the discontinued LLVM Phabricator instance.

sanitizer_common: prefix thread-safety macros with SANITIZER_
ClosedPublic

Authored by dvyukov on Jan 5 2022, 4:36 AM.

Details

Summary

Currently we use very common names for macros like ACQUIRE/RELEASE,
which cause conflicts with system headers.
Prefix all macros with SANITIZER_ to avoid conflicts.

Diff Detail

Unit TestsFailed

Event Timeline

dvyukov created this revision.Jan 5 2022, 4:36 AM
dvyukov requested review of this revision.Jan 5 2022, 4:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 5 2022, 4:36 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
vitalybuka accepted this revision.Jan 5 2022, 10:54 AM

Awesome! Thanks!

compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
174

is possible to fix these clang-format checks?

This revision is now accepted and ready to land.Jan 5 2022, 10:54 AM
dvyukov updated this revision to Diff 398117.Jan 7 2022, 5:59 AM

fixed lint warnings

compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
174

Humm... not sure why arc did not fix this...
Done now.

This revision was landed with ongoing or failed builds.Jan 7 2022, 6:11 AM
This revision was automatically updated to reflect the committed changes.

hi,

So this change seems to break Fuchsia's canary builders for LLVM. Seems maybe a few of the macros were not updated?

If this is not too hard to fix, could you revert until a patch is ready?

The error we're seeing is:

FAILED: compiler-rt/lib/scudo/CMakeFiles/clang_rt.scudo_minimal-x86_64.dir/scudo_allocator.cpp.obj 
/b/s/w/ir/x/w/staging/llvm_build/./bin/clang++ --target=x86_64-unknown-fuchsia --sysroot=/b/s/w/ir/x/w/cipd/sdk/arch/x64/sysroot -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/scudo/.. --target=x86_64-unknown-fuchsia -I/b/s/w/ir/x/w/cipd/sdk/pkg/sync/include -I/b/s/w/ir/x/w/cipd/sdk/pkg/fdio/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -ffunction-sections -fdata-sections -ffile-prefix-map=/b/s/w/ir/x/w/staging/llvm_build/runtimes/runtimes-x86_64-unknown-fuchsia-bins=../staging/llvm_build/runtimes/runtimes-x86_64-unknown-fuchsia-bins -ffile-prefix-map=/b/s/w/ir/x/w/llvm-llvm-project/= -no-canonical-prefixes -Wall -std=c++14 -Wno-unused-parameter -O2 -g -DNDEBUG  -fno-lto -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -O3 -gline-tables-only -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -nostdinc++ -fbuiltin -fno-rtti -Wno-format -fno-omit-frame-pointer -nostdinc++ -UNDEBUG -MD -MT compiler-rt/lib/scudo/CMakeFiles/clang_rt.scudo_minimal-x86_64.dir/scudo_allocator.cpp.obj -MF compiler-rt/lib/scudo/CMakeFiles/clang_rt.scudo_minimal-x86_64.dir/scudo_allocator.cpp.obj.d -o compiler-rt/lib/scudo/CMakeFiles/clang_rt.scudo_minimal-x86_64.dir/scudo_allocator.cpp.obj -c /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/scudo/scudo_allocator.cpp
In file included from /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/scudo/scudo_allocator.cpp:21:
In file included from /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/scudo/scudo_tsd.h:61:
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/scudo/scudo_tsd_shared.inc:45:37: error: expected function body after function declarator
getTSDAndLock(bool *UnlockRequired) NO_THREAD_SAFETY_ANALYSIS {
                                    ^
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/scudo/scudo_allocator.cpp:352:23: error: use of undeclared identifier 'getTSDAndLock'; did you mean 'getTSDAndLockSlow'?
      ScudoTSD *TSD = getTSDAndLock(&UnlockRequired);
                      ^~~~~~~~~~~~~
                      getTSDAndLockSlow
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/scudo/scudo_tsd_shared.inc:42:11: note: 'getTSDAndLockSlow' declared here
ScudoTSD *getTSDAndLockSlow(ScudoTSD *TSD);
          ^
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/scudo/scudo_allocator.cpp:352:37: error: cannot initialize a parameter of type '__scudo::ScudoTSD *' with an rvalue of type 'bool *'
      ScudoTSD *TSD = getTSDAndLock(&UnlockRequired);
                                    ^~~~~~~~~~~~~~~
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/scudo/scudo_tsd_shared.inc:42:39: note: passing argument to parameter 'TSD' here
ScudoTSD *getTSDAndLockSlow(ScudoTSD *TSD);
                                      ^
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/scudo/scudo_allocator.cpp:418:25: error: use of undeclared identifier 'getTSDAndLock'; did you mean 'getTSDAndLockSlow'?
        ScudoTSD *TSD = getTSDAndLock(&UnlockRequired);
                        ^~~~~~~~~~~~~
                        getTSDAndLockSlow
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/scudo/scudo_tsd_shared.inc:42:11: note: 'getTSDAndLockSlow' declared here
ScudoTSD *getTSDAndLockSlow(ScudoTSD *TSD);
          ^
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/scudo/scudo_allocator.cpp:418:39: error: cannot initialize a parameter of type '__scudo::ScudoTSD *' with an rvalue of type 'bool *'
        ScudoTSD *TSD = getTSDAndLock(&UnlockRequired);
                                      ^~~~~~~~~~~~~~~
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/scudo/scudo_tsd_shared.inc:42:39: note: passing argument to parameter 'TSD' here
ScudoTSD *getTSDAndLockSlow(ScudoTSD *TSD);
                                      ^
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/scudo/scudo_allocator.cpp:437:23: error: use of undeclared identifier 'getTSDAndLock'; did you mean 'getTSDAndLockSlow'?
      ScudoTSD *TSD = getTSDAndLock(&UnlockRequired);
                      ^~~~~~~~~~~~~
                      getTSDAndLockSlow
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/scudo/scudo_tsd_shared.inc:42:11: note: 'getTSDAndLockSlow' declared here
ScudoTSD *getTSDAndLockSlow(ScudoTSD *TSD);
          ^
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/scudo/scudo_allocator.cpp:437:37: error: cannot initialize a parameter of type '__scudo::ScudoTSD *' with an rvalue of type 'bool *'
      ScudoTSD *TSD = getTSDAndLock(&UnlockRequired);
                                    ^~~~~~~~~~~~~~~
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/scudo/scudo_tsd_shared.inc:42:39: note: passing argument to parameter 'TSD' here
ScudoTSD *getTSDAndLockSlow(ScudoTSD *TSD);
                                      ^

It seems to me that NO_THREAD_SAFETY_ANALYSIS is just missing the SANITIZER_ prefix. so hopefully this will be easy to address.

Landed D116818 to fix this. Thanks for the report.