This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Avoid pulling libatomic to sanitizer tests
ClosedPublic

Authored by krytarowski on Sep 12 2020, 1:47 PM.

Details

Summary

Avoid fallbacking to software emulated compiler atomics, that are usually
provided by libatomic, which is not always present.

This fixes the test on NetBSD, which does not provide libatomic in base.

Diff Detail

Event Timeline

krytarowski created this revision.Sep 12 2020, 1:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 12 2020, 1:47 PM
Herald added subscribers: Restricted Project, jfb, dberris. · View Herald Transcript
krytarowski requested review of this revision.Sep 12 2020, 1:47 PM

this is about test
how can you avoid this in runtime code?

std::atomic_is_lock_free or an reimplementation of it (without pulling C++ runtime), testing a type and asserting that in runtime or build time that it is lockfree.

https://en.cppreference.com/w/cpp/atomic/atomic_is_lock_free

std::atomic_is_lock_free or an reimplementation of it (without pulling C++ runtime), testing a type and asserting that in runtime or build time that it is lockfree.

https://en.cppreference.com/w/cpp/atomic/atomic_is_lock_free

I mean the existing compiler-rt code already has atomic_uint64_t, do we need to do something about it?

vitalybuka accepted this revision.Sep 16 2020, 2:15 PM
vitalybuka added inline comments.
compiler-rt/lib/sanitizer_common/tests/sanitizer_atomic_test.cpp
76

Not for this patch but these tests must be TYPED_TEST_P

This revision is now accepted and ready to land.Sep 16 2020, 2:15 PM
This revision was landed with ongoing or failed builds.Sep 17 2020, 7:04 AM
This revision was automatically updated to reflect the committed changes.