-
Notifications
You must be signed in to change notification settings - Fork 710
Add support for js-sources #8636
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
Conversation
I've opened #8639 to track the issue with executable components. It has a larger scope because |
Local tests are fine in this case. A tiny changelog file would be very welcome though. @hsyl20: I presume this is ready for review? Based on this assumption, I've set the label and asked @bgamari to have a look (or delegate to somebody in GHC team that works on related issues). Re including in GHC 9.6, we plan to release cabal 3.10 in step with GHC 9.6, so if this PR gets merged in 2022 or shortly thereafter, it's going to be included in GHC 9.6 and in cabal 3.10. I will bug people to make sure it doesn't just get forgotten. |
I've added a changelog. Now it's ready for review. :) |
@@ -561,6 +561,7 @@ buildOrReplLib mReplFlags verbosity numJobs pkg_descr lbi lib clbi = do | |||
, toNubListR (cxxSources libBi) | |||
, toNubListR (cmmSources libBi) | |||
, toNubListR (asmSources libBi) | |||
, toNubListR (jsSources libBi) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is adding JS to cLikeSources
. Is "C-like" a misnomer or was the original intention to exclude JS? Change of plans? I don't see any "non-C-like sources" list in the codebase that we could add JS source to, instead, so this must be the right place.
Perhaps the C-like vs non-C-like distinction is a left over from some special cases for GHCJS? Is JS C-like enough when considered by GHC JS backend, but not C-like when fed to GHCJS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes for the JS backend we've reworked the way JS sources are treated. They are now C-like because we've added support for a "compilation" from .js
to .o
files (basically a file renaming with a header added). It makes them less special for tools like Hadrian and cabal.
(in the GHCJS code path (Distribution.Simple.GHCJS
) these files were directly passed as link options)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this deserves a NOTE JS Sources are C-Like
or similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Profpatsch: GHC note or cabal note? Or one of those and hyperlink from the other place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a comment explaining that JS sources are C-like in the JS backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've verified that this PR changes all the bits of code that are likely to need changing. However, I don't know this functionality enough to understand whether these changes make sense, so I have to trust the results of local testing by the PR author. This is unlikely to break other stuff, though.
hi, this looks great but it would be nice to know the plans to add or modify existing tests |
A possible way would be write tests and run them conditionally on ghc version. They will be eventually executed everywhere. |
This pr seems to be related with #8633 and i guess tests also would be related |
I'll try to do this.
The two PRs aren't related. This other one is for the wasm backend, this one is for the JS backend. |
We'd like to include this commit in the 3.10 branch that is to be cut RSN so, in the worst case, perhaps we could add the test afterwards. However, we need a second review, an in-depth one, ideally prompting some more documentation to be added, so I'm kindly asking @ben to help with that. |
BTW, if this is done in finite time and we have 9.6.1-alpha1 in CI, the test would be able to run. Probably not on Windows, though, because our CI is quite thoroughly broken with GHC >= 9.4 on Windows. |
@Mikolaj You also will need a build of GHC cross-compiling for the JS target. Not sure if it is planned? |
I've added a test but I couldn't run it with |
Oops I forgot to push some changes, now done. Run example:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the test. I think it's fine as the first test of any functionality in any way related to JS.
I've also fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've also fixed skipIfGhcVersion in passing. It probably shouldn't belong to this MR but time is short.
Thanks a lot. It is. :)
Splendid. That's descent behaviour and these are not blockers for this PR, IMHO. |
@Mikolaj Done! Thanks :) |
@mergify refresh |
✅ Pull request refreshed |
Mergify is fussy today, so let me prod it manually. |
@mergify rebase |
To get the future behavior now, you can configure Or you can create a dedicated github account for squash and rebase operations, and use it in different |
✅ Branch has been successfully rebased |
9f4ea9d
to
b55d479
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
late to the party but thanks for working on this (and add the test!)
This PR adds support for
js-sources
with GHC, not only GHCJS.Caveat: for now, similarly to
asm-sources
andcmm-sources
,js-sources
only works forlibrary
components, notexecutable
components. See #8639Not sure how to add tests for this as it requires GHC >= 9.6 built for the JS target. I've only tested it locally.