| ... | ... | @@ -53,10 +53,15 @@ knowledge of Zig internals.** |
| 53 | 53 | |
| 54 | 54 | First, build the Stage 1 compiler as described in [the Building section](#building). |
| 55 | 55 | |
| 56 | | When making changes to the standard library, be sure to edit the files in the |
| 57 | | `std` directory and not the installed copy in the build directory. If you add a |
| 58 | | new file to the standard library, you must also add the file path in |
| 59 | | CMakeLists.txt. |
| 56 | One modification you may want to make is adding `-DZIG_SKIP_INSTALL_LIB_FILES=ON` |
| 57 | to the cmake line. If you use the build directory as a working directory to run |
| 58 | tests with, zig will find the lib files in the source directory, and they will not |
| 59 | be "installed" every time you run `make`. This will allow you to make modifications |
| 60 | directly to the standard library, for example, and have them effective immediately. |
| 61 | Note that if you already ran `make` or `make install` with the default cmake |
| 62 | settings, there will already be a `lib/` directory in your build directory. When |
| 63 | executed from the build directory, zig will find this instead of the source lib/ |
| 64 | directory. Remove the unwanted directory so that the desired one can be found. |
| 60 | 65 | |
| 61 | 66 | To test changes, do the following from the build directory: |
| 62 | 67 | |
| ... | ... | @@ -65,8 +70,9 @@ To test changes, do the following from the build directory: |
| 65 | 70 | 2. `bin/zig build test` (on POSIX) or `bin\zig.exe build test` (on Windows). |
| 66 | 71 | |
| 67 | 72 | That runs the whole test suite, which does a lot of extra testing that you |
| 68 | | likely won't always need, and can take upwards of 2 hours. This is what the |
| 69 | | CI server runs when you make a pull request. |
| 73 | likely won't always need, and can take upwards of 1 hour. This is what the |
| 74 | CI server runs when you make a pull request. (Note: actually it runs a few |
| 75 | more tests; keep reading.) |
| 70 | 76 | |
| 71 | 77 | To save time, you can add the `--help` option to the `zig build` command and |
| 72 | 78 | see what options are available. One of the most helpful ones is |
| ... | ... | @@ -89,3 +95,31 @@ them). |
| 89 | 95 | When making changes to the compiler source code, the most helpful test step to |
| 90 | 96 | run is `test-behavior`. When editing documentation it is `docs`. You can find |
| 91 | 97 | this information and more in the `--help` menu. |
| 98 | |
| 99 | #### Testing Non-Native Architectures with QEMU |
| 100 | |
| 101 | The Linux CI server additionally has qemu installed and sets `-Denable-qemu`. |
| 102 | This provides test coverage for, e.g. aarch64 even on x86_64 machines. It's |
| 103 | recommended for Linux users to install qemu and enable this testing option |
| 104 | when editing the standard library or anything related to a non-native |
| 105 | architecture. |
| 106 | |
| 107 | ##### glibc |
| 108 | |
| 109 | Testing foreign architectures with dynamically linked glibc is one step trickier. |
| 110 | This requires enabling `-Denable-foreign-glibc=/path/to/glibc/multi/install/glibcs`. |
| 111 | This path is obtained by building glibc for multiple architectures. This |
| 112 | process for me took an entire day to complete and takes up 65 GiB on my hard |
| 113 | drive. The CI server does not provide this test coverage. Instructions for |
| 114 | producing this path can be found |
| 115 | [on the wiki](https://github.com/ziglang/zig/wiki/Updating-libc#glibc). |
| 116 | Just the part with `build-many-glibcs.py`. |
| 117 | |
| 118 | It's understood that most contributors will not have these tests enabled. |
| 119 | |
| 120 | #### Testing Windows from a Linux Machine with Wine |
| 121 | |
| 122 | When developing on Linux, another option is available to you: `-Denable-wine`. |
| 123 | This will enable running behavior tests and std lib tests with Wine. It's |
| 124 | recommended for Linux users to install Wine and enable this testing option |
| 125 | when editing the standard library or anything Windows-related. |