Adding -Og to debug builds. (#1964)

* Adding -Og to debug builds.

* Stupid compiler.

* bad, bad, bad compiler
This commit is contained in:
Daniel Lemire
2023-03-09 11:14:42 -05:00
committed by GitHub
parent 77ad00b63c
commit 17a1a8e187
3 changed files with 18 additions and 3 deletions
+15
View File
@@ -95,6 +95,21 @@ if(
)
endif()
# GCC and Clang have horrendous Debug builds when using SIMD.
# A common fix is to use '-Og' instead.
# bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54412
if(
(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
AND CMAKE_BUILD_TYPE STREQUAL "Debug"
)
simdjson_add_props(
target_compile_options PRIVATE
-Og
)
endif()
if(SIMDJSON_ENABLE_THREADS)
find_package(Threads REQUIRED)
simdjson_add_props(target_link_libraries PUBLIC Threads::Threads)
+1 -1
View File
@@ -140,7 +140,7 @@ bool tester(int seed, size_t volume) {
std::vector<char> buffer(1024); // large buffer (can't overflow)
simdjson::dom::parser parser;
RandomEngine rand(seed);
double result;
double result{};
for (size_t i = 0; i < volume; i++) {
if((i%100000) == 0) { std::cout << "."; std::cout.flush(); }
size_t length = build_random_string(rand, buffer.data());
+2 -2
View File
@@ -123,7 +123,7 @@ void recurse(simdjson::dom::element element, stat_t &s, size_t depth) {
if (element.is<int64_t>()) {
s.integer_count++; // because an int can be sometimes represented as a double, we
// to check whether it is an integer first!!!
int64_t v;
int64_t v{};
error = element.get(v);
SIMDJSON_ASSUME(!error);
if((v >= std::numeric_limits<int32_t>::min()) and (v <= std::numeric_limits<int32_t>::max()) ) {
@@ -138,7 +138,7 @@ void recurse(simdjson::dom::element element, stat_t &s, size_t depth) {
} else if (element.is<double>()) {
s.float_count++;
} else if (element.is<bool>()) {
bool v;
bool v{};
error = element.get(v);
SIMDJSON_ASSUME(!error);
if (v) {