aboutsummaryrefslogtreecommitdiff
path: root/mk
AgeCommit message (Collapse)Author
2023-05-15Dedup some markdown -> C++ big literal stuff in build systemJohn Ericson
This pattern rule was unwisely hidden in `src/libstore/local.mk`. Now it is properly in `mk/` and we reuse it for the profile docs too.
2023-04-03Enable -Werror=switch-enumRobert Hensing
switch statements must now match all enum values or disable the warning. Explicit is good. This has helped us find two bugs, after solving another one by debugging. From now on, adding to an enum will raise errors where they are not explicitly handled, which is good for productivity, and helps us decide the correct behavior in all usages. Notably still excluded from this though are the cases where the warning is disabled by local pragmas. fromTOML.cc did not build despite a top-level pragma, so I've had to resort to a makefile solution for that.
2023-03-20Merge pull request #8068 from DieracDelta/jr/compile_darwinEelco Dolstra
Fix build aarch64-darwin for static library
2023-03-18fix: build aarch64-darwinJustin Restivo
2023-03-15Remove "unexpected EOF" retry hackEelco Dolstra
2023-03-08Harden tests' bashJohn Ericson
Use `set -u` and `set -o pipefail` to catch accidental mistakes and failures more strongly. - `set -u` catches the use of undefined variables - `set -o pipefail` catches failures (like `set -e`) earlier in the pipeline. This makes the tests a bit more robust. It is nice to read code not worrying about these spurious success paths (via uncaught) errors undermining the tests. Indeed, I caught some bugs doing this. There are a few tests where we run a command that should fail, and then search its output to make sure the failure message is one that we expect. Before, since the `grep` was the last command in the pipeline the exit code of those failing programs was silently ignored. Now with `set -o pipefail` it won't be, and we have to do something so the expected failure doesn't accidentally fail the test. To do that we use `expect` and a new `expectStderr` to check for the exact failing exit code. See the comments on each for why. `grep -q` is replaced with `grepQuiet`, see the comments on that function for why. `grep -v` when we just want the exit code is replaced with `grepInverse, see the comments on that function for why. `grep -q -v` together is, surprise surprise, replaced with `grepQuietInverse`, which is both combined. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-02-24Add ./configure --disable-tests optionRobert Hensing
Building without tests is useful for bootstrapping with a smaller footprint or running the tests in a separate derivation. Otherwise, we do compile and run them. This isn't fine grained as to allow picking `check` but not `installcheck` or vice versa, but it's good enough for now. I've tried to use Nixpkgs' `checkInputs`, but those inputs weren't discovered properly by the configure script. We can emulate its behavior very well though.
2023-02-14Fix static buildEelco Dolstra
For static builds, we need to propagate all the static library dependencies to the link of the program. E.g. if libstore-tests-exe depends on libnixstore-tests, and libnixstore-tests depends on libstore, then libstore-tests-exe needs to link against libstore. https://hydra.nixos.org/build/209007480
2023-01-29Allow programs to have custom namesJohn Ericson
Logic modeled after that for libraries.
2022-12-21Make `./mk/run-test.sh` work by itself; add `mk/debug-test.sh`John Ericson
First, logic is consolidated in the shell script instead of being spread between them and makefiles. That makes understanding what is going on a little easier. This would not be super interesting by itself, but it gives us a way to debug tests more easily. *That* in turn I hope is much more compelling. See the updated manual for details. Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io> Co-authored-by: Eelco Dolstra <edolstra@gmail.com> Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2022-06-22Fix incremental static buildsEelco Dolstra
$? refers to the object files that are newer, so the resulting file would lack all the older object files.
2022-03-03enable LTO in optimized buildspennae
gives 2-5% performance improvement across a board of tests. LTO is broken when using clang; some libs link fine while others crash the linker with a segfault in the llvm linker plugin. šŸ™
2022-03-02mk/run_test.sh: Add missing backslashEelco Dolstra
2022-03-01Acknowledge that the macOS tests are flakyregnat
Restart the tests (at most once) on `unexpected EOF` errors. This is truly ugly, but might prevent half of the CI runs to fail because of https://github.com/NixOS/nix/issues/3605
2022-02-09Revert "mk: prefert inplace library paths to system ones (take 2)"Sergei Trofimovich
2022-02-07mk: prefert inplace library paths to system ones (take 2)Sergei Trofimovich
It's a second attempt to merge the change. Previous attempt was reverted in b976b34a5b05ba303904cc7b8e0a2579bdb52807. Since then underlying failure exposed by original change was fixed by https://github.com/NixOS/nix/pull/5354. Below goes description of original change: The link failure happens on a system with stable nix-2.3.15 installed in /usr/lib64 (it's libutil.so API differs from master): ``` LANG=C make V=1 g++ -o /home/slyfox/dev/git/nix/src/libstore/libnixstore.so \ -shared -L/usr/lib64 -Wl,--no-copy-dt-needed-entries \ src/libstore/binary-cache-store.o ... src/libstore/uds-remote-store.o \ -lsqlite3 -lcurl -lsodium -pthread -ldl -lseccomp -Wl,-z,defs -Wl,-soname=libnixstore.so -Wl,-rpath,/home/slyfox/dev/git/nix/src/libutil -Lsrc/libutil -lnixutil ld: src/libstore/binary-cache-store.o: in function `nix::BinaryCacheStore::BinaryCacheStore( std::map<std::__cxx11::basic_string<char, std::char_traits<char>, ... nix/src/libstore/binary-cache-store.cc:30: undefined reference to `nix::readFile( std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' ... ... ``` This happens due to `-L/usr/lib64 -Lsrc/libutil` search path ordering. The change turns it into `-Lsrc/libutil -L/usr/lib64`. Closes: https://github.com/NixOS/nix/issues/3087
2021-10-08mk/libraries.mk: fix trace-ld and trace-ar expansionsSergei Trofimovich
Noticed this minor logging deficiency when debugged --disable-shared build: LD AR LD CXX src/libstore/local-store.o After the change build is logged as expected: LD src/libmain/libnixmain.a LD src/libfetchers/libnixfetchers.a AR src/libmain/libnixmain.a CXX src/libstore/local-store.o
2021-10-07Revert "mk: prefert inplace library paths to system ones"Tom Bereknyei
This reverts commit 4993174be59adc688efad49f2f9205688bd2ee26. buildStatic.x86_64-linux and buildStatic.aarch64-linux were broken, see https://hydra.nixos.org/build/151755012
2021-10-02mk/tests.mk: document 'check' and 'installcheck' in 'make help'Sergei Trofimovich
2021-08-28mk: prefert inplace library paths to system onesSergei Trofimovich
The link failure happens on a system with stable nix-2.3.15 installed in /usr/lib64 (it's libutil.so API differs from master): ``` LANG=C make V=1 g++ -o /home/slyfox/dev/git/nix/src/libstore/libnixstore.so \ -shared -L/usr/lib64 -Wl,--no-copy-dt-needed-entries \ src/libstore/binary-cache-store.o ... src/libstore/uds-remote-store.o \ -lsqlite3 -lcurl -lsodium -pthread -ldl -lseccomp -Wl,-z,defs -Wl,-soname=libnixstore.so -Wl,-rpath,/home/slyfox/dev/git/nix/src/libutil -Lsrc/libutil -lnixutil ld: src/libstore/binary-cache-store.o: in function `nix::BinaryCacheStore::BinaryCacheStore( std::map<std::__cxx11::basic_string<char, std::char_traits<char>, ... nix/src/libstore/binary-cache-store.cc:30: undefined reference to `nix::readFile( std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' ... ... ``` This happens due to `-L/usr/lib64 -Lsrc/libutil` search path ordering. The change turns it into `-Lsrc/libutil -L/usr/lib64`. Closes: https://github.com/NixOS/nix/issues/3087
2021-06-23Apply OS checks to host platform, not buildAlyssa Ross
Previously, the build system used uname(1) output when it wanted to check the operating system it was being built for, which meant that it didn't take into-account cross-compilation when the build and host operating systems were different. To fix this, instead of consulting uname output, we consult the host triple, specifically the third "kernel" part. For "kernel"s with stable ABIs, like Linux or Cygwin, we can use a simple ifeq to test whether we're compiling for that system, but for other platforms, like Darwin, FreeBSD, or Solaris, we have to use a more complicated check to take into account the version numbers at the end of the "kernel"s. I couldn't find a way to just strip these version numbers in GNU Make without shelling out, which would be even more ugly IMO. Because these checks differ between kernels, and the patsubst ones are quite fiddly, I've added variables for each host OS we might want to check to make them easier to reuse.
2021-03-01Merge pull request #4582 from puckipedia/cppflagsEelco Dolstra
mk: add support for CPPFLAGS
2021-03-01Merge remote-tracking branch 'origin/ca/move-tests-to-their-own-directory'Eelco Dolstra
2021-03-01Move the CA tests to a sub-directoryregnat
Requires a slight update to the test infra to work properly, but having the possibility to group tests that way makes the whole thing quite cleaner imho
2021-02-26Revert "Add support for building JARs from Java sources"Puck Meerburg
This reverts commit 259086de841d155f7951c2cc50f799a4631aa512.
2021-02-26mk: add support for CPPFLAGSPuck Meerburg
2020-12-03Remove 'dist' targetEelco Dolstra
We're not producing source tarballs anymore so this has been bitrotting.
2020-10-06mk/precompiled-headers.mk: Remove special handling for clangEelco Dolstra
2020-10-06mk/precompiled-headers.mk: Fix clang testEelco Dolstra
"clang++" includes the string "g++" so this test didn't work properly. However the separate handling of clang might not be needed anymore...
2020-09-21Disable precompiled headers in 'nix develop'Eelco Dolstra
They're still enabled in regular builds though.
2020-08-28Close stdin while running testsEelco Dolstra
For some reason, the bash shell started by 'nix develop' sometimes reads from stdin, which can hang.
2020-07-25Allow PRECOMPILE_HEADERS in cross-compilationMatthew Bauer
In cross, CXX will look like aarch64-unknown-linux-gnu-g++. We could run some command to check what kind of compiler it is, but for now we can just check if g++ is anywhere in the string. I couldnā€™t find any "ends with" for makefile, so it can be anywhere in CXX.
2020-07-03Shorten the path to the test rootregnat
Fix a socket length failure on the OSX builders
2020-07-03Fix the test dependenciesregnat
Reuse the pre-existing list rather than the one written as part of #3777
2020-07-02Run the tests in parallelregnat
Cause the time needed to run the testsuite to drop from ~4mins to ~40s
2020-06-09Prelink static libraries into an object fileMatthew Bauer
This combines the *.o into a big .o producing one translation unit. This preserve our unused static initializers, as specified in the C++ standard: If no variable or function is odr-used from a given translation unit, the non-local variables defined in that translation unit may never be initialized (this models the behavior of an on-demand dynamic library). Note that this is very similar to how the --whole-archive flag works. One advantage of this is that users of the final .a library donā€™t have to worry about specifying --whole-archive, or that we have unused static initializers at all!
2020-05-08Don't install unit testsEelco Dolstra
2020-05-08make check: Run unit testsEelco Dolstra
2020-03-30Remove global -I flagsEelco Dolstra
(cherry picked from commit 2c692a3b144523bca68dd6de618124ba6c9bb332)
2020-03-13mk/README.md: RemoveEelco Dolstra
The make-rules repo is not maintained.
2019-12-05Fix precompiled-headers generationEelco Dolstra
It's now regenerated when util.hh changes, and is ordered after config.h to fix a race.
2019-11-07Fix Perl bindingsEelco Dolstra
2019-11-07Precompile headersEelco Dolstra
This cuts 'make install -j6' on my laptop from 170s to 134s.
2019-07-03mk: add support for passing LDFLAGS to libs and binsSergei Trofimovich
autotools-based systems usually allow user to append own LDFLAGS like LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu" at ./configure stage This change plumbs LDFLAGS through similar to existing CXXFLAGS variable. Signed-off-by: Sergei Trofimovich <siarheit@google.com>
2019-02-13Support --disable-shared flag.Matthew Bauer
This tells Nix to not build the shared libraries.
2018-04-08Fix missing $DESTDIR when installing programsAndrew Dunham
2018-02-08Add plugins to make Nix more extensible.Shea Levy
All plugins in plugin-files will be dlopened, allowing them to statically construct instances of the various Register* types Nix supports.
2018-01-16Add pure evaluation modeEelco Dolstra
In this mode, the following restrictions apply: * The builtins currentTime, currentSystem and storePath throw an error. * $NIX_PATH and -I are ignored. * fetchGit and fetchMercurial require a revision hash. * fetchurl and fetchTarball require a sha256 attribute. * No file system access is allowed outside of the paths returned by fetch{Git,Mercurial,url,Tarball}. Thus 'nix build -f ./foo.nix' is not allowed. Thus, the evaluation result is completely reproducible from the command line arguments. E.g. nix build --pure-eval '( let nix = fetchGit { url = https://github.com/NixOS/nixpkgs.git; rev = "9c927de4b179a6dd210dd88d34bda8af4b575680"; }; nixpkgs = fetchGit { url = https://github.com/NixOS/nixpkgs.git; ref = "release-17.09"; rev = "66b4de79e3841530e6d9c6baf98702aa1f7124e4"; }; in (import (nix + "/release.nix") { inherit nix nixpkgs; }).build.x86_64-linux )' The goal is to enable completely reproducible and traceable evaluation. For example, a NixOS configuration could be fully described by a single Git commit hash. 'nixos-rebuild' would do something like nix build --pure-eval '( (import (fetchGit { url = file:///my-nixos-config; rev = "..."; })).system ') where the Git repository /my-nixos-config would use further fetchGit calls or Git externals to fetch Nixpkgs and whatever other dependencies it has. Either way, the commit hash would uniquely identify the NixOS configuration and allow it to reproduced.
2017-11-07Show when tests are skippedEelco Dolstra
Also, don't depend on tput (ncurses). It's really not needed since ANSI escape sequences have been standardized for 35 years or so.
2017-10-09WhitespaceEelco Dolstra