[compiler-rt] r214259 - [UBSan] Allow to override runtime flags defaults by providing
Alexey Samsonov
vonosmas at gmail.com
Tue Jul 29 17:01:41 PDT 2014
Author: samsonov
Date: Tue Jul 29 19:01:41 2014
New Revision: 214259
URL: http://llvm.org/viewvc/llvm-project?rev=214259&view=rev
Log:
[UBSan] Allow to override runtime flags defaults by providing
compile definition UBSAN_DEFAULT_OPTIONS when building the runtime.
This mirrors similar ASan functionality.
Modified:
compiler-rt/trunk/lib/ubsan/ubsan_flags.cc
Modified: compiler-rt/trunk/lib/ubsan/ubsan_flags.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/ubsan_flags.cc?rev=214259&r1=214258&r2=214259&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan/ubsan_flags.cc (original)
+++ compiler-rt/trunk/lib/ubsan/ubsan_flags.cc Tue Jul 29 19:01:41 2014
@@ -17,11 +17,24 @@
namespace __ubsan {
+static const char *GetRuntimeFlagsFromCompileDefinition() {
+#ifdef UBSAN_DEFAULT_OPTIONS
+// Stringize the macro value
+# define UBSAN_STRINGIZE(x) #x
+# define UBSAN_STRINGIZE_OPTIONS(options) UBSAN_STRINGIZE(options)
+ return UBSAN_STRINGIZE_OPTIONS(UBSAN_DEFAULT_OPTIONS);
+#else
+ return "";
+#endif
+}
+
void InitializeCommonFlags() {
CommonFlags *cf = common_flags();
SetCommonFlagsDefaults(cf);
cf->print_summary = false;
- // Common flags may be overriden in UBSAN_OPTIONS.
+ // Override from compile definition.
+ ParseCommonFlagsFromString(cf, GetRuntimeFlagsFromCompileDefinition());
+ // Override from environment variable.
ParseCommonFlagsFromString(cf, GetEnv("UBSAN_OPTIONS"));
}
@@ -38,6 +51,8 @@ void InitializeFlags() {
Flags *f = flags();
// Default values.
f->print_stacktrace = false;
+ // Override from compile definition.
+ ParseFlagsFromString(f, GetRuntimeFlagsFromCompileDefinition());
// Override from environment variable.
ParseFlagsFromString(f, GetEnv("UBSAN_OPTIONS"));
}
More information about the llvm-commits
mailing list