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

Having trouble satisfying cabal #5

Closed
asivitz opened this issue Dec 29, 2017 · 28 comments
Closed

Having trouble satisfying cabal #5

asivitz opened this issue Dec 29, 2017 · 28 comments

Comments

@asivitz
Copy link

asivitz commented Dec 29, 2017

Not sure if this is the best place to post when looking for general help, but here's where I'm stuck:

I have a couple packages that I typically build using stack (cabal new-build is a bit unfamiliar to me). I added a cabal.project file with the following contents:

packages: ../../Hickory/Hickory.cabal foo.cabal 

repository hackage.mobilehaskell
  url: http://hackage.mobilehaskell.org/
  secure: True
  root-keys: 8184c1f23ce05ab836e5ebac3c3a56eecb486df503cc28110e699e24792582da
             81ff2b6c5707d9af651fdceded5702b9a6950117a1c39461f4e2c8fc07d2e36a
             8468c561cd02cc7dfe27c56de0da1a5c1a2b1b264fff21f4784f02b8c5a63edd
  key-threshold: 3

I also have llvm5, the toolchain-wrapper, and the cross platform ghcs in my path.

Now I run x86_64-apple-ios-cabal new-build and I get...

Warning: The package list for 'hackage.mobilehaskell' does not exist. Run
'cabal update' to download it.
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: base-4.11.0.0/installed-4.1... (dependency of Hickory-0.1.0.0)
next goal: vector (dependency of Hickory-0.1.0.0)
rejecting: vector-0.12.0.1 (conflict: base==4.11.0.0/installed-4.1..., vector
=> base>=4.5 && <4.11)
rejecting: vector-0.12.0.0 (conflict: base==4.11.0.0/installed-4.1..., vector
=> base>=4.5 && <4.10)
rejecting: vector-0.11.0.0 (conflict: base==4.11.0.0/installed-4.1..., vector
=> base>=4.3 && <4.10)
trying: vector-0.10.12.3
next goal: primitive (dependency of vector-0.10.12.3)
rejecting: primitive-0.6.2.0 (conflict: vector => primitive>=0.5.0.1 &&
<0.6.2)
rejecting: primitive-0.6.1.0 (conflict: base==4.11.0.0/installed-4.1...,
primitive => base>=4.3 && <4.10)
rejecting: primitive-0.5.4.0 (conflict: base==4.11.0.0/installed-4.1...,
primitive => base>=4.3 && <4.9)
rejecting: primitive-0.5.3.0, primitive-0.5.2.1 (conflict:
base==4.11.0.0/installed-4.1..., primitive => base>=4.3 && <4.8)
rejecting: primitive-0.5.1.0 (conflict: base==4.11.0.0/installed-4.1...,
primitive => base>=4 && <4.8)
rejecting: primitive-0.5.0.1 (conflict: base==4.11.0.0/installed-4.1...,
primitive => base>=4 && <4.7)
rejecting: primitive-0.5, primitive-0.4.1, primitive-0.4.0.1, primitive-0.4,
primitive-0.3.1, primitive-0.3, primitive-0.2.1, primitive-0.2, primitive-0.1
(conflict: vector => primitive>=0.5.0.1 && <0.6.2)
rejecting: primitive-0.6 (conflict: base==4.11.0.0/installed-4.1..., primitive
=> base>=4.3 && <4.9)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: primitive, vector, base, Hickory

First of all, the warning about the missing package list does not go away when I run cabal update or x86_64-apple-ios-cabal update. I'm not sure if that's a real problem...

But I'm not sure how to deal with the dependency mismatches. Should I just go read more cabal documentation, or is there something I should know about the versions of packages used in the mobile hackage overlay? If it helps, here's the package.yaml of my library Hickory, which I guess is the start of the problem: https://github.com/asivitz/Hickory/blob/master/package.yaml

Also, thanks for all your hard work on mobile haskell!

@angerman
Copy link
Contributor

I’ll have to give this a longer answer once I’m at my desk. For now it looks like you run afoul of the 8.4 base.

Did you try passing —allow-newer to cabal?

@angerman
Copy link
Contributor

angerman commented Dec 29, 2017

So...

Warning: The package list for 'hackage.mobilehaskell' does not exist. Run 'cabal update' to download it.

This should be x86_64-apple-ios-cabal new-update.

Together with the --allow-newer, I believe this should get your quite a bit further.

Let me know how it goes!

@asivitz
Copy link
Author

asivitz commented Dec 29, 2017

Ok great, I definitely made progress (cabal HEAD was needed for new-update, but then it worked great).

Now I'm running into trouble building unordered-containers, as it hasn't been updated for the monoid/semigroup changes yet, but I can go ahead and make PR for that. I guess I'll leave this issue open for now in case I run into other problems.

Thanks so much!

@angerman
Copy link
Contributor

Ahh right, I forgot to mention that you need a cabal from HEAD. For the SMP changes, you might just add the repository lines from http://head.hackage.haskell.org/ to your project file as well. And after cabal new-update, if you are lucky the SMP patched packages should be available as well (if they have corresponding patches on the head overlay).

@asivitz
Copy link
Author

asivitz commented Dec 30, 2017

Thanks! That got me a lot further.

I'm failing on zlib now:

Failed to build zlib-0.6.1.2.
Build log (
/Users/asivitz/.cabal/logs/ghc-8.3.20171210/zlb-0.6.1.2-79addfdf.log ):
Configuring library for zlib-0.6.1.2..
Preprocessing library for zlib-0.6.1.2..
dyld: mach-o, but built for simulator (not macOS)
running dist/build/Codec/Compression/Zlib/Stream_hsc_make failed (exit code -6)
command was: dist/build/Codec/Compression/Zlib/Stream_hsc_make  >dist/build/Codec/Compression/Zlib/Stream.hs

@angerman
Copy link
Contributor

That’s due to the cabal bug (failing to pass down flags to dependencies) i believe.

Unpack zlib into your project folder (and apply the zlib patch: haskell/zlib#14).

@asivitz
Copy link
Author

asivitz commented Dec 30, 2017

Awesome, more progress. :)

Any idea on these?

Configuring distributive-0.5.3 (all, legacy fallback)...
Configuring bytes-0.15.3 (all, legacy fallback)...
cabal: Failed to build bytes-0.15.3 (which is required by
ultimatelib-0.1.0.0). The failure occurred during the configure step. The
build process terminated with exit code -6
Failed to build distributive-0.5.3 (which is required by ultimatelib-0.1.0.0).
The failure occurred during the configure step. The build process terminated
with exit code -6

@angerman
Copy link
Contributor

So bytes and distributive failed. Try unpacking/adding them as submodules and see how far that gets you. If that still doesn't help, they might need some massaging :(

@asivitz
Copy link
Author

asivitz commented Dec 31, 2017

I ended up bringing them down and changing the build type to Simple (as well as a bunch of ekmett's other packages), and that worked. Now all the deps are out of the way, onto getting my own code running! ;)

@angerman
Copy link
Contributor

angerman commented Jan 1, 2018

Yes. The non-simple buildtypes are an issue for cross compilation and cabal right now. This is made worse by the abuse of the custom build type to add doctest support. This is a tricky question though. I still believe that non-simple buildtypes should be avoided as much as possible and we ought to provide cabal with less opaque facilities. E.g. cabal doctest/cabal new-doctest.

@asivitz
Copy link
Author

asivitz commented Jan 1, 2018

Ok, all my library code is built and I'm ready to build the static library. But my question is- in your iOS cross compiler blog post, when building the static lib, you link in a custom built libffi. But since I'm using your relocatable cross-compiler, do I still need to do that? I.e., do I need to custom build a libffi? And will there be any problem if it's not the exact same libffi that you linked into the cross compiler?

@angerman
Copy link
Contributor

angerman commented Jan 2, 2018

I believe the libffi that's shipped with the binary distribution should be good to go; just give it a try :)

The issue with the libffi library is essentially just an issue llvm has with it. LLVM started supporting only the unified assembly syntax, while the latest libffi release still used some older assembly syntax.

My suggestions is, just use -staticlib to produce the static binaries and give it a try!

@asivitz
Copy link
Author

asivitz commented Jan 2, 2018

Well, I'm not sure if you have any ideas on this but...

When I try to build in xcode I get a linker error:

Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
     (maybe you meant: _c_main)
ld: symbol(s) not found for architecture x86_64

I'm linking in the libhs.a file I built, so my understanding is that it should have main defined, which then calls out to the c_main I have defined in main.m. So I don't know why it wouldn't have it...

In case it matters, I get these warnings when building the archive:

$ x86_64-apple-ios-ghc -odir x86_64 -hidir x86_64 -threaded -staticlib -o hs-libs/x86_64/libhs.a ios/Main.hs

Linking hs-libs/x86_64/libhs.a ...
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(Win32Utils.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(consUtils.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(longlong.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(Disassembler.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(LdvProfile.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(OldARMAtomic.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(ProfilerReport.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(ProfilerReportJson.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(Profiling.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(RetainerProfile.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(RetainerSet.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(RtsDllMain.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(Trace.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(EventLog.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(Elf.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(PEi386.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(elf_got.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(elf_plt.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(elf_plt_aarch64.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(elf_plt_arm.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(elf_reloc.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(elf_reloc_aarch64.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(elf_util.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(Sanity.thr_o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: hs-libs/x86_64/libhs.a(Select.thr_o) has no symbols

@angerman
Copy link
Contributor

angerman commented Jan 2, 2018

The warning don’t matter. But I believe you have the mains wrong.

Your entry point is the main defined in main.m, which then calls your Haskell library. Having your Haskell library take over the main entry is something I have not explored.

Essentially the main function is the initial entry point. And this has always been the application logic, which then only called out to haskell.

@asivitz
Copy link
Author

asivitz commented Jan 2, 2018

Ah yea, I had followed a different example in the past that did it that way. But I did change it as you suggested and got it working in the simulator! Thanks so much for your help! I'll close this for now and open another issue if I run into another problem. Thanks again!

@asivitz asivitz closed this as completed Jan 2, 2018
@angerman
Copy link
Contributor

angerman commented Jan 2, 2018

Awesome! 👍 Let me know if you get it working on the device as well :)

@Tehnix
Copy link
Contributor

Tehnix commented Jan 9, 2018

Hmm, it would be super interesting if the steps taken here could perhaps be formulated in a list of steps or something? It was a bit confusing following :)

@angerman
Copy link
Contributor

angerman commented Jan 9, 2018

@Tehnix yes, definetly! I plan to setup a read the docs repo this week, and start documenting it. There's also haskell/cabal#4972, which might help a lot. I wanted to try that out prior to writing anything down. With the meetup presentation coming up in two days, I hope to be able to get everything done this week.

@Tehnix
Copy link
Contributor

Tehnix commented Jan 9, 2018

Fantastic! Btw, is the meetup talk about haskell on mobile (and in that case, is it recorded)?

@angerman
Copy link
Contributor

angerman commented Jan 9, 2018

Yes it is, see https://www.meetup.com/HASKELL-SG/events/246341959/

Unless screw up the microphone battery again, it should be properly recorded
and land on youtube (https://www.youtube.com/playlist?list=PLbjcAmsCYuS4xspQb5BHnIHhi4BrWteGz) by the end of the weekend.

@asivitz
Copy link
Author

asivitz commented Jan 9, 2018

Once I'm happy with my Haskell/OpenGL/iOS setup I plan to fully document the steps necessary to recreate it.

@angerman
Copy link
Contributor

angerman commented Jan 9, 2018

Would you be willing to contribute to a shared document?

@asivitz
Copy link
Author

asivitz commented Jan 10, 2018

Definitely, yea.

@angerman
Copy link
Contributor

So I've started some stub here: http://mobile-haskell-user-guide.readthedocs.io/en/latest/ which is essentially mobilehaskell/user-guide feel free to contribute however you like, even if it's just issues, what should be documented.

I hope I'll be able to get docs.mobilehaskell.org working over the weekend. Will fastly support for CDN of mobilehaskell.org I'll have to see how to separate the two.

@angerman
Copy link
Contributor

@asivitz with haskell/cabal#5018, you should not need to unpack or add packages as sub modules anymore. I'll add a copy of hvr/head.hackage#22 to this repository tomorrow, which should make adding and sending patches (e.g. change build-type to Simple) much simpler, so we can share common patches to packages and everyone benefits.

@asivitz
Copy link
Author

asivitz commented Jan 14, 2018

Sounds good; I'll PR my changes once you push that out.

I'm not sure exactly what that cabal patch allows you to do; does it let you change the build type via the command line?

@asivitz
Copy link
Author

asivitz commented Jan 14, 2018

To clarify- unpacking by itself didn't never fixed a package for me. I had to change the build type to Simple in order to get things to compile.

@angerman
Copy link
Contributor

@asivitz unpacking / git submoduling only helps if the package can be used unmodified, but needs the flags to be passed (e.g. foundation, basement, ...) that's what the cabal PR helps with.

For modifying package (e.g. changing build type from custom to simple), that's what the overlay is for. I hope I'll have it fully automated by the end of the day, and adjusted the copy of hvr/head.hackage#22 to deal properly with .cabal only changes.

That should allow you to use cabal new-build (with the patched cabal), and the hackage.mobilehaskell.org hackage overlay.

Ideally all of us would contribute overlay patches to the hackage.mobilehaskell.org repository, and could benefit from the patched packages. I'd really like some way to upstream those patches automatically, but I haven't found one yet. If cabal packages would provide source (git, tag) for the release, that would probably work, but not all do. Maybe we can make cabal provide those fields and encourage them to be set. At that point the script could automatically open Pull Requests against the original source packages.

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

No branches or pull requests

3 participants