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

pacman.d issue: emsdk not detected during libsokol build #21

Closed
Tracked by #3
kassane opened this issue May 17, 2024 · 3 comments
Closed
Tracked by #3

pacman.d issue: emsdk not detected during libsokol build #21

kassane opened this issue May 17, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@kassane
Copy link
Owner

kassane commented May 17, 2024

Source: https://github.com/kassane/pacman.d (WiP)
Zig version: 0.12.0 final-release (xtensa forked)

Based on my tests dub only, no detect libsokol (non-system installed), but build.zig get libsokol artifact.
dependency "sokol-d" version="~>0.1.1" added on dub.sdl allow get modules only.

On output log, first build works building libsokol and get artifact in zig-out/lib, only app.d get issues import modules (from zig build). However on second build, libsokol not build again!

Output - build error
kassane:~/pacman.d $ rm -fr $HOME/.cache/zig/ zig-*
kassane:~/pacman.d $ dub build
    Starting Performing "debug" build using ldmd2 for x86_64.
    Building pacman-d ~main: building configuration [application]
   Pre-build Running commands
source/app.d(132,13): Error: unable to read module `gfx`
source/app.d(132,13):        Expected 'sokol/gfx.d' or 'sokol/gfx/package.d' in one of the following import paths:
import path[0] = source
import path[1] = /home/kassane/.cache/zig/p/12200d0c1ce3d9e2307a194334cdaba3bcb88a886ee44438606bd794b08688d84984/src
import path[2] = /home/kassane/zig-bootstrap/out/host/include/d
install
└─ pacman-d failure
error: the following command exited with error code 1:
/home/kassane/zig-bootstrap/out/host/bin/ldmd2 -w -Isource -betterC -O -release -enable-inlining -boundscheck=off -vcolumns -od=/home/kassane/pacman.d/zig-cache/o/d8c8f831b0e6f7f92860b2aff0a57184 -cache=/home/kassane/pacman.d/zig-cache/o/d8c8f831b0e6f7f92860b2aff0a57184 -oq -cleanup-obj -disable-verify -Hkeep-all-bodies -i -I/home/kassane/.cache/zig/p/12200d0c1ce3d9e2307a194334cdaba3bcb88a886ee44438606bd794b08688d84984/src source/app.d -L--no-as-needed -L-lasound -L-lGL -L-lX11 -L-lXi -L-lXcursor -Xcc=-DIMPL -Xcc=-DSOKOL_GLCORE -Xcc=-DSOKOL_DISABLE_WAYLAND -mtriple=x86_64-linux-gnu -mcpu=znver3 -of=/home/kassane/pacman.d/zig-out/bin/pacman-d /home/kassane/pacman.d/zig-cache/o/eb86ede030492f794ca4b32415c29ce1/libsokol.a 
Build Summary: 2/4 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
└─ pacman-d failure
error: the following build command failed with exit code 1:
/home/kassane/pacman.d/zig-cache/o/fe086b2b08af9bc12832f25a6507766d/build /home/kassane/zig-bootstrap/out/zig-x86_64-xtensa-linux-musl-baseline/zig /home/kassane/pacman.d /home/kassane/pacman.d/zig-cache /home/kassane/.cache/zig --seed 0x8045aabf -Z5497817caa5574d4 -Doptimize=ReleaseFast
Error Command failed with exit code 1: zig build -Doptimize=ReleaseFast
kassane:~/pacman.d $ dub build
    Starting Performing "debug" build using ldmd2 for x86_64.
    Building pacman-d ~main: building configuration [application]
   Pre-build Running commands
thread 40333 panic: no dependency named 'emsdk' in '/home/kassane/.cache/zig/p/1220f76c0e3c7d6c885a15955635fa91685056e2aee47953d93a35434023438bd5ea/build.zig.zon'. All packages used in build.zig must be declared in this file
/home/kassane/zig-bootstrap/out/zig-x86_64-xtensa-linux-musl-baseline/lib/std/Build.zig:1846:20: 0x1147d84 in findPkgHashOrFatal (build)
    std.debug.panic("no dependency named '{s}' in '{s}'. All packages used in build.zig must be declared in this file", .{ name, full_path });
                   ^
/home/kassane/zig-bootstrap/out/zig-x86_64-xtensa-linux-musl-baseline/lib/std/Build.zig:1909:40: 0x11c0aaa in dependency__anon_15732 (build)
    const pkg_hash = findPkgHashOrFatal(b, name);
                                       ^
/home/kassane/.cache/zig/p/1220f76c0e3c7d6c885a15955635fa91685056e2aee47953d93a35434023438bd5ea/build.zig:196:31: 0x11bc57c in build (build)
    const emsdk = b.dependency("emsdk", .{});
                              ^
/home/kassane/zig-bootstrap/out/zig-x86_64-xtensa-linux-musl-baseline/lib/std/Build.zig:2080:43: 0x117d154 in runBuild__anon_14523 (build)
        .ErrorUnion => try build_zig.build(b),
                                          ^
/home/kassane/zig-bootstrap/out/zig-x86_64-xtensa-linux-musl-baseline/lib/std/Build.zig:2060:29: 0x11486a0 in dependencyInner__anon_13830 (build)
        sub_builder.runBuild(bz) catch @panic("unhandled error");
                            ^
/home/kassane/zig-bootstrap/out/zig-x86_64-xtensa-linux-musl-baseline/lib/std/Build.zig:1917:35: 0x10ff087 in dependency__anon_10199 (build)
            return dependencyInner(b, name, pkg.build_root, if (@hasDecl(pkg, "build_zig")) pkg.build_zig else null, pkg_hash, pkg.deps, args);
                                  ^
/home/kassane/pacman.d/build.zig:17:31: 0x10febee in build (build)
    const sokol = b.dependency("sokol", .{
                              ^
/home/kassane/zig-bootstrap/out/zig-x86_64-xtensa-linux-musl-baseline/lib/std/Build.zig:2080:43: 0x10da244 in runBuild__anon_8995 (build)
        .ErrorUnion => try build_zig.build(b),
                                          ^
/home/kassane/zig-bootstrap/out/zig-x86_64-xtensa-linux-musl-baseline/lib/compiler/build_runner.zig:300:29: 0x10d59b2 in main (build)
        try builder.runBuild(root);
                            ^
/home/kassane/zig-bootstrap/out/zig-x86_64-xtensa-linux-musl-baseline/lib/std/start.zig:511:37: 0x10bbc95 in posixCallMainAndExit (build)
            const result = root.main() catch |err| {
                                    ^
/home/kassane/zig-bootstrap/out/zig-x86_64-xtensa-linux-musl-baseline/lib/std/start.zig:253:5: 0x10bb7b1 in _start (build)
    asm volatile (switch (native_arch) {
    ^
???:?:?: 0x8 in ??? (???)
Unwind information for `???:0x8` was not available, trace may be incomplete

error: the following build command crashed:
/home/kassane/pacman.d/zig-cache/o/58c95f6c6e672909e796de237d77dacd/build /home/kassane/zig-bootstrap/out/zig-x86_64-xtensa-linux-musl-baseline/zig /home/kassane/pacman.d /home/kassane/pacman.d/zig-cache /home/kassane/.cache/zig --seed 0x9fda9645 -Z722b86ecb349f116 -Doptimize=ReleaseFast
Error Command failed with exit code 1: zig build -Doptimize=ReleaseFast

Maybe caused by

sokol-d/build.zig

Lines 74 to 82 in 018dc65

// one-time setup of Emscripten SDK
if (try emSdkSetupStep(b, options.emsdk.?)) |emsdk_setup| {
lib.step.dependOn(&emsdk_setup.step);
}
// add the Emscripten system include seach path
const emsdk_sysroot = b.pathJoin(&.{ emSdkPath(b, options.emsdk.?), "upstream", "emscripten", "cache", "sysroot" });
const include_path = b.pathJoin(&.{ emsdk_sysroot, "include" });
lib.addSystemIncludePath(.{ .path = include_path });
}

cc: @floooh

@kassane kassane added the bug Something isn't working label May 17, 2024
@kassane
Copy link
Owner Author

kassane commented May 17, 2024

Also dub get error on shaders, because dub read all modules (unused too):

$ dub build -v
Determined package version using GIT: pacman-d ~main
Scanning local packages...
  Missing dependency sokol-d 0.1.1 of pacman-d
Checking for missing dependencies.
Using fixed selection sokol-d 0.1.1
Dependency resolution result:
  sokol-d: 0.1.1
    Fetching sokol-d 0.1.1 (getting selected version)
Placing to User...
  Found dependency sokol-d 0.1.1
Generating using build
Configuring dependent pacman-d, deps:
    Starting Performing "debug" build using ldc2 for x86_64.
Target '/home/kassane/.dub/cache/pacman-d/~main/build/application-debug-uoJiaUxVVoeoAvGIMeNhoQ/pacman-d' doesn't exist, need rebuild.
    Building pacman-d ~main: building configuration [application]
   Pre-build Running commands
Running zig build -Doptimize=ReleaseFast -Ddub-artifact
Using direct -l... flags for sokol, X11, Xcursor, Xi, GL, asound.
ldc2 -d-debug -g -w --oq -od=/home/kassane/.dub/cache/pacman-d/~main/build/application-debug-uoJiaUxVVoeoAvGIMeNhoQ/obj -d-version=Have_pacman_d -d-version=Have_sokol_d -Isource/ -I../.dub/packages/sokol-d/0.1.1/sokol-d/src/ source/app.d source/data.d source/rom.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/examples/blend.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/examples/clear.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/examples/cube.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/examples/debugtext.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/examples/mrt.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/examples/saudio.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/examples/sgl_context.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/examples/sgl_points.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/examples/triangle.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/examples/user_data.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/handmade/math.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/shaders/blend.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/shaders/bufferoffsets.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/shaders/cube.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/shaders/instancing.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/shaders/mrt.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/shaders/noninterleaved.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/shaders/offscreen.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/shaders/quad.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/shaders/shapes.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/shaders/texcube.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/shaders/triangle.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/sokol/app.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/sokol/audio.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/sokol/debugtext.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/sokol/gfx.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/sokol/gl.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/sokol/glue.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/sokol/log.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/sokol/shape.d ../.dub/packages/sokol-d/0.1.1/sokol-d/src/sokol/time.d -preview=all -i -c -of/home/kassane/.dub/cache/pacman-d/~main/build/application-debug-uoJiaUxVVoeoAvGIMeNhoQ/pacman-d.o -vcolumns
../.dub/packages/sokol-d/0.1.1/sokol-d/src/shaders/texcube.d(66,21): Error: Global variable type does not match previous declaration with same mangled name: `VS_SOURCE_GLSL430`
../.dub/packages/sokol-d/0.1.1/sokol-d/src/shaders/texcube.d(66,21):        Previous IR type: [194 x i8], mutable, non-thread-local
../.dub/packages/sokol-d/0.1.1/sokol-d/src/shaders/texcube.d(66,21):        New IR type:      [374 x i8], mutable, non-thread-local
FAIL /home/kassane/.dub/cache/pacman-d/~main/build/application-debug-uoJiaUxVVoeoAvGIMeNhoQ pacman-d executable
Error ldc2 failed with exit code 1.

@kassane kassane mentioned this issue May 17, 2024
13 tasks
@kassane
Copy link
Owner Author

kassane commented May 17, 2024

Tested on zig 0.12.0 upstream - missing ZON
Note: cached build, re-run zig need zon file to read packages.

$ ~/Downloads/zig-linux-x86_64-0.12.0/zig build --summary new
source/app.d(157,14): `state` is thread local
Build Summary: 3/3 steps succeeded
install success
└─ pacman-d success 109ms MaxRSS:92M
   └─ zig build-lib sokol Debug native success 3s MaxRSS:223M
kassane:~/pacman.d $ ls $HOME/.cache/zig/p/1220f76c0e3c7d6c885a15955635fa91685056e2aee47953d93a35434023438bd5ea/
total 36
-rw-r--r-- 1 kassane kassane   941 2024-05-17 17:10 LICENSE
-rw-r--r-- 1 kassane kassane 30253 2024-05-17 17:10 build.zig
drwxr-xr-x 1 kassane kassane    56 2024-05-17 17:10 src

# fix (add zon file)
$ vim $HOME/.cache/zig/p/1220f76c0e3c7d6c885a15955635fa91685056e2aee47953d93a35434023438bd5ea/build.zig.zon
kassane:~/pacman.d $ ~/Downloads/zig-linux-x86_64-0.12.0/zig build --summary new
source/app.d(157,14): `state` is thread local
Build Summary: 3/3 steps succeeded
install success
└─ pacman-d success 79ms MaxRSS:77M

@kassane
Copy link
Owner Author

kassane commented May 18, 2024

Tested on zig 0.12.0 upstream - missing ZON

maybe fixed in commit: d391d1e - works \o/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant