feat!: Remove TOOLCHAIN logic and replace with CMake presets#162
Conversation
|
Looks good to me. Just looking for clarification on a couple of things mentioned in my comments. |
charlielye
left a comment
There was a problem hiding this comment.
Skimmed. But looks like a great step in the right direction 👍
|
To address @codygunton's issue with GCC12, it seems like we can instead set the generator to Ninja in the CMakePresets.json rather than the VSCode workspace settings. When testing on the mainframe, my build were being parallelized after performing this change. On another note, switching configure preset requires the CMake cache to be rebuilt. The option is "CMake: Delete cache and reconfigure" in VSCode. This could be solved by having a separate build folder for each configuration, though that might be more annoying to setup. (i.e. |
- add clangd setting to ignore GCC-specific flags
|
I've added a commit which sets the generator in the EDIT: I had to modify the docker files to download ninja as well. |
|
VS Code integration is still kind of funky, e.g. building with wasm preset using CMake Tools is extremely slow, but it works for most common workflow, so I'm going to merge. |
…otocol/barretenberg#162) * feat: Add CMake presets to project * fix!: Remove toolchain file and make bootstrap pick correct preset * fix!: Rework toolchain files to be proper cross-compile files * chore: Update dockerfiles to use presets * chore: Rework compare_honk_bench to work with presets (need to double check) * chore: Update docs to use presets throughout * chore: Remove docs about parallel command since presets enable maximum jobs * chore: Rework toolchain docs to call out cross-compiling * Ignore CMakeUserPresets.json as per adrian * Add CMake Tools VS Code plugin config. * Set ninja as the default generator * Export compile commands used for clangd - add clangd setting to ignore GCC-specific flags * add ninja to docker images --------- Co-authored-by: codygunton <codygunton@gmail.com> Co-authored-by: adr1anh <adrian.hamelink@gmail.com>
…otocol/barretenberg#162) * feat: Add CMake presets to project * fix!: Remove toolchain file and make bootstrap pick correct preset * fix!: Rework toolchain files to be proper cross-compile files * chore: Update dockerfiles to use presets * chore: Rework compare_honk_bench to work with presets (need to double check) * chore: Update docs to use presets throughout * chore: Remove docs about parallel command since presets enable maximum jobs * chore: Rework toolchain docs to call out cross-compiling * Ignore CMakeUserPresets.json as per adrian * Add CMake Tools VS Code plugin config. * Set ninja as the default generator * Export compile commands used for clangd - add clangd setting to ignore GCC-specific flags * add ninja to docker images --------- Co-authored-by: codygunton <codygunton@gmail.com> Co-authored-by: adr1anh <adrian.hamelink@gmail.com>
Description
Before these changes, Barretenberg was forcing specific C and C++ Compilers through the
-DTOOLCHAINvariable. This is a flawed design because it doesn't allow consumers to set theCCorCXXenvironment variables to pick their compilers. Being able to set those values is extremely important for cross-compiling.This PR removes all of that
TOOLCHAINlogic and instead leverages CMake Presets to provide the defaults we expect (such as clang, clang-15, gcc, gcc-10 and clang from Homebrew). Shoutout to @adr1anh for sharing the idea for presets which massively helped with this transition plan.It also updates the
bootstrap.shfile to detect and print which preset should be used. If you use cmake commands directly, you'll need to start using the related preset commands.I've also updated the dockerfiles and docs to all reference these preset commands.
The
cmake/toolchainsdirectory still exists, but the files have been re-done as proper CMake Cross-Compile Toolchain files which are really just supposed to set the target name and architecture, but can include extras like the i386 file.I've tested this quite extensively on my Arm Mac but I need feedback for Linux, the dockerfiles, and the compare_honk_bench stuff (because it was non-standard).
Checklist:
/markdown/specshave been updated.@briefdescribing the intended functionality.