[PATCH] D30022: [XRay][compiler-rt] Allow for defining defaults at compile-time

Dean Michael Berris via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 15 19:11:16 PST 2017


dberris created this revision.

Currently, defaulted options cannot be overriden easily. As an example,
we always patch the binary pre-main unless the user defines the option
at the commandline to inhibit this behaviour. This change allows for
building different versions of the XRay archive with different defaults
(whether to patch pre-main, or whether to use FDR mode by default, etc.)
and giving that choice at link-time.

For now we don't create different archives that have different defaults,
but those could be added in later revisions. This change just enables
the possibility.


https://reviews.llvm.org/D30022

Files:
  lib/xray/xray_flags.cc


Index: lib/xray/xray_flags.cc
===================================================================
--- lib/xray/xray_flags.cc
+++ lib/xray/xray_flags.cc
@@ -37,6 +37,16 @@
 #undef XRAY_FLAG
 }
 
+static const char *useCompilerDefinedFlags() {
+#ifdef XRAY_DEFAULT_OPTIONS
+#define XRAY_STRINGIZE(x) #x
+#define XRAY_STRINGIZE_OPTIONS(options) XRAY_STRINGIZE(options)
+  return XRAY_STRINGIZE_OPTIONS(XRAY_DEFAULT_OPTIONS);
+#else
+  return "";
+#endif
+}
+
 void initializeFlags() XRAY_NEVER_INSTRUMENT {
   SetCommonFlagsDefaults();
   auto *F = flags();
@@ -49,6 +59,9 @@
   // Override from command line.
   XRayParser.ParseString(GetEnv("XRAY_OPTIONS"));
 
+  // Use options defaulted at compile-time for the runtime.
+  const char *XRayCompileFlags = useCompilerDefinedFlags();
+  XRayParser.ParseString(XRayCompileFlags);
   InitializeCommonFlags();
 
   if (Verbosity())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30022.88651.patch
Type: text/x-patch
Size: 877 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170216/7dc05c85/attachment.bin>


More information about the llvm-commits mailing list