Bug 101179 - Build failure with ICU 50 and C++11 because of a different UChar definition
Summary: Build failure with ICU 50 and C++11 because of a different UChar definition
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-04 21:51 PST by Arfrever Frehtes Taifersar Arahesis
Modified: 2018-05-08 20:27 PDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arfrever Frehtes Taifersar Arahesis 2012-11-04 21:51:35 PST
When GCC >=4.7 (or another compiler supporting C++11) is used, then UChar type from ICU 50 is a typedef to char16_t instead of unsigned short int. This results in compilation failure in WebKit.

To reproduce this bug, you must:
1. Build ICU 50 using GCC >=4.7. ICU will automatically be built with -std=c++11 flag.
2. Build WebKit with -std=c++11 (or -std=gnu++11) manually added to CXXFLAGS.

Compilation failure does not occur with ICU 49 or older.

Last lines from `make`:

  CXX      Source/JavaScriptCore/API/libjavascriptcoregtk_3_0_la-JSBase.lo
  CXX      Source/JavaScriptCore/API/libjavascriptcoregtk_3_0_la-JSCallbackConstructor.lo
  CXX      Source/JavaScriptCore/API/libjavascriptcoregtk_3_0_la-JSCallbackFunction.lo
  CXX      Source/JavaScriptCore/API/libjavascriptcoregtk_3_0_la-JSCallbackObject.lo
  CXX      Source/JavaScriptCore/API/libjavascriptcoregtk_3_0_la-JSClassRef.lo
  CXX      Source/JavaScriptCore/API/libjavascriptcoregtk_3_0_la-JSContextRef.lo
  CXX      Source/JavaScriptCore/API/libjavascriptcoregtk_3_0_la-JSObjectRef.lo
  CXX      Source/JavaScriptCore/API/libjavascriptcoregtk_3_0_la-JSStringRef.lo
Source/JavaScriptCore/API/JSStringRef.cpp: In function ‘OpaqueJSString* JSStringCreateWithCharacters(const JSChar*, size_t)’:
Source/JavaScriptCore/API/JSStringRef.cpp:39:50: error: invalid conversion from ‘const JSChar* {aka const short unsigned int*}’ to ‘const UChar* {aka const char16_t*}’ [-fpermissive]
In file included from Source/JavaScriptCore/API/JSStringRef.cpp:30:0:
Source/JavaScriptCore/API/OpaqueJSString.h:44:39: error:   initializing argument 1 of ‘static WTF::PassRefPtr<OpaqueJSString> OpaqueJSString::create(const UChar*, unsigned int)’ [-fpermissive]
Source/JavaScriptCore/API/JSStringRef.cpp: In function ‘const JSChar* JSStringGetCharactersPtr(JSStringRef)’:
Source/JavaScriptCore/API/JSStringRef.cpp:75:31: error: invalid conversion from ‘UChar* {aka char16_t*}’ to ‘const JSChar* {aka const short unsigned int*}’ [-fpermissive]
make[1]: *** [Source/JavaScriptCore/API/libjavascriptcoregtk_3_0_la-JSStringRef.lo] Error 1
Comment 1 Alexey Proskuryakov 2012-11-05 10:32:04 PST
Could you please post a snippet of how exactly ICU 5.0 defines UChar?
Comment 2 Jonathan Wakely 2012-11-05 11:02:49 PST
(In reply to comment #1)
> Could you please post a snippet of how exactly ICU 5.0 defines UChar?

See http://gcc.gnu.org/ml/gcc-help/2012-11/msg00018.html
Comment 3 Arfrever Frehtes Taifersar Arahesis 2012-11-05 11:23:48 PST
(In reply to comment #1)
> ICU 5.0

Versioning of ICU has changed since 49:
http://userguide.icu-project.org/design#TOC-ICU-Release-Version-Number-ICU-49-and-later-

(In reply to comment #2)
> See http://gcc.gnu.org/ml/gcc-help/2012-11/msg00018.html

(Undefined references mentioned in that thread will occur when building WebKit with older version of C++11 if ICU has been built with C++11.)
Comment 4 Arfrever Frehtes Taifersar Arahesis 2012-11-05 11:27:33 PST
(In reply to comment #3)
> older version of C++11

s/older version of C++11/older version of C++/
Comment 5 Steven R. Loomis 2012-11-05 21:13:29 PST
Maybe caused by http://bugs.icu-project.org/trac/ticket/9717
Comment 6 Steven R. Loomis 2012-11-05 21:13:49 PST
(In reply to comment #5)
> Maybe caused by http://bugs.icu-project.org/trac/ticket/9717


see there for a possible workaround.
Comment 7 Arfrever Frehtes Taifersar Arahesis 2012-11-05 23:15:51 PST
(In reply to comment #5)
> Maybe caused by http://bugs.icu-project.org/trac/ticket/9717

This bug in WebKit was caused by solution for ICU ticket 9469. ICU ticket 9717 only suggests temporary workaround (forceful disabling of C++11). The proper solution in WebKit is to add appropriate casts (or use char16_t in more places in WebKit code).
Comment 8 Markus Scherer 2012-11-09 10:24:26 PST
In ICU, I just changed UChar to not automatically become char16_t, but users can add something like CPPFLAGS=-DUCHAR_TYPE=char16_t.

See http://bugs.icu-project.org/trac/changeset/32780

If this does not work for WebKit then please reply to http://bugs.icu-project.org/trac/ticket/9728 or on the icu-support mailing list (http://site.icu-project.org/contacts).

Best regards,
markus
Comment 9 Michael Catanzaro 2018-05-08 20:27:26 PDT
Looks like this is obsolete as per comment #8.