Add DAWN_NO_SANITIZE("cfi-icall") to dawn procs

If the dawn procs are used from a shared lib it will trigger CFI errors
when calling across lib boundaries. This was part of the cause of the
crash in http://crbug.com/1510022.

Bug: chromium:1511050
Change-Id: I355774381aa9b71ee326ab50c1b7ae71191835d2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/165522
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Auto-Submit: Clark DuVall <cduvall@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
diff --git a/generator/templates/dawn_proc.c b/generator/templates/dawn_proc.c
index 342f184..ee9faec 100644
--- a/generator/templates/dawn_proc.c
+++ b/generator/templates/dawn_proc.c
@@ -29,6 +29,10 @@
 {% set prefix = Prefix.lower() %}
 #include "dawn/{{prefix}}_proc.h"
 
+// The sanitizer is disabled for calls to procs.* since those functions may be
+// dynamically loaded.
+#include "dawn/common/Compiler.h"
+
 static {{Prefix}}ProcTable procs;
 
 static {{Prefix}}ProcTable nullProcs;
@@ -42,6 +46,7 @@
 }
 
 {% for function in by_category["function"] %}
+    DAWN_NO_SANITIZE("cfi-icall")
     {{as_cType(function.return_type.name)}} {{as_cMethod(None, function.name)}}(
         {%- for arg in function.arguments -%}
             {% if not loop.first %}, {% endif %}{{as_annotated_cType(arg)}}
@@ -58,6 +63,7 @@
 
 {% for type in by_category["object"] %}
     {% for method in c_methods(type) %}
+        DAWN_NO_SANITIZE("cfi-icall")
         {{as_cReturnType(method.return_type)}} {{as_cMethod(type.name, method.name)}}(
             {{-as_cType(type.name)}} {{as_varName(type.name)}}
             {%- for arg in method.arguments -%}
diff --git a/src/dawn/BUILD.gn b/src/dawn/BUILD.gn
index 902c016..c599fbb 100644
--- a/src/dawn/BUILD.gn
+++ b/src/dawn/BUILD.gn
@@ -61,7 +61,10 @@
   DEFINE_PREFIX = "WGPU"
 
   public_deps = [ "${dawn_root}/include/dawn:headers" ]
-  deps = [ ":proc_gen" ]
+  deps = [
+    ":proc_gen",
+    "${dawn_root}/src/dawn/common",
+  ]
   sources = get_target_outputs(":proc_gen")
   sources += [
     "${dawn_root}/include/dawn/dawn_proc.h",
diff --git a/src/dawn/CMakeLists.txt b/src/dawn/CMakeLists.txt
index 5875f64..80ac74c 100644
--- a/src/dawn/CMakeLists.txt
+++ b/src/dawn/CMakeLists.txt
@@ -159,7 +159,13 @@
   PRIVATE
     ${DAWNPROC_GEN_SOURCES}
 )
-target_link_libraries(dawn_proc PUBLIC dawn_headers)
+target_link_libraries(dawn_proc
+  PUBLIC
+  dawn_headers
+  PRIVATE
+  dawn_common
+  dawn_internal_config
+)
 
 install_if_enabled(dawn_proc)