Skip to content
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

Set LD=ld.bfd on Alpine linux during bindist configure #968

Merged
merged 1 commit into from
Jan 20, 2024
Merged

Conversation

hasufell
Copy link
Member

@hasufell hasufell commented Jan 4, 2024

Fixes #967

@hasufell hasufell requested a review from runeksvendsen January 4, 2024 12:54
Copy link
Collaborator

@runeksvendsen runeksvendsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much work would it be to test in CI that this fixes the segfault issue?

@runeksvendsen
Copy link
Collaborator

This also fixes #962, right?

@hasufell
Copy link
Member Author

hasufell commented Jan 7, 2024

This also fixes #962, right?

No, it unfortunately doesn't. I'm suspecting an actual bug in 9.4.8 series.

@hasufell
Copy link
Member Author

hasufell commented Jan 7, 2024

How much work would it be to test in CI that this fixes the segfault issue?

I don't feel that's gonna add much.

We have evidence here:

The minimal reproducer (C code) is shown here (and still works): https://gitlab.haskell.org/ghc/ghc/-/issues/17508#note_372662

There's no minimal reproducer for Haskell.

My past days as Gentoo distributor also remind me that ld.gold was always more problematic, so I don't think it's a good default to begin with.

@hasufell
Copy link
Member Author

hasufell commented Jan 7, 2024

There's no minimal reproducer for Haskell.

Ah, silly me... I didn't edit the settings file correctly.

Obviously, this works:

$ cat Foo.hs
main = putStrLn "hello world"
ghc Foo.hs
./Foo
Segmentation fault (core dumped)

Then make sure your ghc settings file has these lines:

,("C compiler link flags", "-fuse-ld=gold")
,("ld command", "ld.gold")
,("Merge objects command", "ld.gold")

Copy link
Collaborator

@runeksvendsen runeksvendsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way I read the code, we previously ran the configure script with an empty environment — ie. it did not inherit anything from the environment of GHCup. Is this correctly understood?

If this is the case then I'm not convinced that we should pass all of GHCup's environment plus LD=ld.bfd to the configure script in the positive case. In that case why not use an environment with only LD=ld.bfd?

@hasufell
Copy link
Member Author

hasufell commented Jan 7, 2024

we previously ran the configure script with an empty environment — ie. it did not inherit anything from the environment of GHCup. Is this correctly understood?

No, that's not correct. That parameter overwrites the current environment for the subprocess. LD=ld.bfd ghcup install ghc ... works perfectly fine.

@runeksvendsen
Copy link
Collaborator

we previously ran the configure script with an empty environment — ie. it did not inherit anything from the environment of GHCup. Is this correctly understood?

No, that's not correct. That parameter overwrites the current environment for the subprocess. LD=ld.bfd ghcup install ghc ... works perfectly fine.

So passing Just [("LD", "ld.bfd")] as the last argument to execLogged will execute the process in the same environment as that of GHCup but with the LD env var overwritten?

If that's the case then why do we need

(("LD", "ld.bfd") : cEnv)

instead of just

[("LD", "ld.bfd")]

?

@hasufell
Copy link
Member Author

hasufell commented Jan 7, 2024

So passing Just [("LD", "ld.bfd")] as the last argument to execLogged will execute the process in the same environment as that of GHCup but with the LD env var overwritten?

No, you pass the entire environment.

@runeksvendsen
Copy link
Collaborator

Okay I understand now. I thought passing Nothing as the environment means the executed process would have an empty environment. But Nothing means "inherit environment of the parent process" whereas Just [] means "use an empty environment".

Copy link
Collaborator

@runeksvendsen runeksvendsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good to me. But I don't have a way to test it, so I will leave that up to you.

@hasufell hasufell merged commit dd978ff into master Jan 20, 2024
21 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default to ld.bfd for bindist configure (alpine or all linux?)
2 participants