diff options
-rw-r--r-- | boehmgc-coroutine-sp-fallback.diff | 79 | ||||
-rw-r--r-- | boehmgc-traceable_allocator-public.diff | 12 | ||||
-rw-r--r-- | flake.lock | 8 | ||||
-rw-r--r-- | flake.nix | 2 | ||||
-rw-r--r-- | meson.build | 16 | ||||
-rw-r--r-- | meson.options | 4 | ||||
-rw-r--r-- | package.nix | 13 | ||||
-rw-r--r-- | src/libcmd/meson.build | 2 | ||||
-rw-r--r-- | src/libexpr/meson.build | 2 | ||||
-rw-r--r-- | src/libfetchers/meson.build | 2 | ||||
-rw-r--r-- | src/libmain/meson.build | 2 | ||||
-rw-r--r-- | src/libstore/meson.build | 2 | ||||
-rw-r--r-- | src/libutil/meson.build | 2 | ||||
-rw-r--r-- | src/nix/meson.build | 2 | ||||
-rw-r--r-- | tests/nixos/nix-copy.nix | 3 | ||||
-rw-r--r-- | tests/unit/meson.build | 12 |
16 files changed, 64 insertions, 99 deletions
diff --git a/boehmgc-coroutine-sp-fallback.diff b/boehmgc-coroutine-sp-fallback.diff index 24dcfa41a..a53b7f1f5 100644 --- a/boehmgc-coroutine-sp-fallback.diff +++ b/boehmgc-coroutine-sp-fallback.diff @@ -1,56 +1,8 @@ -diff --git a/darwin_stop_world.c b/darwin_stop_world.c -index 0468aaec..b348d869 100644 ---- a/darwin_stop_world.c -+++ b/darwin_stop_world.c -@@ -356,6 +356,7 @@ GC_INNER void GC_push_all_stacks(void) - int nthreads = 0; - word total_size = 0; - mach_msg_type_number_t listcount = (mach_msg_type_number_t)THREAD_TABLE_SZ; -+ size_t stack_limit; - if (!EXPECT(GC_thr_initialized, TRUE)) - GC_thr_init(); - -@@ -411,6 +412,19 @@ GC_INNER void GC_push_all_stacks(void) - GC_push_all_stack_sections(lo, hi, p->traced_stack_sect); - } - if (altstack_lo) { -+ // When a thread goes into a coroutine, we lose its original sp until -+ // control flow returns to the thread. -+ // While in the coroutine, the sp points outside the thread stack, -+ // so we can detect this and push the entire thread stack instead, -+ // as an approximation. -+ // We assume that the coroutine has similarly added its entire stack. -+ // This could be made accurate by cooperating with the application -+ // via new functions and/or callbacks. -+ stack_limit = pthread_get_stacksize_np(p->id); -+ if (altstack_lo >= altstack_hi || altstack_lo < altstack_hi - stack_limit) { // sp outside stack -+ altstack_lo = altstack_hi - stack_limit; -+ } -+ - total_size += altstack_hi - altstack_lo; - GC_push_all_stack(altstack_lo, altstack_hi); - } -diff --git a/include/gc.h b/include/gc.h -index edab6c22..f2c61282 100644 ---- a/include/gc.h -+++ b/include/gc.h -@@ -2172,6 +2172,11 @@ GC_API void GC_CALL GC_win32_free_heap(void); - (*GC_amiga_allocwrapper_do)(a,GC_malloc_atomic_ignore_off_page) - #endif /* _AMIGA && !GC_AMIGA_MAKINGLIB */ - -+#if !__APPLE__ -+/* Patch doesn't work on apple */ -+#define NIX_BOEHM_PATCH_VERSION 1 -+#endif -+ - #ifdef __cplusplus - } /* extern "C" */ - #endif diff --git a/pthread_stop_world.c b/pthread_stop_world.c -index b5d71e62..aed7b0bf 100644 +index 2b45489..0e6d8ef 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c -@@ -768,6 +768,8 @@ STATIC void GC_restart_handler(int sig) +@@ -776,6 +776,8 @@ STATIC void GC_restart_handler(int sig) /* world is stopped. Should not fail if it isn't. */ GC_INNER void GC_push_all_stacks(void) { @@ -59,20 +11,23 @@ index b5d71e62..aed7b0bf 100644 GC_bool found_me = FALSE; size_t nthreads = 0; int i; -@@ -851,6 +853,37 @@ GC_INNER void GC_push_all_stacks(void) - hi = p->altstack + p->altstack_size; +@@ -868,6 +870,40 @@ GC_INNER void GC_push_all_stacks(void) + hi = p->altstack + p->altstack_size; + # endif /* FIXME: Need to scan the normal stack too, but how ? */ - /* FIXME: Assume stack grows down */ + } else { -+#ifdef HAVE_PTHREAD_ATTR_GET_NP -+ if (!pthread_attr_init(&pattr) -+ || !pthread_attr_get_np(p->id, &pattr)) -+#else /* HAVE_PTHREAD_GETATTR_NP */ -+ if (pthread_getattr_np(p->id, &pattr)) -+#endif -+ { ++ #ifdef HAVE_PTHREAD_ATTR_GET_NP ++ if (pthread_attr_init(&pattr) != 0) { ++ ABORT("GC_push_all_stacks: pthread_attr_init failed!"); ++ } ++ if (pthread_attr_get_np(p->id, &pattr) != 0) { ++ ABORT("GC_push_all_stacks: pthread_attr_get_np failed!"); ++ } ++ #else ++ if (pthread_getattr_np(p->id, &pattr)) { + ABORT("GC_push_all_stacks: pthread_getattr_np failed!"); + } ++ #endif + if (pthread_attr_getstacksize(&pattr, &stack_limit)) { + ABORT("GC_push_all_stacks: pthread_attr_getstacksize failed!"); + } @@ -95,5 +50,5 @@ index b5d71e62..aed7b0bf 100644 + #error "STACK_GROWS_UP not supported in boost_coroutine2 (as of june 2021), so we don't support it in Nix." + #endif } - GC_push_all_stack_sections(lo, hi, traced_stack_sect); - # ifdef STACK_GROWS_UP + # ifdef STACKPTR_CORRECTOR_AVAILABLE + if (GC_sp_corrector != 0) diff --git a/boehmgc-traceable_allocator-public.diff b/boehmgc-traceable_allocator-public.diff deleted file mode 100644 index a0c51ef4d..000000000 --- a/boehmgc-traceable_allocator-public.diff +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/include/gc_allocator.h b/include/gc_allocator.h -index 597c7f13..587286be 100644 ---- a/include/gc_allocator.h -+++ b/include/gc_allocator.h -@@ -312,6 +312,7 @@ public: - - template<> - class traceable_allocator<void> { -+public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef void* pointer; diff --git a/flake.lock b/flake.lock index 8e59b2942..1b3e77cf4 100644 --- a/flake.lock +++ b/flake.lock @@ -18,16 +18,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1715123187, - "narHash": "sha256-0czuu757t53lK6uWeo1a5/jJbCd9t4sOtLDFpts60DM=", + "lastModified": 1717796960, + "narHash": "sha256-BKjQ9tQdsuoROrojHZb7KTAv95WprqCkNFvuzatfEo0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "0c592f9a288bdf764b6f24c757277c0e49757a46", + "rev": "8e0a5f16b7bf7f212be068dd302c49888c6ad68f", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-23.11-small", + "ref": "nixos-24.05-small", "repo": "nixpkgs", "type": "github" } @@ -2,7 +2,7 @@ description = "The purely functional package manager"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11-small"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05-small"; nixpkgs-regression.url = "github:NixOS/nixpkgs/215d4d0fd80ca5163643b03a33fde804a29cc1e2"; pre-commit-hooks = { url = "github:cachix/git-hooks.nix"; diff --git a/meson.build b/meson.build index 51c7bda59..e5fb21e88 100644 --- a/meson.build +++ b/meson.build @@ -129,6 +129,20 @@ endif cxx = meson.get_compiler('cpp') + +# clangd breaks when GCC is using precompiled headers lmao +# https://git.lix.systems/lix-project/lix/issues/374 +should_pch = get_option('enable-pch-std') +summary('PCH C++ stdlib', should_pch, bool_yn : true) +if should_pch + # Unlike basically everything else that takes a file, Meson requires the arguments to + # cpp_pch : to be strings and doesn't accept files(). So absolute path it is. + cpp_pch = [meson.project_source_root() / 'src/pch/precompiled-headers.hh'] +else + cpp_pch = [] +endif + + # Translate some historical and Mesony CPU names to Lixy CPU names. # FIXME(Qyriad): the 32-bit x86 code is not tested right now, because cross compilation for Lix # to those architectures is currently broken for other reasons, namely: @@ -175,7 +189,7 @@ configdata = { } # Dependencies # -boehm = dependency('bdw-gc', required : get_option('gc')) +boehm = dependency('bdw-gc', required : get_option('gc'), version : '>=8.2.6') if boehm.found() deps += boehm endif diff --git a/meson.options b/meson.options index 6b13fa8a0..fc2050809 100644 --- a/meson.options +++ b/meson.options @@ -64,3 +64,7 @@ option('internal-api-docs', type : 'feature', value : 'auto', option('profile-dir', type : 'string', value : 'etc/profile.d', description : 'the path to install shell profile files', ) + +option('enable-pch-std', type : 'boolean', value : true, + description : 'whether to use precompiled headers for C++\'s standard library (breaks clangd if you\'re using GCC)', +) diff --git a/package.nix b/package.nix index 9c108308d..91ee6b15f 100644 --- a/package.nix +++ b/package.nix @@ -70,8 +70,6 @@ # `boehmgc-nix` then this will almost certainly have duplicate patches, which means # the patches won't apply and we'll get a build failure. ./boehmgc-coroutine-sp-fallback.diff - # https://github.com/ivmai/bdwgc/pull/586 - ./boehmgc-traceable_allocator-public.diff ]; }; @@ -439,9 +437,14 @@ stdenv.mkDerivation (finalAttrs: { # For Meson to find Boost. env = finalAttrs.env; - # I guess this is necessary because mesonFlags to mkDerivation doesn't propagate in inputsFrom, - # which only propagates stuff set in hooks? idk. - inherit (finalAttrs) mesonFlags; + mesonFlags = + # I guess this is necessary because mesonFlags to mkDerivation doesn't propagate in inputsFrom, + # which only propagates stuff set in hooks? idk. + finalAttrs.mesonFlags + # Clangd breaks when GCC is using precompiled headers, so for the devshell specifically + # we make precompiled C++ stdlib conditional on using Clang. + # https://git.lix.systems/lix-project/lix/issues/374 + ++ [ (lib.mesonBool "enable-pch-std" stdenv.cc.isClang) ]; packages = lib.optional (stdenv.cc.isClang && hostPlatform == buildPlatform) clang-tools_llvm diff --git a/src/libcmd/meson.build b/src/libcmd/meson.build index 4dc0714c8..3d92f36a4 100644 --- a/src/libcmd/meson.build +++ b/src/libcmd/meson.build @@ -54,7 +54,7 @@ libcmd = library( nlohmann_json, lix_doc ], - cpp_pch : ['../pch/precompiled-headers.hh'], + cpp_pch : cpp_pch, install : true, # FIXME(Qyriad): is this right? install_rpath : libdir, diff --git a/src/libexpr/meson.build b/src/libexpr/meson.build index e60a85b5d..080fdb443 100644 --- a/src/libexpr/meson.build +++ b/src/libexpr/meson.build @@ -145,7 +145,7 @@ libexpr = library( include_directories : [ '../libmain', ], - cpp_pch : ['../pch/precompiled-headers.hh'], + cpp_pch : cpp_pch, install : true, # FIXME(Qyriad): is this right? install_rpath : libdir, diff --git a/src/libfetchers/meson.build b/src/libfetchers/meson.build index ee38b6cda..b66d0b9f9 100644 --- a/src/libfetchers/meson.build +++ b/src/libfetchers/meson.build @@ -30,7 +30,7 @@ libfetchers = library( liblixutil, nlohmann_json, ], - cpp_pch : ['../pch/precompiled-headers.hh'], + cpp_pch : cpp_pch, install : true, # FIXME(Qyriad): is this right? install_rpath : libdir, diff --git a/src/libmain/meson.build b/src/libmain/meson.build index 075aa83b2..a7cce287c 100644 --- a/src/libmain/meson.build +++ b/src/libmain/meson.build @@ -20,7 +20,7 @@ libmain = library( liblixutil, liblixstore, ], - cpp_pch : ['../pch/precompiled-headers.hh'], + cpp_pch : cpp_pch, install : true, # FIXME(Qyriad): is this right? install_rpath : libdir, diff --git a/src/libstore/meson.build b/src/libstore/meson.build index 7a129d22c..fa363bd19 100644 --- a/src/libstore/meson.build +++ b/src/libstore/meson.build @@ -220,7 +220,7 @@ libstore = library( nlohmann_json, ], cpp_args : cpp_args, - cpp_pch : ['../pch/precompiled-headers.hh'], + cpp_pch : cpp_pch, install : true, # FIXME(Qyriad): is this right? install_rpath : libdir, diff --git a/src/libutil/meson.build b/src/libutil/meson.build index 8c3377e76..f6d14a11b 100644 --- a/src/libutil/meson.build +++ b/src/libutil/meson.build @@ -129,7 +129,7 @@ libutil = library( openssl, nlohmann_json, ], - cpp_pch : ['../pch/precompiled-headers.hh'], + cpp_pch : cpp_pch, implicit_include_directories : true, install : true, ) diff --git a/src/nix/meson.build b/src/nix/meson.build index 8115a3d08..22f148fcb 100644 --- a/src/nix/meson.build +++ b/src/nix/meson.build @@ -89,7 +89,7 @@ nix = executable( boehm, nlohmann_json, ], - cpp_pch : ['../pch/precompiled-headers.hh'], + cpp_pch : cpp_pch, install : true, # FIXME(Qyriad): is this right? install_rpath : libdir, diff --git a/tests/nixos/nix-copy.nix b/tests/nixos/nix-copy.nix index 3bcc7a988..44aa0b7da 100644 --- a/tests/nixos/nix-copy.nix +++ b/tests/nixos/nix-copy.nix @@ -37,7 +37,8 @@ in { { config, pkgs, ... }: { services.openssh.enable = true; services.openssh.settings.PermitRootLogin = "yes"; - users.users.root.password = "foobar"; + users.users.root.hashedPasswordFile = lib.mkForce null; + users.users.root.password = "foobar"; virtualisation.writableStore = true; virtualisation.additionalPaths = [ pkgB pkgC ]; }; diff --git a/tests/unit/meson.build b/tests/unit/meson.build index 06aff4626..0d3f00ba5 100644 --- a/tests/unit/meson.build +++ b/tests/unit/meson.build @@ -68,7 +68,7 @@ libutil_tester = executable( liblixutil_test_support, nlohmann_json, ], - cpp_pch : ['../../src/pch/precompiled-headers.hh'], + cpp_pch : cpp_pch, ) test( @@ -103,7 +103,7 @@ libstore_test_support = library( include_directories : include_directories( 'libstore-support', ), - cpp_pch : ['../../src/pch/precompiled-headers.hh'], + cpp_pch : cpp_pch, ) liblixstore_test_support = declare_dependency( include_directories : include_directories('libstore-support'), @@ -137,7 +137,7 @@ libstore_tester = executable( gtest, nlohmann_json, ], - cpp_pch : ['../../src/pch/precompiled-headers.hh'], + cpp_pch : cpp_pch, ) test( @@ -169,7 +169,7 @@ libexpr_test_support = library( include_directories : include_directories( 'libexpr-support', ), - cpp_pch : ['../../src/pch/precompiled-headers.hh'], + cpp_pch : cpp_pch, ) liblixexpr_test_support = declare_dependency( include_directories : include_directories('libexpr-support'), @@ -203,7 +203,7 @@ libexpr_tester = executable( gtest, nlohmann_json, ], - cpp_pch : ['../../src/pch/precompiled-headers.hh'], + cpp_pch : cpp_pch, ) test( @@ -230,7 +230,7 @@ libcmd_tester = executable( gtest, boost, ], - cpp_pch : ['../../src/pch/precompiled-headers.hh'], + cpp_pch : cpp_pch, ) test( |