From 4c2e8326aaaef43436fe85fce1db51bb62f137e6 Mon Sep 17 00:00:00 2001
From: David Li
Date: Tue, 12 Mar 2024 08:34:58 -0400
Subject: [PATCH] build(c): set -Og -ggdb and warn about Conda setting -O2
Fixes #1608.
---
c/cmake_modules/AdbcDefines.cmake | 22 +++++++++++++++++++++-
c/driver/sqlite/sqlite.c | 2 +-
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/c/cmake_modules/AdbcDefines.cmake b/c/cmake_modules/AdbcDefines.cmake
index 69a8c1aa82..8c9c37ee61 100644
--- a/c/cmake_modules/AdbcDefines.cmake
+++ b/c/cmake_modules/AdbcDefines.cmake
@@ -60,8 +60,8 @@ if(CXX_LINKER_SUPPORTS_VERSION_SCRIPT)
endif()
# Set common build options
+string(TOLOWER "${CMAKE_BUILD_TYPE}" _lower_build_type)
if("${ADBC_BUILD_WARNING_LEVEL}" STREQUAL "")
- string(TOLOWER "${CMAKE_BUILD_TYPE}" _lower_build_type)
if("${_lower_build_type}" STREQUAL "release")
set(ADBC_BUILD_WARNING_LEVEL "PRODUCTION")
else()
@@ -92,6 +92,26 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"
-Werror
-Wno-unused-parameter)
set(ADBC_C_CXX_FLAGS_PRODUCTION -Wall)
+
+ if(NOT CMAKE_C_FLAGS_DEBUG MATCHES "-O")
+ string(APPEND CMAKE_C_FLAGS_DEBUG " -Og")
+ endif()
+ if(NOT CMAKE_CXX_FLAGS_DEBUG MATCHES "-O")
+ string(APPEND CMAKE_CXX_FLAGS_DEBUG " -Og")
+ endif()
+
+ if(NOT CMAKE_C_FLAGS_DEBUG MATCHES "-g")
+ string(APPEND CMAKE_C_FLAGS_DEBUG " -g3")
+ endif()
+ if(NOT CMAKE_CXX_FLAGS_DEBUG MATCHES "-g")
+ string(APPEND CMAKE_CXX_FLAGS_DEBUG " -g3")
+ endif()
+ if(NOT CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES "-g")
+ string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " -g3")
+ endif()
+ if(NOT CMAKE_CXX_FLAGS_RELWITHDEBINFO MATCHES "-g")
+ string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -g3")
+ endif()
else()
message(WARNING "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}")
endif()
diff --git a/c/driver/sqlite/sqlite.c b/c/driver/sqlite/sqlite.c
index 87390ce351..83d2d61106 100644
--- a/c/driver/sqlite/sqlite.c
+++ b/c/driver/sqlite/sqlite.c
@@ -1584,7 +1584,7 @@ AdbcStatusCode SqliteStatementGetParameterSchema(struct AdbcStatement* statement
ArrowSchemaInit(schema);
CHECK_NA(INTERNAL, ArrowSchemaSetType(schema, NANOARROW_TYPE_STRUCT), error);
CHECK_NA(INTERNAL, ArrowSchemaAllocateChildren(schema, num_params), error);
- char buffer[11];
+ char buffer[12];
for (int i = 0; i < num_params; i++) {
const char* name = sqlite3_bind_parameter_name(stmt->stmt, i + 1);
if (name == NULL) {