This is an archive of the discontinued LLVM Phabricator instance.

Cleanup and generalize -shared-libasan.
ClosedPublic

Authored by eugenis on Oct 3 2017, 5:53 PM.

Details

Summary
  • Add -static-libasan for targets that default to shared.
  • Remove an Android special case. It is now possible (but untested) to use static compiler-rt libraries there.
  • Support libclang_rt.ubsan_standalone as a shared library.

Unlike GCC, this change applies -shared-libasan / -static-libasan to all sanitizers.
I don't see a point in multiple flags like -shared-libubsan, considering that most sanitizers
are not compatible with each other, and each link has basically a single shared/static choice.

Diff Detail

Repository
rL LLVM

Event Timeline

eugenis created this revision.Oct 3 2017, 5:53 PM
rsmith added a subscriber: rsmith.Oct 4 2017, 2:40 PM

Could we perhaps rename these flags to e.g. -static-libsan (with a -static-libasan alias for compatibility)? It seems confusing that the way to enable a static tsan runtime would be with -static-libasan.

vitalybuka edited edge metadata.Oct 4 2017, 4:10 PM

Could we perhaps rename these flags to e.g. -static-libsan (with a -static-libasan alias for compatibility)? It seems confusing that the way to enable a static tsan runtime would be with -static-libasan.

I like this idea as well. If we go this way we need to deprecate "shared-libasan" and avoid adding "static-libasan.

eugenis updated this revision to Diff 117767.Oct 4 2017, 5:16 PM

renamed flags to *-libsan

vitalybuka accepted this revision.Oct 5 2017, 12:48 PM
vitalybuka added inline comments.
clang/lib/Driver/SanitizerArgs.cpp
614 ↗(On Diff #117767)
SharedRuntime = Args.hasFlag(options::OPT_shared_libsan,,
                     options::OPT_static_libsan,
                     TC.getTriple().isAndroid() || TC.getTriple().isOSFuchsia());
clang/lib/Driver/ToolChains/CommonArgs.cpp
563 ↗(On Diff #117767)

Shouldn't ubsan changes be in the separate patch?

This revision is now accepted and ready to land.Oct 5 2017, 12:48 PM
eugenis added inline comments.Oct 5 2017, 1:01 PM
clang/lib/Driver/ToolChains/CommonArgs.cpp
563 ↗(On Diff #117767)

They are quite hard to separate, and without ubsan there is not much point to this change.

eugenis updated this revision to Diff 117875.Oct 5 2017, 1:04 PM

address comment

eugenis added inline comments.Oct 5 2017, 1:05 PM
clang/lib/Driver/SanitizerArgs.cpp
614 ↗(On Diff #117767)

good!

This revision was automatically updated to reflect the committed changes.