Bug 203142

Summary: [Clang][Windows] Options.cpp(317,25): error: no matching function for call to 'optionTypeSpecificIndex'
Product: WebKit Reporter: Fujii Hironori <Hironori.Fujii>
Component: JavaScriptCoreAssignee: Fujii Hironori <Hironori.Fujii>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, keith_miller, mark.lam, msaboff, saam, tzagallo, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
compilation error
none
Patch
none
Patch none

Description Fujii Hironori 2019-10-17 22:24:52 PDT
Created attachment 381272 [details]
compilation error

Since r251226 (Bug 202105)
Clang-cl 8 can't compile WinCairo trunk.


> FAILED: Source/JavaScriptCore/CMakeFiles/JavaScriptCore.dir/runtime/Options.cpp.obj 
> C:\PROGRA~1\LLVM\bin\clang-cl.exe  (...) -c ..\..\Source\JavaScriptCore\runtime\Options.cpp
> ..\..\Source\JavaScriptCore\runtime\Options.cpp(294,12): error: variables defined in a constexpr function must be initialized
>     size_t index;
>            ^
> ..\..\Source\JavaScriptCore\runtime\Options.cpp(317,25): error: no matching function for call to 'optionTypeSpecificIndex'
>     FOR_EACH_JSC_OPTION(DEFINE_OPTION_ACCESSORS)
>     ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
> ..\..\Source\JavaScriptCore\runtime/OptionsList.h(124,5): note: expanded from macro 'FOR_EACH_JSC_OPTION'
>     v(Bool, useKernTCSM, true, Normal, "Note: this needs to go before other options since they depend on this value.") \
>     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ..\..\Source\JavaScriptCore\runtime\Options.cpp(311,49): note: expanded from macro 'DEFINE_OPTION_ACCESSORS'
>         return g_jscConfig.type##type_##Options[optionTypeSpecificIndex<OptionTypeID::type_, OptionID::name_>()]; \
>                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ..\..\Source\JavaScriptCore\runtime\Options.cpp(292,18): note: candidate template ignored: substitution failure [with type = JSC::OptionTypeID::Bool, id = JSC::OptionID::useKernTCSM]
> constexpr size_t optionTypeSpecificIndex()
>                  ^
Comment 1 Fujii Hironori 2019-10-17 23:12:37 PDT
Created attachment 381277 [details]
Patch
Comment 2 Mark Lam 2019-10-17 23:21:24 PDT
Comment on attachment 381277 [details]
Patch

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

> Source/JavaScriptCore/ChangeLog:8
> +        clang-cl reported a compilation error for MSVC bug workaournd code of optionTypeSpecificIndex.

/workaournd/workaround/

> Source/JavaScriptCore/runtime/Options.cpp:294
> +#if COMPILER(CLANG) // for clang-cl

Is both COMPILER(CLANG) and COMPILER(MSVC) true at the same time for MSVC with Clang backend?  Note that this snippet of code is wrapped in a #if COMPILER(MSVC).
Comment 3 Mark Lam 2019-10-17 23:24:26 PDT
Comment on attachment 381277 [details]
Patch

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

> Source/JavaScriptCore/runtime/Options.cpp:297
>      size_t index;

I wonder if we can just change this to "size_t index = 0;" and keep the "index = 0;" below as well.  Would that appease both clang and the MSVC backend?
Comment 4 Fujii Hironori 2019-10-17 23:36:54 PDT
Comment on attachment 381277 [details]
Patch

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

>> Source/JavaScriptCore/runtime/Options.cpp:294
>> +#if COMPILER(CLANG) // for clang-cl
> 
> Is both COMPILER(CLANG) and COMPILER(MSVC) true at the same time for MSVC with Clang backend?  Note that this snippet of code is wrapped in a #if COMPILER(MSVC).

Yes. clang-cl compiles the almost same code path with MSVC.

>> Source/JavaScriptCore/runtime/Options.cpp:297
>>      size_t index;
> 
> I wonder if we can just change this to "size_t index = 0;" and keep the "index = 0;" below as well.  Would that appease both clang and the MSVC backend?

Will try.
Comment 5 Fujii Hironori 2019-10-18 00:17:17 PDT
Created attachment 381281 [details]
Patch
Comment 6 Fujii Hironori 2019-10-18 01:30:24 PDT
Committed r251276: <https://trac.webkit.org/changeset/251276>
Comment 7 Radar WebKit Bug Importer 2019-10-18 01:31:21 PDT
<rdar://problem/56400312>