Skip to content

Commit

Permalink
build(c): set -Og -ggdb and warn about Conda setting -O2
Browse files Browse the repository at this point in the history
Fixes #1608.
  • Loading branch information
lidavidm committed Mar 12, 2024
1 parent 27d62c3 commit 35d06c1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
22 changes: 21 additions & 1 deletion c/cmake_modules/AdbcDefines.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion c/driver/sqlite/sqlite.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
13 changes: 11 additions & 2 deletions c/validation/adbc_validation_statement.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2591,10 +2591,18 @@ void StatementTest::TestConcurrentStatements() {
ASSERT_NO_FATAL_FAILURE(reader1.GetSchema());
}

struct ADBC_EXPORT AdbcError100 {
char* message;
int32_t vendor_code;
char sqlstate[5];
void (*release)(struct AdbcError100* error);
};

// Test that an ADBC 1.0.0-sized error still works
void StatementTest::TestErrorCompatibility() {
static_assert(sizeof(AdbcError100) == ADBC_ERROR_1_0_0_SIZE, "Wrong size");
// XXX: sketchy cast
auto* error = static_cast<struct AdbcError*>(malloc(ADBC_ERROR_1_0_0_SIZE));
auto* error = reinterpret_cast<struct AdbcError*>(malloc(ADBC_ERROR_1_0_0_SIZE));
std::memset(error, 0, ADBC_ERROR_1_0_0_SIZE);

ASSERT_THAT(AdbcStatementNew(&connection, &statement, error), IsOkStatus(error));
Expand All @@ -2605,7 +2613,8 @@ void StatementTest::TestErrorCompatibility() {
ASSERT_THAT(AdbcStatementExecuteQuery(&statement, &reader.stream.value,
&reader.rows_affected, error),
::testing::Not(IsOkStatus(error)));
error->release(error);
auto* old_error = reinterpret_cast<AdbcError100*>(error);
old_error->release(old_error);
free(error);
}

Expand Down

0 comments on commit 35d06c1

Please sign in to comment.