diff options
author | Robert Adam <dev@robert-adam.de> | 2022-08-31 18:59:46 +0300 |
---|---|---|
committer | Robert Adam <dev@robert-adam.de> | 2022-08-31 18:59:46 +0300 |
commit | ece8779362acbba962699656cf7e9f900148d917 (patch) | |
tree | 925f13cb226c5c09a55fb7250676bf80d525008c /public | |
parent | 107975c8defb4a011ec81fd37710515de38bf7fe (diff) |
Fix cpuid symbol redefinition on older GCC versions
Since commit 940f32c1a892dd194c3c6d66bb3550149de919fc building the Tracy
library on Linux using a GCC version < 11 would result in compile errors
due to symbol redefinitions of __get_cpuid_max, __get_cpuid and
__get_cpuid_count.
This is because prior to GCC 11 the cpuid.h header file did not have any
include guards and thus including this header more than once would
produce the abovementioned errors.
To work around this issue, including cpuid.h has been wrapped into a
custom header file that itself uses include guards and thus shields
cpuid.h from being included multiple times.
Fixes #452
Diffstat (limited to 'public')
-rw-r--r-- | public/client/TracyCpuid.hpp | 12 | ||||
-rw-r--r-- | public/client/TracyProfiler.cpp | 2 | ||||
-rw-r--r-- | public/client/TracySysTrace.cpp | 2 |
3 files changed, 14 insertions, 2 deletions
diff --git a/public/client/TracyCpuid.hpp b/public/client/TracyCpuid.hpp new file mode 100644 index 00000000..9820be00 --- /dev/null +++ b/public/client/TracyCpuid.hpp @@ -0,0 +1,12 @@ +#ifndef __TRACYCPUID_HPP__ +#define __TRACYCPUID_HPP__ + +// Prior to GCC 11 the cpuid.h header did not have any include guards and thus +// including it more than once would cause a compiler error due to symbol +// redefinitions. In order to support older GCC versions, we have to wrap this +// include between custom include guards to prevent this issue. +// See also https://github.com/wolfpld/tracy/issues/452 + +#include <cpuid.h> + +#endif diff --git a/public/client/TracyProfiler.cpp b/public/client/TracyProfiler.cpp index 90cc0077..e0783825 100644 --- a/public/client/TracyProfiler.cpp +++ b/public/client/TracyProfiler.cpp @@ -106,7 +106,7 @@ extern "C" typedef BOOL (WINAPI *t_GetLogicalProcessorInformationEx)( LOGICAL_PR #endif #if !defined _WIN32 && ( defined __i386 || defined _M_IX86 || defined __x86_64__ || defined _M_X64 ) -# include <cpuid.h> +# include "TracyCpuid.hpp" #endif #if !( ( defined _WIN32 && _WIN32_WINNT >= _WIN32_WINNT_VISTA ) || defined __linux__ ) diff --git a/public/client/TracySysTrace.cpp b/public/client/TracySysTrace.cpp index ee62547d..23b1020a 100644 --- a/public/client/TracySysTrace.cpp +++ b/public/client/TracySysTrace.cpp @@ -609,7 +609,7 @@ void SysTraceGetExternalName( uint64_t thread, const char*& threadName, const ch # include <sys/syscall.h> # if defined __i386 || defined __x86_64__ -# include <cpuid.h> +# include "TracyCpuid.hpp" # endif # include "TracyProfiler.hpp" |