Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 4ed26b82fdb27bf273ff90a7026a46f958ce193a
https://github.com/WebKit/WebKit/commit/4ed26b82fdb27bf273ff90a7026a46f958ce193a
Author: Chris Dumez <[email protected]>
Date: 2026-04-23 (Thu, 23 Apr 2026)
Changed paths:
M Source/WebCore/CMakeLists.txt
M Source/WebCore/WebCoreMacros.cmake
M Source/WebCore/bindings/scripts/CodeGenerator.pm
M Source/WebCore/bindings/scripts/IDLParser.pm
M Source/WebCore/bindings/scripts/generate-bindings-all.pl
M Source/WebCore/bindings/scripts/generate-bindings.pl
M Source/WebCore/bindings/scripts/preprocess-idls.pl
M Source/WebCore/bindings/scripts/preprocessor.pm
M Source/WebCore/css/make-css-file-arrays.pl
M Source/WebCore/preprocess-localizable-strings.pl
M Source/WebKit/PlatformGTK.cmake
M Source/WebKit/PlatformWPE.cmake
M Source/cmake/WebKitCompilerFlags.cmake
Log Message:
-----------
Speed up IDL bindings generation build step
https://bugs.webkit.org/show_bug.cgi?id=312747
Reviewed by Sam Weinig.
This PR applies the following optimization to the IDL bindings generation
build step:
applyPreprocessor() unconditionally forks clang to preprocess every
file, even though most files don't contain C preprocessor directives.
For those files, reading and stripping comments in Perl avoids the
expensive fork+exec of clang/gcc (~25ms per invocation).
For the files that do use directives, they all follow simple
(including nesting), so evaluate these in Perl as well, eliminating all
clang invocations during the build step. This covers both IDL files
(25 out of ~1,823 use directives) and user agent CSS stylesheets.
Note: // line comments are only stripped for .idl files, not for CSS
files where // appears in URLs and is not a comment delimiter.
This reduces the generate-bindings-all.pl build step from 1 minute 36 seconds
to 21 seconds, on a M4 Max machine.
Additionally, remove the --preprocessor command-line option from all scripts
and the CODE_GENERATOR_PREPROCESSOR CMake variable. The CMake build was passing
an explicit preprocessor path (e.g. clang -E -P -x c++) that did exactly the
same thing the Xcode build was doing implicitly via a fallback default in
applyPreprocessor(). Since the Perl-based preprocessor now handles all cases,
there is no longer any need for an external preprocessor codepath.
* Source/WebCore/bindings/scripts/preprocessor.pm:
(applyPreprocessor): Handle preprocessing entirely in Perl: read the file,
strip comments (/* */ for all files, // only for .idl files), and if the
file contains preprocessor directives, evaluate them using
_evaluatePreprocessorDirectives instead of forking clang. Remove the
$preprocessor parameter and the _applyExternalPreprocessor function.
(_evaluatePreprocessorDirectives): Added. #if / #else / #endif evaluator
using a stack to track nesting.
(_evaluateCondition): Added. Evaluates preprocessor condition expressions
supporting conjunctions (&&), defined() checks, negation (!(...)), and
parenthesized sub-expressions.
* Source/WebCore/bindings/scripts/CodeGenerator.pm:
(new): Remove $preprocessor parameter.
* Source/WebCore/bindings/scripts/IDLParser.pm:
(Parse): Remove $preprocessor parameter.
* Source/WebCore/bindings/scripts/generate-bindings.pl: Remove --preprocessor
option.
* Source/WebCore/bindings/scripts/generate-bindings-all.pl: Remove
--preprocessor option.
* Source/WebCore/bindings/scripts/preprocess-idls.pl: Remove --preprocessor
option.
* Source/WebCore/css/make-css-file-arrays.pl: Remove --preprocessor option.
* Source/WebCore/preprocess-localizable-strings.pl: Remove --preprocessor
option.
* Source/WebCore/CMakeLists.txt: Remove --preprocessor from
make-css-file-arrays.pl invocation.
* Source/WebCore/WebCoreMacros.cmake: Remove --preprocessor from bindings
generation args.
* Source/WebKit/PlatformGTK.cmake: Remove --preprocessor from
make-css-file-arrays.pl invocation.
* Source/WebKit/PlatformWPE.cmake: Remove --preprocessor from
make-css-file-arrays.pl invocation.
* Source/cmake/WebKitCompilerFlags.cmake: Remove CODE_GENERATOR_PREPROCESSOR
variable.
Canonical link: https://commits.webkit.org/311901@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications