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

Implement {cmm.asm}-{options,sources} for real #6033

Closed
wants to merge 2 commits into from

Conversation

hvr
Copy link
Member

@hvr hvr commented May 5, 2019

While those buildinfo fields were added to the parser some time
ago via 57d7f28 and
4a28765 that work was never completed
by implementing the necessary build/sdist logic in Cabal.

This commit remedies this oversight by implementing and wiring up the
missing build logic.

cc @erikd


Things that work now (i.e. that I tested manually; these should be turned into testsuite tests long-term):

  • cmm-sources and asm-sources are compiled (in a separate phase like c-sources are) and the resulting object files are linked into the respective component (i.e. like c-sources)
  • cabal sdist properly includes cmm-sources and asm-sources in the src-dist
  • cmm-options are passed (directly) to GHC when compiling cmm-sources
  • asm-options are passed (via -opta) to GHC when compiling asm-sources files
  • ghc-options are NOT passed to compilation of cmm-sources/asm-sources

@hvr hvr added this to the 3.0 milestone May 5, 2019
@angerman
Copy link
Collaborator

angerman commented May 6, 2019

oversight

🤔

@23Skidoo
Copy link
Member

23Skidoo commented May 6, 2019

TIL about Draft PRs, nice feature.

@phadej phadej mentioned this pull request Jun 10, 2019
@hsyl20
Copy link
Collaborator

hsyl20 commented Jun 26, 2019

I've added some missing C-- bits to @hvr's patch: https://github.com/hsyl20/cabal/tree/hsyl20-asm-cmm-sources
Hopefully we could have this patch for GHC 8.8

@hvr
Copy link
Member Author

hvr commented Jun 26, 2019

@hsyl20 thank you! I'll look at your branch asap and will cherry-pick the delta into this PR if it looks good

@hvr hvr force-pushed the pr/fix-asm-sources branch from 9b7299a to 15f068c Compare June 26, 2019 12:31
@angerman
Copy link
Collaborator

🎉

@hvr
Copy link
Member Author

hvr commented Jun 26, 2019

@hsyl20 I tested the code a bit, and it works partly; specifically cmm-options are not passed to the ghc commandline when compiling the .cmm module; however, ghc-options: ... for the respective component are passed to the .cmm compilation

ghcOptPackages = toNubListR $ mkGhcOptPackages clbi,
ghcOptOptimisation = toGhcOptimisation (withOptimization lbi),
ghcOptDebugInfo = toFlag (withDebugInfo lbi),
ghcOptExtra = hcOptions GHC bi,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oops I forgot to fix this while copy-pasting from the other cases: s/hcOptions GHC bi/cmmOptions bi/
I guess it should fix cmm-options passing.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah... this is the kind of bugs I was worried about... :-)

I've rebased and updated the PR to include your fixup suggestion; I'm currently testdriving this locally

I'm also going to un-DRAFT this PR to invite more code-review

While those buildinfo fields were added to the parser some time
ago via 57d7f28 and
4a28765 that work was never completed
by implementing the necessary build/sdist logic in Cabal.

This commit remedies this oversight by implementing and wiring up the
missing build logic.

*WARNING* this commit is still very WIP; ASM works mostly; C--
          support is still incomplete
@hvr hvr force-pushed the pr/fix-asm-sources branch from 15f068c to c00c122 Compare June 27, 2019 06:59
@hvr hvr marked this pull request as ready for review June 27, 2019 07:02
@hvr hvr force-pushed the pr/fix-asm-sources branch from c00c122 to e222728 Compare June 27, 2019 07:06
Copy link
Member

@23Skidoo 23Skidoo left a comment

Choose a reason for hiding this comment

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

Code looks good modulo one comment.

-- information.
addExtraAsmSources :: BuildInfo -> [FilePath] -> BuildInfo
addExtraAsmSources bi extras = bi { asmSources = new }
where new = Set.toList $ old `Set.union` exs
Copy link
Member

@23Skidoo 23Skidoo Jun 30, 2019

Choose a reason for hiding this comment

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

If I have both preprocessor-generated asm-sources and cmm-sources, won't this add the union of these to the LBI's asmSources?

Copy link
Member

Choose a reason for hiding this comment

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

Actually, this probably will break if I have any preprocessor-generated C files at all.

@23Skidoo
Copy link
Member

23Skidoo commented Jun 30, 2019

Would be also nice to see a test case, would be even nicer if the test case had a custom preprocessor that generated .s and .cmm files.

@@ -216,7 +216,13 @@ buildComponent verbosity numJobs pkg_descr lbi suffixes
setupMessage' verbosity "Building" (packageId pkg_descr)
(componentLocalName clbi) (maybeComponentInstantiatedWith clbi)
let libbi = libBuildInfo lib
lib' = lib { libBuildInfo = addExtraCxxSources (addExtraCSources libbi extras) extras }
Copy link
Member Author

@hvr hvr Jul 1, 2019

Choose a reason for hiding this comment

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

@23Skidoo based on your observation, wasn't this line already broken? i.e. the same FilePaths (i.e. extras) being added to cxx and c sources?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, looks like it.

hvr added a commit that referenced this pull request Jul 1, 2019
While those buildinfo fields were added to the parser some time
ago via 57d7f28 and
4a28765 that work was never completed
by implementing the necessary build/sdist logic in Cabal.

This commit remedies this oversight by implementing and wiring up the
missing build logic.

NOTE: This is a backport of (at time of writing) unfinished
      #6033 to the 3.0 branch
      Specifically preprocessor-generated asm/cmm-sources need more
      work.

Co-authored-by: Sylvain Henry <sylvain@haskus.fr>
@hvr
Copy link
Member Author

hvr commented Jul 1, 2019

@23Skidoo as discussed I've backported the current state of this PR to the 3.0 branch via c5395b8 and this PR remains open for the express purpose to fix the outstanding issues with the preprocessor generated sources

Copy link
Collaborator

@phadej phadej left a comment

Choose a reason for hiding this comment

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

There are no tests.

DanielG pushed a commit to DanielG/cabal that referenced this pull request Aug 17, 2019
While those buildinfo fields were added to the parser some time
ago via 57d7f28 and
4a28765 that work was never completed
by implementing the necessary build/sdist logic in Cabal.

This commit remedies this oversight by implementing and wiring up the
missing build logic.

NOTE: This is a backport of (at time of writing) unfinished
      haskell#6033 to the 3.0 branch
      Specifically preprocessor-generated asm/cmm-sources need more
      work.

Co-authored-by: Sylvain Henry <sylvain@haskus.fr>
@23Skidoo 23Skidoo modified the milestones: 3.0, 3.0.1.0 Oct 16, 2019
This was referenced Nov 27, 2019
@phadej phadej self-assigned this Nov 27, 2019
@phadej
Copy link
Collaborator

phadej commented Nov 28, 2019

#6376 merged, #6377 is tracking leftovers

@phadej phadej closed this Nov 28, 2019
@hvr hvr deleted the pr/fix-asm-sources branch December 8, 2019 09:37
hvr added a commit that referenced this pull request Dec 8, 2019
These are only supported properly starting with
cabal-version:3.0 (which has been enforced by
Hackage as well -- via this very patch).

See #6033 for details
phadej pushed a commit to phadej/cabal that referenced this pull request Dec 12, 2019
These are only supported properly starting with
cabal-version:3.0 (which has been enforced by
Hackage as well -- via this very patch).

See haskell#6033 for details
phadej pushed a commit to phadej/cabal that referenced this pull request Dec 12, 2019
These are only supported properly starting with
cabal-version:3.0 (which has been enforced by
Hackage as well -- via this very patch).

See haskell#6033 for details
phadej pushed a commit to phadej/cabal that referenced this pull request Dec 12, 2019
These are only supported properly starting with
cabal-version:3.0 (which has been enforced by
Hackage as well -- via this very patch).

See haskell#6033 for details
phadej pushed a commit to phadej/cabal that referenced this pull request Dec 12, 2019
These are only supported properly starting with
cabal-version:3.0 (which has been enforced by
Hackage as well -- via this very patch).

See haskell#6033 for details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants