This section shows the step to synchronize HCC with upstream projects, such as Clang, LLVM, and LLD. The process is currently carried out manually but it could and should be automated.
Upstream Clang, LLVM, and LLD all sit in different git repositories and they are almost changed daily. Sometimes a change upstream may affect several projects, but it is usually not easy to figure it out from the commit log.
HCC has been configured use git submodules to track these dependencies, but there are users who prefer using repo tool. This document has been revised to cope with both git submodules and repo.
HCC depends on amd-common LLVM / LLD / Clang, which is a fork maintained by AMD, and may contain patches yet upstreamed. amd-common LLVM / LLD / Clang is automatically synchronized with upstream LLVM / LLD / Clang every 4 hours, so they are very close to the latest codes upstream.
Generally speaking, the process goes like this:
- Clone HCC repo manifest
- Clone HCC with repo
- Initialize git submodules
- Merge master ROCm-Device-Libs commits
- Merge amd-common LLVM commits
- Merge amd-common LLD commits
- Merge master COMPILER-RT commits from llvm-mirror
- Add git remote for amd-common Clang
- Fetch amd-common Clang commits
- Merge amd-common Clang with HCC Clang
- Build merged HCC
- Quick sanity tests on merged HCC
- Push HCC Clang submodules
- Push amd-hcc LLVM submodule
- Push amd-hcc LLD submodule
- Push amd-hcc COMPILER-RT submodule
- Push remove-promote-change-addr-space ROCm-Device-Libs submodule
- Update HCC git submodules configuration
- Update HCC repo manifest
Detailed step-by-step instructions are in following sections.
git locations of repositories used in the merge process are:
- master ROCm-Device-Libs
- URL: git@github.com:RadeonOpenCompute/ROCm-Device-Libs.git
- branch : master
- amd-common LLVM
- URL : git@github.com:RadeonOpenCompute/llvm.git
- branch : amd-common
- amd-common LLD
- URL: git@github.com:RadeonOpenCompute/lld.git
- branch : amd-common
- amd-common COMPILER-RT
- URL: git@github.com:llvm-mirror/compiler-rt.git
- branch : master
- amd-common Clang
- URL: git@github.com:RadeonOpenCompute/clang.git
- branch : amd-common
HCC has been configured to use HTTPS URL by default. It is easy for users to clone it anonymously. But it would be hard for committing changes. Use the following commands to setup SSH URL.
- change to HCC directory
git remote set-url --push github git@github.com:RadeonOpenCompute/hcc.gitcd clanggit remote set-url --push github git@github.com:RadeonOpenCompute/hcc-clang-upgrade.gitcd ../compilergit remote set-url --push github git@github.com:RadeonOpenCompute/llvm.gitcd ../lldgit remote set-url --push github git@github.com:RadeonOpenCompute/lld.gitcd ../compiler-rtgit remote set-url --push github git@github.com:RadeonOpenCompute/compiler-rt.gitcd ../rocdlgit remote set-url --push github git@github.com:RadeonOpenComoute/ROCm-Device-Libs.git
This only needs to be done once.
repo init -u https://github.com/RadeonOpenCompute/HCC-Native-GCN-ISA.gitrepo sync
There will be an hcc directory inside the repo. It would be referred as
HCC directory hereafter.
A manifest directory is created to track working commits for all components.
git clone git@github.com:RadeonOpenCompute/HCC-Native-GCN-ISA.git manifest
This directory would be referred as HCC manifest directory hereafter.
- change to HCC directory
git checkout clang_tot_upgradegit submodule update --init
- change to HCC directory
cd rocdlgit checkout remove-promote-change-addr-spacegit pullgit merge github/master --no-edit
Resolve any merge conflicts encountered here. Commit to remove-promote-change-addr-space branch.
- change to HCC directory
cd compilergit checkout amd-hccgit pullgit merge github/amd-common --no-edit
Resolve any merge conflicts encountered here. Commit to amd-hcc branch.
- change to HCC directory
cd lldgit checkout amd-hccgit pullgit merge github/amd-common --no-edit
Resolve any merge conflicts encountered here. Commit to amd-hcc branch.
- change to HCC directory
cd compiler-rtgit remote -vto check if there is a git remote pointing to:git@github.com:llvm-mirror/compiler-rt.git- If there is not, add it by:
git remote add compiler-rt https://github.com/llvm-mirror/compiler-rt
git checkout amd-hccgit fetch compiler-rtgit merge --no-ff compiler-rt/master --no-edit
Resolve any merge conflicts encountered here. Commit to amd-hcc branch.
- change to HCC directory
cd clanggit remote -vto check if there is a git remote pointing to:git@github.com:RadeonOpenCompute/clang.git- If there is not, add it by:
git remote add clang https://github.com/RadeonOpenCompute/clang
git checkout clang_tot_upgradegit fetch clanggit merge --no-ff clang/amd-common --no-edit
Resolve merge conflicts encountered here. Commit to clang_tot_upgrade branch.
- change to HCC directory
mkdir -p build; cd buildcmake -DCMAKE_BUILD_TYPE=Release ..make
Fix any compilation failures if there is any. Repeat this step until HCC can be built.
Assume commands below are carried out in HCC build directory. And HCC
directory is at ~/hcc.
Test with one C++AMP FP math unit test.
bin/hcc `bin/clamp-config --build --cxxflags --ldflags` -lm \
~/hcc/tests/Unit/AmpMath/amp_math_cos.cpp
./a.out ; echo $?Test with one grid_launch unit test with AM library usage.
bin/hcc `bin/hcc-config --build --cxxflags --ldflags` -lhc_am \
~/hcc/tests/Unit/GridLaunch/glp_const.cpp
./a.out ; echo $?Test with one HC unit test with atomic function and 64-bit arithmetic.
bin/hcc `bin/hcc-config --build --cxxflags --ldflags` \
~/hcc/tests/Unit/HC/hc_atomic_add_global.cpp
./a.out ; echo $?- change to HCC directory
cd clanggit checkout clang_tot_upgradegit push
Following steps are to ensure "master" branch are kept the same as "clang_tot_upgrade" branch.
git checkout mastergit merge clang_tot_upgrade --no-editgit push
Finally switch back to "clang_tot_upgrade" branch.
git checkout clang_tot_upgrade
- change to HCC directory
cd lldgit checkout amd-hccgit push
- change to HCC directory
cd compilergit checkout amd-hccgit push
- change to HCC directory
cd compiler-rtgit checkout amd-hccgit push
- change to HCC directory
cd rocdlgit checkout remove-promote-change-addr-spacegit push
- change to HCC directory
git checkout clang_tot_upgradegit add clang compiler lld compiler-rt rocdlgit commit -m "[Config] revise submodule configuration", or provide custom commit loggit pushto push HCC git submodules configuration online
- change to HCC directory
repo manifest -r > default.xml- copy
default.xmlto HCC manifest directory - change too HCC manifest directory
git add default.xmlgit commit -m "[Config] revise manifest", or provide custom commit loggit pushto push HCC repo manifest online
Upon reaching here, the merge process is completed.