aboutsummaryrefslogtreecommitdiff
path: root/3.8/README.md
blob: e8278e21c63cc1266cacffa6074064903396301f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
Android Clang/LLVM
==================

Platform Projects
-----------------

#### external/llvm
**Branch**: *aosp/dev*

* This branch tracks LLVM upstream directly and contains our Android-specific
patches that do not exist in upstream.

**Branch**: *aosp/master*

* This branch receives updates from the *aosp/dev* branch as a squashed single
commit.
Any patches submitted here need to be replayed in *aosp/dev* as well for
consistency with future rebases.

#### external/clang
**Branch**: *aosp/dev*

* This branch tracks Clang upstream directly and contains our Android-specific
patches that do not exist in upstream.

**Branch**: *aosp/master*

* This branch receives updates from the *aosp/dev* branch as a squashed single
commit.
Any patches submitted here need to be replayed in *aosp/dev* as well for
consistency with future rebases.

#### external/compiler-rt
**Branch**: *aosp/dev*

* This branch tracks compiler-rt upstream directly and contains our
Android-specific patches that do not exist in upstream.

**Branch**: *aosp/master*

* This branch receives updates from the *aosp/dev* branch as a squashed single
commit.
Any patches submitted here need to be replayed in *aosp/dev* as well for
consistency with future rebases.


**Note**: Similar branching strategies can be used for **external/libcxx** and
**external/libcxxabi**, but these projects are less divergent and may not need
special LLVM rebase behavior.


Development Flow
----------------

Rebases take place in the **external/** *aosp/dev* branches by merging
upstream CLs directly.
Conflicts are resolved manually and then a patch is produced to adapt
Android.mk files (as well as to add/delete any updated source files).
Prebuilts are then generated using these projects and placed into the proper
**prebuilts/clang/host** subprojects.

For example, these projects for LLVM 3.8 would be:

    prebuilts/clang/host/linux-x86/3.8
    prebuilts/clang/host/darwin-x86/3.8
    prebuilts/clang/host/windows-x86/3.8

In order to prepare for the actual rebase (including updating dependent
projects), we will copy each **external/** *aosp/dev* project to its
corresponding **external/** *aosp/master* project as a squashed single CL.
This makes rollbacks simpler, and it also reduces churn on the Android build
servers.
This also has the side effect of not spamming non-Android @google.com
committers to upstream LLVM projects, since their commits will be batched up
into a single copy commit on each tracked **external/** project.

Prebuilts for llvm-rs-cc and bcc\_compat also need to be generated for
prebuilts/sdk.
This is done by running **frameworks/rs/update\_rs\_prebuilts.sh** on both Mac
and Linux.
After this completes, the **prebuilts/sdk** project will have a prepared
branch/CL that can be uploaded for review/commit.


Fixing Bugs
-----------

If we find a host-side bug that needs to be fixed, it may trigger an update of
the host prebuilts (i.e. rebase).
Device-side fixes can be pushed directly to **external/** *aosp/master* and then
copied to **external/** *aosp/dev* to speed up the process (assuming that it
doesn’t affect the host builds).


Looking at Upstream
-------------------

Here are the remotes to add in your **external/** projects. You can synchronize
them with `git fetch upstream`.


    Clang: git remote add upstream http://llvm.org/git/clang.git
    LLVM:  git remote add upstream http://llvm.org/git/llvm.git
    compiler-rt: git remote add upstream http://llvm.org/git/compiler-rt.git


LLVM 3.8 era rebase process
---------------------------

Loop over llvm, clang, compiler-rt (in this order):

1. We are working from a separate untracked/merged branch called *aosp/dev*,
so we can’t really use repo start.

        git branch -D working_dev
        git checkout -b working_dev aosp/dev

2. **OPTIONAL FIXUPS**.
These aren't really necessary if you remember to always keep *aosp/dev* and
*aosp/master* synchronized otherwise, but very often someone will forget to
merge back a change.

  1. Grab the squashed commit that went into *aosp/master* and mark it
  committed to *aosp/dev* too.

     **Note**: If there were changes to *aosp/master* before the squashed
     commit, grab those changes (using step 2), before applying this step,
     and finally repeat step 2 for changes after the squashed commit.

          git branch -D clean_master
          git checkout -b clean_master <SHA_FOR_SQUASH>
          git checkout working_dev
          git merge -s ours clean_master
          git push aosp refs/heads/working_dev:refs/heads/dev
          git branch -D clean_master

  2. Grab all outstanding changes that went into *aosp/master* and put them
  into *aosp/dev* too.

          git branch -D clean_master
          git checkout -b clean_master aosp/master
          git checkout working_dev
          git merge clean_master
          git push aosp refs/heads/working_dev:refs/heads/dev
          git branch -D clean_master

3. Merge the upstream branch.
Use `git log upstream/master` to browse upstream commits and find a SHA.

        git merge <upstream_sha>

4. Fix conflicts.

5. Update build rules and commit that patch on top.

6. Test everything before pushing.

7. Submit your work to *aosp/dev*.

        git push aosp refs/heads/working_dev:refs/heads/dev

8. Squash your work for *aosp/master*.

        repo start update_38 .
        git merge --squash working_dev
        git commit -a
        repo upload .

9. Test everything before submitting the patch from the previous step.

10. Grab the squashed commit and replay it in *aosp/dev*.

        repo sync .
        git remote update
        git branch -D clean_master
        git checkout -b clean_master aosp/master
        git checkout working_dev

     Use -s ours to ensure that we skip the squashed set of changes
     If/when we forget this, we have to do it later

        git merge -s ours clean_master
        git push aosp refs/heads/working_dev:refs/heads/dev
        git branch -D clean_master

11. Clean up after our working branch.

        git checkout --detach
        git branch -D working_dev

This works better because we can keep full history in *aosp/dev*, while
maintaining easy reverts/commits through *aosp/master*.

Generating new prebuilts
------------------------

1. Build all of llvm/clang/compiler-rt.

        cd $ANDROID_BUILD_TOP/
        mmma external/llvm external/clang external/compiler-rt -j48

        cd $ANDROID_BUILD_TOP/prebuilts/clang/host/linux-x86/3.8
        ./build_toolchain.sh
        ./build_profile_rt.sh

2. Copy over our new prebuilts.
Note that these were built with the previous clang.

        ./update.sh

3. Now we need to actually rebuild everything with the new clang.
This includes clang itself!

        rm -rf out/
        ./build_toolchain.sh
        ./build_profile_rt.sh

4. Now we need to copy over our actual self-hosted prebuilts.

        ./update.sh

5. Rebuild/test everything one more time to ensure correctness.
There may be necessary fixups here, to handle .ll reading or other projects
where new warnings/errors are firing.

        m -j48 checkbuild

6. Upload the changes produced in **prebuilts/clang/host**.
This may entail more than a simple `git commit -a`, so look at `git status`
before finally uploading/committing.

        repo start updated_toolchain .
        git commit -a
        repo upload --cbr .

7. Update RenderScript prebuilts.

        cd $ANDROID_BUILD_TOP/frameworks/rs
        ./update_rs_prebuilts.sh

8. The prebuilts get copied to **prebuilts/sdk**, so we must upload the
relevant bits from there.

        cd $ANDROID_BUILD_TOP/prebuilts/sdk
        git commit -a
        repo upload .

9. Submit CLs.


Steps/Checklist for testing:
----------------------------

1. Do a Clang-only build and ensure it is not broken:

        USE_CLANG_PLATFORM_BUILD=true m -j48

2. Go to **external/llvm** and run `./android_test.sh` (no known failures
as of 2015-10-08).
3. Ensure successful build for all architectures: 32- and 64- bit ARM, x86 and
Mips.
4. Run 32- and 64- bit RenderScript CTS at least for ARM and AArch64.
5. Test RenderScript apps: RsTest, ImageProcessing, and finally
RSTest\_Compatlib in compatibility mode.
6. Test old APKs with rebased tools: grab the above apps from a different tree
(i.e. without the rebase), push them to a device with the rebased tools, and
test.
This ensures that the rebased BitcodeReader can read the output of old
BitcodeWriters.
7. Test new APKs on an old device: test freshly built APKs for
RSTest\_V{11,14,16}, and ImageProcessing\_2 on an old device (say Manta) and
ensure they pass.
This ensures that the rebase did not break the 2.9 and 3.2 BitcodeWriters.
8. Run ART host tests.
This was broken by a rebase once, and worth testing after every rebase.

        croot && cd art && mma -j40 test-art-host

9. Run ART device tests.

        croot && cd art && mma -j4 test-art-device


Checklist for CLs
-----------------

The following projects will almost always have CLs as a part of the rebase.
Depending on the changes in LLVM, there might be updates to other projects as
well.

* External projects
  * **external/clang**
  * **external/compiler-rt**
  * **external/llvm**
  * **frameworks/compile/mclinker**
* RenderScript projects
  * **frameworks/compile/libbcc**
  * **frameworks/compile/slang**
  * **frameworks/rs**
* Prebuilts
  * **prebuilts/clang/host/darwin-x86/**
  * **prebuilts/clang/host/linux-x86/**
  * **prebuilts/clang/host/windows-x86/**
  * **prebuilts/sdk**
* CTS tests
  * **cts/tests/tests/renderscript**
  * **cts/tests/tests/renderscriptlegacy**
  * **cts/tests/tests/rscpp**