1*d4726bddSHONG Yifandiff --git a/utils/bazel/configure.bzl b/utils/bazel/configure.bzl 2*d4726bddSHONG Yifanindex 4c5ab8bd0972..44de2da1a136 100644 3*d4726bddSHONG Yifan--- a/utils/bazel/configure.bzl 4*d4726bddSHONG Yifan+++ b/utils/bazel/configure.bzl 5*d4726bddSHONG Yifan@@ -70,6 +70,11 @@ def _overlay_directories(repository_ctx): 6*d4726bddSHONG Yifan )) 7*d4726bddSHONG Yifan 8*d4726bddSHONG Yifan def _llvm_configure_impl(repository_ctx): 9*d4726bddSHONG Yifan+ # Force this repository rule to update if any of the overlay 10*d4726bddSHONG Yifan+ # sources change. 11*d4726bddSHONG Yifan+ for target in repository_ctx.attr._srcs: 12*d4726bddSHONG Yifan+ repository_ctx.path(target) 13*d4726bddSHONG Yifan+ 14*d4726bddSHONG Yifan _overlay_directories(repository_ctx) 15*d4726bddSHONG Yifan 16*d4726bddSHONG Yifan # Create a starlark file with the requested LLVM targets. 17*d4726bddSHONG Yifan@@ -86,6 +91,16 @@ llvm_configure = repository_rule( 18*d4726bddSHONG Yifan configure = True, 19*d4726bddSHONG Yifan attrs = { 20*d4726bddSHONG Yifan "targets": attr.string_list(default = DEFAULT_TARGETS), 21*d4726bddSHONG Yifan+ "_srcs": attr.label_list(default = [ 22*d4726bddSHONG Yifan+ Label("//utils/bazel/llvm-project-overlay/clang:BUILD.bazel"), 23*d4726bddSHONG Yifan+ Label("//utils/bazel/llvm-project-overlay/libunwind:BUILD.bazel"), 24*d4726bddSHONG Yifan+ Label("//utils/bazel/llvm-project-overlay/llvm:binary_alias.bzl"), 25*d4726bddSHONG Yifan+ Label("//utils/bazel/llvm-project-overlay/llvm:BUILD.bazel"), 26*d4726bddSHONG Yifan+ Label("//utils/bazel/llvm-project-overlay/llvm:cc_plugin_library.bzl"), 27*d4726bddSHONG Yifan+ Label("//utils/bazel/llvm-project-overlay/llvm:config.bzl"), 28*d4726bddSHONG Yifan+ Label("//utils/bazel/llvm-project-overlay/llvm:tblgen.bzl"), 29*d4726bddSHONG Yifan+ Label("//utils/bazel/llvm-project-overlay/llvm:template_rule.bzl"), 30*d4726bddSHONG Yifan+ ]), 31*d4726bddSHONG Yifan }, 32*d4726bddSHONG Yifan ) 33*d4726bddSHONG Yifan 34*d4726bddSHONG Yifandiff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel 35*d4726bddSHONG Yifanindex a2b1e0f33073..0c1abe607b58 100644 36*d4726bddSHONG Yifan--- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel 37*d4726bddSHONG Yifan+++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel 38*d4726bddSHONG Yifan@@ -5,6 +5,7 @@ 39*d4726bddSHONG Yifan load("//llvm:tblgen.bzl", "gentbl") 40*d4726bddSHONG Yifan load("//llvm:binary_alias.bzl", "binary_alias") 41*d4726bddSHONG Yifan load("//llvm:cc_plugin_library.bzl", "cc_plugin_library") 42*d4726bddSHONG Yifan+load("//llvm:config.bzl", "llvm_stdcxx_copts") 43*d4726bddSHONG Yifan 44*d4726bddSHONG Yifan package( 45*d4726bddSHONG Yifan default_visibility = ["//visibility:public"], 46*d4726bddSHONG Yifan@@ -28,7 +29,7 @@ cc_binary( 47*d4726bddSHONG Yifan ]), 48*d4726bddSHONG Yifan copts = [ 49*d4726bddSHONG Yifan "$(STACK_FRAME_UNLIMITED)", 50*d4726bddSHONG Yifan- ], 51*d4726bddSHONG Yifan+ ] + llvm_stdcxx_copts, 52*d4726bddSHONG Yifan stamp = 0, 53*d4726bddSHONG Yifan deps = [ 54*d4726bddSHONG Yifan "//llvm:Support", 55*d4726bddSHONG Yifan@@ -391,8 +392,8 @@ cc_library( 56*d4726bddSHONG Yifan cc_library( 57*d4726bddSHONG Yifan name = "basic", 58*d4726bddSHONG Yifan srcs = [ 59*d4726bddSHONG Yifan- "include/clang/Basic/Version.inc", 60*d4726bddSHONG Yifan "include/VCSVersion.inc", 61*d4726bddSHONG Yifan+ "include/clang/Basic/Version.inc", 62*d4726bddSHONG Yifan ] + glob([ 63*d4726bddSHONG Yifan "lib/Basic/*.cpp", 64*d4726bddSHONG Yifan "lib/Basic/*.c", 65*d4726bddSHONG Yifan@@ -406,7 +407,7 @@ cc_library( 66*d4726bddSHONG Yifan copts = [ 67*d4726bddSHONG Yifan "-DHAVE_VCS_VERSION_INC", 68*d4726bddSHONG Yifan "$(STACK_FRAME_UNLIMITED)", 69*d4726bddSHONG Yifan- ], 70*d4726bddSHONG Yifan+ ] + llvm_stdcxx_copts, 71*d4726bddSHONG Yifan includes = ["include"], 72*d4726bddSHONG Yifan textual_hdrs = [ 73*d4726bddSHONG Yifan "include/clang/Basic/arm_fp16.inc", 74*d4726bddSHONG Yifan@@ -471,6 +472,7 @@ cc_library( 75*d4726bddSHONG Yifan hdrs = glob([ 76*d4726bddSHONG Yifan "include/clang/Lex/*.h", 77*d4726bddSHONG Yifan ]), 78*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 79*d4726bddSHONG Yifan includes = ["include"], 80*d4726bddSHONG Yifan deps = [ 81*d4726bddSHONG Yifan ":basic", 82*d4726bddSHONG Yifan@@ -711,7 +713,7 @@ cc_library( 83*d4726bddSHONG Yifan # headers such as `CXXABI.h`. 84*d4726bddSHONG Yifan "-I$(GENDIR)/external/llvm-project/clang/lib/AST", 85*d4726bddSHONG Yifan "-I$(GENDIR)/external/llvm-project/clang/lib/AST/Interp", 86*d4726bddSHONG Yifan- ], 87*d4726bddSHONG Yifan+ ] + llvm_stdcxx_copts, 88*d4726bddSHONG Yifan textual_hdrs = [ 89*d4726bddSHONG Yifan "include/clang/AST/AttrImpl.inc", 90*d4726bddSHONG Yifan "include/clang/AST/AttrNodeTraverse.inc", 91*d4726bddSHONG Yifan@@ -763,6 +765,7 @@ cc_library( 92*d4726bddSHONG Yifan "include/clang/Index/*.h", 93*d4726bddSHONG Yifan "include/clang-c/*.h", 94*d4726bddSHONG Yifan ]), 95*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 96*d4726bddSHONG Yifan includes = ["include"], 97*d4726bddSHONG Yifan deps = [ 98*d4726bddSHONG Yifan ":ast", 99*d4726bddSHONG Yifan@@ -786,6 +789,7 @@ cc_library( 100*d4726bddSHONG Yifan hdrs = glob([ 101*d4726bddSHONG Yifan "include/clang/Analysis/**/*.h", 102*d4726bddSHONG Yifan ]), 103*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 104*d4726bddSHONG Yifan includes = ["include"], 105*d4726bddSHONG Yifan textual_hdrs = glob([ 106*d4726bddSHONG Yifan "include/clang/Analysis/**/*.def", 107*d4726bddSHONG Yifan@@ -844,7 +848,7 @@ cc_library( 108*d4726bddSHONG Yifan "include/clang/Sema/*.h", 109*d4726bddSHONG Yifan "include/clang-c/*.h", 110*d4726bddSHONG Yifan ]), 111*d4726bddSHONG Yifan- copts = ["$(STACK_FRAME_UNLIMITED)"], 112*d4726bddSHONG Yifan+ copts = ["$(STACK_FRAME_UNLIMITED)"] + llvm_stdcxx_copts, 113*d4726bddSHONG Yifan includes = ["include"], 114*d4726bddSHONG Yifan textual_hdrs = [ 115*d4726bddSHONG Yifan "include/clang/Sema/AttrParsedAttrImpl.inc", 116*d4726bddSHONG Yifan@@ -911,6 +915,7 @@ cc_library( 117*d4726bddSHONG Yifan "include/clang/Parse/AttrParserStringSwitches.inc", 118*d4726bddSHONG Yifan "include/clang/Parse/AttrSubMatchRulesParserStringSwitches.inc", 119*d4726bddSHONG Yifan ] + glob(["include/clang/Parse/*.h"]), 120*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 121*d4726bddSHONG Yifan includes = ["include"], 122*d4726bddSHONG Yifan deps = [ 123*d4726bddSHONG Yifan ":ast", 124*d4726bddSHONG Yifan@@ -932,6 +937,7 @@ cc_library( 125*d4726bddSHONG Yifan "lib/ASTMatchers/*.h", 126*d4726bddSHONG Yifan ]), 127*d4726bddSHONG Yifan hdrs = glob(["include/clang/ASTMatchers/*.h"]), 128*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 129*d4726bddSHONG Yifan includes = ["include"], 130*d4726bddSHONG Yifan deps = [ 131*d4726bddSHONG Yifan ":ast", 132*d4726bddSHONG Yifan@@ -948,7 +954,7 @@ cc_library( 133*d4726bddSHONG Yifan "lib/ASTMatchers/Dynamic/*.h", 134*d4726bddSHONG Yifan ]), 135*d4726bddSHONG Yifan hdrs = glob(["include/clang/ASTMatchers/Dynamic/*.h"]), 136*d4726bddSHONG Yifan- copts = ["$(STACK_FRAME_UNLIMITED)"], 137*d4726bddSHONG Yifan+ copts = ["$(STACK_FRAME_UNLIMITED)"] + llvm_stdcxx_copts, 138*d4726bddSHONG Yifan includes = ["include"], 139*d4726bddSHONG Yifan deps = [ 140*d4726bddSHONG Yifan ":ast", 141*d4726bddSHONG Yifan@@ -966,6 +972,7 @@ cc_library( 142*d4726bddSHONG Yifan "lib/Rewrite/*.h", 143*d4726bddSHONG Yifan ]), 144*d4726bddSHONG Yifan hdrs = glob(["include/clang/Rewrite/Core/*.h"]), 145*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 146*d4726bddSHONG Yifan includes = ["include"], 147*d4726bddSHONG Yifan deps = [ 148*d4726bddSHONG Yifan ":ast", 149*d4726bddSHONG Yifan@@ -982,6 +989,7 @@ cc_library( 150*d4726bddSHONG Yifan "lib/Testing/*.cpp", 151*d4726bddSHONG Yifan ]), 152*d4726bddSHONG Yifan hdrs = glob(["include/clang/Testing/*.h"]), 153*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 154*d4726bddSHONG Yifan includes = ["include"], 155*d4726bddSHONG Yifan deps = [ 156*d4726bddSHONG Yifan ":basic", 157*d4726bddSHONG Yifan@@ -996,6 +1004,7 @@ cc_library( 158*d4726bddSHONG Yifan "lib/Tooling/Core/*.h", 159*d4726bddSHONG Yifan ]), 160*d4726bddSHONG Yifan hdrs = glob(["include/clang/Tooling/Core/*.h"]), 161*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 162*d4726bddSHONG Yifan includes = ["include"], 163*d4726bddSHONG Yifan deps = [ 164*d4726bddSHONG Yifan ":ast", 165*d4726bddSHONG Yifan@@ -1018,6 +1027,7 @@ cc_library( 166*d4726bddSHONG Yifan hdrs = glob([ 167*d4726bddSHONG Yifan "include/clang/Tooling/*.h", 168*d4726bddSHONG Yifan ]), 169*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 170*d4726bddSHONG Yifan includes = ["include"], 171*d4726bddSHONG Yifan deps = [ 172*d4726bddSHONG Yifan ":ast", 173*d4726bddSHONG Yifan@@ -1042,6 +1052,7 @@ cc_library( 174*d4726bddSHONG Yifan hdrs = glob([ 175*d4726bddSHONG Yifan "include/clang/Tooling/Inclusions/**/*.h", 176*d4726bddSHONG Yifan ]), 177*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 178*d4726bddSHONG Yifan deps = [ 179*d4726bddSHONG Yifan ":basic", 180*d4726bddSHONG Yifan ":lex", 181*d4726bddSHONG Yifan@@ -1061,6 +1072,7 @@ cc_library( 182*d4726bddSHONG Yifan "include/clang/Tooling/Refactoring/**/*.h", 183*d4726bddSHONG Yifan "include/clang/Tooling/Refactoring/**/*.def", 184*d4726bddSHONG Yifan ]), 185*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 186*d4726bddSHONG Yifan deps = [ 187*d4726bddSHONG Yifan ":ast", 188*d4726bddSHONG Yifan ":ast_matchers", 189*d4726bddSHONG Yifan@@ -1094,6 +1106,7 @@ cc_library( 190*d4726bddSHONG Yifan name = "tooling_syntax", 191*d4726bddSHONG Yifan srcs = glob(["lib/Tooling/Syntax/**/*.cpp"]), 192*d4726bddSHONG Yifan hdrs = glob(["include/clang/Tooling/Syntax/**/*.h"]), 193*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 194*d4726bddSHONG Yifan deps = [ 195*d4726bddSHONG Yifan ":ast", 196*d4726bddSHONG Yifan ":basic", 197*d4726bddSHONG Yifan@@ -1108,6 +1121,7 @@ cc_library( 198*d4726bddSHONG Yifan name = "tooling_dependency_scanning", 199*d4726bddSHONG Yifan srcs = glob(["lib/Tooling/DependencyScanning/**/*.cpp"]), 200*d4726bddSHONG Yifan hdrs = glob(["include/clang/Tooling/DependencyScanning/**/*.h"]), 201*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 202*d4726bddSHONG Yifan deps = [ 203*d4726bddSHONG Yifan ":basic", 204*d4726bddSHONG Yifan ":codegen", 205*d4726bddSHONG Yifan@@ -1123,6 +1137,7 @@ cc_library( 206*d4726bddSHONG Yifan name = "transformer", 207*d4726bddSHONG Yifan srcs = glob(["lib/Tooling/Transformer/**/*.cpp"]), 208*d4726bddSHONG Yifan hdrs = glob(["include/clang/Tooling/Transformer/**/*.h"]), 209*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 210*d4726bddSHONG Yifan deps = [ 211*d4726bddSHONG Yifan ":ast", 212*d4726bddSHONG Yifan ":ast_matchers", 213*d4726bddSHONG Yifan@@ -1138,6 +1153,7 @@ cc_library( 214*d4726bddSHONG Yifan name = "ast-diff", 215*d4726bddSHONG Yifan srcs = glob(["lib/Tooling/ASTDiff/*.cpp"]), 216*d4726bddSHONG Yifan hdrs = glob(["include/clang/Tooling/ASTDiff/*.h"]), 217*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 218*d4726bddSHONG Yifan deps = [ 219*d4726bddSHONG Yifan ":ast", 220*d4726bddSHONG Yifan ":basic", 221*d4726bddSHONG Yifan@@ -1150,6 +1166,7 @@ cc_library( 222*d4726bddSHONG Yifan name = "crosstu", 223*d4726bddSHONG Yifan srcs = glob(["lib/CrossTU/*.cpp"]), 224*d4726bddSHONG Yifan hdrs = glob(["include/clang/CrossTU/*.h"]), 225*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 226*d4726bddSHONG Yifan deps = [ 227*d4726bddSHONG Yifan ":ast", 228*d4726bddSHONG Yifan ":basic", 229*d4726bddSHONG Yifan@@ -1174,6 +1191,7 @@ cc_library( 230*d4726bddSHONG Yifan ] + glob([ 231*d4726bddSHONG Yifan "include/clang/Format/*.h", 232*d4726bddSHONG Yifan ]), 233*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 234*d4726bddSHONG Yifan includes = ["include"], 235*d4726bddSHONG Yifan deps = [ 236*d4726bddSHONG Yifan ":basic", 237*d4726bddSHONG Yifan@@ -1188,6 +1206,7 @@ cc_library( 238*d4726bddSHONG Yifan name = "edit", 239*d4726bddSHONG Yifan srcs = glob(["lib/Edit/*.cpp"]), 240*d4726bddSHONG Yifan hdrs = glob(["include/clang/Edit/*.h"]), 241*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 242*d4726bddSHONG Yifan includes = ["include"], 243*d4726bddSHONG Yifan deps = [ 244*d4726bddSHONG Yifan ":ast", 245*d4726bddSHONG Yifan@@ -1222,6 +1241,7 @@ cc_library( 246*d4726bddSHONG Yifan hdrs = glob([ 247*d4726bddSHONG Yifan "include/clang/StaticAnalyzer/Core/**/*.h", 248*d4726bddSHONG Yifan ]), 249*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 250*d4726bddSHONG Yifan includes = ["include"], 251*d4726bddSHONG Yifan textual_hdrs = glob([ 252*d4726bddSHONG Yifan "include/clang/StaticAnalyzer/Core/**/*.def", 253*d4726bddSHONG Yifan@@ -1268,7 +1288,7 @@ cc_library( 254*d4726bddSHONG Yifan ] + glob([ 255*d4726bddSHONG Yifan "include/clang/StaticAnalyzer/Checkers/**/*.h", 256*d4726bddSHONG Yifan ]), 257*d4726bddSHONG Yifan- copts = ["$(STACK_FRAME_UNLIMITED)"], 258*d4726bddSHONG Yifan+ copts = ["$(STACK_FRAME_UNLIMITED)"] + llvm_stdcxx_copts, 259*d4726bddSHONG Yifan includes = ["include"], 260*d4726bddSHONG Yifan deps = [ 261*d4726bddSHONG Yifan ":analysis", 262*d4726bddSHONG Yifan@@ -1316,7 +1336,7 @@ cc_library( 263*d4726bddSHONG Yifan hdrs = glob([ 264*d4726bddSHONG Yifan "include/clang/Driver/*.h", 265*d4726bddSHONG Yifan ]), 266*d4726bddSHONG Yifan- copts = ["$(STACK_FRAME_UNLIMITED)"], 267*d4726bddSHONG Yifan+ copts = ["$(STACK_FRAME_UNLIMITED)"] + llvm_stdcxx_copts, 268*d4726bddSHONG Yifan includes = [ 269*d4726bddSHONG Yifan "include", 270*d4726bddSHONG Yifan # TODO: This is likely a layering issue, but files in Arch are currently 271*d4726bddSHONG Yifan@@ -1479,7 +1499,7 @@ cc_library( 272*d4726bddSHONG Yifan hdrs = glob([ 273*d4726bddSHONG Yifan "include/clang/Frontend/*.h", 274*d4726bddSHONG Yifan ]), 275*d4726bddSHONG Yifan- copts = ["$(STACK_FRAME_UNLIMITED)"], 276*d4726bddSHONG Yifan+ copts = ["$(STACK_FRAME_UNLIMITED)"] + llvm_stdcxx_copts, 277*d4726bddSHONG Yifan data = [":builtin_headers_gen"], 278*d4726bddSHONG Yifan includes = ["include"], 279*d4726bddSHONG Yifan textual_hdrs = glob([ 280*d4726bddSHONG Yifan@@ -1519,6 +1539,7 @@ cc_library( 281*d4726bddSHONG Yifan "lib/Frontend/Rewrite/*.h", 282*d4726bddSHONG Yifan ]), 283*d4726bddSHONG Yifan hdrs = glob(["include/clang/Rewrite/Frontend/*.h"]), 284*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 285*d4726bddSHONG Yifan includes = ["include"], 286*d4726bddSHONG Yifan deps = [ 287*d4726bddSHONG Yifan ":ast", 288*d4726bddSHONG Yifan@@ -1541,6 +1562,7 @@ cc_library( 289*d4726bddSHONG Yifan "lib/Interpreter/*.h", 290*d4726bddSHONG Yifan ]), 291*d4726bddSHONG Yifan hdrs = glob(["include/clang/Interpreter/*.h"]), 292*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 293*d4726bddSHONG Yifan includes = ["include"], 294*d4726bddSHONG Yifan deps = [ 295*d4726bddSHONG Yifan ":analysis", 296*d4726bddSHONG Yifan@@ -1573,7 +1595,7 @@ cc_library( 297*d4726bddSHONG Yifan "lib/CodeGen/*.h", 298*d4726bddSHONG Yifan ]), 299*d4726bddSHONG Yifan hdrs = glob(["include/clang/CodeGen/*.h"]), 300*d4726bddSHONG Yifan- copts = ["$(STACK_FRAME_UNLIMITED)"], 301*d4726bddSHONG Yifan+ copts = ["$(STACK_FRAME_UNLIMITED)"] + llvm_stdcxx_copts, 302*d4726bddSHONG Yifan includes = ["include"], 303*d4726bddSHONG Yifan deps = [ 304*d4726bddSHONG Yifan ":analysis", 305*d4726bddSHONG Yifan@@ -1624,6 +1646,7 @@ cc_library( 306*d4726bddSHONG Yifan "lib/StaticAnalyzer/Frontend/**/*.h", 307*d4726bddSHONG Yifan ]), 308*d4726bddSHONG Yifan hdrs = glob(["include/clang/StaticAnalyzer/Frontend/**/*.h"]), 309*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 310*d4726bddSHONG Yifan includes = ["include"], 311*d4726bddSHONG Yifan deps = [ 312*d4726bddSHONG Yifan ":analysis", 313*d4726bddSHONG Yifan@@ -1678,6 +1701,7 @@ cc_library( 314*d4726bddSHONG Yifan hdrs = glob([ 315*d4726bddSHONG Yifan "include/clang/Serialization/*.h", 316*d4726bddSHONG Yifan ]), 317*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 318*d4726bddSHONG Yifan includes = ["include"], 319*d4726bddSHONG Yifan textual_hdrs = glob([ 320*d4726bddSHONG Yifan "include/clang/Serialization/*.def", 321*d4726bddSHONG Yifan@@ -1705,6 +1729,7 @@ cc_library( 322*d4726bddSHONG Yifan "lib/FrontendTool/*.h", 323*d4726bddSHONG Yifan ]), 324*d4726bddSHONG Yifan hdrs = glob(["include/clang/FrontendTool/*.h"]), 325*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 326*d4726bddSHONG Yifan includes = ["include"], 327*d4726bddSHONG Yifan deps = [ 328*d4726bddSHONG Yifan ":arc_migrate", 329*d4726bddSHONG Yifan@@ -1726,6 +1751,7 @@ cc_library( 330*d4726bddSHONG Yifan "lib/ARCMigrate/*.h", 331*d4726bddSHONG Yifan ]), 332*d4726bddSHONG Yifan hdrs = glob(["include/clang/ARCMigrate/*.h"]), 333*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 334*d4726bddSHONG Yifan includes = ["include"], 335*d4726bddSHONG Yifan deps = [ 336*d4726bddSHONG Yifan ":analysis", 337*d4726bddSHONG Yifan@@ -1752,6 +1778,7 @@ cc_library( 338*d4726bddSHONG Yifan "tools/libclang/*.h", 339*d4726bddSHONG Yifan ]), 340*d4726bddSHONG Yifan hdrs = glob(["include/clang-c/*.h"]), 341*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 342*d4726bddSHONG Yifan defines = ["CINDEX_NO_EXPORTS"], 343*d4726bddSHONG Yifan deps = [ 344*d4726bddSHONG Yifan ":arc_migrate", 345*d4726bddSHONG Yifan@@ -1783,7 +1810,7 @@ cc_plugin_library( 346*d4726bddSHONG Yifan copts = select({ 347*d4726bddSHONG Yifan "@bazel_tools//src/conditions:windows": ["-D_CINDEX_LIB_"], 348*d4726bddSHONG Yifan "//conditions:default": [], 349*d4726bddSHONG Yifan- }), 350*d4726bddSHONG Yifan+ }) + llvm_stdcxx_copts, 351*d4726bddSHONG Yifan strip_include_prefix = "include", 352*d4726bddSHONG Yifan deps = [ 353*d4726bddSHONG Yifan ":arc_migrate", 354*d4726bddSHONG Yifan@@ -1912,7 +1939,7 @@ cc_library( 355*d4726bddSHONG Yifan # Disable stack frame size checks in the driver because 356*d4726bddSHONG Yifan # clang::ensureStackAddressSpace allocates a large array on the stack. 357*d4726bddSHONG Yifan "$(STACK_FRAME_UNLIMITED)", 358*d4726bddSHONG Yifan- ], 359*d4726bddSHONG Yifan+ ] + llvm_stdcxx_copts, 360*d4726bddSHONG Yifan deps = [ 361*d4726bddSHONG Yifan ":analysis", 362*d4726bddSHONG Yifan ":ast", 363*d4726bddSHONG Yifan@@ -1947,6 +1974,7 @@ cc_library( 364*d4726bddSHONG Yifan cc_binary( 365*d4726bddSHONG Yifan name = "clang", 366*d4726bddSHONG Yifan srcs = [], 367*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 368*d4726bddSHONG Yifan stamp = 0, 369*d4726bddSHONG Yifan deps = [ 370*d4726bddSHONG Yifan ":clang-driver", 371*d4726bddSHONG Yifandiff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel 372*d4726bddSHONG Yifanindex 85d79a29b571..716d7f5d9645 100644 373*d4726bddSHONG Yifan--- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel 374*d4726bddSHONG Yifan+++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel 375*d4726bddSHONG Yifan@@ -4,7 +4,7 @@ 376*d4726bddSHONG Yifan 377*d4726bddSHONG Yifan load(":template_rule.bzl", "template_rule") 378*d4726bddSHONG Yifan load(":tblgen.bzl", "gentbl") 379*d4726bddSHONG Yifan-load(":config.bzl", "llvm_config_defines") 380*d4726bddSHONG Yifan+load(":config.bzl", "llvm_config_defines", "llvm_stdcxx_copts") 381*d4726bddSHONG Yifan load(":targets.bzl", "llvm_targets") 382*d4726bddSHONG Yifan load(":enum_targets_gen.bzl", "enum_targets_gen") 383*d4726bddSHONG Yifan load(":binary_alias.bzl", "binary_alias") 384*d4726bddSHONG Yifan@@ -21,10 +21,12 @@ exports_files(["LICENSE.TXT"]) 385*d4726bddSHONG Yifan # toolchain or the `.bazelrc` file. This is just a workaround until we have a 386*d4726bddSHONG Yifan # widely available feature to enable unlimited stack frame instead of using 387*d4726bddSHONG Yifan # this `Make` variable. 388*d4726bddSHONG Yifan-llvm_copts = [ 389*d4726bddSHONG Yifan+llvm_c_only_opts = [ 390*d4726bddSHONG Yifan "$(STACK_FRAME_UNLIMITED)", 391*d4726bddSHONG Yifan ] 392*d4726bddSHONG Yifan 393*d4726bddSHONG Yifan+llvm_copts = llvm_c_only_opts + llvm_stdcxx_copts 394*d4726bddSHONG Yifan+ 395*d4726bddSHONG Yifan enum_targets_gen( 396*d4726bddSHONG Yifan name = "targets_def_gen", 397*d4726bddSHONG Yifan src = "include/llvm/Config/Targets.def.in", 398*d4726bddSHONG Yifan@@ -167,10 +169,69 @@ genrule( 399*d4726bddSHONG Yifan "echo -e '#undef HANDLE_EXTENSION' >> $@\n", 400*d4726bddSHONG Yifan ) 401*d4726bddSHONG Yifan 402*d4726bddSHONG Yifan+# TODO: This separation is required to separate out C++ and C opts 403*d4726bddSHONG Yifan+# https://github.com/bazelbuild/bazel/issues/16551 404*d4726bddSHONG Yifan cc_library( 405*d4726bddSHONG Yifan- name = "Support", 406*d4726bddSHONG Yifan+ name = "Support-c", 407*d4726bddSHONG Yifan srcs = glob([ 408*d4726bddSHONG Yifan "lib/Support/*.c", 409*d4726bddSHONG Yifan+ ]), 410*d4726bddSHONG Yifan+ hdrs = glob([ 411*d4726bddSHONG Yifan+ "include/llvm/Support/**/*.h", 412*d4726bddSHONG Yifan+ "include/llvm/ADT/*.h", 413*d4726bddSHONG Yifan+ ]) + [ 414*d4726bddSHONG Yifan+ "include/llvm-c/Core.h", 415*d4726bddSHONG Yifan+ "include/llvm-c/DataTypes.h", 416*d4726bddSHONG Yifan+ "include/llvm-c/Deprecated.h", 417*d4726bddSHONG Yifan+ "include/llvm-c/DisassemblerTypes.h", 418*d4726bddSHONG Yifan+ "include/llvm-c/Error.h", 419*d4726bddSHONG Yifan+ "include/llvm-c/ErrorHandling.h", 420*d4726bddSHONG Yifan+ "include/llvm-c/ExternC.h", 421*d4726bddSHONG Yifan+ "include/llvm-c/Support.h", 422*d4726bddSHONG Yifan+ "include/llvm-c/Types.h", 423*d4726bddSHONG Yifan+ "include/llvm/ExecutionEngine/JITSymbol.h", 424*d4726bddSHONG Yifan+ "include/llvm/Support/Extension.def", 425*d4726bddSHONG Yifan+ "include/llvm/Support/VCSRevision.h", 426*d4726bddSHONG Yifan+ ], 427*d4726bddSHONG Yifan+ copts = llvm_c_only_opts, 428*d4726bddSHONG Yifan+ includes = ["include"], 429*d4726bddSHONG Yifan+ linkopts = select({ 430*d4726bddSHONG Yifan+ "@bazel_tools//src/conditions:windows": [], 431*d4726bddSHONG Yifan+ "@bazel_tools//src/conditions:freebsd": [ 432*d4726bddSHONG Yifan+ "-pthread", 433*d4726bddSHONG Yifan+ "-lexecinfo", 434*d4726bddSHONG Yifan+ "-ldl", 435*d4726bddSHONG Yifan+ "-lm", 436*d4726bddSHONG Yifan+ ], 437*d4726bddSHONG Yifan+ "//conditions:default": [ 438*d4726bddSHONG Yifan+ "-pthread", 439*d4726bddSHONG Yifan+ "-ldl", 440*d4726bddSHONG Yifan+ "-lm", 441*d4726bddSHONG Yifan+ ], 442*d4726bddSHONG Yifan+ }), 443*d4726bddSHONG Yifan+ textual_hdrs = glob([ 444*d4726bddSHONG Yifan+ "include/llvm/Support/*.def", 445*d4726bddSHONG Yifan+ "lib/Support/*.h", 446*d4726bddSHONG Yifan+ "lib/Support/*.inc", 447*d4726bddSHONG Yifan+ ]), 448*d4726bddSHONG Yifan+ deps = [ 449*d4726bddSHONG Yifan+ ":config", 450*d4726bddSHONG Yifan+ ":Demangle", 451*d4726bddSHONG Yifan+ # We unconditionally depend on the custom LLVM terminfo wrapper. This 452*d4726bddSHONG Yifan+ # will be an empty library unless terminfo is enabled, in which case it 453*d4726bddSHONG Yifan+ # will both provide the necessary dependencies and configuration 454*d4726bddSHONG Yifan+ # defines. 455*d4726bddSHONG Yifan+ "@llvm_terminfo//:terminfo", 456*d4726bddSHONG Yifan+ # We unconditionally depend on the custom LLVM zlib wrapper. This will 457*d4726bddSHONG Yifan+ # be an empty library unless zlib is enabled, in which case it will 458*d4726bddSHONG Yifan+ # both provide the necessary dependencies and configuration defines. 459*d4726bddSHONG Yifan+ "@llvm_zlib//:zlib", 460*d4726bddSHONG Yifan+ ], 461*d4726bddSHONG Yifan+) 462*d4726bddSHONG Yifan+ 463*d4726bddSHONG Yifan+cc_library( 464*d4726bddSHONG Yifan+ name = "Support", 465*d4726bddSHONG Yifan+ srcs = glob([ 466*d4726bddSHONG Yifan "lib/Support/*.cpp", 467*d4726bddSHONG Yifan "lib/Support/*.h", 468*d4726bddSHONG Yifan "lib/Support/*.inc", 469*d4726bddSHONG Yifan@@ -223,6 +284,7 @@ cc_library( 470*d4726bddSHONG Yifan "include/llvm/Support/*.def", 471*d4726bddSHONG Yifan ]), 472*d4726bddSHONG Yifan deps = [ 473*d4726bddSHONG Yifan+ ":Support-c", 474*d4726bddSHONG Yifan ":config", 475*d4726bddSHONG Yifan ":Demangle", 476*d4726bddSHONG Yifan # We unconditionally depend on the custom LLVM terminfo wrapper. This 477*d4726bddSHONG Yifandiff --git a/utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl b/utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl 478*d4726bddSHONG Yifanindex 2ebd39c630dc..e45bd8a1ce92 100644 479*d4726bddSHONG Yifan--- a/utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl 480*d4726bddSHONG Yifan+++ b/utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl 481*d4726bddSHONG Yifan@@ -16,6 +16,7 @@ configure generic aspects of all generated rules such as `testonly`. Lastly, 482*d4726bddSHONG Yifan """ 483*d4726bddSHONG Yifan 484*d4726bddSHONG Yifan load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_import", "cc_library") 485*d4726bddSHONG Yifan+load(":config.bzl", "llvm_stdcxx_copts") 486*d4726bddSHONG Yifan 487*d4726bddSHONG Yifan def cc_plugin_library(name, srcs, hdrs, include_prefix = None, strip_include_prefix = None, alwayslink = False, features = [], tags = [], testonly = False, **kwargs): 488*d4726bddSHONG Yifan # Neither the name of the plugin binary nor tags on whether it is built are 489*d4726bddSHONG Yifan@@ -29,6 +30,7 @@ def cc_plugin_library(name, srcs, hdrs, include_prefix = None, strip_include_pre 490*d4726bddSHONG Yifan dylib_name = name + ".dylib" 491*d4726bddSHONG Yifan interface_output_name = name + "_interface_output" 492*d4726bddSHONG Yifan import_name = name + "_import" 493*d4726bddSHONG Yifan+ copts = kwargs.pop("copts", []) 494*d4726bddSHONG Yifan for impl_name in [dll_name, dylib_name, so_name]: 495*d4726bddSHONG Yifan cc_binary( 496*d4726bddSHONG Yifan name = impl_name, 497*d4726bddSHONG Yifan@@ -38,6 +40,7 @@ def cc_plugin_library(name, srcs, hdrs, include_prefix = None, strip_include_pre 498*d4726bddSHONG Yifan features = features, 499*d4726bddSHONG Yifan tags = ["manual"] + tags, 500*d4726bddSHONG Yifan testonly = testonly, 501*d4726bddSHONG Yifan+ copts = copts + llvm_stdcxx_copts, 502*d4726bddSHONG Yifan **kwargs 503*d4726bddSHONG Yifan ) 504*d4726bddSHONG Yifan native.filegroup( 505*d4726bddSHONG Yifandiff --git a/utils/bazel/llvm-project-overlay/llvm/config.bzl b/utils/bazel/llvm-project-overlay/llvm/config.bzl 506*d4726bddSHONG Yifanindex 2046b2645362..736844bfc2d0 100644 507*d4726bddSHONG Yifan--- a/utils/bazel/llvm-project-overlay/llvm/config.bzl 508*d4726bddSHONG Yifan+++ b/utils/bazel/llvm-project-overlay/llvm/config.bzl 509*d4726bddSHONG Yifan@@ -97,3 +97,8 @@ llvm_config_defines = os_defines + select({ 510*d4726bddSHONG Yifan "__STDC_CONSTANT_MACROS", 511*d4726bddSHONG Yifan "__STDC_FORMAT_MACROS", 512*d4726bddSHONG Yifan ] 513*d4726bddSHONG Yifan+ 514*d4726bddSHONG Yifan+llvm_stdcxx_copts = select({ 515*d4726bddSHONG Yifan+ "@platforms//os:windows": ["/std:c++17"], 516*d4726bddSHONG Yifan+ "//conditions:default": ["-std=c++17"], 517*d4726bddSHONG Yifan+}) 518*d4726bddSHONG Yifandiff --git a/utils/bazel/llvm-project-overlay/llvm/tblgen.bzl b/utils/bazel/llvm-project-overlay/llvm/tblgen.bzl 519*d4726bddSHONG Yifanindex d43390918e39..e0482a6fd4fa 100644 520*d4726bddSHONG Yifan--- a/utils/bazel/llvm-project-overlay/llvm/tblgen.bzl 521*d4726bddSHONG Yifan+++ b/utils/bazel/llvm-project-overlay/llvm/tblgen.bzl 522*d4726bddSHONG Yifan@@ -12,6 +12,8 @@ TODO(chandlerc): Currently this expresses include-based dependencies as 523*d4726bddSHONG Yifan correctly understood by the build system. 524*d4726bddSHONG Yifan """ 525*d4726bddSHONG Yifan 526*d4726bddSHONG Yifan+load(":config.bzl", "llvm_stdcxx_copts") 527*d4726bddSHONG Yifan+ 528*d4726bddSHONG Yifan def gentbl( 529*d4726bddSHONG Yifan name, 530*d4726bddSHONG Yifan tblgen, 531*d4726bddSHONG Yifan@@ -77,5 +79,6 @@ def gentbl( 532*d4726bddSHONG Yifan # distinction between these two. 533*d4726bddSHONG Yifan hdrs = [f for (_, f) in tbl_outs], 534*d4726bddSHONG Yifan features = ["-parse_headers", "-header_modules"], 535*d4726bddSHONG Yifan+ copts = llvm_stdcxx_copts, 536*d4726bddSHONG Yifan **kwargs 537*d4726bddSHONG Yifan ) 538