Bug 244840 - [GLib] Recording build options and provide a way of inspecting them
Summary: [GLib] Recording build options and provide a way of inspecting them
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-06 04:55 PDT by Adrian Perez
Modified: 2022-09-06 05:15 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian Perez 2022-09-06 04:55:00 PDT
Given that the GTK and WPE ports can be configured with a number of options
enabled or disabled at the packager's discretion, we have sometimes found
that replicating some build configuration for debugging, or figure out
what is going on with a reported issue it would be desirable to be able
to know whether certain build options (e.g. USE_OPENJPEG, ENABLE_WEB_RTC,
USE_ANGLE_WEBGL, and so on) were enabled.

This is particularly important with the WPE port, where embedded deployments
may include heavily customized builds that even toggle options which we do not
officially support changing (like ENABLE_VIDEO), or where web views may be
headless and checking the output from webkit://gpu can be quite hard.
Comment 1 Adrian Perez 2022-09-06 05:07:03 PDT
My suggestion here would be to have CMake generate a preprocessor
symbol which expands to a string that contains the list of CMake
build options which have a non-default value. Listing all would make
the list quite long, and we are only really interested in on-default
values (we can always check the defaults from the source code).

Then, I would add a new webkit_get_version_string() function which
would return said string concatenated after the version numbers.
Basically, this:

  const char* webkit_get_version_string(void) {
      return STRINGIZE(WEBKIT_MAJOR_VERSION) "."
             STRINGIZE(WEBKIT_MINOR_VERSION) "."
             STRINGIZE(WEBKIT_MICRO_VERSION)
             WEBKIT_NONDEFAULT_CMAKE_OPTIONS_STRING;
  }

The WEBKIT_NONDEFAULT_CMAKE_OPTIONS_STRING would be a series of
zero or more space-and-option-name items, alphabetically sorted,
e.g. " -DENABLE_WEB_RTC=ON -DUSE_ANGLE_WEBGL=OFF -DUSE_AVIF=OFF".
This way the output from printing webkit_get_version_string() can
be almost copied as-is into a CMake command line.

Also I think we would need to always include -DDEVELOPER_MODE=ON
and -DENABLE_EXPERIMENTAL_FEATURES=ON in case they are enabled,
because they affect the default values of build options.
Comment 2 Adrian Perez 2022-09-06 05:15:01 PDT
On ELF targets we could also add a main() symbol to the WebKit library
which jsut does “printf("%s\n", webkit_get_version_string())”, which will
be ignored when the library is loaded as a dependency for some executable,
but which will run if the library is executed as if it were a program.
Some libraries have done this kind of thing for decades, for example the
GNU C library:

  % /usr/lib/libc.so.6 | head -1       
  GNU C Library (GNU libc) stable release version 2.36.
  %

Although we may as well skip this bit. As long as the build options
string ends up somewhere in the library, one can always run “strings”
on it to find the build options without even running anything.