RFC: config/HaikuConfig.h conversion to const directives?

In my recent post on the WebAssembly Progress thread, I observed that preprocessor macros related to the configuration of the system would have to be converted to “const bool” symbols and #ifdef conditional compilation converted into conventional if statements in order to proceed with the experiment. This shouldn’t affect code quality because all current compiler versions do constant folding and dead-code elimination in their optimizers anyway.

The reason for this is that my experimental WebAssembly-based package manager improvement will need an additional step of having the “const bool” symbols implemented as “extern const bool” symbols so that the definitions will be deferred until the linker stage. This will, in turn, need link-time optimization added as a requirement to do the aforementioned constant folding and dead-code elimination passes when producing bytecode packages.

I’m willing to do the work with some guidance on the forums so it shouldn’t take much away from current efforts. At worst, this will be a fair amount of work for zero performance gain. At best, it will allow us to use one package format for all little-endian architectures and an additional package format for big-endian architectures won’t be too difficult either, once the first one is working.

The reason I’m asking for comments is that this will be a fairly invasive change of the source code and, if my fork of the OS build is successful, it will require some work to merge upstream. I’m assuming config/HaikuConfig.h macros are used throughout the API and affects changes in applications. What do you have to say as developers?

Gcc2 certainly does not do link time optimisations, and in gcc8 it is not enapled by default. Gcc2 is even not that great at dead code elimination in that case (I know because I had to patch some ffmpeg versions to use the preprocessor to do it).

So I don’t think this is a good idea.

1 Like

Ok, gotcha. My original suspicions about this not making it in time for beta 4 were correct. :slightly_frowning_face:

Follow up questions will be added in separate thread.