forked from OSchip/llvm-project
[libc] Make libc memory functions weak by default for bazel
This helps override llvm libc functions for experiment purposes. Differential Revision: https://reviews.llvm.org/D138999
This commit is contained in:
parent
4633599c34
commit
5bdada9c69
|
@ -1096,6 +1096,7 @@ libc_function(
|
||||||
hdrs = ["src/string/memcpy.h"],
|
hdrs = ["src/string/memcpy.h"],
|
||||||
copts = ["-mllvm --tail-merge-threshold=0"],
|
copts = ["-mllvm --tail-merge-threshold=0"],
|
||||||
features = no_sanitize_features,
|
features = no_sanitize_features,
|
||||||
|
weak = True,
|
||||||
deps = [
|
deps = [
|
||||||
":__support_common",
|
":__support_common",
|
||||||
":string_memory_utils",
|
":string_memory_utils",
|
||||||
|
@ -1107,6 +1108,7 @@ libc_function(
|
||||||
srcs = ["src/string/memset.cpp"],
|
srcs = ["src/string/memset.cpp"],
|
||||||
hdrs = ["src/string/memset.h"],
|
hdrs = ["src/string/memset.h"],
|
||||||
features = no_sanitize_features,
|
features = no_sanitize_features,
|
||||||
|
weak = True,
|
||||||
deps = [
|
deps = [
|
||||||
":__support_common",
|
":__support_common",
|
||||||
":string_memory_utils",
|
":string_memory_utils",
|
||||||
|
@ -1118,6 +1120,7 @@ libc_function(
|
||||||
srcs = ["src/string/memmove.cpp"],
|
srcs = ["src/string/memmove.cpp"],
|
||||||
hdrs = ["src/string/memmove.h"],
|
hdrs = ["src/string/memmove.h"],
|
||||||
features = no_sanitize_features,
|
features = no_sanitize_features,
|
||||||
|
weak = True,
|
||||||
deps = [
|
deps = [
|
||||||
":__support_common",
|
":__support_common",
|
||||||
":string_memory_utils",
|
":string_memory_utils",
|
||||||
|
@ -1140,6 +1143,7 @@ libc_function(
|
||||||
srcs = ["src/string/memcmp.cpp"],
|
srcs = ["src/string/memcmp.cpp"],
|
||||||
hdrs = ["src/string/memcmp.h"],
|
hdrs = ["src/string/memcmp.h"],
|
||||||
features = no_sanitize_features,
|
features = no_sanitize_features,
|
||||||
|
weak = True,
|
||||||
deps = [
|
deps = [
|
||||||
":__support_common",
|
":__support_common",
|
||||||
":__support_integer_operations",
|
":__support_integer_operations",
|
||||||
|
@ -1152,6 +1156,7 @@ libc_function(
|
||||||
srcs = ["src/string/bcmp.cpp"],
|
srcs = ["src/string/bcmp.cpp"],
|
||||||
hdrs = ["src/string/bcmp.h"],
|
hdrs = ["src/string/bcmp.h"],
|
||||||
features = no_sanitize_features,
|
features = no_sanitize_features,
|
||||||
|
weak = True,
|
||||||
deps = [
|
deps = [
|
||||||
":__support_common",
|
":__support_common",
|
||||||
":string_memory_utils",
|
":string_memory_utils",
|
||||||
|
@ -1163,6 +1168,7 @@ libc_function(
|
||||||
srcs = ["src/string/bzero.cpp"],
|
srcs = ["src/string/bzero.cpp"],
|
||||||
hdrs = ["src/string/bzero.h"],
|
hdrs = ["src/string/bzero.h"],
|
||||||
features = no_sanitize_features,
|
features = no_sanitize_features,
|
||||||
|
weak = True,
|
||||||
deps = [
|
deps = [
|
||||||
":__support_common",
|
":__support_common",
|
||||||
":string_memory_utils",
|
":string_memory_utils",
|
||||||
|
|
|
@ -10,7 +10,7 @@ load("@bazel_skylib//lib:selects.bzl", "selects")
|
||||||
LIBC_ROOT_TARGET = ":libc_root"
|
LIBC_ROOT_TARGET = ":libc_root"
|
||||||
INTERNAL_SUFFIX = ".__internal__"
|
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.
|
"""Add target for a libc function.
|
||||||
|
|
||||||
The libc function is eventually available as a cc_library target by name
|
The libc function is eventually available as a cc_library target by name
|
||||||
|
@ -23,6 +23,7 @@ def libc_function(name, srcs, deps = None, copts = None, **kwargs):
|
||||||
name: Target name. It is normally the name of the function this target is
|
name: Target name. It is normally the name of the function this target is
|
||||||
for.
|
for.
|
||||||
srcs: The .cpp files which contain the function implementation.
|
srcs: The .cpp files which contain the function implementation.
|
||||||
|
weak: Whether the symbol is marked weak.
|
||||||
deps: The list of target dependencies if any.
|
deps: The list of target dependencies if any.
|
||||||
copts: The list of options to add to the C++ compilation command.
|
copts: The list of options to add to the C++ compilation command.
|
||||||
**kwargs: Other attributes relevant for a cc_library. For example, deps.
|
**kwargs: Other attributes relevant for a cc_library. For example, deps.
|
||||||
|
@ -47,6 +48,8 @@ def libc_function(name, srcs, deps = None, copts = None, **kwargs):
|
||||||
|
|
||||||
# This second target is the llvm libc C function.
|
# This second target is the llvm libc C function.
|
||||||
copts.append("-DLLVM_LIBC_PUBLIC_PACKAGING")
|
copts.append("-DLLVM_LIBC_PUBLIC_PACKAGING")
|
||||||
|
if weak:
|
||||||
|
copts.append("-DLLVM_LIBC_FUNCTION_ATTR=__attribute__((weak))")
|
||||||
native.cc_library(
|
native.cc_library(
|
||||||
name = name,
|
name = name,
|
||||||
srcs = srcs,
|
srcs = srcs,
|
||||||
|
|
Loading…
Reference in New Issue