Skip to content

fix: macOS build - sqlite3 link and missing libtool#5664

Merged
renecannao merged 4 commits into
v3.0from
fix/macos-build-deps
Apr 24, 2026
Merged

fix: macOS build - sqlite3 link and missing libtool#5664
renecannao merged 4 commits into
v3.0from
fix/macos-build-deps

Conversation

@renecannao

@renecannao renecannao commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes two issues preventing ProxySQL from building on macOS (GitHub Actions runners):

  1. sqlite3 shared lib linkcc -shared on macOS requires all symbols resolved at link time, unlike Linux. Added -dynamiclib -undefined dynamic_lookup with OpenSSL link flags for Darwin.

  2. Missing libtoolautoreconf (called by curl build) requires glibtoolize, provided by Homebrew's libtool package. Added to brew install list.

These are real bugs that also affect local macOS builds in clean environments — the sqlite3 issue was masked on machines where OpenSSL was already in the linker search path.

Summary by CodeRabbit

  • Chores
    • macOS CI pipelines updated to include libtool for a more consistent macOS toolchain.
    • macOS build/linking adjusted (SQLite linking and macOS library flags) to improve macOS build reliability and compatibility.
  • Refactor
    • Internal comparison code made const-correct to improve code robustness (no user-facing behavior changes).

- deps/Makefile: Use -dynamiclib -undefined dynamic_lookup for sqlite3
  shared lib on Darwin (Linux -shared allows unresolved symbols, macOS
  does not). Also link OpenSSL for SHA1 symbol resolution.
- workflows: Add libtool to brew install (provides glibtoolize needed
  by curl's autoreconf).
@coderabbitai

coderabbitai Bot commented Apr 23, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 004a3b53-b00e-4373-be43-e4d805f73366

📥 Commits

Reviewing files that changed from the base of the PR and between 514025c and b2b94f0.

📒 Files selected for processing (1)
  • src/Makefile
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: run / trigger
  • GitHub Check: CI-build-macos-macos-14-genai / build (macos-arm64-genai)
  • GitHub Check: CI-build-macos-macos-14-v31 / build (macos-arm64-v31)
  • GitHub Check: CI-build-macos-macos-14 / build (macos-arm64)
  • GitHub Check: build
  • GitHub Check: build
  • GitHub Check: build
  • GitHub Check: claude-review
🔇 Additional comments (1)
src/Makefile (1)

137-138: LGTM — -luuid is correctly removed on Darwin.

On macOS, uuid_generate() / uuid_unparse() are provided by libSystem (the standard C library); libuuid is a Linux-specific package (util-linux/e2fsprogs). So the unconditional UUID calls in lib/ProxySQL_Admin.cpp (around lines 3515‑3525) continue to resolve on Darwin without -luuid, and the Linux/else path at line 130 still links it. The fix is correct and removes a spurious dependency that would fail on clean macOS toolchains.


📝 Walkthrough

Walkthrough

Adds libtool to macOS CI Homebrew install lists across multiple workflows; makes sqlite3 linking conditional on OS (Darwin uses -dynamiclib with @rpath and explicit SSL/crypto libs, others use -shared); marks several TrxId_Interval comparison methods as const and removes const from their scalar return types.

Changes

Cohort / File(s) Summary
macOS CI Workflows
.github/workflows/CI-build-macos-macos-13-genai.yml, .github/workflows/CI-build-macos-macos-13-v31.yml, .github/workflows/CI-build-macos-macos-13.yml, .github/workflows/CI-build-macos-macos-14-genai.yml, .github/workflows/CI-build-macos-macos-14-v31.yml, .github/workflows/CI-build-macos-macos-14.yml
Homebrew package lists updated to include libtool (some replace gpatch); no other workflow steps changed.
SQLite3 build/linking
deps/Makefile
Linking step for libsqlite3.so made OS-aware: on Darwin use -dynamiclib with -undefined dynamic_lookup, -install_name @rpath/libsqlite3.so`` and explicit -lssl -lcrypto; non-Darwin uses `-shared`.
TrxId_Interval comparison API
include/proxysql_gtid.h, lib/proxysql_gtid.cpp
cmp, operator<, operator==, operator!= changed to be const member functions and now return non-const scalar types; header and implementation updated accordingly.
macOS linker flags
src/Makefile
Removed -luuid from macOS MYLIBS linker flags.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

Packages, Compiling

Poem

🐰 I hopped through CI rows and planted libtool neat,

SQLite learned rpaths and danced on Darwin's feet.
TrxId gained a calm "const" and pranced in ordered queues,
A small patch, soft as clover, for happier build-time news.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main changes: fixes to macOS build issues related to sqlite3 linking and missing libtool dependency.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/macos-build-deps

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the deps/Makefile to correctly build libsqlite3.so on macOS by introducing conditional logic for the Darwin platform and applying specific linker flags for dynamic libraries. The review feedback suggests that the macOS build documentation should be updated to include the new libtool dependency mentioned in the PR description. Additionally, it is recommended to remove the explicit linking of SSL and Crypto libraries on macOS, as they are redundant when using -undefined dynamic_lookup and could lead to symbol conflicts.

Comment thread deps/Makefile
cd sqlite3/sqlite3 && patch -p0 < ../sqlite3_pass_exts.patch
cd sqlite3/sqlite3 && patch -p0 < ../throw.patch
cd sqlite3/sqlite3 && ${CC} ${MYCFLAGS} -fPIC -c -o sqlite3.o sqlite3.c -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_DLL=1 -DSQLITE_ENABLE_MATH_FUNCTIONS
ifeq ($(UNAME_S),Darwin)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The pull request description mentions that libtool was added to the Homebrew install list (required for autoreconf in the curl build), but this change is missing from doc/BUILD-MACOS.md. Please include the update to the documentation to ensure that the build environment setup is complete for other users.

Comment thread deps/Makefile Outdated
cd sqlite3/sqlite3 && patch -p0 < ../throw.patch
cd sqlite3/sqlite3 && ${CC} ${MYCFLAGS} -fPIC -c -o sqlite3.o sqlite3.c -DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_DLL=1 -DSQLITE_ENABLE_MATH_FUNCTIONS
ifeq ($(UNAME_S),Darwin)
cd sqlite3/sqlite3 && ${CC} -dynamiclib -undefined dynamic_lookup -install_name @rpath/libsqlite3.so -o libsqlite3.so sqlite3.o $(LIB_SSL_PATH) $(LIB_CRYPTO_PATH)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Linking against $(LIB_SSL_PATH) and $(LIB_CRYPTO_PATH) on macOS is likely redundant when using -undefined dynamic_lookup. On Linux (line 277), libsqlite3.so is linked without these libraries, and ProxySQL (the host process) already provides the OpenSSL symbols at runtime. By using -undefined dynamic_lookup, the macOS linker will similarly allow these symbols to be resolved at runtime. Linking them statically here increases binary size and can lead to duplicate symbol issues if the host process also contains them. Consider removing these flags to maintain consistency with the Linux build.

	cd sqlite3/sqlite3 && ${CC} -dynamiclib -undefined dynamic_lookup -install_name @rpath/libsqlite3.so -o libsqlite3.so sqlite3.o

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
deps/Makefile (1)

274-278: Darwin sqlite3 link flags look correct; minor nit on .so extension.

Using -dynamiclib -undefined dynamic_lookup plus linking OpenSSL to resolve SHA1 is the right fix for Darwin. Two small notes:

  • The output is still named libsqlite3.so on macOS. Since this library is consumed via dlopen(plugin_name, RTLD_NOW) in lib/sqlite3db.cpp with an explicit path, this works, but the conventional macOS extension is .dylib. Keeping .so is fine for consistency with the Linux path/plugin_name and to avoid touching the loader logic — just flagging.
  • -install_name @rpath/libsqlite3.so`` has no practical effect here because the library is dlopen'd by path rather than linked as a dependency (so `LC_RPATH`/install_name resolution isn't exercised). Harmless, but you could drop it to keep the rule minimal.

No change required; the fix resolves the reported build failure.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@deps/Makefile` around lines 274 - 278, The Darwin linking uses -dynamiclib
-undefined dynamic_lookup and explicitly links OpenSSL which fixes the SHA1
symbol issue; leave the current rule that produces libsqlite3.so unchanged (it
works with the dlopen(plugin_name, RTLD_NOW) call in lib/sqlite3db.cpp), but
optionally you may replace the macOS extension with .dylib or remove the
-install_name `@rpath/libsqlite3.so` for minimalism—no functional change required
to the Makefile targets or flags in the sqlite3/sqlite3 rule.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@deps/Makefile`:
- Around line 274-278: The Darwin linking uses -dynamiclib -undefined
dynamic_lookup and explicitly links OpenSSL which fixes the SHA1 symbol issue;
leave the current rule that produces libsqlite3.so unchanged (it works with the
dlopen(plugin_name, RTLD_NOW) call in lib/sqlite3db.cpp), but optionally you may
replace the macOS extension with .dylib or remove the -install_name
`@rpath/libsqlite3.so` for minimalism—no functional change required to the
Makefile targets or flags in the sqlite3/sqlite3 rule.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dc4e2a27-dadf-4b0e-a2b6-57a58dcebf6f

📥 Commits

Reviewing files that changed from the base of the PR and between 085c880 and 6220ebf.

📒 Files selected for processing (7)
  • .github/workflows/CI-build-macos-macos-13-genai.yml
  • .github/workflows/CI-build-macos-macos-13-v31.yml
  • .github/workflows/CI-build-macos-macos-13.yml
  • .github/workflows/CI-build-macos-macos-14-genai.yml
  • .github/workflows/CI-build-macos-macos-14-v31.yml
  • .github/workflows/CI-build-macos-macos-14.yml
  • deps/Makefile
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: CI-builds / builds (ubuntu22,-tap)
  • GitHub Check: CI-builds / builds (ubuntu24,-tap-genai-gcov)
  • GitHub Check: CI-builds / builds (debian12,-dbg)
  • GitHub Check: run / trigger
  • GitHub Check: claude-review
🔇 Additional comments (6)
.github/workflows/CI-build-macos-macos-13-v31.yml (1)

39-39: LGTM — libtool added for glibtoolize.

Needed by autoreconf -fi during the curl build step. Change is consistent across all six macOS workflows.

.github/workflows/CI-build-macos-macos-14-genai.yml (1)

39-39: LGTM.

Same libtool addition; consistent with sibling workflows.

.github/workflows/CI-build-macos-macos-13-genai.yml (1)

39-39: LGTM.

libtool added to provide glibtoolize for curl's autoreconf.

.github/workflows/CI-build-macos-macos-14-v31.yml (1)

39-39: LGTM.

Consistent libtool addition across macOS workflows.

.github/workflows/CI-build-macos-macos-13.yml (1)

39-39: LGTM.

libtool provides glibtoolize required by autoreconf -fi during the curl build.

.github/workflows/CI-build-macos-macos-14.yml (1)

39-39: LGTM.

Matches the other five workflows; resolves the missing glibtoolize on clean macOS runners.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/proxysql_gtid.cpp`:
- Around line 161-171: The operators TrxId_Interval::operator<, operator== and
operator!= are const and call cmp(), so update cmp's signature in both its
declaration and definition to be a const member (e.g., int cmp(const
TrxId_Interval& other) const) so it can be called from const methods; also drop
the redundant const qualifier on the int return type if present. Modify the cmp
declaration in the class and the cmp definition in lib/proxysql_gtid.cpp
accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7d4a85fb-f7eb-4f1f-8301-75654cd36cbd

📥 Commits

Reviewing files that changed from the base of the PR and between 6220ebf and 520bd1b.

📒 Files selected for processing (2)
  • include/proxysql_gtid.h
  • lib/proxysql_gtid.cpp
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: CI-builds / builds (ubuntu24,-tap-genai-gcov)
  • GitHub Check: CI-builds / builds (debian12,-dbg)
  • GitHub Check: CI-builds / builds (ubuntu22,-tap)
  • GitHub Check: run / trigger
  • GitHub Check: claude-review
🧰 Additional context used
📓 Path-based instructions (3)
include/**/*.{h,hpp}

📄 CodeRabbit inference engine (CLAUDE.md)

Use #ifndef __CLASS_*_H include guards in header files

Files:

  • include/proxysql_gtid.h
**/*.{cpp,h,hpp}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{cpp,h,hpp}: Class names should use PascalCase with protocol prefixes (MySQL_, PgSQL_, ProxySQL_)
Member variables should use snake_case naming
Constants and macros should use UPPER_SNAKE_CASE naming
C++17 is required; use conditional compilation via #ifdef PROXYSQLGENAI, #ifdef PROXYSQL31, etc. for feature-gated code
Use jemalloc for memory allocation
Use pthread mutexes for synchronization and std::atomic<> for counters

Files:

  • include/proxysql_gtid.h
  • lib/proxysql_gtid.cpp
lib/**/*.cpp

📄 CodeRabbit inference engine (CLAUDE.md)

One class per file typically in lib/ directory

Files:

  • lib/proxysql_gtid.cpp
🧠 Learnings (1)
📚 Learning: 2026-04-17T16:31:58.196Z
Learnt from: CR
Repo: sysown/proxysql PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-04-17T16:31:58.196Z
Learning: Applies to **/*.{cpp,h,hpp} : C++17 is required; use conditional compilation via `#ifdef PROXYSQLGENAI`, `#ifdef PROXYSQL31`, etc. for feature-gated code

Applied to files:

  • include/proxysql_gtid.h
  • lib/proxysql_gtid.cpp
🔇 Additional comments (1)
include/proxysql_gtid.h (1)

31-33: LGTM — declarations are consistent with the .cpp.

Making the comparison operators const-qualified is the right fix so instances can be compared through const references (required by std::list::sort on the contained TrxId_Intervals). Dropping the meaningless const on the bool return type is also an improvement.

Optional: for consistency, consider applying the same treatment to contains, to_string, append, merge, and cmp in a follow-up (those are unchanged here, and cmp in particular is relevant — see the review comment on lib/proxysql_gtid.cpp).

Comment thread lib/proxysql_gtid.cpp
@sonarqubecloud

Copy link
Copy Markdown

@renecannao
renecannao merged commit 0f2b3e6 into v3.0 Apr 24, 2026
15 of 18 checks passed
@renecannao
renecannao deleted the fix/macos-build-deps branch June 10, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant