Skip to content

Commit ccaba0e

Browse files
committed
stage2: select static/dynamic build via project files instead of configure
Replace the configure-driven static/dynamic selection for stage2 with explicit cabal project files. Previously a `--enable-dynamic` autoconf toggle, together with the `m4/accumulate.m4` helper macros, generated cabal.project.stage2.settings from a .in template, while the Makefile separately appended --enable-dynamic to GHC_CONFIGURE_ARGS when DYNAMIC=1. Keeping these two mechanisms in sync was fragile. Now the stage2 configuration is split into a shared cabal.project.stage2.common plus two thin variants that import it: - cabal.project.stage2.static (default; shared: False) - cabal.project.stage2.dynamic (shared: True, executable-dynamic: True, rts +dynamic) The Makefile selects the project file directly through DYNAMIC_SUFFIX and the new CABAL_PROJECT_FILE variable, so DYNAMIC=1 picks the dynamic file without any configure round-trip. Removed as no longer needed: - the --enable-dynamic configure option and its substitution logic - cabal.project.stage2.settings(.in) template - m4/accumulate.m4
1 parent 62790dc commit ccaba0e

7 files changed

Lines changed: 44 additions & 86 deletions

Makefile

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,16 @@ VERBOSE ?= 0
8585

8686
UNAME := $(shell uname)
8787

88-
# If using autoconf feature toggles you can instead run:
89-
# ./configure --enable-dynamic --enable-profiling --enable-debug
90-
# which generates cabal.project.stage2.settings (imported by cabal.project.stage2).
91-
# The legacy DYNAMIC=1 path still appends flags directly; if both are used the
92-
# configure-generated settings file (import) and these args should agree.
93-
#
9488
# Enable dynamic runtime/linking support when DYNAMIC=1 is passed on the make
95-
# command line. This will build shared libraries, a dynamic RTS (defining
96-
# -DDYNAMIC) and allow tests requiring dynamic linking (e.g. plugins-external)
97-
# to run. The default remains static to keep rebuild cost low.
89+
# command line. This selects the cabal.project.stage2.dynamic project file
90+
# (shared libraries, dynamic executables, dynamic RTS) instead of
91+
# cabal.project.stage2.static, and enables the dynamic-only dist steps below.
92+
# The default remains static to keep rebuild cost low.
9893
DYNAMIC ?= 0
9994

95+
# Suffix selecting the static/dynamic stage2 project file (see CABAL_PROJECT_FILE).
96+
DYNAMIC_SUFFIX := $(if $(filter 1,$(DYNAMIC)),dynamic,static)
97+
10098
# Quiet mode: suppress output unless error (QUIET=1)
10199
QUIET ?= 0
102100

@@ -151,10 +149,6 @@ CABAL_ARGS ?=
151149
CC_LINK_OPT =
152150
GHC_CONFIGURE_ARGS =
153151

154-
ifeq ($(DYNAMIC),1)
155-
GHC_CONFIGURE_ARGS += --enable-dynamic
156-
endif
157-
158152
GHC_TOOLCHAIN_ARGS = --disable-ld-override
159153

160154
#
@@ -308,13 +302,18 @@ endef
308302
#
309303
# NOTE: Do not pass --with-ar or --with-ld to cabal! it will screw up things
310304
#
305+
# Cabal project file for the current stage. stage2 has separate static/dynamic
306+
# variants selected by DYNAMIC (see DYNAMIC_SUFFIX); all other stages use a
307+
# single project file.
308+
CABAL_PROJECT_FILE = cabal.project.$(STAGE)$(if $(filter stage2,$(STAGE)),.$(DYNAMIC_SUFFIX))
309+
311310
define CABAL_BUILD_WITH
312311
$(1) \
313312
--remote-repo-cache $(call NORMALIZE_FP,$(CURDIR)/$(BUILD_DIR)/packages) \
314313
--store-dir $(call NORMALIZE_FP,$(CURDIR)/$(STORE_DIR)) \
315314
--logs-dir $(call NORMALIZE_FP,$(CURDIR)/$(LOGS_DIR)) \
316315
build \
317-
--project-file cabal.project.$(STAGE) \
316+
--project-file $(CABAL_PROJECT_FILE) \
318317
--builddir $(call NORMALIZE_FP,$(CURDIR)/$(STAGE_DIR)) \
319318
$(CABAL_ARGS)
320319
endef
@@ -330,7 +329,7 @@ define CABAL_INSTALL_STAGE0
330329
install \
331330
--installdir $(dir $(CABAL)) \
332331
--builddir $(call NORMALIZE_FP,$(CURDIR)/$(STAGE_DIR)) \
333-
--project-file cabal.project.$(STAGE) \
332+
--project-file $(CABAL_PROJECT_FILE) \
334333
--overwrite-policy=always --install-method=copy \
335334
$(CABAL_ARGS)
336335
endef
@@ -508,8 +507,7 @@ CONFIGURED_FILES := \
508507
libraries/ghc-internal/ghc-internal.cabal \
509508
libraries/ghc-experimental/ghc-experimental.cabal \
510509
libraries/base/base.cabal \
511-
rts/include/ghcversion.h \
512-
cabal.project.stage2.settings
510+
rts/include/ghcversion.h
513511

514512
# __ __ _ _ _
515513
# | \/ | __ _(_)_ __ | |_ __ _ _ __ __ _ ___| |_
@@ -718,7 +716,7 @@ STAGE2_CABAL_BUILD = \
718716

719717
stage2: STAGE=stage2
720718
stage2: TARGET_PLATFORM:=$(HOST_PLATFORM)
721-
stage2: $(GHC1) stable-cabal $(CONFIGURE_SCRIPTS) $(CONFIGURED_FILES) cabal.project.stage2 cabal.project.stage2.settings cabal.project.common libraries/ghc-boot-th-next | stage1
719+
stage2: $(GHC1) stable-cabal $(CONFIGURE_SCRIPTS) $(CONFIGURED_FILES) cabal.project.stage2.common cabal.project.stage2.static cabal.project.stage2.dynamic cabal.project.common libraries/ghc-boot-th-next | stage1
722720
$(call PHASE_START,stage2)
723721
$(call LOG,Starting build of $(STAGE))
724722

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
-- Configuration common to all stages
22
import: cabal.project.common
3-
import: cabal.project.stage2.settings
43

54
-- Disable Hackage, we explicitly include the packages we need.
65
active-repositories: :none
@@ -68,8 +67,8 @@ packages:
6867
https://hackage.haskell.org/package/process-1.6.29.0/process-1.6.29.0.tar.gz
6968
https://hackage.haskell.org/package/semaphore-compat-1.0.0/semaphore-compat-1.0.0.tar.gz
7069
https://hackage.haskell.org/package/stm-2.5.3.1/stm-2.5.3.1.tar.gz
71-
https://hackage.haskell.org/package/template-haskell-lift-0.1.0.0/template-haskell-lift-0.1.0.0.tar.gz
72-
https://hackage.haskell.org/package/template-haskell-quasiquoter-0.1.0.0/template-haskell-quasiquoter-0.1.0.0.tar.gz
70+
-- https://hackage.haskell.org/package/template-haskell-lift-0.1.0.0/template-haskell-lift-0.1.0.0.tar.gz
71+
-- https://hackage.haskell.org/package/template-haskell-quasiquoter-0.1.0.0/template-haskell-quasiquoter-0.1.0.0.tar.gz
7372
https://hackage.haskell.org/package/text-2.1.3/text-2.1.3.tar.gz
7473
https://hackage.haskell.org/package/time-1.15/time-1.15.tar.gz
7574
https://hackage.haskell.org/package/transformers-0.6.1.2/transformers-0.6.1.2.tar.gz
@@ -82,7 +81,6 @@ packages:
8281
https://hackage.haskell.org/package/happy-2.1.5/happy-2.1.5.tar.gz
8382
https://hackage.haskell.org/package/happy-lib-2.1.5/happy-lib-2.1.5.tar.gz
8483

85-
-- wip/angerman/compile-less (cross-compilation + local store + recompilation avoidance)
8684
source-repository-package
8785
type: git
8886
location: https://github.com/stable-haskell/Cabal.git
@@ -124,8 +122,6 @@ allow-newer: hsc2hs:*
124122
, text:*
125123
, time:*
126124
, transformers:*
127-
, template-haskell-lift:*
128-
, template-haskell-quasiquoter:*
129125
, unix:*
130126
, xhtml:*
131127

cabal.project.stage2.dynamic

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-- Dynamic stage2 build (DYNAMIC=1).
2+
--
3+
-- All shared stage2 configuration lives in cabal.project.stage2.common; this
4+
-- file only selects shared libraries, dynamic executables and the dynamic RTS.
5+
-- The Makefile uses this project file when DYNAMIC=1.
6+
import: cabal.project.stage2.common
7+
8+
package *
9+
shared: True
10+
executable-dynamic: True
11+
12+
constraints:
13+
rts +dynamic

cabal.project.stage2.settings.in

Lines changed: 0 additions & 9 deletions
This file was deleted.

cabal.project.stage2.static

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- Static stage2 build (default).
2+
--
3+
-- All shared stage2 configuration lives in cabal.project.stage2.common; this
4+
-- file only selects static libraries. The Makefile uses this project file when
5+
-- DYNAMIC is not set to 1.
6+
import: cabal.project.stage2.common
7+
8+
package *
9+
shared: False
10+
executable-dynamic: False

configure.ac

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,9 @@ AC_SUBST([ProjectPatchLevel2])
2727
AC_SUBST([Suffix],[""])
2828
AC_SUBST([SourceRoot],["."])
2929

30-
# --- Feature toggle (dynamic only) for imported project settings ---
31-
AC_ARG_ENABLE([dynamic],
32-
[AS_HELP_STRING([--enable-dynamic],[Build shared libraries and enable dynamic RTS])],
33-
[enable_dynamic=$enableval],[enable_dynamic=no])
34-
35-
# Initialize accumulation variables
36-
ALL_PACKAGES=""
37-
CONSTRAINTS=""
38-
39-
# Provide defaults first (static)
40-
APPEND_PKG_FIELD([shared: False])
41-
APPEND_PKG_FIELD([executable-dynamic: False])
42-
43-
AS_IF([test "x$enable_dynamic" = "xyes"], [
44-
# Override (we rebuild list to avoid mixing static+dynamic lines)
45-
ALL_PACKAGES=""
46-
APPEND_PKG_FIELD([shared: True])
47-
APPEND_PKG_FIELD([executable-dynamic: True])
48-
APPEND_CONSTRAINT([rts +dynamic])
49-
])
50-
51-
# Indent with two spaces for substitution blocks (uniform handling)
52-
ALL_PACKAGES=`printf '%b' "$ALL_PACKAGES"`
53-
CONSTRAINTS=`printf '%b' "$CONSTRAINTS"`
54-
ALL_PACKAGES_INDENTED=`printf '%s' "$ALL_PACKAGES" | sed 's/^/ /'`
55-
CONSTRAINTS_INDENTED=`printf '%s' "$CONSTRAINTS" | sed 's/^/ /'`
56-
ALL_PACKAGES="$ALL_PACKAGES_INDENTED"
57-
AS_IF([test "x$CONSTRAINTS" = "x"], [CONSTRAINTS=" -- (none)"], [CONSTRAINTS="$CONSTRAINTS_INDENTED"])
58-
59-
AC_SUBST([ALL_PACKAGES])
60-
AC_SUBST([CONSTRAINTS])
30+
# Static vs dynamic stage2 builds are selected by the Makefile choosing between
31+
# cabal.project.stage2.static and cabal.project.stage2.dynamic (DYNAMIC=1), not
32+
# by configure. See cabal.project.stage2.common and its variants.
6133

6234
# --- Define Programs ---
6335
# We don't need to check for CC, MAKE_SET, and others for now, we only want substitution.
@@ -93,7 +65,6 @@ AC_CONFIG_FILES([
9365
libraries/ghc-experimental/ghc-experimental.cabal
9466
libraries/base/base.cabal
9567
rts/include/ghcversion.h
96-
cabal.project.stage2.settings
9768
])
9869

9970
AC_OUTPUT

m4/accumulate.m4

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)