[PATCH] D138999: [libc] Make libc symbols weak by default for bazel

Guillaume Chatelet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 30 03:44:05 PST 2022


gchatelet created this revision.
gchatelet added a reviewer: sivachandra.
Herald added subscribers: ecnelises, tschuett.
Herald added a project: All.
gchatelet requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This helps override llvm libc functions for experiment purposes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138999

Files:
  utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl


Index: utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
===================================================================
--- utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
+++ 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 = True, 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,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138999.478883.patch
Type: text/x-patch
Size: 1341 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221130/6729fd20/attachment.bin>


More information about the llvm-commits mailing list