Skip to content

Commit d1a2f11

Browse files
authored
[builtins] Mark int_lib.h builtins as static (#69305)
Mark the following symbols as `static` to prevent duplicate definitions: `__builtin_ctz` `__builtin_clz` `__builtin_clzll` `__builtin_sadd_overflow` >Without these then all of these functions show up in all object files which include int_lib.h on Windows. This'll help prevent duplicate symbols by ensuring they're not exported. See: rust-lang/compiler-builtins#167 https://reviews.llvm.org/D34599
1 parent 9ff4be6 commit d1a2f11

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

compiler-rt/lib/builtins/int_lib.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,29 +119,29 @@ COMPILER_RT_ABI tu_int __udivmodti4(tu_int a, tu_int b, tu_int *rem);
119119
#if defined(_MSC_VER) && !defined(__clang__)
120120
#include <intrin.h>
121121

122-
int __inline __builtin_ctz(uint32_t value) {
122+
static int __inline __builtin_ctz(uint32_t value) {
123123
unsigned long trailing_zero = 0;
124124
if (_BitScanForward(&trailing_zero, value))
125125
return trailing_zero;
126126
return 32;
127127
}
128128

129-
int __inline __builtin_clz(uint32_t value) {
129+
static int __inline __builtin_clz(uint32_t value) {
130130
unsigned long leading_zero = 0;
131131
if (_BitScanReverse(&leading_zero, value))
132132
return 31 - leading_zero;
133133
return 32;
134134
}
135135

136136
#if defined(_M_ARM) || defined(_M_X64)
137-
int __inline __builtin_clzll(uint64_t value) {
137+
static int __inline __builtin_clzll(uint64_t value) {
138138
unsigned long leading_zero = 0;
139139
if (_BitScanReverse64(&leading_zero, value))
140140
return 63 - leading_zero;
141141
return 64;
142142
}
143143
#else
144-
int __inline __builtin_clzll(uint64_t value) {
144+
static int __inline __builtin_clzll(uint64_t value) {
145145
if (value == 0)
146146
return 64;
147147
uint32_t msh = (uint32_t)(value >> 32);
@@ -154,7 +154,7 @@ int __inline __builtin_clzll(uint64_t value) {
154154

155155
#define __builtin_clzl __builtin_clzll
156156

157-
bool __inline __builtin_sadd_overflow(int x, int y, int *result) {
157+
static bool __inline __builtin_sadd_overflow(int x, int y, int *result) {
158158
if ((x < 0) != (y < 0)) {
159159
*result = x + y;
160160
return false;

0 commit comments

Comments
 (0)