-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
When working on wasm_webgpu bindings library, I realized that after #19097 which landed for Emscripten 3.1.35, I needed to add these directives
which broke the JS library from working on Emscripten < 3.1.35, so in order to make the JS library work for different versions, I had to a backwards compatibility item to the library, that looks like this:
Maintaining that kind of backwards compatibility item is brittle and difficult, since if the upstream code changes in the future, the change won't appear for users who use the wasm_webgpu library.
So instead, what I would like to do is write something like
#if EMSCRIPTEN_VERSION >= 3.1.35
wgpu_object_get_label__deps: ['$stringToUTF8'],
#endif
to make the needed deps appear only for old Emscripten versions, or simply
#if EMSCRIPTEN_VERSION < 3.1.35
#error "lib_webgpu.js requires Emscripten 3.1.35 or newer"
#endif
to require developers to update to a newer version.
However looks like we don't have a construct that would allow implementing a EMSCRIPTEN_VERSION < 3.1.35 yet - seems like we should add one.
Any preferences on how the syntax would like to look?
Use the same kind of compacted version number like the MIN_xxx_VERSION fields?
#if EMSCRIPTEN_VERSION < 30135
or use the same names as C/C++ code gets as preprocessor:
#if __EMSCRIPTEN_major__*10000 + __EMSCRIPTEN_minor__*100 + __EMSCRIPTEN_tiny__ < 30135
or use function syntax?
#if EMSCRIPTEN_VERSION_LESS_THAN(3,1,35)
#if EMSCRIPTEN_VERSION_LESS_OR_EQUAL(3,1,35)
#if EMSCRIPTEN_VERSION_GREATER_THAN(3,1,35)
#if EMSCRIPTEN_VERSION_GREATER_OR_EQUAL(3,1,35)
or something else?
(I think I'd prefer the very first one)