android_webview
apps
ash
base
build
build_overrides
buildtools
cc
chrome
chromecast
chromeos
clank
codelabs
components
content
crypto
dbus
device
docs
accessibility
autofill
chromeos
design
enterprise
experiments
fuchsia
gpu
graphics
images
infra
intl
ios
linux
login
mac
media
memory
memory-infra
patterns
privacy
privacy_budget
process
security
speed
speed_metrics
standards
telemetry_extension
testing
transcripts
ui
updater
webapps
website
webui
workflow
DIR_METADATA
OWNERS
README.md
accessibility.md
ad_tagging.md
adding_to_third_party.md
android_accessing_cpp_enums_in_java.md
android_accessing_cpp_features_in_java.md
android_accessing_cpp_switches_in_java.md
android_build_instructions.md
android_cast_build_instructions.md
android_debugging_instructions.md
android_dynamic_feature_modules.md
android_emulator.md
android_isolated_splits.md
android_jni_ownership_best_practices.md
android_logging.md
android_native_libraries.md
android_studio.md
angle_in_chromium.md
api_keys.md
asan.md
atom.md
benchmark_performance_regressions.md
bfcache.md
bitmap_pipeline.md
branch_gardener.md
building_old_revisions.md
callback.md
ccache_mac.md
chrome_browser_design_principles.md
chrome_os_logging.md
chrome_settings.md
chromedriver_status.md
chromeos_build_instructions.md
chromeos_glossary.md
chromium_browser_vs_google_chrome.md
cipd_and_3pp.md
cl_respect.md
cl_tips.md
clang.md
clang_code_coverage_wrapper.md
clang_format.md
clang_gardening.md
clang_sheriffing.md
clang_static_analyzer.md
clang_tidy.md
clang_tool_refactoring.md
clangd.md
clion.md
closure_compilation.md
cocoa_tips_and_tricks.md
code_review_owners.md
code_reviews.md
commit_checklist.md
component_build.md
configuration.md
contributing.md
cq_fault_attribution.md
cr_respect.md
cr_user_manual.md
cross_platform_ui.md
cygwin_dll_remapping_failure.md
dangling_ptr.md
dangling_ptr_guide.md
dbus_mojo_connection_service.md
debugging_with_crash_keys.md
dependencies.md
deterministic_builds.md
disassemble_code.md
documentation_best_practices.md
documentation_guidelines.md
early-hints.md
eclipse.md
emacs.md
erc_irc.md
flag_expiry.md
flag_guarding_guidelines.md
flag_ownership.md
frame_trees.md
gardener.md
gcs_dependencies.md
gdbinit.md
gerrit_guide.md
get_the_code.md
git_cookbook.md
git_submodules.md
git_tips.md
google_chrome_branded_builds.md
google_play_services.md
graphical_debugging_aid_chromium_views.md
gwp_asan.md
history_manipulation_intervention.md
how_cc_works.md
how_to_add_your_feature_flag.md
how_to_extend_web_test_framework.md
idn.md
initialize_blink_features.md
inlined_stack_traces.md
installation_at_vmware.md
ios_build_instructions.md
ios_infra.md
ios_voiceover.md
kiosk_mode.md
life_of_a_frame.md
lldbinit.md
mac_arm64.md
mac_build_instructions.md
mac_lld.md
modifying_session_history_serialization.md
modules.md
mojo_and_services.md
mojo_ipc_conversion.md
mojo_testing.md
native_relocations.md
navbar.md
navigation-request-navigation-state.gv
navigation-request-navigation-state.png
navigation.md
navigation_concepts.md
network_traffic_annotations.md
no_sources_assignment_filter.md
orderfile.md
origin_trials_integration.md
ozone_overview.md
parsing_test_results.md
pgo.md
piranha_plant.md
process_model_and_site_isolation.md
profiling.md
profiling_content_shell_on_android.md
proxy_auto_config.md
qtcreator.md
release_branch_guidance.md
render-frame-host-lifecycle-state.gv
render-frame-host-lifecycle-state.png
render_document.md
rust-ffi.md
rust-unsafe.md
rust.md
seccomp_sandbox_crash_dumping.md
servicification.md
session_history.md
sheriff.md
shutdown.md
special_case_urls.md
static_initializers.md
sublime_ide.md
system_hardening_features.md
tab_helpers.md
threading_and_tasks.md
threading_and_tasks_faq.md
threading_and_tasks_testing.md
toolchain_support.md
tour_of_luci_ui.md
tpm_quick_ref.md
translation_screenshots.md
unretained_dangling_ptr_guide.md
unsafe_buffers.md
updating_clang.md
updating_clang_format_binaries.md
use_counter_wiki.md
useful_urls.md
user_data_dir.md
user_data_storage.md
user_handle_mapping.md
vanilla_msysgit_workflow.md
vscode.md
vscode_python.md
webview_policies.md
win_cross.md
win_order_files.md
windows_build_instructions.md
windows_native_window_occlusion_tracking.md
windows_pwa_integration.md
windows_shortcut_and_taskbar_handling.md
windows_split_dll.md
windows_virtual_desktop_handling.md
wmax_tokens.md
working_remotely_with_android.md
writing_clang_plugins.md
extensions
fuchsia_web
gin
google_apis
gpu
headless
infra
internal
ios
ios_internal
ipc
media
mojo
native_client
native_client_sdk
net
pdf
ppapi
printing
remoting
rlz
sandbox
services
signing_keys
skia
sql
storage
styleguide
testing
third_party
tools
ui
url
v8
webkit
.clang-format
.clang-tidy
.clangd
.git-blame-ignore-revs
.gitallowed
.gitattributes
.gitignore
.gitmodules
.gn
.mailmap
.rustfmt.toml
.vpython3
.yapfignore
ATL_OWNERS
AUTHORS
BUILD.gn
CODE_OF_CONDUCT.md
CPPLINT.cfg
CRYPTO_OWNERS
DEPS
DIR_METADATA
LICENSE
LICENSE.chromium_os
OWNERS
PRESUBMIT.py
PRESUBMIT_test.py
PRESUBMIT_test_mocks.py
README.md
WATCHLISTS
codereview.settings

* The file extensions for the compressed tarballs are .tar.xz, not .tgz * Update the clang-format diff script so that xargs spawns one clang-format process per file in parallel instead of spawning one clang-format process that formats all files. This considerably speeds things up. Note that the fetch and upload script is still broken for the following reasons that I haven't fixed yet because this is difficult to debug (upload_to_google_storage.py can only be run once per object for example.) * upload_to_google_storage_first_class.py prints a line that goes "Uploading {filename} as gs://{path}" before printing out JSON. This makes jq unhappy. * upload_to_google_storage_first_class.py prints the wrong object_name in the JSON; the object name printed is the same as the sha256sum. There does exist an object with that name and it contains the right data, but it doesn't have the executable bit set. We want another object that does. Change-Id: I6cd5faa0432b71098664e4e79bc7c22140d48545 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6226772 Reviewed-by: Hans Wennborg <hans@chromium.org> Commit-Queue: Alan Zhao <ayzhao@google.com> Cr-Commit-Position: refs/heads/main@{#1415760}
150 lines
6.1 KiB
Markdown
150 lines
6.1 KiB
Markdown
# Updating Clang format binaries
|
|
|
|
Instructions on how to update the [clang-format binaries](clang_format.md) that
|
|
come with a checkout of Chromium.
|
|
|
|
## Prerequisites
|
|
|
|
You'll also need permissions to upload to the appropriate google storage
|
|
bucket. Chromium infrastructure team members have this, and others can be
|
|
granted the permission based on need. If you need this permission, mention this
|
|
in the tracking bug.
|
|
|
|
## Fetch and upload prebuilt clang-format binaries from recent clang rolls
|
|
|
|
Recent clang rolls can be found via looking at the history of
|
|
[update.py](https://crsrc.org/c/tools/clang/scripts/update.py). You can also
|
|
use clang-format packages built in recent successful dry run attempts at
|
|
updating clang as mentioned [here](clang_sheriffing.md).
|
|
|
|
The following will, for each supported host architecture,
|
|
|
|
* Fetch the corresponding clang-format package from the specified clang roll
|
|
* Extract and copy the clang-format binary to the proper directory
|
|
* Upload the binary into a publicly accessible google storage bucket, also
|
|
updating the deps entries in DEPS files in the local checkout of Chrome
|
|
|
|
```shell
|
|
cd $SRC/chromium/src
|
|
|
|
GS_PATH=gs://chromium-browser-clang-staging
|
|
CLANG_REV=llvmorg-15-init-234-g567890abc-2
|
|
|
|
echo Linux
|
|
gsutil cp $GS_PATH/Linux_x64/clang-format-$CLANG_REV.tar.xz /tmp
|
|
tar xf /tmp/clang-format-$CLANG_REV.tgz -C buildtools/linux64 --strip-component=1 bin/clang-format
|
|
|
|
echo Win
|
|
gsutil cp $GS_PATH/Win/clang-format-$CLANG_REV.tar.xz /tmp
|
|
tar xf /tmp/clang-format-$CLANG_REV.tgz -C buildtools/win --strip-component=1 bin/clang-format.exe
|
|
|
|
echo 'Mac x64'
|
|
gsutil cp $GS_PATH/Mac/clang-format-$CLANG_REV.tar.xz /tmp
|
|
tar xf /tmp/clang-format-$CLANG_REV.tgz -C buildtools/mac --strip-component=1 bin/clang-format
|
|
mv buildtools/mac/clang-format buildtools/mac/clang-format.x64
|
|
|
|
echo 'Mac arm64'
|
|
gsutil cp $GS_PATH/Mac_arm64/clang-format-$CLANG_REV.tgz /tmp
|
|
tar xf /tmp/clang-format-$CLANG_REV.tgz -C buildtools/mac --strip-component=1 bin/clang-format
|
|
mv buildtools/mac/clang-format buildtools/mac/clang-format.arm64
|
|
|
|
# TODO(crbug.com/339490714): Remove sha1 file creation once all downstream repos that
|
|
# use clang-format are migrated over to recursedeps into buildtools.
|
|
echo '(Legacy) Uploading to GCS and creating sha1 files'
|
|
upload_to_google_storage.py --bucket=chromium-clang-format buildtools/linux64/clang-format
|
|
upload_to_google_storage.py --bucket=chromium-clang-format buildtools/win/clang-format.exe
|
|
upload_to_google_storage.py --bucket=chromium-clang-format buildtools/mac/clang-format.x64
|
|
upload_to_google_storage.py --bucket=chromium-clang-format buildtools/mac/clang-format.arm64
|
|
|
|
echo 'Uploading to GCS and updating DEPS files'
|
|
# helper function to set deps entries in DEPS file using `gclient setdep`
|
|
# first argument relative DEPS path.
|
|
# second argument object_info
|
|
function set_deps {
|
|
gclient setdep -r src/buildtools/$1@$2
|
|
gclient setdep -r $1@$2 --deps-file=buildtools/DEPS
|
|
}
|
|
# helper function to upload content to GCS and set DEPS
|
|
# first argument: google storage path
|
|
# second argument: relative DEPS path
|
|
# This function parses out the object info outputted by upload_to_google_storage_first_class.py
|
|
# and formats it into a format that gclient setdep understands
|
|
function upload_and_set {
|
|
object_info=$(upload_to_google_storage_first_class.py --bucket=chromium-clang-format $1 | jq -r .path.objects[0][] | sed -z 's/\n/,/g;s/,$/\n/')',clang-format'
|
|
if [[ $2 == 'win/format' ]]; then
|
|
object_info+='.exe'
|
|
fi;
|
|
set_deps $2 $object_info
|
|
}
|
|
|
|
upload_and_set buildtools/linux64/clang-format linux64-format
|
|
upload_and_set buildtools/win/clang-format.exe win-format
|
|
upload_and_set buildtools/mac/clang-format.x64 mac-format
|
|
upload_and_set buildtools/mac/clang-format.arm64 mac_arm64-format
|
|
|
|
# Clean up
|
|
rm /tmp/clang-format-$CLANG_REV.tgz
|
|
# These aren't in .gitignore because these mac per-arch paths only exist when updating clang-format.
|
|
# gclient runhooks puts these binaries at buildtools/mac/clang-format.
|
|
rm buildtools/mac/clang-format.x64 buildtools/mac/clang-format.arm64
|
|
```
|
|
|
|
## Check that the new clang-format works as expected
|
|
|
|
Compare the diffs created by running the old and new clang-format versions to
|
|
see if the new version does anything unexpected. Running them on some
|
|
substantial directory like `third_party/blink` or `base` should be sufficient.
|
|
Upload the diffs as two patchsets in a CL for easy inspection of the
|
|
clang-format differences by choosing patchset 1 as the base for the gerrit diff.
|
|
|
|
```shell
|
|
## New gerrit CL with results of old clang-format.
|
|
|
|
# For mac, use:
|
|
# export NPROC=$(sysctl -n hw.logicalcpu)
|
|
export NPROC=$(nproc --all)
|
|
|
|
# use old clang-format
|
|
find base -name '*.cc' -o -name '*.c' -o -name '*.h' -o -name '*.mm' | xargs -P $NPROC -n1 ./buildtools/linux64-format/clang-format -i
|
|
git commit -a
|
|
git cl upload --bypass-hooks
|
|
## New patchset on gerrit CL with results of new clang-format.
|
|
# update to new clang-format
|
|
find base -name '*.cc' -o -name '*.c' -o -name '*.h' -o -name '*.mm' | xargs -P $NPROC -n1 ./buildtools/linux64/clang-format -i
|
|
git commit -a --amend --no-edit
|
|
git cl upload --bypass-hooks
|
|
```
|
|
|
|
If there are any unexpected diffs, file a bug upstream (and fix it if you can :)).
|
|
|
|
## Upload a CL according to the following template
|
|
|
|
Update clang-format binaries and scripts for all platforms.
|
|
|
|
I followed these instructions:
|
|
https://chromium.googlesource.com/chromium/src/+/main/docs/updating_clang_format_binaries.md
|
|
|
|
The binaries were built at clang revision ####### on ##CRREV##.
|
|
|
|
Diff on base/ from previous revision of clang-format to this version:
|
|
https://crrev.com/c/123123123/1..2
|
|
|
|
Bug: #######
|
|
|
|
The change should **always** include new `.sha1` files for each platform (we
|
|
want to keep these in lockstep), should **never** include `clang-format`
|
|
binaries directly. The change should **always** update `README.chromium`
|
|
|
|
clang-format binaries should weigh in at 1.5MB or less. Watch out for size
|
|
regressions.
|
|
|
|
## Clean up downloaded binaries
|
|
Delete the binaries that were just extracted. To use the new binaries that were
|
|
updated in the DEPS files, run gclient sync.
|
|
```shell
|
|
rm buildtools/linux64/clang-format
|
|
rm buildtools/win/clang-format.exe
|
|
rm buildtools/mac/clang-format.x64
|
|
rm buildtools/mac/clang-format.arm64
|
|
```
|