# Circle 2022 - Sean Baxter - firstname.lastname@example.org Follow me on Twitter, [@seanbax](https://www.twitter.com/seanbax), for compiler updates. > Download the latest version: [Build 170](https://www.circle-lang.org/linux/build_170.tgz) for 64-bit Linux. Circle is a new C++20 compiler. It's written from scratch and designed for easy extension. ## Major extensions Circle extends C++ by adding many novel language features. Here are the big ones: * [Circle implementations of Standard Library classes](https://github.com/seanbaxter/circle/blob/master/stdlib#circle-implementations-of-standard-library-classes) * [Member packs and `std::tuple`](https://github.com/seanbaxter/circle/blob/master/tuple#circle-tuple) * [Member packs and `std::variant`](https://github.com/seanbaxter/circle/blob/master/variant#circle-variant) * [Member packs and `mdspan`](https://github.com/seanbaxter/mdspan/tree/circle#mdspan-circle) * [Reflection and user-defined attributes](https://github.com/seanbaxter/circle/blob/master/reflection/README.md#circle-reflection-and-typed-enums) * [Circle Imperative Arguments (CIA)](https://github.com/seanbaxter/circle/blob/master/imperative/README.md) * [Member traits](https://github.com/seanbaxter/circle/blob/master/member-traits/README.md) * [Circle conditionals](https://github.com/seanbaxter/circle/blob/master/conditional/README.md) * [Universal member access](https://github.com/seanbaxter/circle/blob/master/universal/README.md) * [Dynamic slices and list comprehensions](https://github.com/seanbaxter/circle/blob/master/comprehension/README.md) This is a compiler with the the capabilities I've always wanted. ## The C++ of the future Because Circle is so easy to extend, I've gone ahead and implemented some of the most promising WG21 proposals for the C++23 timeframe. * [P2392R1](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2392r1.pdf) - [Pattern matching using `is` and `as`](https://github.com/seanbaxter/circle/tree/master/pattern#pattern-matching) * [P1938R3](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p1938r3.html) - `if consteval` * [P1985R1](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1985r1.pdf) - Universal template parameters * [P0847R5](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p0847r5.html) - Deducing this * [P2128R5](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2128r5.pdf) - Multidimensional subscript operator * [P0849R7](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0849r7.html) - auto(x): decay-copy in the language * [P2041R1](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2041r1.html) - template = delete * [P2025R2](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2025r2.html) - Guaranteed copy elision for return variables * [P2071R0](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2071r0.html) - Named Universal Character Escapes * [P1040R3](http://www.open-std.org/jtc1/sc22/WG21/docs/papers/2020/p1040r6.html) - [std::embed](https://github.com/seanbaxter/circle/blob/master/embed/embed.md) Taken together, these make C++ programming experience a lot nicer! ## GPU targets Circle's main target is 64-bit Linux. Because all modern non-Microsoft operating systems use the same [C++ ABI](https://itanium-cxx-abi.github.io/cxx-abi/abi.html), it would be easy to bring Circle to these other platforms. But Circle supports both major GPU targets as well: 1. [Circle supports GPU compute](https://github.com/seanbaxter/circle/tree/master/cuda#cuda-on-circle) with a single-pass flavor of CUDA. * Use [libc and the C++ Standard Library](https://github.com/seanbaxter/circle/tree/master/cuda#improved-c-and-c-library-support-for-cuda) in device code. * Use [reflection and _if-target_](https://github.com/seanbaxter/circle/tree/master/cuda#reflection-and-if-target) to programmatically define the best tuning for each PTX architecture. 2. [Circle supports shader programming](https://github.com/seanbaxter/shaders#circle-c-shaders) by embedding [GLSL 4.6](https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.60.pdf) into C++ and emitting both SPIR-V (OpenGL and Vulkan) and DXIL (Direct3D 12) byte codes. * Tag functions and objects with [`spirv` attributes](https://github.com/seanbaxter/shaders#interface-attributes) to target all 12 standard shader stages. * Use reflection and user-defined attributes to automatically [generate interfaces](https://github.com/seanbaxter/shaders#reflection-and-attributes-for-shadertoy-development) to guide shader development. * Write device-portable GPGPU code with Vulkan compute, using real pointers into [physical storage buffers](https://github.com/seanbaxter/shaders#physical-storage-buffers), a powerful feature only implemented by the Circle compiler. Circle is a heterogeneous compiler. In one translation unit, [mix x64 code, CUDA code, and shader code](https://github.com/seanbaxter/circle/tree/master/cuda#circle-as-a-heterogeneous-compiler). No tags are required. Only a single frontend pass is performed. This is the most seamless integration of CPU and GPU code of any programming language. ## Using Circle > Download the latest version: [Build 170](https://www.circle-lang.org/linux/build_170.tgz) for 64-bit Linux. Circle is best used locally, on any recent x86-64 Linux installation. You have two choices for C++ standard library: 1. libstdc++ (gcc) is Circle's default standard library, and is the default on almost all Linux distributions. I like libstdc++-10.2. 2. libc++ (LLVM) is supported by specifying `-stdlib=libc++` or specifying `_LIBCPP_ABI_VERSION` as a command-line macro definitiono. If you're on an incompatible distribution, or a different OS altogether, try running Circle through this [Dockerfile](https://www.circle-lang.org/Dockerfile). Circle is also hosted on [Compiler Explorer](https://godbolt.org/z/zK7j8WrME), so you can use it over the web. ## Basic command-line options * `--help` list all command-line options. * `-c` only compiles to an object file, without linking. * `-E` only run the preprocessor. * `-fsyntax-only` only run the preprocessor and parser. * `-S` emits an ASM file (.s). * `-S -emit-llvm` emits a human-readable LLVM IR file (.ll). * `-c -emit-llvm` emits a binary LLVM IR bitcode file (.bc). * `-console` prints the output (if text) to the terminal. This is very useful when paired with -S or -S -emit-llvm * `-O0`, `-O1`, `-O2` and `-O3` are the usual optimization levels. * `-g` generates debug info. * `-dM` dump macros. * `-M` names a compile-time shared object library. This enables compile-time foreign function calls to compiled code. * `-stat` reports on files opened and lines lexed. * `-no-demangle` prints mangled names in link errors. * `-P2128` enable multi-dimensional subscript operator.