[PATCH] D52160: [Driver] Support XRay on Fuchsia

Petr Hosek via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 21 18:40:20 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC347444: [Driver] Support XRay on Fuchsia (authored by phosek, committed by ).
Herald added a subscriber: mgorny.

Changed prior to commit:
  https://reviews.llvm.org/D52160?vs=165706&id=175009#toc

Repository:
  rC Clang

https://reviews.llvm.org/D52160

Files:
  cmake/caches/Fuchsia-stage2.cmake
  lib/Driver/ToolChains/Fuchsia.cpp
  lib/Driver/XRayArgs.cpp
  test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.xray-basic.a
  test/Driver/Inputs/resource_dir_with_per_target_subdir/aarch64-fuchsia/lib/libclang_rt.xray.a
  test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.xray-basic.a
  test/Driver/Inputs/resource_dir_with_per_target_subdir/x86_64-fuchsia/lib/libclang_rt.xray.a
  test/Driver/fuchsia.c


Index: lib/Driver/XRayArgs.cpp
===================================================================
--- lib/Driver/XRayArgs.cpp
+++ lib/Driver/XRayArgs.cpp
@@ -58,6 +58,15 @@
         D.Diag(diag::err_drv_clang_unsupported)
             << (std::string(XRayInstrumentOption) + " on " + Triple.str());
       }
+    } else if (Triple.getOS() == llvm::Triple::Fuchsia) {
+      switch (Triple.getArch()) {
+      case llvm::Triple::x86_64:
+      case llvm::Triple::aarch64:
+        break;
+      default:
+        D.Diag(diag::err_drv_clang_unsupported)
+            << (std::string(XRayInstrumentOption) + " on " + Triple.str());
+      }
     } else {
       D.Diag(diag::err_drv_clang_unsupported)
           << (std::string(XRayInstrumentOption) + " on " + Triple.str());
Index: lib/Driver/ToolChains/Fuchsia.cpp
===================================================================
--- lib/Driver/ToolChains/Fuchsia.cpp
+++ lib/Driver/ToolChains/Fuchsia.cpp
@@ -109,7 +109,8 @@
                   D.getLTOMode() == LTOK_Thin);
   }
 
-  bool NeedSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
+  bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
+  bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
   ToolChain.addProfileRTLibs(Args, CmdArgs);
 
@@ -133,9 +134,12 @@
       }
     }
 
-    if (NeedSanitizerDeps)
+    if (NeedsSanitizerDeps)
       linkSanitizerRuntimeDeps(ToolChain, CmdArgs);
 
+    if (NeedsXRayDeps)
+      linkXRayRuntimeDeps(ToolChain, CmdArgs);
+
     AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
     if (Args.hasArg(options::OPT_pthread) ||
Index: cmake/caches/Fuchsia-stage2.cmake
===================================================================
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -147,6 +147,7 @@
   llvm-size
   llvm-strip
   llvm-symbolizer
+  llvm-xray
   opt
   sancov
   CACHE STRING "")
Index: test/Driver/fuchsia.c
===================================================================
--- test/Driver/fuchsia.c
+++ test/Driver/fuchsia.c
@@ -149,6 +149,26 @@
 // CHECK-SCUDO-SHARED: "-fsanitize=safe-stack,scudo"
 // CHECK-SCUDO-SHARED: "[[RESOURCE_DIR]]{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}lib{{/|\\\\}}libclang_rt.scudo.so"
 
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN:     -fxray-instrument -fxray-modes=xray-basic \
+// RUN:     -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:     -fuse-ld=lld 2>&1 \
+// RUN:     | FileCheck %s -check-prefix=CHECK-XRAY-X86
+// CHECK-XRAY-X86: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-XRAY-X86: "-fxray-instrument"
+// CHECK-XRAY-X86: "[[RESOURCE_DIR]]{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}lib{{/|\\\\}}libclang_rt.xray.a"
+// CHECK-XRAY-X86: "[[RESOURCE_DIR]]{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}lib{{/|\\\\}}libclang_rt.xray-basic.a"
+
+// RUN: %clang %s -### --target=aarch64-fuchsia \
+// RUN:     -fxray-instrument -fxray-modes=xray-basic \
+// RUN:     -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:     -fuse-ld=lld 2>&1 \
+// RUN:     | FileCheck %s -check-prefix=CHECK-XRAY-AARCH64
+// CHECK-XRAY-AARCH64: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-XRAY-AARCH64: "-fxray-instrument"
+// CHECK-XRAY-AARCH64: "[[RESOURCE_DIR]]{{/|\\\\}}aarch64-fuchsia{{/|\\\\}}lib{{/|\\\\}}libclang_rt.xray.a"
+// CHECK-XRAY-AARCH64: "[[RESOURCE_DIR]]{{/|\\\\}}aarch64-fuchsia{{/|\\\\}}lib{{/|\\\\}}libclang_rt.xray-basic.a"
+
 // RUN: %clang %s -### --target=aarch64-fuchsia \
 // RUN:     -O3 -flto -mcpu=cortex-a53 2>&1 \
 // RUN:     -fuse-ld=lld \


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52160.175009.patch
Type: text/x-patch
Size: 3648 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181122/d7a84cb7/attachment-0001.bin>


More information about the cfe-commits mailing list