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

Build not picking up external libraries #674

Closed
locallycompact opened this issue Jun 11, 2020 · 11 comments
Closed

Build not picking up external libraries #674

locallycompact opened this issue Jun 11, 2020 · 11 comments

Comments

@locallycompact
Copy link
Contributor

Hi, I'm trying to get the result of stack-to-nix to build the vulkan libraries but it does not seem to be able to pick it up. I have in package.yaml

extra-libraries:
- vulkan-headers

which seems to generate

libs = [ (pkgs."vulkan-headers" or (sysDepError "vulkan-headers")) ];

but I still get a build error that is package not found.

Source: https://gitlab.com/shakebook-site/shakebook-site.gitlab.io/-/tree/staging/vulkan
Error: https://gitlab.com/shakebook-site/shakebook-site.gitlab.io/-/jobs/591709328

@angerman
Copy link
Collaborator

You will need to open a PR like #669, I'm afraid I don't know which nix package provides the vulkan-headers. You'll essentially need to provide haskell.nix with a mapping of the library name to the corresponding nix pkg that provides the data.

If the extra-libraries name matches the package name in nix, it will work automatically, if not, we need a mapping.

@locallycompact
Copy link
Contributor Author

The package name in nix is vulkan-headers so I'm not sure what more has to happen.

@michaelpj
Copy link
Collaborator

I think the problem is that http://hackage.haskell.org/package/VulkanMemoryAllocator-0.3.2/VulkanMemoryAllocator.cabal doesn't declare any dependency on a vulkan-headers C library.

@expipiplus1
Copy link
Contributor

It's a little weird, vulkan-headers isn't a library, it is just the C header vulkan.h, so there wouldn't be anything to link to if it was specified as a c-library. Perhaps there's something which could be done with pkg-config here?

In nixpkgs it's handled by adding this dependency explicitly NixOS/nixpkgs@53594c6

@michaelpj
Copy link
Collaborator

Cabal lets you state pkg-conf dependencies, perhaps that's what should happen?

@locallycompact
Copy link
Contributor Author

I tried forking it and adding that to the cabal file but it says no vulkan-headers found.

Fork of vulkan: https://github.com/locallycompact/vulkan/blob/master/VulkanMemoryAllocator/VulkanMemoryAllocator.cabal#L62
CI: https://gitlab.com/shakebook-site/shakebook-site.gitlab.io/-/jobs/593421904

@expipiplus1
Copy link
Contributor

Sorry, suggesting pkg-config was not the right thing to do, as vulkan-headers doesn't have any pkg-config information associated

The important question to answer is: how are non-library build time dependencies supposed to be specified?

@jkopanski
Copy link
Contributor

I think the correct way is to use cabal pkgconfig-depends field, and move vulkan mapping from lib/system-nixpkgs-map.nix to lib/pkgconf-nixpkgs-map.nix.

vulkan-loader on nixpkgs is pkgconfig aware and is pulling in vulkan-headers already. Recently it was changed so vulkan-loader pkgconfig populates includedir for headers as well. This just isn't available on 20.03.

Doing that cabal finds vulkan header.

@expipiplus1
Copy link
Contributor

It surprises me that there is no equivalent of addBuildDepend in haskell.nix. It would be a good solution here.

Strictly speaking: VulkanMemoryAllocator doesn't depend on vulkan-loader, just vulkan-headers. (That being said it does depend on haskellPackages.vulkan which depends (for now) on vulkan-loader so the dependency tree wouldn't be made any bigger)

Additionally vulkan-loader doesn't seem to install vulkan-headers on other OSs (such as arch https://www.archlinux.org/packages/extra/x86_64/vulkan-icd-loader/) (assuming I'm reading the .PKGINFO correctly).

I'm open to any change to the Haskell VMA package as long as it doesn't impact compilation on other OSs or with the nixpkgs Haskell infrastructure. In particular compilation with stack on Windows is quite fragile as the mingw vulkan-loader installed by stack doesn't work and mustn't be linked against. I'm not sure if a pkgconfig dependency would cause that to be linked instead of (or in addition to) the library installed by the SDK; of course this isn't haskell.nix's concern, but might be useful to anyone looking to change things on the package side.

@stale
Copy link

stale bot commented Sep 28, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 28, 2022
@hamishmack
Copy link
Collaborator

I think this was by #1001. It is annoying there was not a way to set the headers as an input before pkg-config support was included by vulkan. I think that issue is covered by #679 though.

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

6 participants