Skip to content

Commit d2e8003

Browse files
committed
Fix building with clang on non-darwin platforms
Signed-off-by: Rye <[email protected]>
1 parent eaafd49 commit d2e8003

30 files changed

+81
-147
lines changed

indra/cmake/00-Common.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ endif(DARWIN)
216216
if (LINUX OR DARWIN)
217217
add_compile_options(-Wall -Wno-sign-compare -Wno-trigraphs -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-variable)
218218

219+
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
220+
add_compile_options(-Wno-unused-private-field)
221+
endif()
222+
219223
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
220224
add_compile_options(-Wno-unused-local-typedef)
221225
endif()

indra/cmake/UI.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ if (LINUX)
1515
pkg_check_modules(WAYLAND_CLIENT wayland-client)
1616

1717
if(WAYLAND_CLIENT_FOUND)
18+
target_include_directories(ll::uilibraries INTERFACE ${WAYLAND_CLIENT_INCLUDE_DIRS})
1819
target_compile_definitions(ll::uilibraries INTERFACE LL_WAYLAND=1)
1920
else()
2021
message("pkgconfig could not find wayland client, compiling without full wayland support")

indra/llcommon/StackWalker.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,8 @@ struct IMAGEHLP_MODULE64_V2 {
785785
case 8: //SymVirtual:
786786
szSymType = "Virtual";
787787
break;
788+
case NumSymTypes:
789+
break;
788790
}
789791
}
790792
LPCSTR pdbName = Module.LoadedImageName;

indra/llcommon/llapr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,11 @@ bool LLVolatileAPRPool::isFull()
230230
bool _ll_apr_warn_status(apr_status_t status, const char* file, int line)
231231
{
232232
if(APR_SUCCESS == status) return false;
233-
#if !LL_LINUX
233+
234234
char buf[MAX_STRING]; /* Flawfinder: ignore */
235235
apr_strerror(status, buf, sizeof(buf));
236236
LL_WARNS("APR") << "APR: " << file << ":" << line << " " << buf << LL_ENDL;
237-
#endif
237+
238238
return true;
239239
}
240240

indra/llcommon/lldate.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,7 @@ void LLDate::toStream(std::ostream& s) const
131131
}
132132

133133
s << std::dec << std::setfill('0');
134-
#if( LL_WINDOWS || __GNUC__ > 2)
135134
s << std::right;
136-
#else
137-
s.setf(ios::right);
138-
#endif
139135
s << std::setw(4) << (exp_time.tm_year + 1900)
140136
<< '-' << std::setw(2) << (exp_time.tm_mon + 1)
141137
<< '-' << std::setw(2) << (exp_time.tm_mday)

indra/llcommon/llfindlocale.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ accumulate_locstring(const char *str, FL_Locale *l) {
134134
return 0;
135135
}
136136

137-
137+
#ifndef LL_WINDOWS
138138
static int
139139
accumulate_env(const char *name, FL_Locale *l) {
140140
char *env;
@@ -148,7 +148,7 @@ accumulate_env(const char *name, FL_Locale *l) {
148148
free(lang); free(country); free(variant);
149149
return 0;
150150
}
151-
151+
#endif
152152

153153
static void
154154
canonise_fl(FL_Locale *l) {

indra/llcommon/llinstancetracker.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,7 @@ class LLInstanceTracker
246246
}
247247

248248
protected:
249-
#if LL_CLANG || LL_GNUC
250-
__attribute__((no_sanitize("vptr")))
251-
#endif
249+
LL_UBSAN_SUPRESS_VPTR
252250
LLInstanceTracker(const KEY& key)
253251
{
254252
// We do not intend to manage the lifespan of this object with
@@ -487,9 +485,7 @@ class LLInstanceTracker<T, void, KEY_COLLISION_BEHAVIOR>
487485
using key_snapshot_of = instance_snapshot_of<SUBCLASS>;
488486

489487
protected:
490-
#if LL_CLANG || LL_GNUC
491-
__attribute__((no_sanitize("vptr")))
492-
#endif
488+
LL_UBSAN_SUPRESS_VPTR
493489
LLInstanceTracker()
494490
{
495491
// Since we do not intend for this shared_ptr to manage lifespan, give

indra/llcommon/llmd5.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ void LLMD5::raw_digest(unsigned char* s) const
255255
memcpy(s, digest, 16); /* Flawfinder: ignore */
256256
}
257257

258-
#if LL_DARWIN
258+
#if LL_CLANG
259259
#pragma clang diagnostic push
260260
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
261261
#endif
@@ -280,7 +280,7 @@ void LLMD5::hex_digest(char* s) const
280280
s[32] = '\0';
281281
}
282282

283-
#if LL_DARWIN
283+
#if LL_CLANG
284284
#pragma clang diagnostic pop
285285
#endif
286286

indra/llcommon/llmemory.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,6 @@ void LLMemory::updateMemoryInfo()
146146
LL_WARNS() << "task_info failed" << LL_ENDL;
147147
}
148148
#elif defined(LL_LINUX)
149-
// Use sysinfo() to get the total physical memory.
150-
struct sysinfo info;
151-
sysinfo(&info);
152149
sAllocatedMemInKB = U32Kilobytes::convert(U64Bytes(LLMemory::getCurrentRSS())); // represents the RAM allocated by this process only (in line with the windows implementation)
153150
#else
154151
//not valid for other systems for now.

indra/llcommon/llpreprocessor.h

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -61,45 +61,48 @@
6161
# define LL_UNLIKELY(EXPR) (EXPR)
6262
#endif
6363

64-
6564
// Figure out differences between compilers
66-
#if defined(__clang__)
67-
#define GCC_VERSION (__GNUC__ * 10000 \
68-
+ __GNUC_MINOR__ * 100 \
69-
+ __GNUC_PATCHLEVEL__)
65+
#if defined(__MSVC_VER__) || defined(_MSC_VER)
66+
#ifndef LL_MSVC
67+
#define LL_MSVC 1
68+
#endif
69+
70+
// Clang CL is MSVC-like but also supports its own macros
71+
#if defined(__clang__)
72+
#ifndef LL_CLANG
73+
#define LL_CLANG 1
74+
#endif
75+
#endif
76+
#elif defined(__clang__)
77+
#define CLANG_VERSION (__clang_major__ * 10000 \
78+
+ __clang_minor__ * 100 \
79+
+ __clang_patchlevel__)
7080
#ifndef LL_CLANG
7181
#define LL_CLANG 1
7282
#endif
73-
#ifndef LL_GNUC
74-
#define LL_GNUC 1
75-
#endif
7683
#elif defined(__GNUC__)
7784
#define GCC_VERSION (__GNUC__ * 10000 \
7885
+ __GNUC_MINOR__ * 100 \
7986
+ __GNUC_PATCHLEVEL__)
8087
#ifndef LL_GNUC
8188
#define LL_GNUC 1
8289
#endif
83-
#elif defined(__MSVC_VER__) || defined(_MSC_VER)
84-
#ifndef LL_MSVC
85-
#define LL_MSVC 1
86-
#endif
8790
#endif
8891

8992
// Set up CPU architecture defines
9093
#if LL_MSVC && defined(_M_ARM64)
9194
# define LL_ARM64 1
92-
#elif LL_GNUC && (defined(__arm64__) || defined(__aarch64__))
95+
#elif (LL_GNUC || LL_CLANG) && (defined(__arm64__) || defined(__aarch64__))
9396
# define LL_ARM64 1
9497
#elif LL_MSVC && _M_X64
9598
# define LL_X86_64 1
9699
# define LL_X86 1
97100
#elif LL_MSVC && _M_IX86
98101
# define LL_X86 1
99-
#elif LL_GNUC && ( defined(__amd64__) || defined(__x86_64__) )
102+
#elif (LL_GNUC || LL_CLANG) && ( defined(__amd64__) || defined(__x86_64__) )
100103
# define LL_X86_64 1
101104
# define LL_X86 1
102-
#elif LL_GNUC && ( defined(__i386__) )
105+
#elif (LL_GNUC || LL_CLANG) && ( defined(__i386__) )
103106
# define LL_X86 1
104107
#endif
105108

@@ -116,16 +119,6 @@
116119

117120
#endif
118121

119-
// Although thread_local is now a standard storage class, we can't just
120-
// #define LL_THREAD_LOCAL as thread_local because the *usage* is different.
121-
// We'll have to take the time to change LL_THREAD_LOCAL declarations by hand.
122-
#if LL_WINDOWS
123-
# define LL_THREAD_LOCAL __declspec(thread)
124-
#else
125-
# define LL_THREAD_LOCAL __thread
126-
#endif
127-
128-
129122
#if defined(LL_WINDOWS)
130123
#define BOOST_REGEX_NO_LIB 1
131124
#define CURL_STATICLIB 1
@@ -150,7 +143,7 @@
150143
#define LL_DLLIMPORT
151144
#endif // LL_WINDOWS
152145

153-
#if __clang__ || ! defined(LL_WINDOWS)
146+
#if LL_CLANG || ! defined(LL_WINDOWS)
154147
// Only on Windows, and only with the Microsoft compiler (vs. clang) is
155148
// wchar_t potentially not a distinct type.
156149
#define LL_WCHAR_T_NATIVE 1
@@ -211,6 +204,13 @@
211204
#define LL_PRETTY_FUNCTION __PRETTY_FUNCTION__
212205
#endif
213206

207+
// vptr warning supression funtionality for undefined behavior sanitizer
208+
#if LL_CLANG || LL_GNUC
209+
# define LL_UBSAN_SUPRESS_VPTR __attribute__((no_sanitize("vptr")))
210+
#else
211+
# define LL_UBSAN_SUPRESS_VPTR
212+
#endif
213+
214214
#if LL_ARM64
215215
#define GLM_FORCE_NEON 1
216216
#else

0 commit comments

Comments
 (0)