-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cctools ld segfaults when linking haskellPackages.Agda (2.6.2 only?) #149692
Comments
Does adding |
Ah, sorry. This is about fixing the "Killed: 9" error, not |
Yeah, |
Would help to post a crash dump from Other -> Console -> User Reports |
Indeed, would be nice if someone could have a look at this locally, I can only check on Hydra logs, really. |
Getting:
on 7370b26 |
Is this maybe fixed since 2.6.2.1 (https://hydra.nixos.org/build/161184182)? |
Interesting, let's keep this open in case it happens in another package |
I have the exact same error with |
Agda 2.6.2.1 started failing again as well iirc. I suspect this could possibly be OOM or a segfault, but impossible to test from my position. |
Can someone on darwin reproduce and bisect? |
I'm hitting this locally on |
I can't find the commit where this succeeds on |
2c85c77 according to hydra |
Result of Bisect, which sadly, that's a huge commit |
My bisection agrees:
|
Hello. I faced the same issue while building
My nixpkgs are
|
@unbel13ver That can't be related. Please file a separate issue. |
I don't know if it is the same issue
|
For anyone on M1 experiencing this issue, overriding with the x86_64-darwin package works with Rosetta. |
A+ suggestion! In case others (like me 😅) want to try this but aren't familiar with how, here's a blog that talks about configuring nix to build x86_64 programs: https://evanrelf.com/building-x86-64-packages-with-nix-on-apple-silicon |
For what it's worth, this is happening to me too, with Ormolu:
It's nice that there's the workaround of compiling for x86_64, but is there really no other way? |
@denizdogan Please post a stacktrace. You can find it using Other -> Console -> Crash Reports. |
Hi @cidkidnix , thanks for taking the time to reply to this. I'll try that and see if that fixes things for me. |
I ran into this segfault trying to compile Hasura on aarch64 and this flag was the final missing puzzle piece. Thank you very much! |
Interesting, we could consider enabling this by default via Can you compare output size of built libraries with and without this flag? Stripping efficiency would be interesting to know for making this decision. |
I'm interested too, Been meaning to submit a patch upstream to GHC but I haven't found the time the relevant fix would be something akin to (assuming the output size isn't massively different) osSubsectionsViaSymbols :: Platform -> Bool
osSubsectionsViaSymbols platform = case (platformArch platform, platformOS platform) of
(ArchAArch64, OSDarwin) -> False
(_, OSDarwin) -> True
(_, _) -> False in https://gitlab.haskell.org/ghc/ghc/-/blob/master/compiler/GHC/Platform.hs#L230 |
Oh yeah, also @john-rodewald the flag should actually be |
diff --git a/compiler/GHC/Linker/Static.hs b/compiler/GHC/Linker/Static.hs
index aa51a2b7d6..eac801617b 100644
--- a/compiler/GHC/Linker/Static.hs
+++ b/compiler/GHC/Linker/Static.hs
@@ -135,7 +135,7 @@ linkBinary' staticLink logger tmpfs dflags unit_env o_files dep_units = do
let
dead_strip
| gopt Opt_WholeArchiveHsLibs dflags = []
- | otherwise = if osSubsectionsViaSymbols (platformOS platform)
+ | otherwise = if osSubsectionsViaSymbols platform
then ["-Wl,-dead_strip"]
else []
let lib_paths = libraryPaths dflags
diff --git a/compiler/GHC/Platform.hs b/compiler/GHC/Platform.hs
index a5a609d252..e1fcbb1aa1 100644
--- a/compiler/GHC/Platform.hs
+++ b/compiler/GHC/Platform.hs
@@ -227,9 +227,11 @@ osUsesFrameworks _ = False
platformUsesFrameworks :: Platform -> Bool
platformUsesFrameworks = osUsesFrameworks . platformOS
-osSubsectionsViaSymbols :: OS -> Bool
-osSubsectionsViaSymbols OSDarwin = True
-osSubsectionsViaSymbols _ = False
+osSubsectionsViaSymbols :: Platform -> Bool
+osSubsectionsViaSymbols plat = case (platformArch plat, platformOS plat) of
+ (ArchAArch64, OSDarwin) -> False
+ (_, OSDarwin) -> True
+ (_, _) -> False
-- | Minimum representable Int value for the given platform
platformMinInt :: Platform -> Integer Here's the patch based on GHC master that should fix the linking issues on aarch64-darwin. I think it should work for any GHC newer than ~3years |
This problem is also actual to me .-. After some updates my project has stopped builing with an error:
I've tried building with 9.4.5 and 9.4.6 version and got same result. But yesterday my project was building that is weird. I've tried rollback my nix-channel but it had no effect. My setup: mac m2, ghc 9.4.5/9.4.6 |
What happens if you run the linker manually with no input? If it still crashes, something may have happened to the codesigning. |
Do you mean just try to run
|
Yep, thanks. Looks like it works, so it’s not a codesigning issue. |
I've read the thread and try pass the option '-fwhole-archive-hs-libs' to GHC and it kind a works :) Thanks all for help! |
I’m working on updating cctools and ld64 to the latest versions. These versions are using Apple’s upstream sources and match the versions of those tools included with Xcode 15.3. If those don’t work, then I don’t know. More details on Discourse: https://discourse.nixos.org/t/darwin-updates-news/42249/10 |
Had this same error message on an executable on a M1 with ghc 9.4.8 and package set from recent nixpkgs. Both
Poking around with
and indeed that build directory contain a As for the It seems like there's two bugs here, where both flags workaround the first bug that @cidkidnix has a patch for above, but avoiding with |
Is this reproducible, and is there a public repo? I’d like to see if it crashes on my ld64 update branch. |
@reckenrode thanks for looking into this - here's a small repro using ghc 9.6 and the Doing |
@alexfmpe Thanks for the repo. I cloned it and confirmed the crash with the haskell-updates branch, then I pointed it at my local ld64 update branch. $ cabal build --project-file cabal.project all
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.
Resolving dependencies...
Build profile: -w ghc-9.6.4 -O1
In order, the following will be built (use -v for more details):
- a-0.1 (lib) (first run)
- a-0.1 (exe:a) (first run)
Configuring library for a-0.1..
Preprocessing library for a-0.1..
Building library for a-0.1..
[1 of 1] Compiling A ( src/A.hs, /Users/reckenrode/Developer/tmp/reproducible-segfault-rpath/dist-newstyle/build/aarch64-osx/ghc-9.6.4/a-0.1/build/A.o, /Users/reckenrode/Developer/tmp/reproducible-segfault-rpath/dist-newstyle/build/aarch64-osx/ghc-9.6.4/a-0.1/build/A.dyn_o )
Configuring executable 'a' for a-0.1..
Preprocessing executable 'a' for a-0.1..
Building executable 'a' for a-0.1..
[1 of 1] Compiling Main ( src-bin/main.hs, /Users/reckenrode/Developer/tmp/reproducible-segfault-rpath/dist-newstyle/build/aarch64-osx/ghc-9.6.4/a-0.1/x/a/build/a/a-tmp/Main.o )
[2 of 2] Linking /Users/reckenrode/Developer/tmp/reproducible-segfault-rpath/dist-newstyle/build/aarch64-osx/ghc-9.6.4/a-0.1/x/a/build/a/a
$ cabal run --project-file cabal.project all
it worked It could be the version jump (going from 609 to 951.9) or the source (switching to Apple’s OSS release from cctools-port), but I suspect the issue is cctools-port does not appear to build ld64 with |
Plausible, since my repro seems to vanish if I don't import from meaty dependencies. |
Indeed, I got the same results.
It does, and it seems for dynamic linking I should instead be using |
FWIW, if you’re using the ld64 branch in my nixpkgs repo, it’s a bit old. ld64 should be fine, but it’s missing some additional compatibility work I’ve done. Once I’ve built the Darwin channel blockers successfully, I plan to open a draft PR for feedback. |
A note to anyone thinking of using |
Update: It must be late. I was testing against master. I changed it to download the tarball for staging-next, and the test case passes with the workarounds disabled. It does experience the rpath issue. There probably should be one for the test case’s |
If someone can find a reproducible test case after the ld64 upgrade, please reopen. If I have to do it, I’ll rewrite the recursion to remove it, but the larger default stack size should make this a non-issue now. Closed via #307880. |
Example Log:
Steps To Reproduce
nix-build -A haskellPackages.Agda
onaarch64-darwin
cc @NixOS/darwin-maintainers
The text was updated successfully, but these errors were encountered: