-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Fix for -lGL
+ AUTO_NATIVE_LIBRARIES=0
#14337
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
Conversation
a608686
to
b89154e
Compare
tests/test_other.py
Outdated
|
||
def test_explict_gl_linking(self): | ||
# ensure libgl exists | ||
self.run_process([EMBUILDER, 'build', 'libgl']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if embuilder isn't run here? wouldn't we build the library automatically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. As of today if you use NO_AUTO_NATIVE_LIBRARIES
there is no way to trigger the auto-building of the affected libraries (libgl, libal, libhtml5). I think we can fix that as part of #14341
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(this PR doesn't change that)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force pushes make it hard to see, but is the addition of NO_AUTO_NATIVE_LIBRARIES
new? Or did I just miss it before?
Regardless, why is it here? Wouldn't the test be shorter without it, as we could delete the above line?
If the reasoning is that NO_AUTO_NATIVE_LIBRARIES
gives us an error if we try to use a missing library, and the point of the test is to check for that error, how does this avoid the library already existing because it was built by the test harness (or another test) before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NO_AUTO_NATIVE_LIBRARIES
was always there.
And yes I can not remove the line above your are right. Sorry about that.
The reason that NO_AUTO_NATIVE_LIBRARIES
is needed is because -lGL
was previously failing in that mode (NO_AUTO_NATIVE_LIBRARIES
is enabled in strict mode which is more common than the almost unknown/unused NO_AUTO_NATIVE_LIBRARIES
).
Before:
-sSTRING -lGL
-> link failure because to interpret -lGL
as being just about JS libraries
After:
-sSTRICT -lGL
-> link success because we find and use the native library.
a91b043
to
c662994
Compare
Removed hacky comment and workaround. This should be good to go now. |
tools/building.py
Outdated
@@ -1339,7 +1339,6 @@ def is_wasm_dylib(filename): | |||
def map_to_js_libs(library_name): | |||
# Some native libraries are implemented in Emscripten as system side JS libraries | |||
library_map = { | |||
'c': [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it safe to remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its not just safe, but essential if we want to continue to allow folks to do -lc
on the command line.
The reason is that previously we would search for libc.a on the filesystem before looking in this map. With this change we call map_to_js_libs first, so this would cause -lc
to be ignored, which we don't want.
In practice anyone who passes -lc
today might not get the correct version of libc, but that was true both before and after this change. To fix that issue we have #14355, although that issue is completely separate to this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am having a hard time understanding this. How is, say, libc
(which is removed here) different from libdl
(which is not)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
libdl
and libm
don't exist under musl, since they all get rolled into libc
. So the libdl
and libm
cases here are different because we really do want them to be no-ops.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are pretending to have -ldl
support for compat with glibc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, how about comments on each one explaining the issues? Sorry, but this is all quite unclear to me. Maybe this is just part of the codebase I am unfamiliar with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree.. that would be more clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After rebasing on top of #14382 perhaps this is more clear now?
982bc5e
to
483091e
Compare
690236f
to
7b3716a
Compare
17240e5
to
c77b6c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks a lot better! But still, I don't get the test, see comment...
tests/test_other.py
Outdated
|
||
def test_explict_gl_linking(self): | ||
# ensure libgl exists | ||
self.run_process([EMBUILDER, 'build', 'libgl']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force pushes make it hard to see, but is the addition of NO_AUTO_NATIVE_LIBRARIES
new? Or did I just miss it before?
Regardless, why is it here? Wouldn't the test be shorter without it, as we could delete the above line?
If the reasoning is that NO_AUTO_NATIVE_LIBRARIES
gives us an error if we try to use a missing library, and the point of the test is to check for that error, how does this avoid the library already existing because it was built by the test harness (or another test) before?
Rebased onto refactor #14384 |
Side note, the github UI seems to be hitting a bug here... you responded in detail to my previous comment (thanks!) but it does not show up on this page, nor on the file contents page. It makes sense not to be there, since the file was updated around the comment. But it's like your response is gone, with even the "conversations" tab not allowing access to it... I had to find the email to me to re-read it. |
When calling `map_to_js_libs('GL')` we were mapping this to the JS libraries, and not also including the native `libgl` library. Normally this doesn't matter since `libgl` is included by default, but not when `AUTO_NATIVE_LIBRARIES=0` is used. This also happens to fix an old bug (#10171) where we would look on the file system for `libGL.a` before looking in `map_to_js_libs`. Fixes: #10171 Fixes: #14335
When calling
map_to_js_libs('GL')
we were mapping this to the JSlibraries, and not also including the native
libgl
library. Normallythis doesn't matter since
libgl
is included by default, but notwhen
AUTO_NATIVE_LIBRARIES=0
is used.This also happens to fix an old bug (#10171) where we would look on the
file system for
libGL.a
before looking inmap_to_js_libs
.Fixes: #10171
Fixes: #14335