Skip to content

Commit 36b056b

Browse files
committed
Add support for Nix
1 parent b26af26 commit 36b056b

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ INCLUDE=include
1616
# own device app* you just need to include tkey/debug.h and define
1717
# either of them. You don't need to recompile tkey-libs.
1818

19-
CFLAGS = -target riscv32-unknown-none-elf -march=rv32iczmmul -mabi=ilp32 \
19+
CFLAGS = $(EXTRA_CFLAGS) -target riscv32-unknown-none-elf -march=rv32iczmmul -mabi=ilp32 \
2020
-mcmodel=medany -static -std=gnu99 -O2 -ffast-math -fno-common \
2121
-fno-builtin-printf -fno-builtin-putchar -nostdlib -mno-relax -flto \
2222
-Wall -Werror=implicit-function-declaration \
2323
-I $(INCLUDE) -I .
2424

2525
AS = clang
2626
AR = llvm-ar
27-
ASFLAGS = -target riscv32-unknown-none-elf -march=rv32iczmmul -mabi=ilp32 \
27+
ASFLAGS = $(EXTRA_ASFLAGS) -target riscv32-unknown-none-elf -march=rv32iczmmul -mabi=ilp32 \
2828
-mcmodel=medany -mno-relax
2929

3030
LDFLAGS=-T app.lds -L libcommon/ -lcommon -L libcrt0/ -lcrt0

shell.nix

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
with import <nixpkgs> {};
2+
let
3+
# Use unwrapped clang to avoid hardening flags
4+
unwrappedClang = clang_multi.cc;
5+
in
6+
mkShell {
7+
nativeBuildInputs = [
8+
gnumake
9+
unwrappedClang
10+
unwrappedClang.lib
11+
llvm
12+
lld
13+
go
14+
pre-commit
15+
];
16+
17+
# Override CC/AS to use unwrapped clang (avoids Nix hardening wrapper)
18+
# Set resource directory for built-in headers (stddef.h, stdint.h, etc.)
19+
shellHook = ''
20+
export CC="${unwrappedClang}/bin/clang"
21+
export AS="${unwrappedClang}/bin/clang"
22+
export EXTRA_CFLAGS="-resource-dir ${unwrappedClang.lib}/lib/clang/19"
23+
export EXTRA_ASFLAGS="-resource-dir ${unwrappedClang.lib}/lib/clang/19"
24+
'';
25+
}

0 commit comments

Comments
 (0)