Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ if (NOT NO_ISA_EXTENSIONS)
endif()
endif()
if(WIN32)
add_compile_options(/arch:AVX2)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
add_compile_options(-mavx2)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options(/arch:AVX2)
endif()
endif()
endif()

Expand All @@ -30,15 +34,20 @@ endif()

if(WIN32)
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN -D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)
add_compile_options(/MP)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options(/MP)
endif()
endif()

if(EMSCRIPTEN)
add_compile_options(-pthread -DIMGUI_IMPL_OPENGL_ES2)
endif()

if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT EMSCRIPTEN)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
# Mingw gcc on windows can't handle section count resulting during compilation of profiler/src/profiler/TracyMicroArchitecture.cpp
if(NOT (MINGW OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") AND WIN32 AND NOT ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move WIN32 as first condition for better readability.

set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
endif()
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
Expand Down
3 changes: 3 additions & 0 deletions cmake/server.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ list(TRANSFORM TRACY_SERVER_SOURCES PREPEND "${TRACY_SERVER_DIR}/")
add_library(TracyServer STATIC EXCLUDE_FROM_ALL ${TRACY_COMMON_SOURCES} ${TRACY_SERVER_SOURCES})
target_include_directories(TracyServer PUBLIC ${TRACY_COMMON_DIR} ${TRACY_SERVER_DIR})
target_link_libraries(TracyServer PUBLIC TracyCapstone libzstd PPQSort::PPQSort)
if(WIN32)
target_link_libraries(TracyServer PRIVATE Ws2_32)
endif()
if(NO_STATISTICS)
target_compile_definitions(TracyServer PUBLIC TRACY_NO_STATISTICS)
endif()
4 changes: 3 additions & 1 deletion import/src/import-chrome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
#include <unordered_map>
#include <zstd.h>

#ifdef _MSC_VER
#if defined _MSC_VER || defined __clang__ || defined __GNUC__
// all checked compilers contain _stat64
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes behavior on non-win32 platforms.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix it.

# define stat64 _stat64
#endif

#if defined __APPLE__
# define stat64 stat
#endif
Expand Down
5 changes: 3 additions & 2 deletions import/src/import-fuchsia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
#include <variant>
#include <zstd.h>

#ifdef _MSC_VER
#define stat64 _stat64
#if defined _MSC_VER || defined __clang__ || defined __GNUC__
// all checked compilers contain _stat64
# define stat64 _stat64
#endif
#if defined __APPLE__
#define stat64 stat
Expand Down
18 changes: 9 additions & 9 deletions import/src/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16799,7 +16799,7 @@ class binary_writer

void write_compact_float(const number_float_t n, detail::input_format_t format)
{
#ifdef __GNUC__
#if defined __GNUC__ || defined __clang__
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

% clang -dM -E -x c /dev/null | grep __GNUC__
#define __GNUC__ 4

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just being explicit. I can change it if needed.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to go to each of the upstream projects with this change (that is not really needed)?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that this would be due to having unified #if conditions. I removed obviously not needed checks for __clang__, only left ones that coexist with version checking of GNU, as I don't know if there can be any differences, just to be sure.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, does that mean that if __GNUC__ version is checked then for sure clang will not be supported for this block of code, or it still can be checked via #if (<GNUC version check>) || defined __clang__? Because if only version check done in this way is not valid then it still should be possible to check if clang is compiler that is used.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang defines a very old version of gcc version macro, which may affect what features are available. This can be problematic in rare circumstances.

Copy link
Copy Markdown
Author

@FilipNur FilipNur Jun 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But is #if (<GNUC version check>) || defined __clang__ method valid then or not? Or clang version must be checked separately through for example __clang_major__ __clang_minor__ __clang_patchlevel__ macros?

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
#endif
Expand All @@ -16819,7 +16819,7 @@ class binary_writer
: get_msgpack_float_prefix(n));
write_number(n);
}
#ifdef __GNUC__
#if defined __GNUC__ || defined __clang__
#pragma GCC diagnostic pop
#endif
}
Expand Down Expand Up @@ -17981,7 +17981,7 @@ char* to_chars(char* first, const char* last, FloatType value)
*first++ = '-';
}

#ifdef __GNUC__
#if defined __GNUC__ || defined __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
#endif
Expand All @@ -17993,7 +17993,7 @@ char* to_chars(char* first, const char* last, FloatType value)
*first++ = '0';
return first;
}
#ifdef __GNUC__
#if defined __GNUC__ || defined __clang__
#pragma GCC diagnostic pop
#endif

Expand Down Expand Up @@ -21187,7 +21187,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
detail::negation<std::is_same<ValueType, typename string_t::value_type>>,
detail::negation<detail::is_basic_json<ValueType>>,
detail::negation<std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>>,
#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || defined(__clang__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914))
detail::negation<std::is_same<ValueType, std::string_view>>,
#endif
#if defined(JSON_HAS_CPP_17) && JSON_HAS_STATIC_RTTI
Expand Down Expand Up @@ -22983,13 +22983,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @sa https://json.nlohmann.me/api/basic_json/operator_eq/
bool operator==(const_reference rhs) const noexcept
{
#ifdef __GNUC__
#if defined __GNUC__ || defined __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
#endif
const_reference lhs = *this;
JSON_IMPLEMENT_OPERATOR( ==, true, false, false)
#ifdef __GNUC__
#if defined __GNUC__ || defined __clang__
#pragma GCC diagnostic pop
#endif
}
Expand Down Expand Up @@ -23087,12 +23087,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
/// @sa https://json.nlohmann.me/api/basic_json/operator_eq/
friend bool operator==(const_reference lhs, const_reference rhs) noexcept
{
#ifdef __GNUC__
#if defined __GNUC__ || defined __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
#endif
JSON_IMPLEMENT_OPERATOR( ==, true, false, false)
#ifdef __GNUC__
#if defined __GNUC__ || defined __clang__
#pragma GCC diagnostic pop
#endif
}
Expand Down
8 changes: 8 additions & 0 deletions profiler/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
# include <windows.h>
#endif

#if defined _WIN32 && (defined __GNUC__ && !defined __clang__)
//_WIN32 - only tested on windows

// gcc throws error for not present std::pow function,
// clang does not have that problem
#include <cmath>
#endif

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed here?

[18:59 wolf@oberon:~/tracy]% git grep std::pow 
profiler/src/profiler/TracyView_Timeline.cpp:            const auto mult = 1 + std::max( 0.0, 0.7 * std::pow( x, 1.6 ) - 0.8 * std::pow( x, 1.4 ) );

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, and turns out that using cmake from clang toolchain and gcc compiler created errors. So not needed, will remove.

#define STB_IMAGE_IMPLEMENTATION
#define STBI_ONLY_PNG
#include "stb_image.h"
Expand Down
8 changes: 8 additions & 0 deletions profiler/src/profiler/TracyView_Timeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
#include "TracyTimelineItemThread.hpp"
#include "TracyView.hpp"

#if defined _WIN32 && (defined __GNUC__ && !defined __clang__)
//_WIN32 - only tested on windows

// gcc throws error for not present std::pow function,
// clang does not have that problem
#include <cmath>
#endif
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The correct solution would be to change std::pow to pow and include math.h (with no platform checks).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checks are made only to not include it where it is not needed. Code uses std::pow so to change the least amount of stuff only header is added.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that solution is wrong and only works due to happenstance.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, and turns out that using cmake from clang toolchain and gcc compiler created errors. So not needed, will remove.


namespace tracy
{

Expand Down
Loading