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

Package manager: Build needs to include dynamic libraries as dependencies as Step #16172

Closed
edyu opened this issue Jun 24, 2023 · 7 comments
Closed
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management
Milestone

Comments

@edyu
Copy link
Contributor

edyu commented Jun 24, 2023

Zig Version

0.11.0-dev.3777+64f0059cd

Steps to Reproduce and Observed Behavior

Currently where is no way to install the dependencies (let's say A) of a package B as part of package C if C depends on B.
Say package A is a library written in another language and that exposes a dynamic library A.so.
Let's say B is a Zig wrapper for A so B needs A.so to work. B build ok with build.zig. B even installs A.so as part of the install step.

Now, say C is using the B wrapper but C cannot build because it will need A.so but by using the package manager, it can only use things such as Artifact or Module which are Compile.Step not Install.Step so there is no way for C to compile or install A.so (since C cannot touch anything other than the artifact of B) as part of C output.

right now we can do C.installLibraryHeaders(dep.artifact("B")) but not C.installLibrary(dep.install("B")) if A.so is part of B's install step.

Expected Behavior

I think there are two things:

  1. There should be a way to expose other Steps in addition to Compile.Step.
  2. There should be a way to include Install.Step as part of dependency just like how artifact is used so Install.Step should be part of Artifact as well.
@edyu edyu added the bug Observed behavior contradicts documented or intended behavior label Jun 24, 2023
@matu3ba
Copy link
Contributor

matu3ba commented Jun 24, 2023

Suggestion: Change title to ".. include dynamic libraries as dependencies as Step".
This graphic might be simpler do understand:

Let packages A, B, C be denoted by PA, PB, PC.

         depends_on                        depends_on
    PA ◄──────────────────────── PB ◄─────────────────────── PC
 (create A.so)   (binding to dynamic lib A.so)               │
     ▲                                                       │
     └───────────────────────────────────────────────────────┘
               depends on generated A.so, but there is no Step
               `C.installLibrary(dep.install("B"))` to install A.so
               into PC.

@edyu edyu changed the title Package manager: Build artifact needs to have a way to include dependencies Package manager: Build needs to include dynamic libraries as dependencies as Step Jun 28, 2023
@edyu
Copy link
Contributor Author

edyu commented Jun 28, 2023

Suggestion: Change title to ".. include dynamic libraries as dependencies as Step". This graphic might be simpler do understand:

Let packages A, B, C be denoted by PA, PB, PC.

         depends_on                        depends_on
    PA ◄──────────────────────── PB ◄─────────────────────── PC
 (create A.so)   (binding to dynamic lib A.so)               │
     ▲                                                       │
     └───────────────────────────────────────────────────────┘
               depends on generated A.so, but there is no Step
               `C.installLibrary(dep.install("B"))` to install A.so
               into PC.

Thank you. Done. Changed the Title.

@edyu
Copy link
Contributor Author

edyu commented Jun 28, 2023

I was told by @InKryption that #14731 might fix this.

@edyu
Copy link
Contributor Author

edyu commented Jul 2, 2023

So my problem statement is simple. I’d like to be able to incorporate the dynamic library in my build but separate the dynamic library and the wrapper in their respective packages separate from the main project.

If I separate them into 3 projects, then libduckdb.so doesn’t get exposed to the next layer using either artifact nor module.

@edyu
Copy link
Contributor Author

edyu commented Jul 2, 2023

Project A, libduckdb needs to expose libduckdb.so
Project B, libduck needs to be built based on libduckdb.so and expose both libduck.a and libduckdb.so
Project C needs to be built using both libduck.a and libduckdb.so
Basically, just like how the current build system allows you to use addLibraryHeaders(), I need a way to have something similar like addDynamicLibraries().

In addition, for project A, there should be a way to not require either a source code or a linking step in order to create an artifact. An artifact can also be a set of steps that “copies” over files to destination directory.

For project C, the dynamic library libduckdb.so needs to be part of the artifact of project C to be part of the destination directory.

@andrewrk andrewrk added zig build system std.Build, the build runner, `zig build` subcommand, package management enhancement Solving this issue will likely involve adding new logic or components to the codebase. and removed bug Observed behavior contradicts documented or intended behavior labels Jul 22, 2023
@andrewrk andrewrk added this to the 0.12.0 milestone Jul 22, 2023
@andrewrk andrewrk modified the milestones: 0.13.0, 0.12.0 Aug 5, 2023
@glyh
Copy link

glyh commented Aug 31, 2023

Run into the same issue when trying to fit libpcre.zig into zon's ecosystem. I would like to help, could you provide some instructions? Thanks.

@andrewrk
Copy link
Member

This use case has finally been addressed in #18160 which landed in 289ae45.

Now you can attach dynamic libraries to a Module in the build system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management
Projects
None yet
Development

No branches or pull requests

4 participants