An experimental take on a safer, simpler C++ standard library.
Please don't use this library. This is an experiment and we don't yet know where it will take us. There will be breaking changes without warning, and there is no stable version.
All source files must include this header:
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
The latest LLVM release does not have sufficient C++20 support to format the library correctly. To get a more bleeding edge clang-format executable, we get it from the Chromium project:
- Install python3 (or from the Windows Store) and add it to your path.
- Download depot_tools, extract it, and put it in your path.
- Run
gclient
in a terminal to set it up. - Make a directory to hold the clang-format binary.
- Download the sha1 file for your platform and put it in that directory.
- From in that same directory, in a terminal, run download_from_google_storage
to pull down the clang-format binary.
- On Windows:
python ..\depot_tools\download_from_google_storage.py --no_resume --no_auth --bucket chromium-clang-format -s clang-format.exe.sha1
- Elsewhere:
python ..\depot_tools\download_from_google_storage.py --no_resume --no_auth --bucket chromium-clang-format -s clang-format.sha1
- The command comes from here.
- On Windows:
- Point your IDE to the downloaded clang-format executable.
- Install Visual Studio 2022. Don't bother installing the CMake tools from it, they don't work as well
- Set the "Windows SDK Version" in VSCode to
10.0.19041.0
(or the version installed with Visual Studio) - Set the "CMake: Generator" in VSCode to
Visual Studio 17 2022
, or add it to "CMake: Preferred Generators"
CIR is a midlevel representaion of C++ built on Clang in the spirit of Rust's MIR.
CIR requires an installation of LLVM from Git HEAD, including the LLVM/Clang headers and libraries.
By default, in VSCode it looks for llvm and clang in the following places, from
Subspace's .vscode/settings.json
, but you will need to set these environment
variables if building in another way.
"cmake.environment": {
"LLVM_DIR": "../../llvm/build/install/lib/cmake/llvm",
"CLANG_DIR": "../../llvm/build/install/lib/cmake/clang",
},
To build LLVM from VSCode, the following can be put in LLVM's
.vscode/settings.json
:
{
"cmake.configureOnOpen": false,
"cmake.sourceDirectory": "${workspaceFolder}/llvm",
"cmake.buildDirectory": "${workspaceFolder}/build/${buildType}/${variant:platform}",
"cmake.installPrefix": "${workspaceFolder}/build/install",
"cmake.generator": "Ninja",
"cmake.configureArgs": [
"-DLLVM_ENABLE_PROJECTS=clang",
],
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
}
Then use VSCode to choose a build configuration and run the "CMake: Build" and "CMake: Install" tasks.
On windows, set the envionment variable LLVM_DEBUG=1
if the LLVM build was a
debug build in order for CIR to link the appropriate runtime.