mirror of
https://github.com/rizsotto/Bear.git
synced 2026-05-28 00:20:45 +02:00
fc7eb4ad91
`cc` and `c++` are GCC on most Linuxes but Clang on FreeBSD, OpenBSD, NetBSD, DragonFly, and macOS. The regex defaulted them to GCC, which corrupted the compilation database on those hosts via wrong flag-arity tables (e.g. Clang's `-Xclang <arg>` consumes the next argv slot, GCC's does not). Recognition now runs `--version` lazily for these ambiguous basenames, classifies by signature, and dispatches accordingly. The probe is the sole classifier: gcc.yaml deliberately omits `cc`/`c++`, so a failed probe returns NotRecognized rather than guessing -- a missing entry is visible and debuggable, whereas a wrongly-classified entry corrupts the database silently via mismatched flag-arity tables (the bug this work exists to fix). Layered design: - CompilerRecognizer dispatches. - CompilerProbe classifies. VersionProbe on Unix (hardened: closed stdin, process-group SIGKILL on timeout, LD_PRELOAD / DYLD_INSERT_LIBRARIES stripped); NoProbe on Windows where basenames are unambiguous and the Unix subprocess primitives the probe relies on aren't available. - CachingProbe memoizes the probe's verdict per canonical path so each unique compiler is fork-exec'd at most once per process. A user `compilers:` entry preempts the probe -- the sole supported override. Also simplifies the WrapperInterpreter that the probe work exposed: replaces the cyclic Arc::new_cyclic + OnceLock<Box<dyn Interpreter>> + Weak<dyn Interpreter> machinery with a flat wrapper::unwrap() helper called inline from CompilerInterpreter::recognize. See requirements/recognition-ambiguous-name-probe.md for the spec. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>