From e29c031b9c788a1869deb6474eecbf6a08f2a5e8 Mon Sep 17 00:00:00 2001
From: David Li
Date: Tue, 26 Mar 2024 15:31:57 -0400
Subject: [PATCH] ci: build wheels with debug info (#1599)
Fixes #1583.
---
.github/workflows/packaging.yml | 4 +
LICENSE.txt | 27 +
c/cmake_modules/AdbcDefines.cmake | 1 +
c/driver/framework/status.h | 2 +-
c/driver/sqlite/sqlite.cc | 3 +-
c/driver/sqlite/statement_reader.c | 13 +-
c/vendor/backward/LICENSE.txt | 21 +
c/vendor/backward/backward.cpp | 42 +
c/vendor/backward/backward.hpp | 4505 +++++++++++++++++
c/vendor/vendor_backward.sh | 32 +
ci/scripts/python_util.sh | 2 +-
ci/scripts/python_wheel_unix_build.sh | 3 +
ci/scripts/python_wheel_windows_build.bat | 5 +-
dev/release/rat_exclude_files.txt | 1 +
license.tpl | 27 +
python/adbc_driver_manager/.gitignore | 1 +
python/adbc_driver_manager/MANIFEST.in | 1 +
.../adbc_driver_manager/_backward.pyx | 44 +
python/adbc_driver_manager/setup.py | 10 +
19 files changed, 4733 insertions(+), 11 deletions(-)
create mode 100644 c/vendor/backward/LICENSE.txt
create mode 100644 c/vendor/backward/backward.cpp
create mode 100644 c/vendor/backward/backward.hpp
create mode 100755 c/vendor/vendor_backward.sh
create mode 100644 python/adbc_driver_manager/adbc_driver_manager/_backward.pyx
diff --git a/.github/workflows/packaging.yml b/.github/workflows/packaging.yml
index 824bf670d9..31bc168159 100644
--- a/.github/workflows/packaging.yml
+++ b/.github/workflows/packaging.yml
@@ -876,6 +876,7 @@ jobs:
adbc/python/adbc_driver_postgresql/repaired_wheels/*.whl
adbc/python/adbc_driver_sqlite/repaired_wheels/*.whl
adbc/python/adbc_driver_snowflake/repaired_wheels/*.whl
+ adbc/build/**/*.pdb
- name: Test wheel
shell: cmd
@@ -965,6 +966,8 @@ jobs:
RELEASE_TAG=${GITHUB_REF#refs/*/}
# Deduplicate wheels built in different jobs with same tag
+ # Include .pdb files since those are debug symbols for Windows
+ # wheels
mkdir -p upload-staging
find ./release-artifacts/ \
'(' \
@@ -972,6 +975,7 @@ jobs:
-name '*.jar' -or \
-name '*.nupkg' -or \
-name '*.snupkg' -or \
+ -name '*.pdb' -or \
-name '*.pom' -or \
-name '*.whl' -or \
-name 'adbc_*.tar.gz' -or \
diff --git a/LICENSE.txt b/LICENSE.txt
index 6b1a9f794b..0ef6328723 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -307,6 +307,33 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
+3rdparty dependency backward-cpp is statically linked in certain binary
+distributions, like the Python wheels. backward-cpp has the following license:
+
+Copyright 2013 Google Inc. All Rights Reserved.
+
+The MIT License (MIT)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+--------------------------------------------------------------------------------
+
3rdparty dependency libpq is statically linked in certain binary
distributions, like the Python wheels. libpq has the following license:
diff --git a/c/cmake_modules/AdbcDefines.cmake b/c/cmake_modules/AdbcDefines.cmake
index c0bf38a41c..8364df8a12 100644
--- a/c/cmake_modules/AdbcDefines.cmake
+++ b/c/cmake_modules/AdbcDefines.cmake
@@ -79,6 +79,7 @@ if(MSVC)
add_compile_options(/wd4100)
# Nanoarrow emits a lot of conversion warnings
add_compile_options(/wd4365)
+ add_compile_options(/wd4242)
add_compile_options(/wd4458)
add_compile_options(/wd4514)
add_compile_options(/wd4582)
diff --git a/c/driver/framework/status.h b/c/driver/framework/status.h
index 482a9cea30..b6375b8e87 100644
--- a/c/driver/framework/status.h
+++ b/c/driver/framework/status.h
@@ -129,7 +129,7 @@ class Status {
template
friend class Driver;
- int CDetailCount() const { return impl_ ? impl_->details.size() : 0; }
+ int CDetailCount() const { return impl_ ? static_cast(impl_->details.size()) : 0; }
AdbcErrorDetail CDetail(int index) const {
if (!impl_ || index < 0 || static_cast(index) >= impl_->details.size()) {
diff --git a/c/driver/sqlite/sqlite.cc b/c/driver/sqlite/sqlite.cc
index 3643337892..a955da17a1 100644
--- a/c/driver/sqlite/sqlite.cc
+++ b/c/driver/sqlite/sqlite.cc
@@ -427,7 +427,8 @@ struct SqliteGetObjectsHelper : public driver::GetObjectsHelper {
ColumnXdbc xdbc;
bool notnull = sqlite3_column_int(columns->stmt(), 3) != 0;
xdbc.xdbc_type_name = GetColumnText(columns->stmt(), 2);
- xdbc.xdbc_nullable = notnull ? 0 : 1;
+ xdbc.xdbc_nullable =
+ notnull ? std::make_optional(0) : std::make_optional(1);
if (sqlite3_column_type(columns->stmt(), 4) != SQLITE_NULL) {
xdbc.xdbc_column_def = GetColumnText(columns->stmt(), 4);
}
diff --git a/c/driver/sqlite/statement_reader.c b/c/driver/sqlite/statement_reader.c
index 0c57c1aff3..39edce69fa 100644
--- a/c/driver/sqlite/statement_reader.c
+++ b/c/driver/sqlite/statement_reader.c
@@ -608,15 +608,14 @@ int StatementReaderGetOneValue(struct StatementReader* reader, int col,
return ArrowArrayAppendBytes(out, value);
}
- default: {
- snprintf(reader->error.message, sizeof(reader->error.message),
- "[SQLite] Internal error: unknown inferred column type %d",
- reader->types[col]);
- return ENOTSUP;
- }
+ default:
+ break;
}
- return 0;
+ snprintf(reader->error.message, sizeof(reader->error.message),
+ "[SQLite] Internal error: unknown inferred column type %d",
+ reader->types[col]);
+ return ENOTSUP;
}
int StatementReaderGetNext(struct ArrowArrayStream* self, struct ArrowArray* out) {
diff --git a/c/vendor/backward/LICENSE.txt b/c/vendor/backward/LICENSE.txt
new file mode 100644
index 0000000000..269e8abbc0
--- /dev/null
+++ b/c/vendor/backward/LICENSE.txt
@@ -0,0 +1,21 @@
+Copyright 2013 Google Inc. All Rights Reserved.
+
+The MIT License (MIT)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/c/vendor/backward/backward.cpp b/c/vendor/backward/backward.cpp
new file mode 100644
index 0000000000..110441cba9
--- /dev/null
+++ b/c/vendor/backward/backward.cpp
@@ -0,0 +1,42 @@
+// Pick your poison.
+//
+// On GNU/Linux, you have few choices to get the most out of your stack trace.
+//
+// By default you get:
+// - object filename
+// - function name
+//
+// In order to add:
+// - source filename
+// - line and column numbers
+// - source code snippet (assuming the file is accessible)
+
+// Install one of the following libraries then uncomment one of the macro (or
+// better, add the detection of the lib and the macro definition in your build
+// system)
+
+// - apt-get install libdw-dev ...
+// - g++/clang++ -ldw ...
+// #define BACKWARD_HAS_DW 1
+
+// - apt-get install binutils-dev ...
+// - g++/clang++ -lbfd ...
+// #define BACKWARD_HAS_BFD 1
+
+// - apt-get install libdwarf-dev ...
+// - g++/clang++ -ldwarf ...
+// #define BACKWARD_HAS_DWARF 1
+
+// Regardless of the library you choose to read the debug information,
+// for potentially more detailed stack traces you can use libunwind
+// - apt-get install libunwind-dev
+// - g++/clang++ -lunwind
+// #define BACKWARD_HAS_LIBUNWIND 1
+
+#include "backward.hpp"
+
+namespace backward {
+
+backward::SignalHandling sh;
+
+} // namespace backward
diff --git a/c/vendor/backward/backward.hpp b/c/vendor/backward/backward.hpp
new file mode 100644
index 0000000000..a42c481c74
--- /dev/null
+++ b/c/vendor/backward/backward.hpp
@@ -0,0 +1,4505 @@
+/*
+ * backward.hpp
+ * Copyright 2013 Google Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef H_6B9572DA_A64B_49E6_B234_051480991C89
+#define H_6B9572DA_A64B_49E6_B234_051480991C89
+
+#ifndef __cplusplus
+#error "It's not going to compile without a C++ compiler..."
+#endif
+
+#if defined(BACKWARD_CXX11)
+#elif defined(BACKWARD_CXX98)
+#else
+#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
+#define BACKWARD_CXX11
+#define BACKWARD_ATLEAST_CXX11
+#define BACKWARD_ATLEAST_CXX98
+#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
+#define BACKWARD_ATLEAST_CXX17
+#endif
+#else
+#define BACKWARD_CXX98
+#define BACKWARD_ATLEAST_CXX98
+#endif
+#endif
+
+// You can define one of the following (or leave it to the auto-detection):
+//
+// #define BACKWARD_SYSTEM_LINUX
+// - specialization for linux
+//
+// #define BACKWARD_SYSTEM_DARWIN
+// - specialization for Mac OS X 10.5 and later.
+//
+// #define BACKWARD_SYSTEM_WINDOWS
+// - specialization for Windows (Clang 9 and MSVC2017)
+//
+// #define BACKWARD_SYSTEM_UNKNOWN
+// - placebo implementation, does nothing.
+//
+#if defined(BACKWARD_SYSTEM_LINUX)
+#elif defined(BACKWARD_SYSTEM_DARWIN)
+#elif defined(BACKWARD_SYSTEM_UNKNOWN)
+#elif defined(BACKWARD_SYSTEM_WINDOWS)
+#else
+#if defined(__linux) || defined(__linux__)
+#define BACKWARD_SYSTEM_LINUX
+#elif defined(__APPLE__)
+#define BACKWARD_SYSTEM_DARWIN
+#elif defined(_WIN32)
+#define BACKWARD_SYSTEM_WINDOWS
+#else
+#define BACKWARD_SYSTEM_UNKNOWN
+#endif
+#endif
+
+#define NOINLINE __attribute__((noinline))
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#if defined(BACKWARD_SYSTEM_LINUX)
+
+// On linux, backtrace can back-trace or "walk" the stack using the following
+// libraries:
+//
+// #define BACKWARD_HAS_UNWIND 1
+// - unwind comes from libgcc, but I saw an equivalent inside clang itself.
+// - with unwind, the stacktrace is as accurate as it can possibly be, since
+// this is used by the C++ runtime in gcc/clang for stack unwinding on
+// exception.
+// - normally libgcc is already linked to your program by default.
+//
+// #define BACKWARD_HAS_LIBUNWIND 1
+// - libunwind provides, in some cases, a more accurate stacktrace as it knows
+// to decode signal handler frames and lets us edit the context registers when
+// unwinding, allowing stack traces over bad function references.
+//
+// #define BACKWARD_HAS_BACKTRACE == 1
+// - backtrace seems to be a little bit more portable than libunwind, but on
+// linux, it uses unwind anyway, but abstract away a tiny information that is
+// sadly really important in order to get perfectly accurate stack traces.
+// - backtrace is part of the (e)glib library.
+//
+// The default is:
+// #define BACKWARD_HAS_UNWIND == 1
+//
+// Note that only one of the define should be set to 1 at a time.
+//
+#if BACKWARD_HAS_UNWIND == 1
+#elif BACKWARD_HAS_LIBUNWIND == 1
+#elif BACKWARD_HAS_BACKTRACE == 1
+#else
+#undef BACKWARD_HAS_UNWIND
+#define BACKWARD_HAS_UNWIND 1
+#undef BACKWARD_HAS_LIBUNWIND
+#define BACKWARD_HAS_LIBUNWIND 0
+#undef BACKWARD_HAS_BACKTRACE
+#define BACKWARD_HAS_BACKTRACE 0
+#endif
+
+// On linux, backward can extract detailed information about a stack trace
+// using one of the following libraries:
+//
+// #define BACKWARD_HAS_DW 1
+// - libdw gives you the most juicy details out of your stack traces:
+// - object filename
+// - function name
+// - source filename
+// - line and column numbers
+// - source code snippet (assuming the file is accessible)
+// - variable names (if not optimized out)
+// - variable values (not supported by backward-cpp)
+// - You need to link with the lib "dw":
+// - apt-get install libdw-dev
+// - g++/clang++ -ldw ...
+//
+// #define BACKWARD_HAS_BFD 1
+// - With libbfd, you get a fair amount of details:
+// - object filename
+// - function name
+// - source filename
+// - line numbers
+// - source code snippet (assuming the file is accessible)
+// - You need to link with the lib "bfd":
+// - apt-get install binutils-dev
+// - g++/clang++ -lbfd ...
+//
+// #define BACKWARD_HAS_DWARF 1
+// - libdwarf gives you the most juicy details out of your stack traces:
+// - object filename
+// - function name
+// - source filename
+// - line and column numbers
+// - source code snippet (assuming the file is accessible)
+// - variable names (if not optimized out)
+// - variable values (not supported by backward-cpp)
+// - You need to link with the lib "dwarf":
+// - apt-get install libdwarf-dev
+// - g++/clang++ -ldwarf ...
+//
+// #define BACKWARD_HAS_BACKTRACE_SYMBOL 1
+// - backtrace provides minimal details for a stack trace:
+// - object filename
+// - function name
+// - backtrace is part of the (e)glib library.
+//
+// The default is:
+// #define BACKWARD_HAS_BACKTRACE_SYMBOL == 1
+//
+// Note that only one of the define should be set to 1 at a time.
+//
+#if BACKWARD_HAS_DW == 1
+#elif BACKWARD_HAS_BFD == 1
+#elif BACKWARD_HAS_DWARF == 1
+#elif BACKWARD_HAS_BACKTRACE_SYMBOL == 1
+#else
+#undef BACKWARD_HAS_DW
+#define BACKWARD_HAS_DW 0
+#undef BACKWARD_HAS_BFD
+#define BACKWARD_HAS_BFD 0
+#undef BACKWARD_HAS_DWARF
+#define BACKWARD_HAS_DWARF 0
+#undef BACKWARD_HAS_BACKTRACE_SYMBOL
+#define BACKWARD_HAS_BACKTRACE_SYMBOL 1
+#endif
+
+#include
+#include
+#ifdef __ANDROID__
+// Old Android API levels define _Unwind_Ptr in both link.h and
+// unwind.h Rename the one in link.h as we are not going to be using
+// it
+#define _Unwind_Ptr _Unwind_Ptr_Custom
+#include
+#undef _Unwind_Ptr
+#else
+#include
+#endif
+#if defined(__ppc__) || defined(__powerpc) || defined(__powerpc__) || \
+ defined(__POWERPC__)
+// Linux kernel header required for the struct pt_regs definition
+// to access the NIP (Next Instruction Pointer) register value
+#include
+#endif
+#include
+#include
+#include
+#include
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#include
+#undef _GNU_SOURCE
+#else
+#include
+#endif
+
+#if BACKWARD_HAS_BFD == 1
+// NOTE: defining PACKAGE{,_VERSION} is required before including
+// bfd.h on some platforms, see also:
+// https://sourceware.org/bugzilla/show_bug.cgi?id=14243
+#ifndef PACKAGE
+#define PACKAGE
+#endif
+#ifndef PACKAGE_VERSION
+#define PACKAGE_VERSION
+#endif
+#include
+#endif
+
+#if BACKWARD_HAS_DW == 1
+#include
+#include
+#include
+#endif
+
+#if BACKWARD_HAS_DWARF == 1
+#include
+#include
+#include
+#include
+#include