JS: bitfields and flags are inconsistent between platforms
We have some consistency issues between platforms for code generated by the JavaScript backends.
On nodejs we have some operations that return bitfields, such as the stat.st_mode
field with file type information. On nodejs we can interpret the flags using the constants defined in the fs.constants
object. This contains the correct bits for the platform that the nodejs instance is running on.
However, we also have some haskell code in .hsc
files that interprets the bits directly. The bits/masks for the .hsc
files come from the emsdk toolchain, and can be different from those of the platform that node.js is running on.
The way to solve this:
- always convert flags/bits produced by node.js operating system specific code to the layout that is consistent with emsdk, before returning the values to Haskell code
- always expect emsdk values for flags from Haskell code, convert them to the appropriate node.js flags just before calling the node.js API.
- use the autoconf tooling and C preprocessor to retrieve flag/mask information from emsdk to use in the JavaScript code. Values may change between emsdk versions and we have to make sure that the
.js
and.hsc
files are always consistent with the emsdk version that we're building with
I have a mostly working fix for this (at least for the base
library), but it touches much of the same code as !10918 (merged), which should be merged first.