Not sure this is 100% relevant to the discussion, but -Q also implies --no-site-file which inhibits site-start.el. This will interfere with Emacs builds such as https://github.com/jimeh/emacs-builds for macOS. They rely on site-start to establish bundled native compiler runtime dependencies. Running a flymake batch without those dependencies may have unintended flymake performance implications.

On Thu, Nov 14, 2024 at 6:19 AM Pengji Zhang <me@pengjiz.com> wrote:
Spencer Baugh <sbaugh@janestreet.com> writes:

> I think this should also switch from passing "-Q" to passing just
> "-q". If we're include ~/.emacs.d/elpa on load-path, we should include
> the site-lisp directories too, which -Q suppresses.

I agree. How about the following change?

--8<---------------cut here---------------start------------->8---
         :name "elisp-flymake-byte-compile"
         :buffer output-buffer
         :command `(,(expand-file-name invocation-name invocation-directory)
-                   "-Q"
+                   ,@(if elisp-flymake--byte-compile-activate-packages
+                         ;; Add site-lisp directories to `load-path' so
+                         ;; that system-wide packages (installed into
+                         ;; site-lisp/elpa) are activated.
+                         '("-q" "--no-site-file")
+                       '("-Q"))
                    "--batch"
                    ;; "--eval" "(setq load-prefer-newer t)" ; for testing
                    ,@(mapcan (lambda (path) (list "-L" path))
--8<---------------cut here---------------end--------------->8---

> Probably we should specifically pass "--batch --no-site-file" instead
> of "-Q --batch", since --batch also implies -q.

I am not sure if it is a good idea to always include the site-lisp
directories. I myself want this only when checking my init.el. When
developing packages, I prefer a pristine environment.