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

[embind] Using EMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0 fails with polymorphic types #21619

Open
sbc100 opened this issue Mar 26, 2024 · 4 comments · Fixed by #21621
Open

[embind] Using EMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0 fails with polymorphic types #21619

sbc100 opened this issue Mar 26, 2024 · 4 comments · Fixed by #21621
Assignees

Comments

@sbc100
Copy link
Collaborator

sbc100 commented Mar 26, 2024

The EMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0 feature seems to not work with polymorphic types.

Adding a flavor of other.test_embind that builds with EMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0 causes the test to fail with:

Error: expected: PolyDerived, actual: PolyBase
    at Object.assert.equal (/usr/local/google/home/sbc/dev/wasm/emscripten/out/test/embind_test.js:6055:18)
    at Object.<anonymous> (/usr/local/google/home/sbc/dev/wasm/emscripten/out/test/embind_test.js:6688:20)
    at runTest (/usr/local/google/home/sbc/dev/wasm/emscripten/out/test/embind_test.js:5887:23)
    at run_all (/usr/local/google/home/sbc/dev/wasm/emscripten/out/test/embind_test.js:5907:26)
    at run_all_tests (/usr/local/google/home/sbc/dev/wasm/emscripten/out/test/embind_test.js:6410:5)
    at Object.<anonymous> (/usr/local/google/home/sbc/dev/wasm/emscripten/out/test/embind_test.js:9366:5)
    at Module._compile (node:internal/modules/cjs/loader:1196:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
    at Module.load (node:internal/modules/cjs/loader:1074:32)
    at Function.Module._load (node:internal/modules/cjs/loader:909:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:22:47
error: Error: expected: PolyDerived, actual: PolyBase
    at Object.assert.equal (/usr/local/google/home/sbc/dev/wasm/emscripten/out/test/embind_test.js:6055:18)
    at Object.<anonymous> (/usr/local/google/home/sbc/dev/wasm/emscripten/out/test/embind_test.js:6688:20)
    at runTest (/usr/local/google/home/sbc/dev/wasm/emscripten/out/test/embind_test.js:5887:23)
    at run_all (/usr/local/google/home/sbc/dev/wasm/emscripten/out/test/embind_test.js:5907:26)
    at run_all_tests (/usr/local/google/home/sbc/dev/wasm/emscripten/out/test/embind_test.js:6410:5)
    at Object.<anonymous> (/usr/local/google/home/sbc/dev/wasm/emscripten/out/test/embind_test.js:9366:5)
    at Module._compile (node:internal/modules/cjs/loader:1196:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1250:10)
    at Module.load (node:internal/modules/cjs/loader:1074:32)
    at Function.Module._load (node:internal/modules/cjs/loader:909:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:22:47 {
  info: { Expected: 'PolyDerived', Actual: 'PolyBase' }
}

I believe this is because getLightTypeID() is able to inspect the type of a value when EMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES is enabled but other wise it only looks at the type T and not the value:

if (has_unbound_type_names) {
#if __has_feature(cxx_rtti)
return &typeid(value);
#else
static_assert(!has_unbound_type_names,
"Unbound type names are illegal with RTTI disabled. "
"Either add -DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0 to or remove -fno-rtti "
"from the compiler arguments");
#endif
}
return LightTypeID<T>::get();

@sbc100
Copy link
Collaborator Author

sbc100 commented Mar 26, 2024

It looks like when this feature was first added we only used the LightTypeID when the type was not polymorphic: 2bbdb0c

However this check was removed in #10914

@sbc100
Copy link
Collaborator Author

sbc100 commented Mar 26, 2024

@brendandahl

@sbc100
Copy link
Collaborator Author

sbc100 commented Mar 26, 2024

@dnfield it seems like the assumption of #10914 is that all cases should work find without RTTI. If that is true why do we have the rtti mode still? Why not default to not -DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0 and no rtti usage.

However, based on the above failure, I'm not sure this assumption is true.

@sbc100
Copy link
Collaborator Author

sbc100 commented Mar 26, 2024

CC @chadaustin

sbc100 added a commit to sbc100/emscripten that referenced this issue Mar 26, 2024
Automatic downcasting of polymorphic types in embind has been broken
without rtti since emscripten-core#10914 landed.

This test update confirms this brokenness rather than fixing it since
this as has been the behavior since 2020.

Fixes: emscripten-core#21619
sbc100 added a commit to sbc100/emscripten that referenced this issue Mar 26, 2024
Automatic downcasting of polymorphic types in embind has been broken
without rtti since emscripten-core#10914 landed.

This test update confirms this brokenness rather than fixing it since
this has been the behavior since 2020.

Fixes: emscripten-core#21619
sbc100 added a commit to sbc100/emscripten that referenced this issue Mar 27, 2024
Automatic downcasting of polymorphic types in embind has been broken
without rtti since emscripten-core#10914 landed.

This test update confirms this brokenness rather than fixing it since
this has been the behavior since 2020.

Fixes: emscripten-core#21619
sbc100 added a commit to sbc100/emscripten that referenced this issue Mar 27, 2024
Automatic downcasting of polymorphic types in embind has been broken
without rtti since emscripten-core#10914 landed.

This test update confirms this brokenness rather than fixing it since
this has been the behavior since 2020.

Fixes: emscripten-core#21619
sbc100 added a commit to sbc100/emscripten that referenced this issue Mar 27, 2024
Automatic downcasting of polymorphic types in embind has been broken
without rtti since emscripten-core#10914 landed.

This test update confirms this brokenness rather than fixing it since
this has been the behavior since 2020.

Fixes: emscripten-core#21619
sbc100 added a commit that referenced this issue Mar 27, 2024
Automatic downcasting of polymorphic types in embind has been broken
without rtti since #10914 landed.

This test update confirms this brokenness rather than fixing it since
this has been the behavior since 2020.

Fixes: #21619
@sbc100 sbc100 reopened this Mar 27, 2024
@sbc100 sbc100 self-assigned this Mar 27, 2024
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 a pull request may close this issue.

1 participant