[PATCH] add supporting of the sanitizer arguments into Clang on FreeBSD platform.
Richard Smith
richard at metafoo.co.uk
Tue Jan 28 17:08:15 PST 2014
This patch needs a corresponding set of tests in test/Driver.
Do the asan, msan, tsan, ubsan, ... test suites pass on freebsd with this change?
================
Comment at: lib/Driver/Tools.cpp:5896
@@ +5895,3 @@
+ (Args.hasArg(options::OPT_pie) || Sanitize.hasZeroBaseShadow());
+ const bool needsDefaultLibs =
+ !Args.hasArg(options::OPT_nostdlib) &&
----------------
Local variable names should start with an uppercase letter.
================
Comment at: lib/Driver/Tools.cpp:5889
@@ -5841,3 +5888,3 @@
const char *LinkingOutput) const {
- const toolchains::FreeBSD& ToolChain =
+ const toolchains::FreeBSD& ToolChain =
static_cast<const toolchains::FreeBSD&>(getToolChain());
----------------
Put the & on the right, please, since you're touching this line anyway =)
================
Comment at: lib/Driver/Tools.cpp:5899-5904
@@ +5898,8 @@
+ !Args.hasArg(options::OPT_nodefaultlibs);
+ const bool needsCXXSanRt =
+ !Args.hasArg(options::OPT_shared) &&
+ (Sanitize.needsAsanRt() ||
+ Sanitize.needsTsanRt() ||
+ Sanitize.needsMsanRt() ||
+ Sanitize.needsLsanRt());
+ const bool needsUbsanRt = Sanitize.needsUbsanRt();
----------------
I think you only need a C++ stdlib if you're using certain parts of ubsan (asan, tsan, msan, and lsan shouldn't require it IIUC).
================
Comment at: lib/Driver/Tools.cpp:1963
@@ +1962,3 @@
+ const StringRef Sanitizer) {
+ // Sanitizer runtime is located in the Linux library directory and
+ // has name "libclang_rt.<Sanitizer>-<ArchName>.a".
----------------
You mean, "in the freebsd directory"?
================
Comment at: lib/Driver/Tools.cpp:6029
@@ +6028,3 @@
+ bool ex = false;
+ ex = (Sanitize.needsAsanRt() &&
+ !addSanitizerRTLinkFlagFreeBSD(ToolChain, Args, CmdArgs, "asan")) || ex;
----------------
ex |= ... ?
================
Comment at: lib/Driver/Tools.cpp:6027-6028
@@ +6026,4 @@
+ }
+ // export-dynamic option flag.
+ bool ex = false;
+ ex = (Sanitize.needsAsanRt() &&
----------------
Please give this a more informative name rather than using a comment to describe what it is.
================
Comment at: lib/Driver/Tools.cpp:6058-6062
@@ +6057,7 @@
+
+ if (needsUbsanRt && D.CCCIsCXX()) {
+ // Only include the bits of the runtime which need a C++ ABI library if
+ // we're linking in C++ mode.
+ addSanitizerRTLinkFlagFreeBSD(ToolChain, Args, CmdArgs, "ubsan_cxx");
+ }
+
----------------
I would expect this either needs `-whole-archive` or needs to come at the end of the linker arguments? (None of the symbols in this archive will be needed at this point.)
http://llvm-reviews.chandlerc.com/D2644
More information about the cfe-commits
mailing list