fix the static build

- launch-builder-linux.cc was missing an include for musl
  and used function that are not defined in the launchers
- musl caches pids used for raise, breaking sandbox setup
- the mtls contrib plugin won't build, didn't try fixing,
  static builds can't really use plugins reliably anyway.

Change-Id: I5ab1664e45ea977e5bcf05e41d825e6014e62146
This commit is contained in:
eldritch horrors
2026-03-17 14:24:13 +01:00
parent f87d753987
commit 022e43aa7f
3 changed files with 14 additions and 3 deletions
+6 -1
View File
@@ -3,6 +3,7 @@
#include "lix/libutil/rpc.hh"
#include <cassert>
#include <csignal>
#include <fcntl.h>
#include <filesystem>
#include <format>
#include <kj/io.h>
@@ -224,7 +225,11 @@ bool prepareChildSetup(build::Request::Reader request)
};
const fs::path dst = chrootRootDir / target.relative_path();
fs::create_directories(dst.parent_path());
writeFile(dst, std::string_view((const char *) sh, sizeof(sh)));
kj::AutoCloseFd fd(open(dst.c_str(), O_RDWR | O_CREAT, 0755));
if (fd == nullptr) {
throw SysError("cannot create sandbox shell");
}
writeFull(fd.get(), std::string_view((const char *) sh, sizeof(sh)));
fs::permissions(dst, fs::perms(0555));
} else
#endif
+4 -1
View File
@@ -1348,7 +1348,10 @@ Pid LinuxLocalDerivationGoal::startChild(AutoCloseFD setupFD, AutoCloseFD logPTY
(wantUserNS ? CLONE_NEWUSER : 0) | (wantNetNS ? CLONE_NEWNET : 0) | CLONE_VM | CLONE_FILES,
[]() -> int {
for (;;) {
raise(SIGSTOP);
// NOTE: musl apparently caches the pid of the process, which fucks with raise().
// we must explicitly use getpid() to bypass this cache instead of using raise; a
// raise(SIGSTOP) would stop the *daemon* process, and this breaks sandbox setup.
kill(getpid(), SIGSTOP);
}
}
)};
+4 -1
View File
@@ -366,7 +366,10 @@ stdenv.mkDerivation (finalAttrs: {
"-Dc_link_args=-fuse-ld=lld"
"-Dcpp_link_args=-fuse-ld=lld"
]
++ lib.optional hostPlatform.isStatic "-Denable-embedded-sandbox-shell=true"
++ lib.optionals hostPlatform.isStatic [
"-Denable-embedded-sandbox-shell=true"
"-Denable-contrib-plugins=false"
]
++ lib.optional ciBuildAndDeleteBothLibraries "-Ddefault_library=both"
# musl doesn't support fibers, and we can't detect this with meson alone.
++ lib.optional hostPlatform.isMusl "-Ddisable-fibers=true"