Skip to content

sqlparser_derive embeds its build-time manifest directory in the proc-macro binary #2724

Open

Description

@ashi009

sqlparser_derive 0.6.0 embeds its build-time CARGO_MANIFEST_DIR in the proc-macro binary through DERIVE_CRATE_DIR in read_dialect_mod_file. Changing only that environment value changes the final binary, even without incremental compilation or debug info. Under Bazel this is a temporary sandbox path, so identical recorded action inputs produce different outputs and the cached macro retains the producer's source location.

This is also a source-tree dependency during macro expansion, independent of Bazel: derive_dialect! reads sqlparser/src/dialect/mod.rs to discover the Dialect method signatures. Compiled dependencies alone are insufficient; expansion fails if none of the searched source trees is present.

The repro compiles the same published source twice with the same dependencies and rustc arguments, changing only /tmp/sqlparser-a to /tmp/sqlparser-b:

$ git clone https://gist.github.com/595a35ecfc805046695680b837d79cc5.git sqlparser-manifest-repro && cd sqlparser-manifest-repro
$ sh repro.sh
rustc 1.98.0 (88d9e12ae 2026-08-18)
binary: rustc
commit-hash: 88d9e12ae178fab0fb5cc050a94da85685d449ea
commit-date: 2026-08-18
host: aarch64-unknown-linux-gnu
release: 1.98.0
LLVM version: 22.1.8
   Compiling proc-macro2 v1.0.93
   Compiling unicode-ident v1.0.27
   Compiling quote v1.0.37
   Compiling syn v3.0.3
   Compiling sqlparser-repro-deps v0.0.0 (/var/tmp/sqlparser-manifest-repro/deps)
    Finished `release` profile [optimized] target(s) in 3.58s
f8ab25524043be6591fc56954d3e860b4b431283a058c404c05e62a8d3494afc  sqlparser-a.so
6281c9bf299132340f68453662a1c966191076951c1484b70323386ecc0a8378  sqlparser-b.so
/tmp/sqlparser-a
/tmp/sqlparser-b

The proposed fix in #2725 stores those signatures as macro tokens in the compiled sqlparser library, which passes them to the proc macro during expansion. The proc-macro binary and compiled sqlparser dependency are sufficient; neither crate's source tree needs to remain available. Verified by building both crates, deleting their source trees, then compiling and running a consumer: this fails on unpatched upstream and passes with the fix.

Prepared and posted with Codex.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions