lifting-bits / cxx-common

Common dependency management for various Trail of Bits C++ codebases
Apache License 2.0
31 stars 11 forks source link

Linux arm cross compile build #1018

Closed ekilmer closed 1 year ago

ekilmer commented 1 year ago

Should merge #1021 first and then update Docker image name reference

Changelog

  1. Use GCC to cross-compile Linux arm64 binaries in CI
    • Fixed compilation of remill with GCC
  2. Use new Docker image as a base with installed cross-compilation dependencies
  3. Patch LLVM 15 and 16 to compile for target architecture (ports/llvm-{15,16}/portfile.cmake)
  4. Patch LLVM 15 and 16 to pass the correct compiler for cross-compiling and native binary builds (ports/llvm-{15,16}/portfile.cmake)
  5. Update to LLVM 16.0.4
  6. Patch protobuf port to always build target executable (ports/protobuf/portfile.cmake)
  7. Patch XED to remove usage of -m architecture flags that broke during ARM cross-compilation (ports/xed/0001-mbuild-remove-m64.patch)
  8. Patch glog to fix linker error between GCC and Clang (ports/glog/fix_logstream_linker_error.patch)
  9. Patch vcpkg to correctly find compatible host executables to run
  10. Use GCC to compile compatible lifting tools
  11. No longer force clang as the default compiler when using build_dependencies.sh script

Notes

I went through a lot of trial and error trying to first crosscompile using clang, but this method does not seem to be well-tested. Instead, I am using GCC to compile everything, which shouldn't be a problem.

I also fixed compilation of remill with GCC.

I had to modify vcpkg Linux toolchain to properly detect cross-compilation and fix LLVM builds. Ideally, this goes to upstream, but I have been having issues getting cross-compilation fixes merged.

TODO: