Giter VIP home page Giter VIP logo

Comments (2)

aherrmann avatar aherrmann commented on June 2, 2024

Thanks for raising this @antsareeverywhere. Do you have a minimal repro that you could share that illustrates the use of the feature?

rules_haskell implemenents most of the handling of CC libraries in this module. I'm not super familiar with the always link feature. Is it sufficient to handle the alwayslink field on LibraryToLink objects or is additional handling required?

Adding support for this to rules_haskell will probably require a bit of thought. rules_haskell relies on the extra-libraries field in the GHC package configuration file. I'm not sure if that has support for the alwayslink concept.

Essentially, the .lo files would need to be handled in the logic that passes arguments to GHC rather than the logic that generates Cabal files. Currently what happens is that haskell_library correctly detects the dependency, but adds it to the generated Cabal file as a linker argument.

Could you clarify what you mean by this? rules_haskell doesn't generate Cabal files. Are you referring to the GHC package configuration files, i.e. what's generated here?

from rules_haskell.

antsareeverywhere avatar antsareeverywhere commented on June 2, 2024

Do you have a minimal repro that you could share that illustrates the use of the feature?

As a minimal repro, you can add alwayslink = True to the cbits cc_library target of rules_haskell_tests/tests/indirect-link/BUILD.bazel. Then try building the indirect-link-static target. It will fail with a linker error about finding -ltests_Sindirect-link_Slibcbits.

Is it sufficient to handle the alwayslink field on LibraryToLink objects or is additional handling required?

Possibly, but I'm not certain. You fix the linking error above by explicitly adding the explicit path to intf.pic.o to the args returned by ghc_cc_program_args in cc.bzl. For example, lines 220-222 might look like

        cc + " -E -undef -traditional",
        "-optc-fno-stack-protector",
        "/home/foo/bar/rules_haskell/rules_haskell_tests/bazel-out/k8-fastbuild/bin/tests/indirect-link/_objs/cbits/intf.pic.o"
    ]

I found out which pic.o file to add here by calling nm bazel-out/k8-fastbuild/bin/tests/indirect-link/libcbits.lo from therules_haskell_tests directory. I believe the names of the pic.o files should be available as outputs of the appropriate action for cbits. You can see this, for example, by running

bazel aquery 'mnemonic("CppCompile",":cbits")' | grep Outputs

What I don't know is whether all the information that's available to Bazel is available in the CcInfo object of haskell_library dependencies. It looks to me like rules_haskell constructs a custom CcInfo object that may diverge from the object Bazel's rules_cc would create. It may be necessary to do work in the haskell_library implementation to pipe the appropriate info through.

rules_haskell doesn't generate Cabal files. Are you referring to the GHC package configuration files, i.e. what's generated here?

Yes sorry, that's my mistake. Once the appropriate pic.o files are passed to GHC, you would need to remove the dependency from the GHC package configuration files. AFAICT from the GHC package config documentation, GHC doesn't support .lo files, so they probably shouldn't be added there.

from rules_haskell.

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.