From 05738565aba282dca95e759c5aacf588929e5e18 Mon Sep 17 00:00:00 2001 From: Artem Pelenitsyn Date: Fri, 16 Oct 2026 07:46:08 -0400 Subject: [PATCH] docs: post-build hooks run after a component is built, not before linking Both the Hooks guide and the Distribution.Simple.SetupHooks module docs described per-component post-build hooks as running "before linking", or as "pre-linking hooks". That is not when they run: build_setupHooks in Distribution.Simple.Build calls the post-build hook right after buildComponent, which for GHC compiles and links. The uses the proposal lists for the hook -- injecting data into the executable, stripping it, signing it -- all need the linked binary. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01MWUpUBVSHTCWHGYNCwsjFL --- Cabal-hooks/src/Distribution/Simple/SetupHooks.hs | 6 ++++-- doc/how-to-use-setup-hooks.rst | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Cabal-hooks/src/Distribution/Simple/SetupHooks.hs b/Cabal-hooks/src/Distribution/Simple/SetupHooks.hs index da928ad82a9..683332715a0 100644 --- a/Cabal-hooks/src/Distribution/Simple/SetupHooks.hs +++ b/Cabal-hooks/src/Distribution/Simple/SetupHooks.hs @@ -432,8 +432,10 @@ Note that 'SetupHooks' can be monoidally combined, e.g.: * Per-component post-build hooks. - These can be thought of as "pre-linking hooks" and allow injecting - additional data into the final executable. + These run after a component has been built, i.e. after compilation + and linking, and allow post-processing of the resulting build + artifacts: injecting additional data into the final executable, + stripping or signing it, or running a freshly built executable. * The install phase, via 'InstallHooks'. diff --git a/doc/how-to-use-setup-hooks.rst b/doc/how-to-use-setup-hooks.rst index 6036509761a..d05a762baab 100644 --- a/doc/how-to-use-setup-hooks.rst +++ b/doc/how-to-use-setup-hooks.rst @@ -84,7 +84,10 @@ build system. The following hooks exist: * Pre-build rules. Used to define code generators or custom preprocessors, i.e. rules to generate source files. - * Post-build hook. Used before linking to inject data into build artifacts. + * Post-build hook. Runs once a component has been built, i.e. after + compilation and linking. Used to post-process the build artifacts, e.g. + to inject data into a freshly built executable, strip it, sign it, or + run it. * Hooks into the install phase (per component). These are used to copy over extra files when installing an executable.