Skip to content

Commit e430468

Browse files
author
jinqiang zhang
committed
update chrome-icu 102
1 parent 6850cec commit e430468

File tree

5 files changed

+1487
-0
lines changed

5 files changed

+1487
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# The Chrome ICU package
2+
3+
This ebuild builds and installs the [icu package in chrome][chrome-icu-location]
4+
so that it can be used in Chrome OS. Compared with the vanilla ICU library, it
5+
is customised for Chrome so there are some missing functionality and encoding
6+
(e.g. ISO-2022-CN and ISO-2022-KR). But it should be powerful enough for most
7+
usages. (It supports the i18n of Chrome!)
8+
9+
[TOC]
10+
11+
## Why chrome-icu?
12+
13+
The biggest reason is to save resources. Chrome-icu saves,
14+
15+
1. 10MB of rootfs disk space due to sharing the icu data.
16+
2. Up to 10MB of RAM because of sharing the icu data.
17+
3. Maintaining effort in Chrome OS (icu needs regular major uprev every 6
18+
months and small bug fixes from time to time).
19+
20+
## How to use it?
21+
22+
> Please give us a heads-up if you want to use it. This is because chrome-icu
23+
> is currently a static library, so linking it will non-trivially increase the
24+
> disk space. And if the users of chrome-icu become more and more, we will
25+
> spend the effort to make it into a shared library. (This will not affect your
26+
> usage, please see [the tracker][make-into-shared-library].)
27+
28+
1. Add `chrome-icu` as a dependency in your ebuild.
29+
2. Link `icui18n-chrome` and `icuuc-chrome` libraries.
30+
3. Add header paths `${sysroot}/usr/include/icu-chrome/common` and
31+
`${sysroot}/usr/include/icu-chrome/i18n`.
32+
4. If some headers are missing, you can add them to [here][chrome-icu-headers].
33+
5. At run time, load the icu data file from `/opt/google/chrome/icudtl.dat`.
34+
You can follow the example [here][ml-service-load-icu-data].
35+
36+
## TODO
37+
38+
1. We should consider
39+
[setting up a CQ tryjob for chrome-icu][chrome-side-tryjob-tracker],
40+
although this has become not very urgent after we
41+
[only configure the icu package][cl-that-only-configure-icu] in compiling
42+
chrome-icu.
43+
2. We should consider having a `build-chrome.eclass` and avoid the duplication
44+
between `chromeos-chrome.ebuild` and `chrome-icu.ebuild`. (We used to
45+
duplicate the code because chrome-icu used to be very experimental so we do
46+
not want to greatly change the `chromeos-chrome.ebuild` for it. With
47+
chrome-icu method becoming stable, we can consider it now.)
48+
49+
## Other questions
50+
51+
### Emerging chrome-icu in cros chroot takes ages. What happened and how to resolve it?
52+
53+
This normally means that there is no prebuilt binary available for chrome-icu
54+
so it has to build chrome-icu from source and this needs the whole chrome repo.
55+
Because chrome-icu and chrome share a similar build mechanism, this usually
56+
implies that there is no prebuilt binary available for chrome too. So if you
57+
just did a repo sync and found it has to build chrome-icu from source in running
58+
`build_packages`, it means you will also need to build chrome from source too
59+
--- it is only because chrome depends on chrome-icu so the latter will be built
60+
first.
61+
62+
How to resolve it: There are a few methods that you could try,
63+
64+
1. Run `emerge-$BOARD -G chrome-icu` and see if this succeeds and
65+
satisfies your needs. (This command enforce emerging chrome-icu from
66+
prebuilt binary.)
67+
2. If this is because the repo synced is very fresh, consider syncing to an
68+
older version of Chrome OS (e.g. [sync to green][sync-to-green]).
69+
3. If this is caused by changing configurations (e.g. USE flag changes), you
70+
could let chrome-icu built from your local chrome checkout. First, you
71+
need to enter your chroot with the `--chrome-root` option pointing to your
72+
local chrome checkout. Then after entering the chroot, the chrome checkout
73+
is located at "~/chrome_root". Second, now you can run
74+
`CHROME_ORIGIN=LOCAL_SOURCE emerge-$BOARD chrome-icu` to build it form
75+
local chrome checkout.
76+
77+
### Why is chrome-icu a static library, not a shared library?
78+
79+
This is because: First, making it into a static library is easier and
80+
requires less modifications in chrome; Second, currently only two packages
81+
are using it, and total size increase of linking it statically is smaller
82+
than that of making it into a shared library.
83+
84+
### After we make chrome-icu into a shared library, can chrome use it too to save more disk space?
85+
86+
The answer is no. This is because in chrome, icu is compiled with
87+
"control-flow integrity (CFI)" turned on. And CFI currently does not work
88+
well with shared libraries.
89+
90+
### I want to use the chrome-icu mechanism to share other code in Chrome with Chrome OS. How should I do this?
91+
92+
Theoretically, the method used by chrome-icu should be able to share any
93+
code in chrome to Chrome OS. But considering that 1) the chrome-icu method
94+
is still very new and 2) it requires changes in both chrome and the infra
95+
configurations, we recommend you to first chat with the Chrome OS build team
96+
to discuss about your problem before moving forward. And there are other
97+
(e.g. more lightweight) [sharing methods](http://go/chromeos-code-sharing) which
98+
may be more suitable.
99+
100+
101+
[chrome-side-tryjob-tracker]: https://crbug.com/1133101
102+
[cl-that-only-configure-icu]: https://crrev.com/c/2524460
103+
[sync-to-green]: https://chromium.googlesource.com/chromiumos/docs/+/HEAD/developer_guide.md#sync-to-green
104+
[make-into-shared-library]: https://crbug.com/1152936
105+
[chrome-icu-headers]: https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/HEAD/chromeos-base/chrome-icu/chrome-icu-9999.ebuild#629
106+
[ml-service-load-icu-data]: https://chromium.googlesource.com/chromiumos/platform2/+/HEAD/ml/machine_learning_service_impl.cc#75
107+
[chrome-icu-location]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/icu/

0 commit comments

Comments
 (0)