Skip to content

Commit a193fe3

Browse files
committed
hsc2hs: batch cross-compilation for massive speedup (#154)
* hsc2hs: batch cross-compilation for massive speedup Replace hackage hsc2hs-0.68.10 with stable-haskell/hsc2hs fork that includes batch cross-compilation support. This reduces C compiler invocations from hundreds/thousands per .hsc file to just 1-2 total by batching all constant-like directives (#const, #size, #alignment, step with graceful fallback to per-directive compilation. Key changes in the fork (bf966e8): - Batch collection of all batchable directives with conditional stack tracking - Single C file generation with all constants as global variables - Assembly parsing via ATTParser to extract all values at once - Graceful try/catch around ATT.parse for compilers producing non-AT&T assembly (e.g. emcc for WebAssembly), falling through to per-directive path - --no-batch flag for debugging/fallback Performance impact per .hsc file: - Before (non-via-asm): ~28 compilations per directive (e.g. 4089 for Flags.hsc) - Before (via-asm): 1 compilation per directive (e.g. 147 for Flags.hsc) - After (batch): 2 compilations total per file (validity check + batch) Fork: https://github.com/stable-haskell/hsc2hs/tree/feat/batch-cross-compilation * fix: update hsc2hs fork with Windows CodeView debug section fix Update hsc2hs fork reference to include fix for ATT parser crash on Windows where Clang emits CodeView .debug$S sections even with -g0. The parser now filters out debug sections and handles unrecognized instruction patterns gracefully.
1 parent 9b71cef commit a193fe3

1 file changed

Lines changed: 76 additions & 62 deletions

File tree

cabal.project.stage2

Lines changed: 76 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
-- Configuration common to all stages
2-
import: cabal.project.common
3-
import: cabal.project.stage2.settings
1+
allow-boot-library-installs: True
2+
benchmarks: False
3+
tests: False
44

55
-- Disable Hackage, we explicitly include the packages we need.
66
active-repositories: :none
77

8+
-- Import configure/generated feature toggles (dynamic, etc.) if present.
9+
-- A default file is kept in-tree; configure will overwrite with substituted values.
10+
import: cabal.project.stage2.settings
11+
812
packages:
913
-- RTS
1014
rts-headers
@@ -38,15 +42,44 @@ packages:
3842
utils/ghc-iserv
3943
utils/ghc-pkg
4044
utils/ghc-toolchain
41-
utils/haddock
42-
utils/haddock/haddock-api
43-
utils/haddock/haddock-library
4445
utils/hp2ps
4546
utils/runghc
4647
utils/unlit
48+
utils/haddock
49+
utils/haddock/haddock-api
50+
utils/haddock/haddock-library
4751

4852
-- The following are packages available on Hackage but included as submodules
49-
-- https://hackage.haskell.org/package/hsc2hs-0.68.10/hsc2hs-0.68.10.tar.gz
53+
libraries/array
54+
libraries/binary
55+
libraries/bytestring
56+
libraries/Cabal/Cabal
57+
libraries/Cabal/Cabal-syntax
58+
libraries/containers/containers
59+
libraries/deepseq
60+
libraries/directory
61+
libraries/exceptions
62+
libraries/file-io
63+
libraries/filepath
64+
libraries/haskeline
65+
libraries/hpc
66+
libraries/libffi-clib
67+
libraries/mtl
68+
libraries/os-string
69+
libraries/parsec
70+
libraries/pretty
71+
libraries/process
72+
libraries/semaphore-compat
73+
libraries/stm
74+
libraries/terminfo
75+
libraries/text
76+
libraries/time
77+
libraries/transformers
78+
libraries/unix
79+
libraries/Win32
80+
libraries/xhtml
81+
utils/hpc
82+
-- hsc2hs: see source-repository-package below
5083

5184
https://hackage.haskell.org/package/Win32-2.14.2.1/Win32-2.14.2.1.tar.gz
5285
https://hackage.haskell.org/package/array-0.5.8.0/array-0.5.8.0.tar.gz
@@ -84,55 +117,6 @@ packages:
84117
https://hackage.haskell.org/package/happy-2.1.5/happy-2.1.5.tar.gz
85118
https://hackage.haskell.org/package/happy-lib-2.1.5/happy-lib-2.1.5.tar.gz
86119

87-
-- wip/andrea/local-store
88-
source-repository-package
89-
type: git
90-
location: https://github.com/stable-haskell/Cabal.git
91-
tag: d7bf2ce3f9a7da4640833ddc5bb7740d2557b6a7
92-
subdir: Cabal
93-
Cabal-syntax
94-
95-
source-repository-package
96-
type: git
97-
location: https://github.com/stable-haskell/hpc-bin.git
98-
tag: 5923da3fe77993b7afc15b5163cffcaa7da6ecf5
99-
100-
if !os(windows)
101-
packages:
102-
https://hackage.haskell.org/package/terminfo-0.4.1.7/terminfo-0.4.1.7.tar.gz
103-
104-
allow-newer: hsc2hs:*
105-
, Win32:*
106-
, array:*
107-
, binary:*
108-
, bytestring:*
109-
, containers:*
110-
, deepseq:*
111-
, directory:*
112-
, exceptions:*
113-
, file-io:*
114-
, filepath:*
115-
, haskeline:*
116-
, hpc:*
117-
, libffi-clib:*
118-
, mtl:*
119-
, os-string:*
120-
, parsec:*
121-
, pretty:*
122-
, process:*
123-
, semaphore-compat:*
124-
, stm:*
125-
, terminfo:*
126-
, text:*
127-
, time:*
128-
, transformers:*
129-
, unix:*
130-
, xhtml:*
131-
132-
if !os(windows)
133-
package *
134-
library-for-ghci: True
135-
136120
--
137121
-- Constraints
138122
--
@@ -148,8 +132,28 @@ constraints:
148132
-- Package level configuration
149133
--
150134

135+
package haddock-api
136+
flags: +in-ghc-tree
137+
138+
if !os(windows)
139+
packages:
140+
libraries/terminfo
141+
142+
package *
143+
library-vanilla: True
144+
-- shared/executable-dynamic now controlled by Makefile (DYNAMIC variable)
145+
-- so we do not pin them here; default (static) remains when DYNAMIC=0.
146+
executable-profiling: False
147+
executable-static: False
148+
149+
if !os(windows)
150+
package *
151+
library-for-ghci: True
152+
153+
import: cabal.project.rts
154+
151155
package libffi-clib
152-
ghc-options: -no-rts -optc-Wno-error
156+
ghc-options: -no-rts
153157

154158
-- We end up injecting the following depednency:
155159
--
@@ -196,12 +200,15 @@ package ghc-internal
196200
flags: +bignum-native
197201
ghc-options: -no-rts
198202

199-
package rts
200-
ghc-options: -no-rts
201-
flags: +tables-next-to-code
203+
package text
204+
flags: -simdutf
202205

203-
package rts-headers
204-
ghc-options: -no-rts
206+
-- TODO: What is this? Why do we need _in-ghc-tree_ here?
207+
package hsc2hs
208+
flags: +in-ghc-tree
209+
210+
package haskeline
211+
flags: -terminfo
205212

206213
package rts-fs
207214
ghc-options: -no-rts
@@ -212,3 +219,10 @@ source-repository-package
212219
type: git
213220
location: https://github.com/stable-haskell/hsc2hs.git
214221
tag: d07eea1260894ce5fe456f881fbc62366c9eb1b7
222+
223+
--
224+
-- Program options
225+
--
226+
227+
program-options
228+
ghc-options: -fhide-source-paths -j

0 commit comments

Comments
 (0)