Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(c): set -g3 in debug/relwithdebuginfo builds #1609

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading