-
Notifications
You must be signed in to change notification settings - Fork 125
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
building emscripten: "No emscripten cache. Generate it!" #134
Comments
oh! I made a mistake with "editing raylib/src/build.zig" -- now that I've changed it to this: const cache_include = std.fs.path.join(b.allocator, &.{ b.sysroot.?, "include" }) catch @panic("Out of memory");
defer b.allocator.free(cache_include);
var dir = std.fs.cwd().openDir(cache_include, std.fs.Dir.OpenDirOptions{ .access_sub_paths = true, .no_follow = true }) catch @panic("No emscripten cache. Generate it!");
dir.close();
raylib.addIncludePath(.{ .cwd_relative = cache_include }); my new error is this: > zig build run -Dtarget=wasm32-emscripten --sysroot ~/.emscripten_cache/sysroot
run
└─ run /home/pancelor/.emscripten_cache/sysroot/emrun
└─ run /home/pancelor/.emscripten_cache/sysroot/emcc failure
error: unable to spawn /home/pancelor/.emscripten_cache/sysroot/emcc: FileNotFound
Build Summary: 6/9 steps succeeded; 1 failed (disable with --summary none) This makes sense, |
more progress!
|
Ok, so far this doesn't look like a raylib-zig issue. Could you try adding raylib as a dependency directly and building without raylib-zig in between? If the error persists, please take this to the raylib repo (you can reference this issue there, I'm also looking into main raylib issues occasionally) |
For me it was:
|
@pancelor could you check if these steps work for you, and if so open an issue on the raylib repo? |
I tried adding I don't think the |
I think I'm done trying to make this work for now; here's my thoughts on what I think should happen. I realize that just writing them here doesn't do much, but it seems best to write them somewhere, and I don't have the social energy right now to start an additional issue in the raylib repo, so I'll write my thoughts here and then close this.
|
I am unsure what the point of this file is, so maybe I should not be removing it. But the comment says to try removing it to see if things work fine, and things work fine on my machine when I remove it. I tested 3 or 4 of the builtin examples using commands like this: zig build raw_stream -Dtarget=wasm32-emscripten --sysroot ~/.emscripten_cache/sysroot (see also Not-Nik#134; my sysroot setup is a bit weird. but I don't think that would affect this at all)
I think I like the "emcc as a dependency" thing, but this has to start at a raylib level. I can add a small patch that just attempts to find emcc in the PATH, but that won't fix your cache issue. In the meantime I can't even get an emscripten build going WITH emsdk, so I can't work on this too much. |
I am unsure what the point of this file is, so maybe I should not be removing it. But the comment says to try removing it to see if things work fine, and things work fine on my machine when I remove it. I tested 3 or 4 of the builtin examples using commands like this: zig build raw_stream -Dtarget=wasm32-emscripten --sysroot ~/.emscripten_cache/sysroot (see also #134; my sysroot setup is a bit weird. but I don't think that would affect this at all)
This is going to be a bit of a rambling issue; sorry about that. I'm confused about what exactly the problem is here, there's too many things going on that I'm unfamiliar with.
tl;dr
I don't have
emsdk
but I do have the manjaroemscripten
package; I think raylib is hard-coded to assume I have emsdk, and it's causing problems when try to build for web. But I'm not really certain about anything and don't know the best way to fix it.emsdk
I'm running Manjaro Linux, and I have the emscripten package installed:
This installed
emcc
etc for me:> emcc -v emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.61-git (67fa4c16496b157a7fc3377afd69ee0445e8a6e3) clang version 19.0.0git (/startdir/llvm-project 7cfffe74eeb68fbb3fb9706ac7071f8caeeb6520) Target: wasm32-unknown-emscripten Thread model: posix InstalledDir: /opt/emscripten-llvm/bin
When I run
> ls $(dirname $(which emcc))
I see various other executables, likeem++
,emrun
,emstrip
. But I don't have emsdk (> which emsdk
says "emsdk not found")My best guess about what's going on here is that emsdk is "a small package manager for controlling which tools are installed" , and Manjaro doesn't want another package manager around, so the manjaro
emscripten
package is meant to replace any need for havingemsdk
.zig build ... emscripten
My project uses zig 0.13.0 and a recent version of this library (raylib-zig). My build file is minimally modified from the example project, and includes these lines:
I tried to build it with
> zig build run -Dtarget=wasm32-emscripten
but gotpanic: Pass '--sysroot "$EMSDK/upstream/emscripten"'
. But, I don't have EMSDK!> echo $EMSDK
prints nothing.I figured out where my emscripten cache is by running
> emcc main.c
on a simple Hello World program:Alright, so then I tried
> zig build run -Dtarget=wasm32-emscripten --sysroot ~/.emscripten_cache/sysroot
but this fails with "panic: No emscripten cache. Generate it!"This is coming from raylib/src/build.zig, which seems to be assuming that my cache is managed by emsdk? This line:
const cache_include = std.fs.path.join(b.allocator, &.{ b.sysroot.?, "cache", "sysroot", "include" }) catch @panic("Out of memory")
.I think this means it's looking for
~/.emscripten_cache/sysroot/cache/sysroot/include
on my machine and not finding it, because it doesn't exist. I think it should be looking for~/.emscripten_cache/sysroot/include
instead, but it's hard-coded to assume I have emsdk, which I don't.editing
raylib/src/build.zig
I tried hacking at
raylib/src/build.zig
and using this:which worked(?) but is now giving me
error: 'stdlib.h' file not found
,error: 'math.h' file not found
, etc. pretty similar to #108. Maybe I didn't "fully" generate the emscripten cache somehow, and I need to flesh it out somehow? But,> ls ~/.emscripten_cache/sysroot/include/stdlib.h
finds the file -- it exists.edit: ah! my bad, I needed
b.sysroot.? ++ "/include"
. well, not that exact syntax; see my comment belowquestions
raylib/src/build.zig
? I did that above but I feel like I'm probably making this way harder somehowwhy do I get(edit: resolved, see below)error: 'stdlib.h' file not found
, when then file exists?The text was updated successfully, but these errors were encountered: