You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[#28914] YSQL: link postgres's excutables with CXX instead of CC
Summary:
There are multiple postgres's executable linked with various YB libraries (`-lyb_pggate_util` `-lyb_pggate`). These libraries are linked dynamically.
In case of running such executables built in `ASAN` mode the `symbol lookup` error like the following may occur:
```
[2025-10-01T23:49:31.377Z] [m-1] W1001 23:49:25.568262 371043 subprocess.cc:210] [initdb] /share/jenkins/workspace/yugabyte-db-phabricator/yugabyte-db/build/asan-clang19-dynamic-ninja/postgres/bin/initdb: symbol lookup error: /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20250812204937-6c7155ea61-almalinux9-x86_64-clang19/installed/asan/lib/libprotobuf.so.32: undefined symbol: __ubsan_vptr_type_cache
```
The root cause of such error is that there is no `__ubsan_vptr_type_cache` function in executable while dynamically library use it. This function is added/used when executable/library is build (linked) with the `-fsanitize` flag.
In spite of the fact postgres executables uses same set of flags (including `-fsanitize`) for building like YB's C++ library C and C++ compilers process them in different way (i.e. uses different set of auxiliary functions).
To solve the issue it is required to use C++ for linking instead of C for executables which may load instrumented dynamic libraries build with C++.
This approach is already used for `postgres` executable:
```
...
CCLD = $(CXX)
...
postgres: $(OBJS)
$(CCLD) $(CFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) $(LIBS) -o $@
...
```
This diff spreads same approach on all executables which are linked (i.e. adds `-lyb_pggate*`) against YB's libraries in `Makefile`.
Jira: DB-18637
Test Plan: Jenkins
Reviewers: fizaa, pjain, myang, kramanathan, jason
Reviewed By: jason
Subscribers: jason, yql
Tags: #jenkins-ready
Differential Revision: https://phorge.dev.yugabyte.com/D47153
0 commit comments