tree: 8a03e83836c03c6578bbeb6a6cdc6b10b23c963b [path history] [tgz]
  1. testdata/
  2. android_config_test.go
  3. bisect_flag.go
  4. bisect_flag_test.go
  5. build.py
  6. bundle.py
  7. bundle.README
  8. ccache_flag.go
  9. ccache_flag_test.go
  10. clang_flags.go
  11. clang_flags_test.go
  12. clang_syntax_flag.go
  13. clang_syntax_flag_test.go
  14. clang_tidy_flag.go
  15. clang_tidy_flag_test.go
  16. command.go
  17. command_test.go
  18. compile_with_fallback.go
  19. compile_with_fallback_test.go
  20. compiler_wrapper.go
  21. compiler_wrapper_test.go
  22. config.go
  23. config_test.go
  24. cros_hardened_config_test.go
  25. cros_host_config_test.go
  26. cros_llvm_next_flags.go
  27. cros_nonhardened_config_test.go
  28. disable_werror_flag.go
  29. disable_werror_flag_test.go
  30. env.go
  31. env_test.go
  32. errors.go
  33. errors_test.go
  34. gcc_flags.go
  35. gcc_flags_test.go
  36. go.mod
  37. go_exec.go
  38. goldenutil_test.go
  39. install_compiler_wrapper.sh
  40. kernel_bug.go
  41. kernel_bug_test.go
  42. libc_exec.go
  43. libgcc_flags.go
  44. libgcc_flags_test.go
  45. main.go
  46. print_cmdline_flag.go
  47. print_cmdline_flag_test.go
  48. print_config_flag.go
  49. print_config_flag_test.go
  50. README.md
  51. remote_build_flag_test.go
  52. remote_build_flags.go
  53. reset_compiler_wrapper.sh
  54. rusage_flag.go
  55. rusage_flag_test.go
  56. sanitizer_flags.go
  57. sanitizer_flags_test.go
  58. stackprotector_flags.go
  59. stackprotector_flags_test.go
  60. sysroot_flag.go
  61. sysroot_flag_test.go
  62. testutil_test.go
  63. thumb_flags.go
  64. thumb_flags_test.go
  65. unsupported_flags.go
  66. unsupported_flags_test.go
  67. x64_flags.go
  68. x64_flags_test.go
compiler_wrapper/README.md

Compiler wrapper

See the comments on the top of main.go. Build is split into 2 steps via separate commands:

  • bundle: copies the sources and the build.py file into a folder.
  • build: builds the actual go binary, assuming it is executed from the folder created by bundle.py.

This allows to copy the sources to a ChromeOS / Android package, including the build script, and then build from there without a dependency on toolchain-utils itself.

Testing Inside the Chroot

To test updates to the wrapper locally:

Run install_compiler_wrapper.sh to install the new wrapper in the chroot:

(chroot) ~/trunk/src/third_party/toolchain-utils/compiler_wrapper/install_compiler_wrapper.sh

Then perform the tests, e.g. build with the new compiler.

Updating the Wrapper for ChromeOS

To update the wrapper for everyone, the new wrapper configuration must be copied into chromiumos-overlay, and new revisions of the gcc and llvm ebuilds must be created.

Copy over sources and build.py to chromiumos-overlay:

(chroot) /mnt/host/source/src/third_party/chromiumos-overlay/sys-devel/llvm/files/update_compiler_wrapper.sh

Rename chromiumos-overlay/sys-devel/llvm/llvm-${VERSION}.ebuild to the next revision number. For example, if the current version is 11.0_pre394483_p20200618-r2:

(chroot) cd ~/trunk/src/third_party/chromiumos-overlay
(chroot) git mv llvm-11.0_pre394483_p20200618-r2.ebuild llvm-11.0_pre394483_p20200618-r3.ebuild

Rename chromiumos-overlay/sys-devel/gcc/gcc-${VERSION}.ebuild to the next revision number. For example, if the current version is 10.2.0-r3:

(chroot) cd ~/trunk/src/third_party/chromiumos-overlay
(chroot) git mv sys-devel/gcc/gcc-10.2.0-r3.ebuild sys-devel/gcc/gcc-10.2.0-r4.ebuild

Commit those changes together with the changes made by update_compiler_wrapper.sh.

The changes can then be reviewed and submitted through the normal process.

Paths

build.py is called by these ebuilds:

  • third_party/chromiumos-overlay/sys-devel/llvm/llvm-*.ebuild
  • third_party/chromiumos-overlay/sys-devel/gcc/gcc-*.ebuild

Generated wrappers are stored here:

  • Sysroot wrapper with ccache: /usr/x86_64-pc-linux-gnu/<arch>/gcc-bin/10.2.0/sysroot_wrapper.hardened.ccache
  • Sysroot wrapper without ccache: /usr/x86_64-pc-linux-gnu/<arch>/gcc-bin/10.2.0/sysroot_wrapper.hardened.noccache
  • Clang host wrapper: /usr/bin/clang_host_wrapper
  • Gcc host wrapper: /usr/x86_64-pc-linux-gnu/gcc-bin/10.2.0/host_wrapper