WIP: type per command #4

Draft
vinzenz wants to merge 25 commits from next into main
3 changed files with 36 additions and 33 deletions
Showing only changes of commit 7b33084a3e - Show all commits

View file

@ -36,7 +36,6 @@ THIS_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
REPO_ROOT := $(realpath $(THIS_DIR)/..) REPO_ROOT := $(realpath $(THIS_DIR)/..)
CARGO_OBJDIR := cargo/$(RUST_TARGET)/$(_profile) CARGO_OBJDIR := cargo/$(RUST_TARGET)/$(_profile)
# TODO: check if override is needed
_rust_cli_profile := $(if $(filter $(_profile),debug),dev,$(_profile)) _rust_cli_profile := $(if $(filter $(_profile),debug),dev,$(_profile))
# TODO: `make LINK=static` fails with linker error "undefined reference to `_dl_find_object'" in libgcc_eh.a # TODO: `make LINK=static` fails with linker error "undefined reference to `_dl_find_object'" in libgcc_eh.a
@ -57,7 +56,7 @@ CARGOFLAGS += --manifest-path=$(REPO_ROOT)/Cargo.toml \
CFLAGS += -Wall -Wextra -pedantic -fwhole-program -fPIE -pie CFLAGS += -Wall -Wextra -pedantic -fwhole-program -fPIE -pie
_no_debug_cflags := -ffunction-sections -fdata-sections -Wl,--gc-sections _no_debug_cflags := -ffunction-sections -fdata-sections -Wl,--gc-sections
size_optimized_CFLAGS += -Oz \ size_optimized_CFLAGS += -Oz \
-fwrapv -fomit-frame-pointer -fno-stack-protector\ -fwrapv -fomit-frame-pointer -fno-stack-protector \
-fno-unroll-loops \ -fno-unroll-loops \
-fno-unwind-tables -fno-asynchronous-unwind-tables \ -fno-unwind-tables -fno-asynchronous-unwind-tables \
-fmerge-all-constants \ -fmerge-all-constants \
@ -85,16 +84,16 @@ endif
size_optimized_RUSTFLAGS += -Zlocation-detail=none \ size_optimized_RUSTFLAGS += -Zlocation-detail=none \
-Zfmt-debug=none \ -Zfmt-debug=none \
-C link-arg=-z,norelro \ -C link-arg=-z,norelro \
-C panic=abort -C panic=abort \
#-C link-arg=--hash-style=gnu -C link-arg=-Wl,--hash-style=gnu
musl_RUSTFLAGS += --crate-type=staticlib -Ctarget-feature=-crt-static static_RUSTFLAGS += --crate-type=staticlib -Ctarget-feature=+crt-static
RUSTFLAGS += $($(_libc)_RUSTFLAGS) $($(_profile)_RUSTFLAGS) $($(_link_type)_RUSTFLAGS) RUSTFLAGS += $($(_libc)_RUSTFLAGS) $($(_profile)_RUSTFLAGS) $($(_link_type)_RUSTFLAGS)
ifneq ($(_profile), debug) ifneq ($(_profile), debug)
RUSTFLAGS += -C link-arg=-s -C link-arg=-Wl,--gc-sections RUSTFLAGS += -C link-arg=-s -C link-arg=-Wl,--gc-sections
endif endif
# TODO: wildcard does not work with VPATH # ADD NEW EXAMPLES HERE
_c_src := src/announce.c src/brightness_tester.c src/header_logger.c \ _c_src := src/announce.c src/brightness_tester.c src/header_logger.c \
src/moving_line.c src/random_stuff.c src/wiping_clear.c src/moving_line.c src/random_stuff.c src/wiping_clear.c
_programs := $(basename $(notdir $(_c_src))) _programs := $(basename $(notdir $(_c_src)))

View file

@ -2,16 +2,16 @@
"nodes": { "nodes": {
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1748037224, "lastModified": 1748302896,
"narHash": "sha256-92vihpZr6dwEMV6g98M5kHZIttrWahb9iRPBm1atcPk=", "narHash": "sha256-ixMT0a8mM091vSswlTORZj93WQAJsRNmEvqLL+qwTFM=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "f09dede81861f3a83f7f06641ead34f02f37597f", "rev": "7848cd8c982f7740edf76ddb3b43d234cb80fc4d",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "owner": "nixos",
"ref": "nixos-24.11", "ref": "nixos-25.05",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }

View file

@ -2,7 +2,7 @@
description = "Flake for the servicepoint library."; description = "Flake for the servicepoint library.";
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
}; };
outputs = outputs =
@ -31,37 +31,41 @@
{ {
devShells = forAllSystems ( devShells = forAllSystems (
{ pkgs, system }: { pkgs, system }:
let
toolchain = pkgs.symlinkJoin {
name = "rust-toolchain";
paths = with pkgs; [
rustc
cargo
rustPlatform.rustcSrc
rustPlatform.rustLibSrc
rustfmt
clippy
cargo-expand
cargo-tarpaulin
];
};
in
{ {
default = pkgs.mkShell rec { default = pkgs.mkShell rec {
buildInputs = with pkgs; [ packages = with pkgs; [
toolchain
gcc
gdb
gnumake
pkg-config
xe xe
xz xz
libgcc libgcc
libunwind libunwind
pkgsStatic.gcc
pkgsStatic.libgcc
pkgsStatic.musl pkgsStatic.musl
]; ];
nativeBuildInputs = with pkgs; [ RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
(pkgs.symlinkJoin { RUST_BACKTRACE = 1;
name = "rust-toolchain"; RUST_LOG = "all";
paths = with pkgs; [
rustc
cargo
rustPlatform.rustcSrc
rustfmt
clippy
cargo-expand
cargo-tarpaulin
];
})
gcc
gdb
pkgsStatic.gcc
gnumake
pkg-config
];
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
}; };
} }
); );