-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[win] fix Error: CFI instruction used without previous .cfi_startproc
- Loading branch information
Showing
3 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
This file contains bugs we find while working on haskell.nix. The format is as | ||
follow: | ||
<separator: 80 * '-'> | ||
YYYY-MM-DD: nix-job name | ||
|
||
<error> | ||
|
||
<discussion> | ||
|
||
-------------------------------------------------------------------------------- | ||
2024-04-09 x86_64-linux.R2305.ghc8107.mingwW64.ghc | ||
|
||
/build/ghc62733_0/ghc_1.s:50:0: error: | ||
Error: CFI instruction used without previous .cfi_startproc | ||
| | ||
50 | .cfi_escape 0x16, 0x07, 0x04, 0x77, 152, 65 | ||
| ^ | ||
`x86_64-w64-mingw32-cc' failed in phase `Assembler'. (Exit code: 1) | ||
make[1]: *** [rts/ghc.mk:325: rts/dist/build/StgCRun.o] Error 1 | ||
|
||
The source for this is | ||
> https://github.com/ghc/ghc/blob/1f02b7430b2fbab403d7ffdde9cfd006e884678e/rts/StgCRun.c#L433 | ||
|
||
It appears that GCC C17 12.2.0 does _not_ emit .cfi_startproc / .cfi_endprocs | ||
whereas GCC C17 13.2.0 _does_. Specificall x86_64-w64-mingw32-cc. So this might | ||
be a cross compilation issue. | ||
|
||
The -g is hardcoded in | ||
https://github.com/ghc/ghc/blob/1f02b7430b2fbab403d7ffdde9cfd006e884678e/mk/config.mk.in#L361 | ||
|
||
Turns out, this was disabled for anything but linux in https://github.com/ghc/ghc/commit/5b08e0c06e038448a63aa9bd7f163b23d824ba4b, | ||
hence we backport that patch to GHC-8.10 when targeting windows (to prevent mass rebuilds for | ||
other archs). | ||
|
||
-------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
overlays/patches/ghc/5b08e0c06e038448a63aa9bd7f163b23d824ba4b.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
From 5b08e0c06e038448a63aa9bd7f163b23d824ba4b Mon Sep 17 00:00:00 2001 | ||
From: Ben Gamari <[email protected]> | ||
Date: Mon, 3 Feb 2020 09:27:42 -0500 | ||
Subject: [PATCH] StgCRun: Enable unwinding only on Linux | ||
|
||
It's broken on macOS due and SmartOS due to assembler differences | ||
(#15207) so let's be conservative in enabling it. Also, refactor things | ||
to make the intent clearer. | ||
--- | ||
rts/StgCRun.c | 15 +++++++++++---- | ||
1 file changed, 11 insertions(+), 4 deletions(-) | ||
|
||
diff --git a/rts/StgCRun.c b/rts/StgCRun.c | ||
index 2600f1e569ca..55a3bf0c2d97 100644 | ||
--- a/rts/StgCRun.c | ||
+++ b/rts/StgCRun.c | ||
@@ -29,6 +29,13 @@ | ||
#include "PosixSource.h" | ||
#include "ghcconfig.h" | ||
|
||
+// Enable DWARF Call-Frame Information (used for stack unwinding) on Linux. | ||
+// This is not supported on Darwin and SmartOS due to assembler differences | ||
+// (#15207). | ||
+#if defined(linux_HOST_OS) | ||
+#define ENABLE_UNWINDING | ||
+#endif | ||
+ | ||
#if defined(sparc_HOST_ARCH) || defined(USE_MINIINTERPRETER) | ||
/* include Stg.h first because we want real machine regs in here: we | ||
* have to get the value of R1 back from Stg land to C land intact. | ||
@@ -405,7 +412,7 @@ StgRunIsImplementedInAssembler(void) | ||
"movq %%xmm15,136(%%rax)\n\t" | ||
#endif | ||
|
||
-#if !defined(darwin_HOST_OS) | ||
+#if defined(ENABLE_UNWINDING) | ||
/* | ||
* Let the unwinder know where we saved the registers | ||
* See Note [Unwinding foreign exports on x86-64]. | ||
@@ -444,7 +451,7 @@ StgRunIsImplementedInAssembler(void) | ||
#error "RSP_DELTA too big" | ||
#endif | ||
"\n\t" | ||
-#endif /* !defined(darwin_HOST_OS) */ | ||
+#endif /* defined(ENABLE_UNWINDING) */ | ||
|
||
/* | ||
* Set BaseReg | ||
@@ -519,7 +526,7 @@ StgRunIsImplementedInAssembler(void) | ||
"i"(RESERVED_C_STACK_BYTES + STG_RUN_STACK_FRAME_SIZE | ||
/* rip relative to cfa */) | ||
|
||
-#if !defined(darwin_HOST_OS) | ||
+#if defined(ENABLE_UNWINDING) | ||
, "i"((RSP_DELTA & 127) | (128 * ((RSP_DELTA >> 7) > 0))) | ||
/* signed LEB128-encoded delta from rsp - byte 1 */ | ||
#if (RSP_DELTA >> 7) > 0 | ||
@@ -538,7 +545,7 @@ StgRunIsImplementedInAssembler(void) | ||
#endif | ||
#undef RSP_DELTA | ||
|
||
-#endif /* !defined(darwin_HOST_OS) */ | ||
+#endif /* defined(ENABLE_UNWINDING) */ | ||
|
||
); | ||
/* |