authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-26 01:57:34-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-26 02:21:29-04:00
log2f208330975041cdb36763fab314037e46c291fc
tree1a67d83307e9fb229ece6b14093075bc12162e44
parent68bb3945708c43109c48bda3664176307d45b62c
signaturelock-open Commit is signed but in an unrecognized format.

add -DZIG_SKIP_INSTALL_LIB_FILES cmake option

closes #2221

2 files changed, 47 insertions(+), 7 deletions(-)

CMakeLists.txt+7-1
......@@ -41,6 +41,7 @@ message("Configuring zig version ${ZIG_VERSION}")
4141
4242set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)")
4343set(ZIG_STATIC_LLVM off CACHE BOOL "Prefer linking against static LLVM libraries")
44set(ZIG_SKIP_INSTALL_LIB_FILES off CACHE BOOL "Disable copying lib/ files to install prefix")
4445
4546if(ZIG_STATIC)
4647 set(ZIG_STATIC_LLVM "on")
......@@ -599,10 +600,15 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
599600else()
600601 set(LIBUSERLAND_RELEASE_MODE "true")
601602endif()
603if(ZIG_SKIP_INSTALL_LIB_FILES)
604 set(ZIG_BUILD_INSTALL_STEP "")
605else()
606 set(ZIG_BUILD_INSTALL_STEP "install")
607endif()
602608add_custom_target(zig_build_libuserland ALL
603609 COMMAND zig0 build
604610 --override-lib-dir "${CMAKE_SOURCE_DIR}/lib"
605 libuserland install
611 libuserland ${ZIG_BUILD_INSTALL_STEP}
606612 "-Doutput-dir=${CMAKE_BINARY_DIR}"
607613 "-Drelease=${LIBUSERLAND_RELEASE_MODE}"
608614 "-Dlib-files-only"
CONTRIBUTING.md+40-6
......@@ -53,10 +53,15 @@ knowledge of Zig internals.**
5353
5454First, build the Stage 1 compiler as described in [the Building section](#building).
5555
56When 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
58new file to the standard library, you must also add the file path in
59CMakeLists.txt.
56One modification you may want to make is adding `-DZIG_SKIP_INSTALL_LIB_FILES=ON`
57to the cmake line. If you use the build directory as a working directory to run
58tests with, zig will find the lib files in the source directory, and they will not
59be "installed" every time you run `make`. This will allow you to make modifications
60directly to the standard library, for example, and have them effective immediately.
61Note that if you already ran `make` or `make install` with the default cmake
62settings, there will already be a `lib/` directory in your build directory. When
63executed from the build directory, zig will find this instead of the source lib/
64directory. Remove the unwanted directory so that the desired one can be found.
6065
6166To test changes, do the following from the build directory:
6267
......@@ -65,8 +70,9 @@ To test changes, do the following from the build directory:
65702. `bin/zig build test` (on POSIX) or `bin\zig.exe build test` (on Windows).
6671
6772That runs the whole test suite, which does a lot of extra testing that you
68likely won't always need, and can take upwards of 2 hours. This is what the
69CI server runs when you make a pull request.
73likely won't always need, and can take upwards of 1 hour. This is what the
74CI server runs when you make a pull request. (Note: actually it runs a few
75more tests; keep reading.)
7076
7177To save time, you can add the `--help` option to the `zig build` command and
7278see what options are available. One of the most helpful ones is
......@@ -89,3 +95,31 @@ them).
8995When making changes to the compiler source code, the most helpful test step to
9096run is `test-behavior`. When editing documentation it is `docs`. You can find
9197this information and more in the `--help` menu.
98
99#### Testing Non-Native Architectures with QEMU
100
101The Linux CI server additionally has qemu installed and sets `-Denable-qemu`.
102This provides test coverage for, e.g. aarch64 even on x86_64 machines. It's
103recommended for Linux users to install qemu and enable this testing option
104when editing the standard library or anything related to a non-native
105architecture.
106
107##### glibc
108
109Testing foreign architectures with dynamically linked glibc is one step trickier.
110This requires enabling `-Denable-foreign-glibc=/path/to/glibc/multi/install/glibcs`.
111This path is obtained by building glibc for multiple architectures. This
112process for me took an entire day to complete and takes up 65 GiB on my hard
113drive. The CI server does not provide this test coverage. Instructions for
114producing this path can be found
115[on the wiki](https://github.com/ziglang/zig/wiki/Updating-libc#glibc).
116Just the part with `build-many-glibcs.py`.
117
118It's understood that most contributors will not have these tests enabled.
119
120#### Testing Windows from a Linux Machine with Wine
121
122When developing on Linux, another option is available to you: `-Denable-wine`.
123This will enable running behavior tests and std lib tests with Wine. It's
124recommended for Linux users to install Wine and enable this testing option
125when editing the standard library or anything Windows-related.