Tracy: autotools setup

Well, this was as painful as expected.

Introducing a proper autotool-based tracy build. I don't think this is
the right approach, but hey, it works.

Tracy is not distributing any pkg-config file, so we had to fallback
to a more "manual" method to propagate the headers path. Instead of
having a plain enable/disable flag, we send the path to the tracy
/public subfolder (~= $out in the Tracy Nix derivation).

The flake Nixpkgs is currently pointing to 23.05. The tracy derivation
was only building the visualizer, not the client library back then. We
introduce a 23.11 Nixpkgs and build its Tracy derivation with the
23.05 toolchain to go around some glibc ABI incompatibilities.

Kudos to Mic92 for the help for the flake bit.

Co-authored-by: Jörg Thalheim <joerg@thalheim.io>
This commit is contained in:
Félix Baylac Jacqué 2024-02-07 16:43:05 +01:00
parent 376d9dd520
commit a53425cac4
6 changed files with 54 additions and 6 deletions

View File

@ -14,6 +14,7 @@ ENABLE_FUNCTIONAL_TESTS = @ENABLE_FUNCTIONAL_TESTS@
ENABLE_INTERNAL_API_DOCS = @ENABLE_INTERNAL_API_DOCS@
ENABLE_S3 = @ENABLE_S3@
ENABLE_UNIT_TESTS = @ENABLE_UNIT_TESTS@
ENABLE_TRACY = @ENABLE_TRACY@
GTEST_LIBS = @GTEST_LIBS@
HAVE_LIBCPUID = @HAVE_LIBCPUID@
HAVE_SECCOMP = @HAVE_SECCOMP@

View File

@ -348,6 +348,15 @@ if test "$gc" = yes; then
AC_DEFINE(HAVE_BOEHMGC, 1, [Whether to use the Boehm garbage collector.])
fi
AC_ARG_ENABLE(tracy-profiler, AS_HELP_STRING([--enable-tracy-profiler],[Profile the Nix evaluation using the Tracy profiler (default no)]),
TRACY_PROFILER=$enableval, TRACY_PROFILER=no)
if test "$TRACY_PROFILER" != no; then
# We don't have any pkg-config file for tracy, we have to inject the
# headers manually…
CXXFLAGS="-I $TRACY_PROFILER/include/Tracy $CXXFLAGS"
fi
AC_SUBST(TRACY_PROFILER)
AS_IF([test "$ENABLE_UNIT_TESTS" == "yes"],[
# Look for gtest.

View File

@ -64,12 +64,29 @@
"type": "github"
}
},
"nixpkgs-tracy": {
"locked": {
"lastModified": 1707205788,
"narHash": "sha256-dFPctGYh7cNPAuJQY9i4+1/M+LdrRDpk0RRwpClEQ4w=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e311f423a6e56505afae9d4b621759826e7270c0",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.11-small",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"libgit2": "libgit2",
"nixpkgs": "nixpkgs",
"nixpkgs-regression": "nixpkgs-regression"
"nixpkgs-regression": "nixpkgs-regression",
"nixpkgs-tracy": "nixpkgs-tracy"
}
}
},

View File

@ -2,11 +2,14 @@
description = "The purely functional package manager";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05-small";
# Tracy is in a half-broken situation on 23.05. We need the changes
# introduced by https://github.com/NixOS/nixpkgs/pull/261589.
inputs.nixpkgs-tracy.url = "github:NixOS/nixpkgs/nixos-23.11-small";
inputs.nixpkgs-regression.url = "github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2";
inputs.flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
inputs.libgit2 = { url = "github:libgit2/libgit2"; flake = false; };
outputs = { self, nixpkgs, nixpkgs-regression, libgit2, ... }:
outputs = { self, nixpkgs, nixpkgs-regression, libgit2, nixpkgs-tracy, ... }:
let
inherit (nixpkgs) lib;
@ -186,6 +189,14 @@
stdenv
versionSuffix
;
# We have to use the nixos-23.11 tracy version. However,
# we can't link the 23.11 lib on our 23.05 nix without
# hitting some Glibc ABI incompatibilities.
#
# To go around that issue, we build the 23.11 tracy
# derivation with the 23.05 toolchain/libs.
tracy = final.callPackage (nixpkgs-tracy.legacyPackages.${final.hostPlatform.system}.path + "/pkgs/development/tools/tracy") {};
enableTracy = true;
officialRelease = false;
boehmgc = final.boehmgc-nix;
libgit2 = final.libgit2-nix;
@ -223,6 +234,10 @@
self.packages.${system}.nix.override { enableGC = false; }
);
buildWithTracy = forAllSystems (system:
self.packages.${system}.nix.override { enableTracy = true; }
);
buildNoTests = forAllSystems (system:
self.packages.${system}.nix.override {
doCheck = false;
@ -394,7 +409,7 @@
stdenvs)));
devShells = let
makeShell = pkgs: stdenv: (pkgs.nix.override { inherit stdenv; forDevShell = true; }).overrideAttrs (attrs: {
makeShell = pkgs: stdenv: (pkgs.nix.override { inherit stdenv; forDevShell = true; enableTracy = true; }).overrideAttrs (attrs: {
installFlags = "sysconfdir=$(out)/etc";
shellHook = ''
PATH=$prefix/bin:$PATH

View File

@ -34,6 +34,7 @@
, rapidcheck
, sqlite
, util-linux
, tracy
, xz
, busybox-sandbox-shell ? null
@ -76,6 +77,9 @@
# only leaked *within* the process.)
, enableGC ? true
# TODO
, enableTracy ? false
# Whether to enable Markdown rendering in the Nix binary.
, enableMarkdown ? !stdenv.hostPlatform.isWindows
@ -234,6 +238,7 @@ in {
rapidcheck
] ++ lib.optional stdenv.isLinux libseccomp
++ lib.optional stdenv.hostPlatform.isx86_64 libcpuid
++ lib.optional enableTracy tracy
# There have been issues building these dependencies
++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform && (stdenv.isLinux || stdenv.isDarwin))
(aws-sdk-cpp.override {
@ -287,6 +292,8 @@ in {
(lib.enableFeature enableMarkdown "markdown")
(lib.enableFeature installUnitTests "install-unit-tests")
(lib.withFeatureAs true "readline-flavor" readlineFlavor)
] ++ lib.optionals (enableTracy) [
"--enable-tracy-profiler=${tracy}"
] ++ lib.optionals (!forDevShell) [
"--sysconfdir=/etc"
] ++ lib.optionals installUnitTests [

View File

@ -10,10 +10,9 @@ libexpr_SOURCES := \
$(wildcard $(d)/primops/*.cc) \
$(wildcard $(d)/flake/*.cc) \
$(d)/lexer-tab.cc \
$(d)/parser-tab.cc \
$(d)/tracy/public/TracyClient.cpp
$(d)/parser-tab.cc
libexpr_CXXFLAGS += -I src/libutil -I src/libstore -I src/libfetchers -I src/libmain -I src/libexpr -I src/libexpr/tracy/public -DTRACY_ENABLE=1
libexpr_CXXFLAGS += -I src/libutil -I src/libstore -I src/libfetchers -I src/libmain -I src/libexpr
libexpr_LIBS = libutil libstore libfetchers