|
20 | 20 | #include "duckdb_python/pybind11/conversions/python_udf_type_enum.hpp" |
21 | 21 | #include "duckdb_python/pybind11/conversions/python_csv_line_terminator_enum.hpp" |
22 | 22 | #include "duckdb/common/enums/statement_type.hpp" |
| 23 | +#include "duckdb/common/adbc/adbc-init.hpp" |
23 | 24 |
|
24 | 25 | #include "duckdb.hpp" |
25 | 26 |
|
@@ -1007,14 +1008,34 @@ static void RegisterExpectedResultType(py::handle &m) { |
1007 | 1008 | expected_return_type.export_values(); |
1008 | 1009 | } |
1009 | 1010 |
|
1010 | | -/** |
1011 | | - * Fwd declaration of duckdb_adbc_init (the entrypoint of our ADBC driver) that must be exported. |
1012 | | - */ |
1013 | | -extern "C" PYBIND11_EXPORT void duckdb_adbc_init(void); |
| 1011 | +// ###################################################################### |
| 1012 | +// Symbol exports |
| 1013 | +// |
| 1014 | +// We want to limit the symbols we export to only the absolute minimum. |
| 1015 | +// This means we compile with -fvisibility=hidden to hide all symbols, |
| 1016 | +// and then explicitly export only the symbols we want. |
| 1017 | +// |
| 1018 | +// Right now we export two symbols only: |
| 1019 | +// - duckdb_adbc_init: the entrypoint for our ADBC driver |
| 1020 | +// - PyInit__duckdb: the entrypoint for the python extension |
| 1021 | +// |
| 1022 | +// All symbols that need exporting must be added to both the list below |
| 1023 | +// AND to CMakeLists.txt. |
| 1024 | +extern "C" { |
| 1025 | +PYBIND11_EXPORT void *_force_symbol_inclusion() { |
| 1026 | + static void *symbols[] = { |
| 1027 | + // Add functions to export here |
| 1028 | + (void *)&duckdb_adbc_init, |
| 1029 | + }; |
| 1030 | + return symbols; |
| 1031 | +} |
| 1032 | +}; |
1014 | 1033 |
|
1015 | 1034 | PYBIND11_MODULE(DUCKDB_PYTHON_LIB_NAME, m) { // NOLINT |
1016 | | - // Take address to force duckdb_adbc_init symbol inclusion |
1017 | | - (void)&duckdb_adbc_init; |
| 1035 | + // DO NOT REMOVE: the below forces that we include all symbols we want to export |
| 1036 | + volatile auto *keep_alive = _force_symbol_inclusion(); |
| 1037 | + (void)keep_alive; |
| 1038 | + // END |
1018 | 1039 |
|
1019 | 1040 | py::enum_<duckdb::ExplainType>(m, "ExplainType") |
1020 | 1041 | .value("STANDARD", duckdb::ExplainType::EXPLAIN_STANDARD) |
|
0 commit comments