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

Text-2.0 causes non-portable binaries by default on windows #487

Closed
hasufell opened this issue Jan 13, 2023 · 14 comments
Closed

Text-2.0 causes non-portable binaries by default on windows #487

hasufell opened this issue Jan 13, 2023 · 14 comments
Labels

Comments

@hasufell
Copy link
Member

haskell/ghcup-hs#745

It uses simdutf by default. That causes GHC to link against its internal libstdc++ on windows, which may not be installed at all or exposed as lib search path.

@tfausak
Copy link

tfausak commented Jan 13, 2023

I'm not certain, but this sounds related to #461.

@bgamari
Copy link
Contributor

bgamari commented Jan 13, 2023

Yes, this is indeed a hazard of enabling simdutf by default and was one of my concerns about enabling it in the GHC distribution. The thought was that users wanting to redistribute executables would do one of the following:

  • include libstdc++ in their distribution if they depend upon text
  • statically link against the C++ standard library; sadly, this is surprisingly tricky to arrange in a platform agnostic manner
  • ensure they they explicitly disable the simdutf flag in their install plan

@hasufell
Copy link
Member Author

@bgamari
Copy link
Contributor

bgamari commented Jan 13, 2023

For the record, we have in fact disabled simdutf in all of the GHC distributions shipping with text-2 thusfar. In light of issues like this, it is hard for me to imagine being able to change that.

The one possible strategy I can think of would be to link text statically against the C++ standard library. However, as noted above, this is quite nontrivial as it is quite platform-dependent. IIRC Apple platforms don't even provide a static object to link against. Moreover, even on Linux it can be risky since exception handling often relies on dladdr. However, this may not matter in the case of a library like simdutf which is (AFAICT) entirely noexcept.

@Lysxia Lysxia added the bug label Jan 13, 2023
@Bodigrim
Copy link
Contributor

For the record, we have in fact disabled simdutf in all of the GHC distributions shipping with text-2 thusfar.

If that's the case then why ghcup build was affected?

@bgamari
Copy link
Contributor

bgamari commented Jan 13, 2023

If that's the case then why ghcup build was affected?

Presumably because the constraints of @hasufell's project precluded use of his compiler's (GHC 8.10.7) pre-existing text and text.cabal enables the simdutf flag by default. He told me via IRC that for the moment he has explicitly disabled the simdutf flag in his project.

@hasufell
Copy link
Member Author

haskell/ghcup-hs@e00899d

Correct. I reinstall the text boot library. This isn't very uncommon.

@Bodigrim
Copy link
Contributor

Sigh, that's all pretty disappointing. I was under illusion that build-depends: system-cxx-std-lib is all a package needs to declare for GHC to take care of the rest.

Probably we have to disable simdutf by default on Windows. A CI job, running in an empty environment, similar to haskell/bytestring#500, would be helpful to reproduce the issue.

@Bodigrim
Copy link
Contributor

Right, with GHC 8.10 we do not pass build-depends: system-cxx-std-lib, but rather extra-libraries: stdc++, which is problematic.

@hasufell What would happen if you try GHC 9.4 and text +simdutf? Does the problem persist?

@phadej
Copy link
Contributor

phadej commented Jan 15, 2023

What would happen if you try GHC 9.4 and text +simdutf? Does the problem persist?

I think nothing. That's a limitation of cabal-install and ghc-pkg package databases: The latter doesn't record flags, and cabal-install doesn't really have a way to force recompilation of exactly the same version as in global package db (if you want to change flags).

E.g.

aeson% cabal build -w ghc-9.4.3 --constraint='text +simdutf' --dry
...
Build profile: -w ghc-9.4.3 -O1
In order, the following would be built (use -v for more details):
...

and then cabal-plan topo shows text in blue

Screenshot from 2023-01-15 19-28-58

meaning it is coming from global db.

@bgamari
Copy link
Contributor

bgamari commented Jan 17, 2023

I think nothing. That's a limitation of cabal-install and ghc-pkg package databases:

That is an interesting point; this is something that we should probably try to address. Encoding flag settings in the package database wouldn't be hard although it's not entirely clear to me whether they belong there. They aren't defined in the CABAL specification but given that they are now enshrined in the package description format, I suppose it would be sensible to include them in the package registration format as well. We should open a haskell/cabal ticket about this.

@bgamari
Copy link
Contributor

bgamari commented Jan 26, 2023

We should open a haskell/cabal ticket about this.

I have opened haskell/cabal#8702 to track this.

@Bodigrim
Copy link
Contributor

I don't think there is anything here we can fix on text side, so I suggest to close.

@hasufell
Copy link
Member Author

Correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants