File tree Expand file tree Collapse file tree 2 files changed +18
-11
lines changed
utils/bazel/llvm-project-overlay/libc Expand file tree Collapse file tree 2 files changed +18
-11
lines changed Original file line number Diff line number Diff line change 2121#define LLVM_LIBC_FUNCTION_ATTR
2222#endif
2323
24- // Allow each function `func` can have extra attributes specified by defining:
24+ // Allow each function `func` to have extra attributes specified by defining:
2525// `LLVM_LIBC_FUNCTION_ATTR_func` macro, which should always start with
26- // "LLVM_LIBC_EMPTY,"
26+ // "LLVM_LIBC_EMPTY, "
2727//
28- // For example:
29- // #define LLVM_LIBC_FUNCTION_ATTR_memcpy LLVM_LIBC_EMPTY, __attribute__((weak))
28+ // For examples:
29+ // #define LLVM_LIBC_FUNCTION_ATTR_memcpy LLVM_LIBC_EMPTY, [[gnu::weak]]
30+ // #define LLVM_LIBC_FUNCTION_ATTR_memchr LLVM_LIBC_EMPTY, [[gnu::weak]] \
31+ // [[gnu::visibility("default")]]
3032#define LLVM_LIBC_EMPTY
3133
3234#define GET_SECOND (first, second, ...) second
3335#define EXPAND_THEN_SECOND (name ) GET_SECOND(name, LLVM_LIBC_EMPTY, )
3436
3537#define LLVM_LIBC_ATTR (name ) EXPAND_THEN_SECOND(LLVM_LIBC_FUNCTION_ATTR_##name)
36- #define EXPAND_ATTR (name ) LLVM_LIBC_ATTR(name)
3738
3839// MacOS needs to be excluded because it does not support aliasing.
3940#if defined(LIBC_COPT_PUBLIC_PACKAGING) && (!defined(__APPLE__))
4041#define LLVM_LIBC_FUNCTION_IMPL (type, name, arglist ) \
41- EXPAND_ATTR (name) \
42+ LLVM_LIBC_ATTR (name) \
4243 LLVM_LIBC_FUNCTION_ATTR decltype(LIBC_NAMESPACE::name) \
4344 __##name##_impl__ __asm__ (#name); \
4445 decltype (LIBC_NAMESPACE::name) name [[gnu::alias(#name)]]; \
Original file line number Diff line number Diff line change @@ -113,11 +113,17 @@ def libc_function(
113113
114114 # This second target is the llvm libc C function with either a default or hidden visibility.
115115 # All other functions are hidden.
116- func_attrs = ["__attribute__((visibility(\" default\" )))" ]
117- if weak :
118- func_attrs = func_attrs + ["__attribute__((weak))" ]
119- local_defines = local_defines or ["LIBC_COPT_PUBLIC_PACKAGING" ]
120- local_defines = local_defines + ["LLVM_LIBC_FUNCTION_ATTR='%s'" % " " .join (func_attrs )]
116+ global_func_attrs = [
117+ "[[gnu::visibility(" default ")]]" ,
118+ ]
119+ func_attrs = [
120+ "LLVM_LIBC_FUNCTION_ATTR_" + name + "='LLVM_LIBC_EMPTY, [[gnu::weak]]'" ,
121+ ] if weak else []
122+
123+ local_defines = (local_defines
124+ + ["LIBC_COPT_PUBLIC_PACKAGING" ]
125+ + ["LLVM_LIBC_FUNCTION_ATTR='%s'" % " " .join (global_func_attrs )]
126+ + func_attrs )
121127 _libc_library (
122128 name = name ,
123129 hidden = True ,
You can’t perform that action at this time.
0 commit comments