diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel @@ -1096,6 +1096,7 @@ hdrs = ["src/string/memcpy.h"], copts = ["-mllvm --tail-merge-threshold=0"], features = no_sanitize_features, + weak = True, deps = [ ":__support_common", ":string_memory_utils", @@ -1107,6 +1108,7 @@ srcs = ["src/string/memset.cpp"], hdrs = ["src/string/memset.h"], features = no_sanitize_features, + weak = True, deps = [ ":__support_common", ":string_memory_utils", @@ -1118,6 +1120,7 @@ srcs = ["src/string/memmove.cpp"], hdrs = ["src/string/memmove.h"], features = no_sanitize_features, + weak = True, deps = [ ":__support_common", ":string_memory_utils", @@ -1140,6 +1143,7 @@ srcs = ["src/string/memcmp.cpp"], hdrs = ["src/string/memcmp.h"], features = no_sanitize_features, + weak = True, deps = [ ":__support_common", ":__support_integer_operations", @@ -1152,6 +1156,7 @@ srcs = ["src/string/bcmp.cpp"], hdrs = ["src/string/bcmp.h"], features = no_sanitize_features, + weak = True, deps = [ ":__support_common", ":string_memory_utils", @@ -1163,6 +1168,7 @@ srcs = ["src/string/bzero.cpp"], hdrs = ["src/string/bzero.h"], features = no_sanitize_features, + weak = True, deps = [ ":__support_common", ":string_memory_utils", diff --git a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl b/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl --- a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl +++ b/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl @@ -10,7 +10,7 @@ LIBC_ROOT_TARGET = ":libc_root" INTERNAL_SUFFIX = ".__internal__" -def libc_function(name, srcs, deps = None, copts = None, **kwargs): +def libc_function(name, srcs, weak = False, deps = None, copts = None, **kwargs): """Add target for a libc function. The libc function is eventually available as a cc_library target by name @@ -23,6 +23,7 @@ name: Target name. It is normally the name of the function this target is for. srcs: The .cpp files which contain the function implementation. + weak: Whether the symbol is marked weak. deps: The list of target dependencies if any. copts: The list of options to add to the C++ compilation command. **kwargs: Other attributes relevant for a cc_library. For example, deps. @@ -47,6 +48,8 @@ # This second target is the llvm libc C function. copts.append("-DLLVM_LIBC_PUBLIC_PACKAGING") + if weak: + copts.append("-DLLVM_LIBC_FUNCTION_ATTR=__attribute__((weak))") native.cc_library( name = name, srcs = srcs,