Skip to content

Commit d9dc867

Browse files
committed
[win] fix Error: CFI instruction used without previous .cfi_startproc
1 parent c9b9ab5 commit d9dc867

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed

BUGLOG

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
This file contains bugs we find while working on haskell.nix. The format is as
2+
follow:
3+
<separator: 80 * '-'>
4+
YYYY-MM-DD: nix-job name
5+
6+
<error>
7+
8+
<discussion>
9+
10+
--------------------------------------------------------------------------------
11+
2024-04-09 x86_64-linux.R2305.ghc8107.mingwW64.ghc
12+
13+
/build/ghc62733_0/ghc_1.s:50:0: error:
14+
Error: CFI instruction used without previous .cfi_startproc
15+
|
16+
50 | .cfi_escape 0x16, 0x07, 0x04, 0x77, 152, 65
17+
| ^
18+
`x86_64-w64-mingw32-cc' failed in phase `Assembler'. (Exit code: 1)
19+
make[1]: *** [rts/ghc.mk:325: rts/dist/build/StgCRun.o] Error 1
20+
21+
The source for this is
22+
> https://github.com/ghc/ghc/blob/1f02b7430b2fbab403d7ffdde9cfd006e884678e/rts/StgCRun.c#L433
23+
24+
It appears that GCC C17 12.2.0 does _not_ emit .cfi_startproc / .cfi_endprocs
25+
whereas GCC C17 13.2.0 _does_. Specificall x86_64-w64-mingw32-cc. So this might
26+
be a cross compilation issue.
27+
28+
The -g is hardcoded in
29+
https://github.com/ghc/ghc/blob/1f02b7430b2fbab403d7ffdde9cfd006e884678e/mk/config.mk.in#L361
30+
31+
Turns out, this was disabled for anything but linux in https://github.com/ghc/ghc/commit/5b08e0c06e038448a63aa9bd7f163b23d824ba4b,
32+
hence we backport that patch to GHC-8.10 when targeting windows (to prevent mass rebuilds for
33+
other archs).
34+
35+
--------------------------------------------------------------------------------

overlays/bootstrap.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ in {
253253
++ final.lib.optional (versionAtLeast "8.10" && versionLessThan "9.4" && final.stdenv.targetPlatform != final.stdenv.hostPlatform) ./patches/ghc/ghc-make-stage-1-lib-ghc.patch
254254
++ final.lib.optional (versionAtLeast "8.10" && versionLessThan "9.0" && final.stdenv.targetPlatform.isAarch64) ./patches/ghc/ghc-8.10-better-symbol-addr-debug.patch
255255
++ final.lib.optional (versionAtLeast "8.10" && versionLessThan "9.0" && final.stdenv.targetPlatform.isAarch64) ./patches/ghc/ghc-8.10-aarch64-handle-none-rela.patch
256+
++ final.lib.optional (versionAtLeast "8.10" && versionLessThan "9.0" && final.stdenv.targetPlatform.isWindows) ./patches/ghc/5b08e0c06e038448a63aa9bd7f163b23d824ba4b.patch
256257
++ final.lib.optional (versionAtLeast "9.0" && final.stdenv.targetPlatform.isAarch64) ./patches/ghc/ghc-9.0-better-symbol-addr-debug.patch
257258
++ final.lib.optional (versionAtLeast "9.0" && final.stdenv.targetPlatform.isAarch64) ./patches/ghc/ghc-9.0-aarch64-handle-none-rela.patch
258259
++ final.lib.optional (versionAtLeast "9.6.3" && versionLessThan "9.6.4" && final.stdenv.targetPlatform.isWindows) ./patches/ghc/ghc-9.6-hadrian-splitsections.patch
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
From 5b08e0c06e038448a63aa9bd7f163b23d824ba4b Mon Sep 17 00:00:00 2001
2+
From: Ben Gamari <[email protected]>
3+
Date: Mon, 3 Feb 2020 09:27:42 -0500
4+
Subject: [PATCH] StgCRun: Enable unwinding only on Linux
5+
6+
It's broken on macOS due and SmartOS due to assembler differences
7+
(#15207) so let's be conservative in enabling it. Also, refactor things
8+
to make the intent clearer.
9+
---
10+
rts/StgCRun.c | 15 +++++++++++----
11+
1 file changed, 11 insertions(+), 4 deletions(-)
12+
13+
diff --git a/rts/StgCRun.c b/rts/StgCRun.c
14+
index 2600f1e569ca..55a3bf0c2d97 100644
15+
--- a/rts/StgCRun.c
16+
+++ b/rts/StgCRun.c
17+
@@ -29,6 +29,13 @@
18+
#include "PosixSource.h"
19+
#include "ghcconfig.h"
20+
21+
+// Enable DWARF Call-Frame Information (used for stack unwinding) on Linux.
22+
+// This is not supported on Darwin and SmartOS due to assembler differences
23+
+// (#15207).
24+
+#if defined(linux_HOST_OS)
25+
+#define ENABLE_UNWINDING
26+
+#endif
27+
+
28+
#if defined(sparc_HOST_ARCH) || defined(USE_MINIINTERPRETER)
29+
/* include Stg.h first because we want real machine regs in here: we
30+
* have to get the value of R1 back from Stg land to C land intact.
31+
@@ -405,7 +412,7 @@ StgRunIsImplementedInAssembler(void)
32+
"movq %%xmm15,136(%%rax)\n\t"
33+
#endif
34+
35+
-#if !defined(darwin_HOST_OS)
36+
+#if defined(ENABLE_UNWINDING)
37+
/*
38+
* Let the unwinder know where we saved the registers
39+
* See Note [Unwinding foreign exports on x86-64].
40+
@@ -444,7 +451,7 @@ StgRunIsImplementedInAssembler(void)
41+
#error "RSP_DELTA too big"
42+
#endif
43+
"\n\t"
44+
-#endif /* !defined(darwin_HOST_OS) */
45+
+#endif /* defined(ENABLE_UNWINDING) */
46+
47+
/*
48+
* Set BaseReg
49+
@@ -519,7 +526,7 @@ StgRunIsImplementedInAssembler(void)
50+
"i"(RESERVED_C_STACK_BYTES + STG_RUN_STACK_FRAME_SIZE
51+
/* rip relative to cfa */)
52+
53+
-#if !defined(darwin_HOST_OS)
54+
+#if defined(ENABLE_UNWINDING)
55+
, "i"((RSP_DELTA & 127) | (128 * ((RSP_DELTA >> 7) > 0)))
56+
/* signed LEB128-encoded delta from rsp - byte 1 */
57+
#if (RSP_DELTA >> 7) > 0
58+
@@ -538,7 +545,7 @@ StgRunIsImplementedInAssembler(void)
59+
#endif
60+
#undef RSP_DELTA
61+
62+
-#endif /* !defined(darwin_HOST_OS) */
63+
+#endif /* defined(ENABLE_UNWINDING) */
64+
65+
);
66+
/*

0 commit comments

Comments
 (0)