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

Fix adding module arguments for Step.Compile #19267

Merged
merged 3 commits into from
Jul 2, 2024

Conversation

PanSashko
Copy link
Contributor

The existing implementation adds the same module multiple times in the following case:

  1. Module app depends on the static library lib and the module mod.
// file: app/build.zig.zon
.{
    .name = "app",
    .version = "0.0.0",
    .dependencies = .{
        .lib = .{ .path = "../lib", },
        .mod = .{ .path = "../mod", },
    },
    .paths = .{ "" },
}
  1. Static library lib depends on the module mod too.
// file: lib/build.zig.zon
.{
    .name = "lib",
    .version = "0.0.0",
    .dependencies = .{
        .mod = .{ .path = "../mod", },
    },
    .paths = .{ "" },
}

The build fails with

error: error: unable to add module 'mod': already exists as 'mod.zig'

This PR fixed the above problem.

According to my limited understanding of the convoluted Zig build system, the proposed fix should not break any other uses of build dependencies.

@PanSashko
Copy link
Contributor Author

Sorry for recreating the PR. I used the master branch in my fork by mistake, and GitHub closes the PR on the master branch sync.

@PanSashko PanSashko force-pushed the compile-dup-mod branch 3 times, most recently from 7433d8a to 781323c Compare March 12, 2024 11:26
@PanSashko
Copy link
Contributor Author

PanSashko commented Mar 12, 2024

The test revealed another bug:

no dependency named 'mod' in '/home/ci/actions-runner1/_work/zig/zig/test/standalone/dep_duplicate_module/build.zig.zon'. All packages used in build.zig must be declared in this file

Manual build of the test "project" passes. The bug might be related to Builder.createChild(...).

I simplified the test to avoid using build.zig.zon. It should work now.

@PanSashko PanSashko force-pushed the compile-dup-mod branch 3 times, most recently from 73ab8fb to 77602a1 Compare March 17, 2024 08:01
@andrewrk andrewrk enabled auto-merge July 1, 2024 23:40
@andrewrk
Copy link
Member

andrewrk commented Jul 1, 2024

Thank you

@andrewrk andrewrk disabled auto-merge July 2, 2024 05:10
@andrewrk andrewrk merged commit fed8d90 into ziglang:master Jul 2, 2024
9 of 10 checks passed
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

Successfully merging this pull request may close these issues.

3 participants