Giter Club home page Giter Club logo

Comments (11)

facundominguez avatar facundominguez commented on May 25, 2024

Hello. The haskell_binary call is not passing "-pie" to ghc. The BUILD file shows how to do it, but not the example in the readme. I will mention it in the readme.

from clodl.

mboes avatar mboes commented on May 25, 2024

https://github.com/tweag/clodl#usage talks about the PIE requirement, but the binary_closure section should be made consistent with this later section.

from clodl.

lunaris avatar lunaris commented on May 25, 2024

Hi both. Thanks very much for responding to this. So I've added -pie (and -dynamic and -threaded, though those too appear to already be in the generated command line) to both my haskell_binary and, when that failed, to the haskell_library it depends on, to no avail. I then set about seeing if perhaps I needed to play the bootstrap trick you are playing in this repository (in which you export a cc_library of GHC's RTS includes and make main a weak symbol), but before I did so thought I'd check in here to see whether or not that's an expected requirement.

from clodl.

facundominguez avatar facundominguez commented on May 25, 2024

The bootstrap bit shoudn't be necessary. At least bazel run clotestbin doesn't use it and works in CI.

If you have a repo to share (or a gist or whatever), I could have a look.

from clodl.

lunaris avatar lunaris commented on May 25, 2024

I've created https://github.com/lunaris/bazel-example, which I think is a reproduction of the issue I'm seeing. It depends on a few common Haskell libraries to make sure there are a variety of cbits etc. floating around -- you can try and build a closure using bazel build //engine:test-closure. Many thanks!

from clodl.

facundominguez avatar facundominguez commented on May 25, 2024

Adding -rdynamic to compiler_flags fixes it for me. But I don't understand yet why it isn't necessary in the clodl repo.

from clodl.

lunaris avatar lunaris commented on May 25, 2024

Interesting. Is it perhaps that your bootstrapping stuff references main in a way that means it is considered a "used" symbol whereas in my example that recognition is missing for some reason?

from clodl.

facundominguez avatar facundominguez commented on May 25, 2024

That would explain it for the cases where we use the bootstrap library. But it also works without it.

from clodl.

facundominguez avatar facundominguez commented on May 25, 2024

That would explain it for the cases where we use the bootstrap library. But it also works without it.

I was wrong. Linking bootstrap does have an effect here, and we are always linking bootstrap.

Linking bootstrap into hello-hs includes main in the table of dynamic symbols:

$ nm -D bazel-bin/hello-hs | grep main
                 U hs_main
                 U __libc_start_main
00000000000024d3 T main

But if we don't link bootstrap, main is missing.

$ nm -D bazel-bin/engine/test-bin | grep main
                 U hs_main
                 U __libc_start_main

We will have to update the documentation to account for this. We either ask -rdynamic, or -Wl,--dynamic-list=<file with a list of symbols including main>. Also, we can test if the input binary defines main when using binary_closure and suggest in the error message one of these alternatives.

from clodl.

lunaris avatar lunaris commented on May 25, 2024

Thanks so much for helping out with this!

from clodl.

facundominguez avatar facundominguez commented on May 25, 2024

You're welcome. Thanks for reporting the issue and putting the testing repo together.

from clodl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.