<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>267080</bug_id>
          
          <creation_ts>2024-01-04 07:35:01 -0800</creation_ts>
          <short_desc>FEATURE_DEFINES_WITH_SPACE_SEPARATOR is fragile</short_desc>
          <delta_ts>2024-01-11 07:35:04 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKitGTK</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=267123</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Anne van Kesteren">annevk</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bugs-noreply</cc>
    
    <cc>emw</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>mike</cc>
    
    <cc>ntim</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2002959</commentid>
    <comment_count>0</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2024-01-04 07:35:01 -0800</bug_when>
    <thetext>We started auto-generating more selector parsing code and that ends up depending on this define. However, as I found in bug 266947 what this define includes is a subset of all environment variables (which the Cocoa build process provides) and as such subtle bugs can occur where parsing certain pseudo-classes and pseudo-elements won&apos;t work on Glib platforms for inexplicable reasons.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2002983</commentid>
    <comment_count>1</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2024-01-04 10:11:15 -0800</bug_when>
    <thetext>In particular GTK enables INPUT_TYPE_DATE but at this point in processing that hasn&apos;t been translated to enabling DATE_AND_TIME_INPUT_TYPES it seems, but some pseudo-elements do depend on that. As a result the pseudo-elements that depend on that end up being unsupported.

I&apos;ve hacked around this as this seems like a general flaw in this setup.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2003017</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2024-01-04 14:05:17 -0800</bug_when>
    <thetext>In this comment:

https://github.com/WebKit/WebKit/pull/22274#discussion_r1442124307

I found the problem is just that the feature isn&apos;t defined properly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2003018</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2024-01-04 14:07:50 -0800</bug_when>
    <thetext>That is, FEATURE_DEFINES_WITH_SPACE_SEPARATOR only contains features that actually exist. To declare a feature, you have to use WEBKIT_OPTION_DEFINE(). This can be done in WebKitFeatures.cmake for cross-platform features, or Options*.cmake for port-specific features.

tbh I don&apos;t think there&apos;s any real problem with FEATURE_DEFINES_WITH_SPACE_SEPARATOR. And I cannot think of any way to enforce that new feature flags are created properly. If we forget to define the flag for CMake, there&apos;s not really anything that CMake can do about that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2003123</commentid>
    <comment_count>4</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2024-01-04 23:46:30 -0800</bug_when>
    <thetext>I think the problem is that these scripts that generate C++ don&apos;t just expect ENABLE() defines, it can be anything that follows `#if`. And that won&apos;t work for Glib platforms.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2003145</commentid>
    <comment_count>5</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2024-01-05 03:00:19 -0800</bug_when>
    <thetext>This is also true when they are used in html.css it seems:

https://github.com/WebKit/WebKit/pull/22424</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2003153</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2024-01-05 04:54:42 -0800</bug_when>
    <thetext>(In reply to Anne van Kesteren from comment #4)
&gt; I think the problem is that these scripts that generate C++ don&apos;t just
&gt; expect ENABLE() defines, it can be anything that follows `#if`. And that
&gt; won&apos;t work for Glib platforms.

There&apos;s nothing special about GLib here. Surely it won&apos;t work for the macOS/Windows/PlayStation CMake builds either?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2003155</commentid>
    <comment_count>7</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2024-01-05 04:58:37 -0800</bug_when>
    <thetext>Is it possible to change the script to fail if we use a conditional value and it&apos;s not defined to either 0 or 1?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2003178</commentid>
    <comment_count>8</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2024-01-05 09:05:07 -0800</bug_when>
    <thetext>Maybe? That code predated Tim and I touching the script and is also present in other scripts. I&apos;m also not sure how much more time I can put into this issue, especially as vacation time is nearly over.

It also won&apos;t help with the code introduced in html.css, right?

I think you are correct that it&apos;s not technically a CMake problem, but CMake builds will continue to run into subtle issues due to this mismatch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2003195</commentid>
    <comment_count>9</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2024-01-05 10:54:42 -0800</bug_when>
    <thetext>(In reply to Anne van Kesteren from comment #8)
&gt; Maybe? That code predated Tim and I touching the script and is also present
&gt; in other scripts. I&apos;m also not sure how much more time I can put into this
&gt; issue, especially as vacation time is nearly over.

Ah! Well it&apos;s certainly not your job to fix every bug, especially if you are doing so during vacation time.

&gt; It also won&apos;t help with the code introduced in html.css, right?

Hmm, I wonder how this file works at all? At first I thought it was a misnamed template file that&apos;s used to generate the real html.css and which should be renamed to html.css.in. But checking Source/WebCore/CMakeLists.txt, I see that no, it&apos;s just really the actual final html.css that gets processed by WebKit. That seems really weird? I have no clue how this file is supposed to work, because no command removes the build guards.

I suspect this is a completely separate problem, actually. This html.css just doesn&apos;t make sense. Am I missing something?

To make it actually work, we could preprocess html.css using unifdef, passing FEATURE_DEFINES_WITH_SPACE_SEPARATOR to unifdef.

&gt; I think you are correct that it&apos;s not technically a CMake problem, but CMake
&gt; builds will continue to run into subtle issues due to this mismatch.

Well it&apos;s impossible for CMake to define values that it doesn&apos;t know about, so ultimately they&apos;re going to have to be defined one way or another if a script wants to use them. WEBKIT_OPTION_DEFINE() is surely the best way to do that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2003724</commentid>
    <comment_count>10</comment_count>
    <who name="Elliott Williams">emw</who>
    <bug_when>2024-01-08 16:57:20 -0800</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #7)
&gt; Is it possible to change the script to fail if we use a conditional value
&gt; and it&apos;s not defined to either 0 or 1?

This is what came to mind for me too. I think it would be more intuitive for the script to act like a normal preprocessor with -Wundef enabled. That probably means passing _all_ of the known features into the FEATURE_DEFINES_WITH_SPACE_SEPARATOR string, using `FEATURE_NAME=0` to denote disabled features.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2003815</commentid>
    <comment_count>11</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2024-01-09 06:21:29 -0800</bug_when>
    <thetext>Agreed.

Currently the lists FEATURE_DEFINES and FEATURE_DEFINES_WITH_SPACE_SEPARATOR are populated in WEBKIT_OPTION_END. Unfortunately only values that are enabled are added.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>