nix: build with clang
Some checks failed
Test / Create distribution (push) Failing after 30s
Test / Sandbox (push) Successful in 40s
Test / Sandbox (race detector) (push) Successful in 41s
Test / Hpkg (push) Successful in 41s
Test / Hakurei (push) Successful in 2m33s
Test / Hakurei (race detector) (push) Successful in 3m11s
Test / Flake checks (push) Successful in 1m36s

Clang is better than gcc in various ways. This also pulls in clang-format which is very helpful.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
Ophestra 2025-11-15 16:27:34 +09:00
parent a91920310d
commit 2c51ff8c83
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q
4 changed files with 16 additions and 7 deletions

View File

@ -114,7 +114,7 @@
inherit (pkgs) inherit (pkgs)
# passthru.buildInputs # passthru.buildInputs
go go
gcc clang
# nativeBuildInputs # nativeBuildInputs
pkg-config pkg-config
@ -129,6 +129,10 @@
zstd zstd
gnutar gnutar
coreutils coreutils
# for check
util-linux
nettools
; ;
}; };
hsu = pkgs.callPackage ./cmd/hsu/package.nix { inherit (self.packages.${system}) hakurei; }; hsu = pkgs.callPackage ./cmd/hsu/package.nix { inherit (self.packages.${system}) hakurei; };

View File

@ -38,7 +38,7 @@ static void hakurei_shim_sigaction(int sig, siginfo_t *si, void *ucontext) {
void hakurei_shim_setup_cont_signal(pid_t ppid, int fd) { void hakurei_shim_setup_cont_signal(pid_t ppid, int fd) {
if (hakurei_shim_param_ppid != -1 || hakurei_shim_fd != -1) if (hakurei_shim_param_ppid != -1 || hakurei_shim_fd != -1)
*(int *)NULL = 0; /* unreachable */ *(volatile int *)NULL = 0; /* unreachable */
struct sigaction new_action = {0}, old_action = {0}; struct sigaction new_action = {0}, old_action = {0};
if (sigaction(SIGCONT, NULL, &old_action) != 0) if (sigaction(SIGCONT, NULL, &old_action) != 0)

View File

@ -20,7 +20,7 @@
# for passthru.buildInputs # for passthru.buildInputs
go, go,
gcc, clang,
# for check # for check
util-linux, util-linux,
@ -81,8 +81,13 @@ buildGoModule rec {
hsuPath = "/run/wrappers/bin/hsu"; hsuPath = "/run/wrappers/bin/hsu";
}; };
# nix build environment does not allow acls env = {
env.GO_TEST_SKIP_ACL = 1; # use clang instead of gcc
CC = "clang -O3 -Werror";
# nix build environment does not allow acls
GO_TEST_SKIP_ACL = 1;
};
buildInputs = [ buildInputs = [
libffi libffi
@ -135,7 +140,7 @@ buildGoModule rec {
passthru.targetPkgs = [ passthru.targetPkgs = [
go go
gcc clang
xorg.xorgproto xorg.xorgproto
util-linux util-linux

View File

@ -44,7 +44,7 @@ nixosTest {
cd ${self.packages.${system}.hakurei.src} cd ${self.packages.${system}.hakurei.src}
${fhs}/bin/hakurei-fhs -c \ ${fhs}/bin/hakurei-fhs -c \
'go test ${if withRace then "-race" else "-count 16"} ./...' \ 'CC="clang -O3 -Werror" go test ${if withRace then "-race" else "-count 16"} ./...' \
&> /tmp/hakurei-test.log && \ &> /tmp/hakurei-test.log && \
touch /tmp/hakurei-test-ok touch /tmp/hakurei-test-ok
touch /tmp/hakurei-test-done touch /tmp/hakurei-test-done