Skip to content

Conversation

@ypujante
Copy link
Contributor

As I was working on another port, something that should not be working was working... so I investigated and found an issue. The contrib port ended up overriding the built-in GLFW in the cache.

After this fix it doesn't happen anymore:

# ls -la cache/sysroot/include/GLFW
-rw-r--r--@ 1 ypujante  wheel  215860 Mar 21 12:54 glfw3.h
# ls -la cache/sysroot/include/contrib.glfw3/GLFW
-rw-r--r--@ 1 ypujante  wheel    6219 Mar 21 12:54 emscripten_glfw3.h
-rw-r--r--@ 1 ypujante  wheel  241826 Mar 21 12:54 glfw3.h

As you can see after the fix the 2 directories contain different versions of glfw3.h (which is expected since as you know I upgraded the contrib port to GLFW 3.4).

When you run the emcc command, you can see that the search path is set properly:

/usr/local/emsdk/emscripten/main/emcc --verbose --use-port=contrib.glfw3 --shell-file=shell.html main.cpp -o build/index.html
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/emsdk/emscripten/main/cache/sysroot/include/contrib.glfw3
 /usr/local/emsdk/emscripten/main/cache/sysroot/include/fakesdl
 /usr/local/emsdk/emscripten/main/cache/sysroot/include/compat
 /usr/local/emsdk/emscripten/main/cache/sysroot/include/c++/v1
 /usr/local/emsdk/upstream/lib/clang/19/include
 /usr/local/emsdk/emscripten/main/cache/sysroot/include

So when a source code includes

#include <GLFW/glfw3.h>

then it will pick up the right one under cache/sysroot/include/contrib.glfw3 (and not the one under cache/sysroot/include which is last in the list)

This fix requires a minor change in ports.install_headers to allow for nested folders (which BTW, I also need for another project I am working on)

@sbc100 sbc100 merged commit 86b6aff into emscripten-core:main Mar 22, 2024
@ypujante ypujante deleted the contrib-glfw3-wrong-include branch December 15, 2024 18:18
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.

2 participants