Skip to main content

configure

Function configure 

Source
pub fn configure()
Expand description

Configure the link line for a mysql-handler engine cdylib.

Call this from build.rs. The helper performs three steps:

  1. Shim staticlib. When the mysql-handler crate’s build script produced libha_rusty_shim.a, it exports the output directory via DEP_HA_RUSTY_SHIM_STATICLIB_DIR (Cargo’s links metadata bridge). The helper emits rustc-link-search and rustc-link-lib=static=ha_rusty_shim so the cdylib picks the staticlib up.
  2. C++ runtime. On Apple targets the helper links c++; on Linux, stdc++. Other targets are skipped — engines targeting them must wire their own runtime.
  3. macOS dynamic lookup. On Apple targets, the helper adds -Wl,-undefined,dynamic_lookup so the C++ symbols defined inside mysqld (the loading host) are resolved at plugin-load time rather than at link time.

When DEP_HA_RUSTY_SHIM_STATICLIB_DIR is unset — that is, the user has not opted into MYSQL_HANDLER_FROM_SOURCE=1 or MYSQL_HANDLER_ARCHIVE=<path> for the mysql-handler dependency — the helper emits a cargo:warning= describing the env vars to set. The build is not failed; cargo check and IDE workflows still work, but the produced cdylib will not load into mysqld.

§Panics

Panics if Cargo did not export TARGET. Cargo always exports it before invoking a build script, so this branch is unreachable in practice.