chdb-io / chdb

chDB is an in-process OLAP SQL Engine 🚀 powered by ClickHouse
https://clickhouse.com/docs/en/chdb
Apache License 2.0
2.03k stars 72 forks source link

Add dummy_calls to ensure query_stable and free_result not optimized out #171

Closed auxten closed 9 months ago

auxten commented 9 months ago

The dummy_calls function is used to prevent certain functions from being optimized out by the compiler. It includes calls to 'query_stable' and 'free_result' within a condition that is always false. This approach ensures these functions are recognized as used by the compiler, particularly under high optimization levels like -O3, where unused functions might otherwise be discarded.

Without this the Github runner macOS 12 builder will fail to find query_stable and free_result. It is strange because the same code works fine on my own macOS 12 x86_64 and arm64 machines.

To prevent further clang or ClickHouse compile flags from affecting this, the function is defined and called from mainEntryClickHouseLocal.