mirror of
https://github.com/wolfpld/tracy.git
synced 2026-06-08 00:23:47 +00:00
Merge pull request #1335 from siliceum/feature/check-macros-mismatch
Detecting macro definitions mismatches at link time
This commit is contained in:
@@ -211,6 +211,7 @@ set(client_includes
|
||||
${TRACY_PUBLIC_DIR}/client/TracyDxt1.hpp
|
||||
${TRACY_PUBLIC_DIR}/client/TracyFastVector.hpp
|
||||
${TRACY_PUBLIC_DIR}/client/TracyLock.hpp
|
||||
${TRACY_PUBLIC_DIR}/client/TracyMangle.hpp
|
||||
${TRACY_PUBLIC_DIR}/client/TracyProfiler.hpp
|
||||
${TRACY_PUBLIC_DIR}/client/TracyRingBuffer.hpp
|
||||
${TRACY_PUBLIC_DIR}/client/TracyScoped.hpp
|
||||
|
||||
@@ -570,9 +570,17 @@ noborder=true,
|
||||
couleur=black!5,
|
||||
logo=\bcbombe
|
||||
]{Keep everything consistent}
|
||||
When working with multiple libraries, it is easy to make a mistake and use different sets of feature macros between any two compilation jobs. If you do so, Tracy will not be able to work correctly, and there will be no error or warning messages about the problem. Henceforth, you must make sure each shared object you want to link with, or load uses the same set of macro definitions.
|
||||
When working with multiple libraries, it is easy to make a mistake and use different sets of feature macros between any two compilation jobs. If you do so, Tracy will not be able to work correctly. Henceforth, you must make sure each shared object you want to link with, or load uses the same set of macro definitions.
|
||||
|
||||
Please note that using a prebuilt shared Tracy library, as provided by some package manager or system distribution, also qualifies as using multiple libraries.
|
||||
Tracy will attempt to detect such mismatches at link time. It does so by encoding the relevant build options into an internal function name, so a mismatch will produce a linker error such as (with MSVC):
|
||||
|
||||
\begin{lstlisting}
|
||||
error LNK2019: unresolved external symbol "int __cdecl GetProfiler_CFG_E1_OD1_DI0_ML0_F0_DHT0_TF0(void) ...
|
||||
\end{lstlisting}
|
||||
|
||||
The full list of abbreviations is defined in \texttt{public/client/TracyMangle.hpp}. Comparing the suffix against your build settings will tell you which define is wrong.
|
||||
|
||||
Note that one case is undetectable: if your code omits \texttt{TRACY\_ENABLE} but the library was built with it, the build will succeed yet Tracy will still start up and attempt to connect to a profiler.
|
||||
\end{bclogo}
|
||||
|
||||
\subsubsection{Problematic platforms}
|
||||
|
||||
@@ -165,6 +165,7 @@ client_includes = [
|
||||
'public/client/TracyFastVector.hpp',
|
||||
'public/client/TracyKCore.hpp',
|
||||
'public/client/TracyLock.hpp',
|
||||
'public/client/TracyMangle.hpp',
|
||||
'public/client/TracyProfiler.hpp',
|
||||
'public/client/TracyRingBuffer.hpp',
|
||||
'public/client/TracyScoped.hpp',
|
||||
|
||||
57
public/client/TracyMangle.hpp
Normal file
57
public/client/TracyMangle.hpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef __TRACYMANGLE_HPP__
|
||||
#define __TRACYMANGLE_HPP__
|
||||
|
||||
#ifdef TRACY_ENABLE
|
||||
#define TRACY_ENABLE_MANGLE _E1
|
||||
#else
|
||||
#define TRACY_ENABLE_MANGLE _E0
|
||||
#endif
|
||||
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
#define TRACY_ON_DEMAND_MANGLE _OD1
|
||||
#else
|
||||
#define TRACY_ON_DEMAND_MANGLE _OD0
|
||||
#endif
|
||||
|
||||
#ifdef TRACY_DELAYED_INIT
|
||||
#define TRACY_DELAYED_INIT_MANGLE _DI1
|
||||
#else
|
||||
#define TRACY_DELAYED_INIT_MANGLE _DI0
|
||||
#endif
|
||||
|
||||
#ifdef TRACY_MANUAL_LIFETIME
|
||||
#define TRACY_MANUAL_LIFETIME_MANGLE _ML1
|
||||
#else
|
||||
#define TRACY_MANUAL_LIFETIME_MANGLE _ML0
|
||||
#endif
|
||||
|
||||
#ifdef TRACY_FIBERS
|
||||
#define TRACY_FIBERS_MANGLE _F1
|
||||
#else
|
||||
#define TRACY_FIBERS_MANGLE _F0
|
||||
#endif
|
||||
|
||||
#ifdef TRACY_DISALLOW_HW_TIMER
|
||||
#define TRACY_DISALLOW_HW_TIMER_MANGLE _DHT1
|
||||
#else
|
||||
#define TRACY_DISALLOW_HW_TIMER_MANGLE _DHT0
|
||||
#endif
|
||||
|
||||
#ifdef TRACY_TIMER_FALLBACK
|
||||
#define TRACY_TIMER_FALLBACK_MANGLE _TF1
|
||||
#else
|
||||
#define TRACY_TIMER_FALLBACK_MANGLE _TF0
|
||||
#endif
|
||||
|
||||
#define MANGLED_NAME_BASED_ON_CONFIG(base) \
|
||||
TracyConcat(TracyConcat(TracyConcat(TracyConcat(TracyConcat(TracyConcat(TracyConcat( \
|
||||
base##_CFG, \
|
||||
TRACY_ENABLE_MANGLE), \
|
||||
TRACY_ON_DEMAND_MANGLE), \
|
||||
TRACY_DELAYED_INIT_MANGLE), \
|
||||
TRACY_MANUAL_LIFETIME_MANGLE), \
|
||||
TRACY_FIBERS_MANGLE), \
|
||||
TRACY_DISALLOW_HW_TIMER_MANGLE), \
|
||||
TRACY_TIMER_FALLBACK_MANGLE)
|
||||
|
||||
#endif // __TRACYMANGLE_HPP__
|
||||
@@ -1374,7 +1374,7 @@ static ProfilerThreadData& GetProfilerThreadData()
|
||||
#endif
|
||||
|
||||
TRACY_API moodycamel::ConcurrentQueue<QueueItem>::ExplicitProducer* GetToken() { return GetProfilerThreadData().token.ptr; }
|
||||
TRACY_API Profiler& GetProfiler() { return GetProfilerData().profiler; }
|
||||
TRACY_API Profiler& MANGLED_NAME_BASED_ON_CONFIG(GetProfiler)() { return GetProfilerData().profiler; }
|
||||
TRACY_API moodycamel::ConcurrentQueue<QueueItem>& GetQueue() { return GetProfilerData().queue; }
|
||||
TRACY_API int64_t GetInitTime() { return GetProfilerData().initTime; }
|
||||
TRACY_API std::atomic<uint32_t>& GetLockCounter() { return GetProfilerData().lockCounter; }
|
||||
@@ -1434,7 +1434,7 @@ thread_local LuaZoneState init_order(104) s_luaZoneState { 0, false };
|
||||
static Profiler init_order(105) s_profiler;
|
||||
|
||||
TRACY_API moodycamel::ConcurrentQueue<QueueItem>::ExplicitProducer* GetToken() { return s_token.ptr; }
|
||||
TRACY_API Profiler& GetProfiler() { return s_profiler; }
|
||||
TRACY_API Profiler& MANGLED_NAME_BASED_ON_CONFIG(GetProfiler)() { return s_profiler; }
|
||||
TRACY_API moodycamel::ConcurrentQueue<QueueItem>& GetQueue() { return s_queue; }
|
||||
TRACY_API int64_t GetInitTime() { return s_initTime.val; }
|
||||
TRACY_API std::atomic<uint32_t>& GetLockCounter() { return s_lockCounter; }
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "tracy_SPSCQueue.h"
|
||||
#include "TracyCallstack.hpp"
|
||||
#include "TracyKCore.hpp"
|
||||
#include "TracyMangle.hpp"
|
||||
#include "TracySysPower.hpp"
|
||||
#include "TracySysTime.hpp"
|
||||
#include "TracyFastVector.hpp"
|
||||
@@ -85,7 +86,8 @@ struct GpuCtxWrapper
|
||||
};
|
||||
|
||||
TRACY_API moodycamel::ConcurrentQueue<QueueItem>::ExplicitProducer* GetToken();
|
||||
TRACY_API Profiler& GetProfiler();
|
||||
TRACY_API Profiler& MANGLED_NAME_BASED_ON_CONFIG(GetProfiler)();
|
||||
tracy_force_inline Profiler& GetProfiler() { return MANGLED_NAME_BASED_ON_CONFIG(GetProfiler)(); }
|
||||
TRACY_API std::atomic<uint32_t>& GetLockCounter();
|
||||
TRACY_API std::atomic<uint8_t>& GetGpuCtxCounter();
|
||||
TRACY_API GpuCtxWrapper& GetGpuCtx();
|
||||
|
||||
Reference in New Issue
Block a user