Bug 208711

Summary: REGRESSION(r257975): [GTK][WPE] Build failure after a clean build
Product: WebKit Reporter: Carlos Alberto Lopez Perez <clopez>
Component: WebKitGTKAssignee: Yusuke Suzuki <ysuzuki>
Status: RESOLVED FIXED    
Severity: Normal CC: aakash_jain, annulen, aperez, bugs-noreply, cdumez, commit-queue, ews-watchlist, gyuyoung.kim, Hironori.Fujii, pnormand, ryuan.choi, saam, sergio, stephan.szabo, webkit-bot-watchers-bugzilla, ysuzuki
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=205107
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

Description Carlos Alberto Lopez Perez 2020-03-06 07:36:12 PST
A build failure happens on GTK and WPE after a clean build in r257995 (this is the revision I'm testing; doesn't mean it caused it.. it may have been a previous issue, the failure doesn't trigger if you build continuously instead from a clean build)

It has been detected in the EWS bots since those bots do a clean build after a patch doesn't build, but the bots at build.webkit.org always build continously

The failure is this one:

Sources/WebCore/JSInternalSettingsGenerated.cpp.o.d -o Source/WebCore/CMakeFiles/WebCoreTestSupport.dir/__/__/DerivedSources/WebCore/JSInternalSettingsGenerated.cpp.o -c DerivedSources/WebCore/JSInternalSettingsGenerated.cpp
DerivedSources/WebCore/JSInternalSettingsGenerated.cpp: In static member function ‘static JSC::IsoSubspace* WebCore::JSInternalSettingsGenerated::subspaceForImpl(JSC::VM&)’:
DerivedSources/WebCore/JSInternalSettingsGenerated.cpp:5927:30: error: ‘class WebCore::DOMIsoSubspaces’ has no member named ‘m_subspaceForInternalSettingsGenerated’; did you mean ‘m_subspaceForInternalSettings’?
     if (auto* space = spaces.m_subspaceForInternalSettingsGenerated.get())
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                              m_subspaceForInternalSettings
DerivedSources/WebCore/JSInternalSettingsGenerated.cpp:5931:16: error: ‘class WebCore::DOMIsoSubspaces’ has no member named ‘m_subspaceForInternalSettingsGenerated’; did you mean ‘m_subspaceForInternalSettings’?
         spaces.m_subspaceForInternalSettingsGenerated = makeUnique<IsoSubspace> ISO_SUBSPACE_INIT(vm.heap, vm.destructibleObjectHeapCellType.get(), JSInternalSettingsGenerated);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                m_subspaceForInternalSettings
DerivedSources/WebCore/JSInternalSettingsGenerated.cpp:5933:16: error: ‘class WebCore::DOMIsoSubspaces’ has no member named ‘m_subspaceForInternalSettingsGenerated’; did you mean ‘m_subspaceForInternalSettings’?
         spaces.m_subspaceForInternalSettingsGenerated = makeUnique<IsoSubspace> ISO_SUBSPACE_INIT(vm.heap, vm.cellHeapCellType.get(), JSInternalSettingsGenerated);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                m_subspaceForInternalSettings
DerivedSources/WebCore/JSInternalSettingsGenerated.cpp:5934:26: error: ‘class WebCore::DOMIsoSubspaces’ has no member named ‘m_subspaceForInternalSettingsGenerated’; did you mean ‘m_subspaceForInternalSettings’?
     auto* space = spaces.m_subspaceForInternalSettingsGenerated.get();
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                          m_subspaceForInternalSettings


And its tricky because it only triggers once, and if you try to re-build after it has triggered then it will build fine. So it only fails once :? That also explain why the EWS its only failing for patches not failing to build (because it triggers clean build after a patch fails to build), but on those building fine it will pass since it tries the patch from a previous rebuild.

So to trigger this you have to test always from a clean build.
Comment 1 Carlos Alberto Lopez Perez 2020-03-06 07:44:36 PST
(In reply to Carlos Alberto Lopez Perez from comment #0)
> A build failure happens on GTK and WPE after a clean build in r257995 (this
> is the revision I'm testing; doesn't mean it caused it.. it may have been a
> previous issue, the failure doesn't trigger if you build continuously
> instead from a clean build)
> 

This has been caused by r257975
I tried to revert r257975 locally and the issue is gone (a clean builds works now).
Comment 2 Carlos Alberto Lopez Perez 2020-03-06 07:46:19 PST
BTW, I don't have time today to fix this. Feel free to pick it if you wish. I'm only reporting the issue.

It will be nice to have this fixed ASAP as it causing issues on the GTK and WPE EWS. The EWS are unable to determine when a patch fails to build because of the patch or because of a previous failure because the clean build without patch that they try at the end fails due to this.
Comment 3 Carlos Alberto Lopez Perez 2020-03-06 11:02:04 PST
I triggered a clean build on the GTK and WPE release buildbots at build.webkit.org. As I was expecting this happened:

* Clean build at r257995 ordered failed: https://build.webkit.org/builders/GTK%20Linux%2064-bit%20Release%20%28Build%29/builds/30766
* Next build that happened at r257996 worked because it was not a clean build, but a continuous build from the previous state https://build.webkit.org/builders/GTK%20Linux%2064-bit%20Release%20%28Build%29/builds/30767

And the issue seems gone there, as the bot continues to do continuous builds. But the problem remains. This issue only triggers the first time you build from clean.
Comment 4 Ryan Haddad 2020-03-06 11:25:36 PST
Yusuke, could you take a look at this?
Comment 5 Yusuke Suzuki 2020-03-06 13:53:23 PST
My guess is that this is caused because dependency from the first generate-bindings-all.pl to InternalSettingsGenerated.idl is not set in CMake.
Comment 6 Yusuke Suzuki 2020-03-06 14:22:49 PST
Created attachment 392773 [details]
Patch
Comment 7 Yusuke Suzuki 2020-03-06 14:23:53 PST
Speculative attempt to fix.
Comment 8 Yusuke Suzuki 2020-03-06 15:12:49 PST
Comment on attachment 392773 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=392773&action=review

> Source/WebCore/WebCoreMacros.cmake:209
> +    add_custom_command(${target}

And I think we should use add_custom_target.
Comment 9 Aakash Jain 2020-03-06 15:16:16 PST
(In reply to Yusuke Suzuki from comment #7)
> Speculative attempt to fix.

https://ews-build.webkit.org/#/builders/8/builds/17679/steps/8/logs/stdio

CMake Error at Source/WebCore/WebCoreMacros.cmake:209 (add_custom_command):
  add_custom_command Wrong syntax.  Unknown type of argument.
Comment 10 Stephan Szabo 2020-03-06 15:26:09 PST
Comment on attachment 392773 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=392773&action=review

>> Source/WebCore/WebCoreMacros.cmake:209
>> +    add_custom_command(${target}
> 
> And I think we should use add_custom_target.

Possibly, but add_custom_target has no output file, so you have to be careful with using the output file as a dependency to other things since it doesn't exist at generation time and there's no rule specifically creating it.
We might be able to get both with add_custom_command (specifying no target) and then add_custom_target(${target} DEPENDS [output file from the add_custom_command]).
Comment 11 Konstantin Tokarev 2020-03-06 15:37:57 PST
Comment on attachment 392773 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=392773&action=review

>>> Source/WebCore/WebCoreMacros.cmake:209
>>> +    add_custom_command(${target}
>> 
>> And I think we should use add_custom_target.
> 
> Possibly, but add_custom_target has no output file, so you have to be careful with using the output file as a dependency to other things since it doesn't exist at generation time and there's no rule specifically creating it.
> We might be able to get both with add_custom_command (specifying no target) and then add_custom_target(${target} DEPENDS [output file from the add_custom_command]).

What is this change supposed to do? It doesn't look like a correct invocation of add_custom_command(), ${target} is likely just ignored.
And no, we shouldn't use add_custom_target here.
Comment 12 Konstantin Tokarev 2020-03-06 15:39:58 PST
Comment on attachment 392773 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=392773&action=review

> Source/WebCore/ChangeLog:3
> +        REGRESSION(r257975): [GTK][WPE] Build failure after a clean build

Seems like it's actually not a regression from r257975, but an issue introduced much earlier
Comment 13 Yusuke Suzuki 2020-03-06 15:40:41 PST
I think the problem here is that CMake ports are not properly setting dependencies between InternalSettingGenerated.idl and GENERATE_BINDINGS. So in some way, we need to represent dependencies.
Maybe, we should place InternalSettingsGenerated.idl as an output of this add_custom_command.
Comment 14 Yusuke Suzuki 2020-03-06 15:41:32 PST
Created attachment 392791 [details]
Patch
Comment 15 Yusuke Suzuki 2020-03-06 15:44:56 PST
(In reply to Yusuke Suzuki from comment #14)
> Created attachment 392791 [details]
> Patch

Some speculative attempts since I don't have any environments using CMake WebCore right now.
Comment 16 Konstantin Tokarev 2020-03-06 16:43:25 PST
Comment on attachment 392791 [details]
Patch

Still doesn't work here. I guess .idl file should be main product and not Settings.h, as it's needed earlier (or idl generation should depend on Setting.h, but that would be illogical)
Comment 17 Konstantin Tokarev 2020-03-06 16:48:47 PST
Got it: GENERATE_SETTINGS_MACROS takes 2 arguments, but is given 3, and idl file is just ignored
Comment 18 Stephan Szabo 2020-03-06 17:58:30 PST
(In reply to Konstantin Tokarev from comment #17)
> Got it: GENERATE_SETTINGS_MACROS takes 2 arguments, but is given 3, and idl
> file is just ignored

Handling the two outfiles in GENERATE_SETTINGS_MACROS didn't seem to be enough locally at least on wincairo, unless I also made GENERATE_BINDINGS set a DEPENDS on the input and pp input files in its add_custom_target. I'm not sure if that's a reasonable set of dependencies to set there.
Comment 19 Konstantin Tokarev 2020-03-06 19:28:18 PST
Created attachment 392840 [details]
Patch
Comment 20 Yusuke Suzuki 2020-03-06 21:23:09 PST
Comment on attachment 392840 [details]
Patch

Looks nice.
Comment 21 Fujii Hironori 2020-03-06 21:32:08 PST
Comment on attachment 392840 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=392840&action=review

> Source/WebCore/WebCoreMacros.cmake:209
> +    add_custom_target(${_target}

I think add_custom_target makes it won’t stop recompiling.
Comment 22 Fujii Hironori 2020-03-07 00:04:33 PST
Created attachment 392853 [details]
Patch
Comment 23 WebKit Commit Bot 2020-03-07 01:17:07 PST
Comment on attachment 392853 [details]
Patch

Clearing flags on attachment: 392853

Committed r258068: <https://trac.webkit.org/changeset/258068>
Comment 24 WebKit Commit Bot 2020-03-07 01:17:09 PST
All reviewed patches have been landed.  Closing bug.
Comment 25 Konstantin Tokarev 2020-03-07 08:20:49 PST
Comment on attachment 392853 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=392853&action=review

> Source/WebCore/WebCoreMacros.cmake:210
> +        OUTPUT ${WebCore_DERIVED_SOURCES_DIR}/${_outfile} ${_extra_output}

This change reverts https://bugs.webkit.org/show_bug.cgi?id=163774. I wasn't involved with that patch, so I didn't dare to do this.
Fujii, is it intentional?
Comment 26 Konstantin Tokarev 2020-03-07 08:25:05 PST
Comment on attachment 392853 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=392853&action=review

>> Source/WebCore/WebCoreMacros.cmake:210
>> +        OUTPUT ${WebCore_DERIVED_SOURCES_DIR}/${_outfile} ${_extra_output}
> 
> This change reverts https://bugs.webkit.org/show_bug.cgi?id=163774. I wasn't involved with that patch, so I didn't dare to do this.
> Fujii, is it intentional?

AFAIU, it introduces race condition in parallel build
Comment 27 Fujii Hironori 2020-03-07 12:19:48 PST
Comment on attachment 392853 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=392853&action=review

>>> Source/WebCore/WebCoreMacros.cmake:210
>>> +        OUTPUT ${WebCore_DERIVED_SOURCES_DIR}/${_outfile} ${_extra_output}
>> 
>> This change reverts https://bugs.webkit.org/show_bug.cgi?id=163774. I wasn't involved with that patch, so I didn't dare to do this.
>> Fujii, is it intentional?
> 
> AFAIU, it introduces race condition in parallel build

Good point. I forgot it completely.

It was a CMake Visual Studio generator specific issue.
Ninja generator builds aren't affected.

And, the issue was fixed in CMake 3.12.
https://gitlab.kitware.com/cmake/cmake/issues/16767
https://gitlab.kitware.com/cmake/cmake/commit/5a6c6292898fe238f3a5105133b8904209fbedaf

All Windows ports are using newer CMake for Visual Studio 2019 support.
Actually, WebKit CMake scripts relies on the fix to avoid unnecessary recompilation.

However, I realize one problem related to it. Will fix it in another ticket.
Comment 28 Fujii Hironori 2020-03-07 14:05:51 PST
(In reply to Fujii Hironori from comment #27)
> However, I realize one problem related to it. Will fix it in another ticket.

Filed : Bug 208771 – [CMake][Win] GenerateSettings.rb are invoked twice in WebCoreBindings.vcxproj and WebCoreTestSupportBindings.vcxproj