diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2026-04-06 15:55:33 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2026-04-06 15:55:33 +0200 |
| commit | fc41f7917531693680b5baf71ffe38c47333fe84 (patch) | |
| tree | a6e62232e05e7779034c5f9d1bf743b6f1c198e3 /README.md | |
| parent | fe534f1497da6447153064d7bba00243000f803b (diff) | |
| download | nissy-core-fc41f7917531693680b5baf71ffe38c47333fe84.tar.gz nissy-core-fc41f7917531693680b5baf71ffe38c47333fe84.zip | |
Make the project build with Microsoft's broken C compiler.
MSVC is not fully C11-compliant, even when compiling with /std:c11.
Some changes were needed to make the codebase compatible. Notably, the
notation a[static N] and a[n] for function parameters of array type is
not supported, so that had to be hidden behind a macro. Atomic types
are also an experimental feature, apparently, but at least they work
with the correct compiler flag.
One thing that MSVC does well, however, is warning on integer conversions
on /W4 level. I am not sure if Clang and GCC have something similar,
so I took this chance to fix some of these.
Diffstat (limited to '')
| -rw-r--r-- | README.md | 39 |
1 files changed, 31 insertions, 8 deletions
| @@ -39,14 +39,26 @@ is going to configure `nissy` to use at most 3 threads, and build it with | |||
| 39 | 39 | ||
| 40 | ### Windows | 40 | ### Windows |
| 41 | 41 | ||
| 42 | It is possible to build this project on Windows using `build.bat`. The | 42 | It is possible to build this project on Windows using `build.bat`, using |
| 43 | [Clang](https://clang.llvm.org/) compiler must be installed, and the | 43 | either MSVC (default) or [Clang](https://clang.llvm.org/). In either case, |
| 44 | command prompt must be correctly configured to run it. | 44 | the command prompt must be correctly configured to run the compiler from |
| 45 | the command line. | ||
| 45 | 46 | ||
| 46 | We suggest installing Clang via the Visual Studio Installer, selecting | 47 | For Clang, we suggest installing it via the Visual Studio Installer, |
| 47 | the "C++ development" pack, as well as the "clang" and "Windows SDK 11" | 48 | selecting the "C++ development" pack, as well as the "clang" and "Windows |
| 48 | components. It is advised to use "x64 Native Tools Command Prompt for | 49 | SDK 11" components. It is advised to use "x64 Native Tools Command Prompt |
| 49 | VS 2022" instead of a regular command prompt to run the build script. | 50 | for VS 2022" instead of a regular command prompt to run the build script. |
| 51 | |||
| 52 | |||
| 53 | You can specify the compiler to use by setting the | ||
| 54 | `CC` environment variable to either `clang` or `msvc`. For example: | ||
| 55 | |||
| 56 | ``` | ||
| 57 | > SET CC=clang | ||
| 58 | > build.bat test | ||
| 59 | ``` | ||
| 60 | |||
| 61 | Will run all the tests using clang. | ||
| 50 | 62 | ||
| 51 | The `build.bat` script has the same syntax as the `build.sh` script, | 63 | The `build.bat` script has the same syntax as the `build.sh` script, |
| 52 | but not all options are available. For example | 64 | but not all options are available. For example |
| @@ -64,9 +76,20 @@ can be used to build the basic shell, while | |||
| 64 | Builds and runs the unit tests. See `build.bat help` for a list of | 76 | Builds and runs the unit tests. See `build.bat help` for a list of |
| 65 | all available options. | 77 | all available options. |
| 66 | 78 | ||
| 67 | Note: The build script for Windows does not support all the options | 79 | #### Caveats for building on Windows |
| 80 | |||
| 81 | * The build script for Windows does not support all the options | ||
| 68 | available with build.sh. If you want to tune the build options, you'll | 82 | available with build.sh. If you want to tune the build options, you'll |
| 69 | have to manually edit the build script. | 83 | have to manually edit the build script. |
| 84 | * If you are building on an old x86-64 machine that does not support AVX2 | ||
| 85 | instructions, you will have to manually set the architecture to `PORTABLE` | ||
| 86 | with `SET ARCH=PORTABLE`. | ||
| 87 | * Build on Windows on ARM has not been tested at all. | ||
| 88 | * When building with MSVC, the option `/experimental:c11atomics` is used. | ||
| 89 | Despite atomic types being part of the C11 standard for 15 years now, | ||
| 90 | they have only [recently been | ||
| 91 | implemented](https://devblogs.microsoft.com/cppblog/c11-atomics-in-visual-studio-2022-version-17-5-preview-2), | ||
| 92 | and Microsoft still considers them an experimental feature. Impressive! | ||
| 70 | 93 | ||
| 71 | ## Running tests | 94 | ## Running tests |
| 72 | 95 | ||
