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

No GHC v8.4.1 compatibility due to base max version requirement #87

Open
moll opened this issue Oct 7, 2018 · 26 comments
Open

No GHC v8.4.1 compatibility due to base max version requirement #87

moll opened this issue Oct 7, 2018 · 26 comments

Comments

@moll
Copy link

moll commented Oct 7, 2018

Hey,

Cabal on GHC >= v8.4.1 seems to fail to install fltkhs because of the custom-setup section's base max non-exclusive version of v4.11 Removing that does raise a few issues in Setup.hs that I'm working through. Have you or anyone else perhaps already done that, but not yet published their fixes?

Thanks!

@deech
Copy link
Owner

deech commented Oct 7, 2018

I have been mostly concentrating on the 1.4.0 branch, which includes a ton of bug fixes and sync's fltkhs with FLTK-1.4.0 which itself has a lot of bug fixes and features. I've removed that restriction there, are you able to use it?

Unfortunately it also breaks a lot of the API. It's currently under active development but I feel like the API changes are done at this point. If you're porting an existing codebase I'm happy to help you migrate.

@moll
Copy link
Author

moll commented Oct 7, 2018

Ah, great. Thanks! I didn't notice there were active branches here. Fortunately a new app, so nothing to port over.

c7de421 is sure one big commit. ^_^ I take it using it would be mostly cloning it to a local directory and cabal sandbox add-source path-to-fltkhs?

I'm new to the FLTK scene. Is FLTK v1.4 getting closer to its completion that you've decided to focus on that?

@deech
Copy link
Owner

deech commented Oct 7, 2018

Sorry about the commit size. I'll be cleaning that up when I release it. For now expect that Git history will change.

I've only ever done installed it with stack. I haven't documented Git workflow but basically you would clone the repo into some directory that also contains your app directory ( if you don't have a prexisting app, I recommend the starter kit ) and build them all with stack build --flag fltkhs:bundled --silent with the following stack.yaml in the root of the project directory:

resolver: lts-12.11
packages:
- fltkhs
- fltkhs-hello-world
allow-newer: true
extra-deps:
- load-font-0.1.0.2
- asset-bundle-0.1.0.0
- Cabal-2.4.0.1

@deech
Copy link
Owner

deech commented Oct 7, 2018

To answer your last question, yes, FLTK v.1.4 appears to be moving closer to release but the core team haven't committed to a date. For now fltkhs bundles a development snapshot which seems pretty stable.

As an aside there is also active ( and unreleased ) work going on to make fltkhs look better.

@moll
Copy link
Author

moll commented Oct 7, 2018

I'll give the current branch one last go before delving to v1.4. :) It has worked without the bundled flag ever, right? I'm seeing it still try to fire up Make through dist/build/c-src/Makefile and seek FLTK's source files, even though /usr/bin/fltk-config exists and has its shared libraries under /usr/lib.

@deech
Copy link
Owner

deech commented Oct 7, 2018

I does work (although I haven't tried it for a while) but you're better off building it from source yourself because I've noticed that package managers don't tend to do a good job of using the right build switches etc. For example, fltkhs tries to create statically linked binaries but package managers only provide shared libs. This maybe causing the problems you're seeing. This why I included the bundled option which automates that for you.

@moll
Copy link
Author

moll commented Oct 7, 2018

I do have FLTK with static libs as I just rebuilt the Arch Linux FLTK package and see its .a files... I've been staring at this (fixing Setup.hs in the current master) for some time and I can't figure it out. It feels like it should be a ten line shell script, but it is 400 lines of Haskell. ^_^ I'd like to play it conservative initially and not jump on an unreleased version of FLTK (v1.4). Usually unreleased things lack good documentation and end up being a larger time sink than the added functionality. :)

Mind quickly walking me through what Setup.hs is supposed to do, let's say, when fltk is already installed on the system? I couldn't get the bundled approach to work either in a Cabal sandbox that has fltkhs as an add-source-style dependency. I tried to mimic your v1.4 branch fixes, but something is still off.

So, in the following scenario, my understanding is as follows:

  • git clone $repo fltkhs
  • mkdir app && cd app && cabal sandbox init && cabal sandbox add-source ../fltkhs
  • cabal install fltkhs
  • This first triggers your pre-conf hook, which in turn calls autoconf in the directory of ../fltkhs and generates a configure shell script.
  • Then execution is passed on to Cabal itself and that calls the generated configure not in ../fltkhs, but in ../fltkhs/dist/dist-sandbox-1616d5af/build. This creates a Makefile, c-src/Makefile and a few other files.
  • Next Cabal initiates compiling (building) and calls into the build hook.
  • "Thanks" to my fixes of calling make in the build directory (presumably the same ../fltkhs/dist/dist-sandbox-1616d5af/build directory), the first Makefile is loaded, which in turn loads the one in c-src/Makefile. That assumes the sources files are in its directory and fails, because they're really way-up in the directory stack.
    I do see you added a copy routine to the configure hook to copy the contents of c-src to the build directory. Doesn't smell like a good solution, but I can understand why you did it. When I do it, however, something, possibly autoconf or the configure script, or who knows, detects duplicate headers and deletes the contents of c-src in the repo, thereby preventing any secondary reconfiguration (or the initial install itself) from finishing. That's because after libfltkc.a is created, Cabal continues on to Preprocessing library for fltkhs-0.5.4.5.., which seems to invoke c2hs and it can't find Fl_ExportMacros.h presumably because it was looking at it in ../fltkhs/c-src and that's been emptied.

I can't help but think the problem of compiling the bindings and linking FLTK to them cannot be that complicated that it requires 440 lines of Haskell, 64 lines of autoconf that generates 4919 lines of configure script, which in turn somehow generates a 24 line Makefile which calls another 164 line Makefile and probably a bunch I'm missing. :P

I put the version of Setup.hs that I based my description above at https://github.com/moll/fltkhs/commits/master.

@moll
Copy link
Author

moll commented Oct 7, 2018

Found that header removal is to be blamed on Cabal's configure at https://github.com/haskell/cabal/blob/a94364183f9a7dcb1d15de990d2d3e37c8c75980/Cabal/Distribution/Simple/Configure.hs#L1667. This is one facepalm worthy action of Cabal's --- to delete files from the source directory that a person might be working in.

@sboosali
Copy link
Contributor

sboosali commented Oct 7, 2018 via email

@moll
Copy link
Author

moll commented Oct 7, 2018

@sboosali, I suppose my steps above should lead you to a convoluted reproduction case. ^_^ The behavior is, after all, described in the comment above the checkDuplicateHeaders function I linked to above.

@sboosali
Copy link
Contributor

sboosali commented Oct 7, 2018 via email

@moll
Copy link
Author

moll commented Oct 7, 2018

Yeah, in my tests it consistently deleted the headers from c-src from the folder path given to cabal sandbox add-source if those headers were also copied to dist like @deech's v1.4 and my quick-fixed Setup.hs do (moll@bd3ec58#diff-8288955e209cfbead5b318a8598be9c0R166).

@moll
Copy link
Author

moll commented Oct 7, 2018

And that's exactly what the comment in Cabal says it does. :P

@sboosali
Copy link
Contributor

sboosali commented Oct 8, 2018 via email

@moll
Copy link
Author

moll commented Oct 8, 2018

I wish I could, but hdevtools doesn't support new-build (hdevtools/hdevtools#55) and its type checking while saving in Vim (with Syntastic) is indispensable. haskell/cabal#2771 says changes necessary to accommodate hdevtools aren't in Cabal yet either.

Although I wouldn't be surprised if the same Setup.hs problems described above remain with new-build. After all, it has to run for the FLTK bindings to be compiled. ^_^

@deech
Copy link
Owner

deech commented Oct 8, 2018

Wow, you're right, Cabal-2.4.0.1 does delete my headers. I even tried adding those files to a data-files stanza, same result.

In any case, aside from that crazy bug, I do have a working fltkhs app building from the master branch with a pre-installed ( not bundled ) FLTK. It required a few changes to Setup.hs and fltkhs.cabal and using the multi-project feature of the new Cabal. I can put that out on a branch but I can't merge with master while this bug exists.

While I agree that this project needs a good non-stack dev/deploy workflow even without bugs in Cabal it's still a lot of work to get right across platforms (especially Windows) and currently stack seems to work pretty smoothly so can we go with that for now?

Also does anyone know how to set per-project flags on the command line, cabal new-configure -f<what-goes-here>? I can't seem to figure out how to set the bundled flag on the fltkhs project.

@sboosali
Copy link
Contributor

sboosali commented Oct 8, 2018 via email

@deech
Copy link
Owner

deech commented Oct 8, 2018

I'm aware of that but there has to be a way of setting it on a per project bases, stack allows fltkhs:bundled.

@sboosali
Copy link
Contributor

sboosali commented Oct 8, 2018 via email

@sboosali
Copy link
Contributor

sboosali commented Oct 8, 2018 via email

@sboosali
Copy link
Contributor

sboosali commented Oct 8, 2018 via email

@deech
Copy link
Owner

deech commented Oct 8, 2018

I have pushed up a couple of fixes to a branch that work with Cabal. @moll, if you could try them out I would appreciate it.

I upgraded to Cabal 2.4.0.1, once you have that installed hopefully the following workflow goes smoothly:

# install FLTK
> wget http://fltk.org/pub/fltk/1.3.4/fltk-1.3.4-1-source.tar.gz
> tar -zxf fltk-1.3.4-1-source.tar.gz
> cd fltk-1.3.4-1
> ./autogen.sh
> ./configure --enable-shared --enable-localjpeg --enable-localzlib --enable-localpng
> make
> sudo make install


# create a Cabal project
> mkdir app
> cd app
> cabal init
> git clone -b Cabal2401 https://github.com/deech/fltkhs
> git clone -b Cabal2401 https://github.com/deech/fltkhs-hello-world
> cabal new-configure
> cabal new-build all
> ./dist-newstyle/build/x86_64-linux/ghc-8.4.3/fltkhs-hello-world-0.0.0.1/build/fltkhs-hello-world/fltkhs-hello-world
# The above path maybe a little different if you're not running GHC 8.4.3

@moll
Copy link
Author

moll commented Oct 10, 2018

Great, @deech! Thank you! You've been a good sport! I can't promise a quick confirmation as it unfortunately turned out FLTK didn't support rendering to an OpenGL buffer, but merely created the context for it. :/ I was initially under the impression FLTK was a great little library to use in a 3D game-ish project of mine.

I did give new-build itself a try today! Definitely better than Cabal's sandbox, but I couldn't find any tool to provide type checking for it. :( Neither Hdevtools nor the newer Haskell IDE Engine (internally using ghc-mod) support it. Definitely peculiar that the tooling section of the Haskell world moves so slowly. Do either of you use anything to go with your Vim/Emacs/Non-Vim-editor?

@deech
Copy link
Owner

deech commented Oct 10, 2018

Re: editors, I do use Emacs but have very little tooling turned on because they're usually fairly buggy.

Re: OpenGL, does this fit your needs https://github.com/deech/fltkhs-gl-demos/blob/master/src/fluid-triangle.hs#L19? It's just the famous triangle demo, FLTK seems to be doing more than creating a context.

@moll
Copy link
Author

moll commented Oct 10, 2018

I was more thinking of something in which you make your windows, buttons, pass a few keyboard and mouse events as input and get back an array of bytes to then send to the GPU. That's what I meant by "rendering to OpenGL". https://github.com/ocornut/imgui seems to be an example of that, although going with that would require me to dive into writing Haskell bindings, too. ^_^

@sboosali
Copy link
Contributor

sboosali commented Oct 10, 2018 via email

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