Bug 108373

Summary: [harfbuzz] WebKit fails to build with MinGW compiler because of invalid cast in HarfBuzzShaper.cpp
Product: WebKit Reporter: tuxator
Component: PlatformAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, darin, dglazkov, d-r, kalevlember, mrobinson, peter+ews, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
proposed fix
none
Update for directory rename
eflews.bot: commit-queue-
don't ommit const
darin: review-
Patch updated with the changelog
none
updated none

Description tuxator 2013-01-30 13:19:23 PST
Build dies with the following error

  GEN      generate-testwebkitapi-forwarding-headers
  GEN      DerivedSources/JavaScriptCore/LLIntAssembly.h
offlineasm: Parsing ./Source/JavaScriptCore/llint/LowLevelInterpreter.asm and Programs/LLIntOffsetsExtractor.exe and creating assembly file DerivedSources/JavaScriptCore/LLIntAssembly.h.
offlineasm: No magic values found. Skipping assembly file generation.
make  all-am
make[1]: Wejście do katalogu `/home/pawel/src/webkit'
/usr/bin/mkdir -p ./.deps/DerivedSources
  CXX      Source/WebCore/platform/graphics/harfbuzz/ng/libWebCore_la-HarfBuzzShaper.lo
Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp: In member function 'bool WebCore::HarfBuzzShaper::shapeHarfBuzzRuns(bool)':
Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp:340:138: error: invalid conversion from 'const UChar* {aka const wchar_t*}' to 'const uint16_t* {aka const short unsigned int*}' [-fpermissive]
In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/harfbuzz/hb.h:32:0,
                 from Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.h:38,
                 from Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp:32:
/usr/i686-w64-mingw32/sys-root/mingw/include/harfbuzz/hb-buffer.h:230:1: error:   initializing argument 2 of 'void hb_buffer_add_utf16(hb_buffer_t*, const uint16_t*, int, unsigned int, int)' [-fpermissive]
Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp:342:167: error: invalid conversion from 'WTF::OwnArrayPtr<wchar_t>::PtrType {aka wchar_t*}' to 'const uint16_t* {aka const short unsigned int*}' [-fpermissive]
In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/harfbuzz/hb.h:32:0,
                 from Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.h:38,
                 from Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp:32:
/usr/i686-w64-mingw32/sys-root/mingw/include/harfbuzz/hb-buffer.h:230:1: error:   initializing argument 2 of 'void hb_buffer_add_utf16(hb_buffer_t*, const uint16_t*, int, unsigned int, int)' [-fpermissive]
make[1]: *** [Source/WebCore/platform/graphics/harfbuzz/ng/libWebCore_la-HarfBuzzShaper.lo] Błąd 1
make[1]: Opuszczenie katalogu `/home/pawel/src/webkit'
make: *** [all] Błąd 2
Comment 1 tuxator 2013-01-30 13:44:29 PST
Created attachment 185553 [details]
proposed fix
Comment 2 tuxator 2013-01-31 03:51:14 PST
Created attachment 185739 [details]
Update for directory rename
Comment 3 EFL EWS Bot 2013-01-31 03:58:36 PST
Comment on attachment 185739 [details]
Update for directory rename

Attachment 185739 [details] did not pass efl-ews (efl):
Output: http://queues.webkit.org/results/16266173
Comment 4 WebKit Review Bot 2013-01-31 04:11:51 PST
Comment on attachment 185739 [details]
Update for directory rename

Attachment 185739 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/16271193
Comment 5 Peter Beverloo (cr-android ews) 2013-01-31 04:22:10 PST
Comment on attachment 185739 [details]
Update for directory rename

Attachment 185739 [details] did not pass cr-android-ews (chromium-android):
Output: http://queues.webkit.org/results/16252352
Comment 6 tuxator 2013-01-31 04:23:45 PST
Created attachment 185745 [details]
don't ommit const
Comment 7 Martin Robinson 2013-02-04 11:37:47 PST
Comment on attachment 185745 [details]
don't ommit const

This kind of cast always makes me nervous.
Comment 8 Dominik Röttsches (drott) 2013-02-05 01:46:44 PST
(In reply to comment #0)
> Build dies with the following error
> 
>   GEN      generate-testwebkitapi-forwarding-headers
>   GEN      DerivedSources/JavaScriptCore/LLIntAssembly.h
> offlineasm: Parsing ./Source/JavaScriptCore/llint/LowLevelInterpreter.asm and Programs/LLIntOffsetsExtractor.exe and creating assembly file DerivedSources/JavaScriptCore/LLIntAssembly.h.
> offlineasm: No magic values found. Skipping assembly file generation.
> make  all-am
> make[1]: Wejście do katalogu `/home/pawel/src/webkit'
> /usr/bin/mkdir -p ./.deps/DerivedSources
>   CXX      Source/WebCore/platform/graphics/harfbuzz/ng/libWebCore_la-HarfBuzzShaper.lo
> Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp: In member function 'bool WebCore::HarfBuzzShaper::shapeHarfBuzzRuns(bool)':
> Source/WebCore/platform/graphics/harfbuzz/ng/HarfBuzzShaper.cpp:340:138: error: invalid conversion from 'const UChar* {aka const wchar_t*}' to 'const uint16_t* {aka const short unsigned int*}' [-fpermissive]

m_normalizedBuffer is declared as follow:
OwnArrayPtr<UChar> m_normalizedBuffer;
Are you sure you have a correctly sized UChar typedef/declaration on your platform? What configuration are you building? Does it match one of the bots?
Comment 9 tuxator 2013-02-05 09:07:57 PST
(In reply to comment #8)

> 
> m_normalizedBuffer is declared as follow:
> OwnArrayPtr<UChar> m_normalizedBuffer;
> Are you sure you have a correctly sized UChar typedef/declaration on your platform? What  configuration are you building? Does it match one of the bots?

I try to cross compile WebkitGTK for Windows using MinGW stack, there is no such build bot like
that as far as i know.
Comment 10 Dominik Röttsches (drott) 2013-02-05 09:23:46 PST
(In reply to comment #9)
> (In reply to comment #8)
> 
> > 
> > m_normalizedBuffer is declared as follow:
> > OwnArrayPtr<UChar> m_normalizedBuffer;
> > Are you sure you have a correctly sized UChar typedef/declaration on your platform? What  configuration are you building? Does it match one of the bots?
> 
> I try to cross compile WebkitGTK for Windows using MinGW stack, there is no such build bot like
> that as far as i know.

I would try to follow up why UChar/wchar_t is not matching uint16_t in this configuration, maybe there is something wrong with your build configuration of ICU.
Comment 11 Darin Adler 2013-03-06 09:13:40 PST
Comment on attachment 185745 [details]
don't ommit const

Change looks fine. Patch needs a change log.
Comment 12 Kalev Lember 2013-06-03 14:12:54 PDT
UChar is always defined as a 16 bit type. Depending on the build configuration, the exact type can vary, but it's always a 16 bit type.

In the GTK+/MinGW configuration, the preprocessor magic chooses it to be wchar_t, but only after making sure wchar_t is a 16 bit type.

Unfortunately, even though the source and target types are both 16 bit, gcc considers them to be different, so it needs an explicit reinterpret_cast.

From Source/JavaScriptCore/icu/unicode/umachine.h:
#if U_SIZEOF_WCHAR_T==2
    typedef wchar_t UChar;
#elif U_GNUC_UTF16_STRING
#if defined _GCC_
    typedef __CHAR16_TYPE__ char16_t;
#endif
    typedef char16_t UChar;
#else
    typedef uint16_t UChar;
#endif
Comment 13 tuxator 2013-06-03 14:45:29 PDT
Created attachment 203629 [details]
Patch updated with the changelog
Comment 14 Martin Robinson 2013-06-03 14:52:32 PDT
Comment on attachment 203629 [details]
Patch updated with the changelog

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

> Source/WebCore/ChangeLog:10
> +        No new tests (OOPS!).

You need to remove this line for the patch to pass the tools.
Comment 15 tuxator 2013-06-03 15:19:02 PDT
Created attachment 203631 [details]
updated
Comment 16 WebKit Commit Bot 2013-06-03 15:47:38 PDT
Comment on attachment 203631 [details]
updated

Clearing flags on attachment: 203631

Committed r151141: <http://trac.webkit.org/changeset/151141>
Comment 17 WebKit Commit Bot 2013-06-03 15:47:42 PDT
All reviewed patches have been landed.  Closing bug.