> compile NEMU
ysyx_22040000 李心杨 Linux calcite 6.6.18 #1-NixOS SMP PREEMPT_DYNAMIC Fri Feb 23 08:25:28 UTC 2024 x86_64 GNU/Linux 23:05:05 up 7:22, 2 users, load average: 0.43, 0.37, 0.33
This commit is contained in:
parent
a915be2262
commit
01960837e0
9 changed files with 104 additions and 184 deletions
|
@ -66,8 +66,8 @@ LINKAGE = $(OBJS) \
|
|||
## 3. General Compilation Flags
|
||||
|
||||
### (Cross) compilers, e.g., mips-linux-gnu-g++
|
||||
AS = $(CROSS_COMPILE)cc
|
||||
CC = $(CROSS_COMPILE)cc
|
||||
AS = $(CROSS_COMPILE)gcc
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
CXX = $(CROSS_COMPILE)g++
|
||||
LD = $(CROSS_COMPILE)ld
|
||||
AR = $(CROSS_COMPILE)ar
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1701680307,
|
||||
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
|
||||
"lastModified": 1709126324,
|
||||
"narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
|
||||
"rev": "d465f4819400de7c8d874d50b982301f28a84605",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -20,11 +20,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1704722960,
|
||||
"narHash": "sha256-mKGJ3sPsT6//s+Knglai5YflJUF2DGj7Ai6Ynopz0kI=",
|
||||
"lastModified": 1709237383,
|
||||
"narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "317484b1ead87b9c1b8ac5261a8d2dd748a0492d",
|
||||
"rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -34,31 +34,10 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nur-xin": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1704680562,
|
||||
"narHash": "sha256-ffec3HL8OgbHB/TvLHILvC3ylou6N+KDtrn4qYVV+U4=",
|
||||
"ref": "refs/heads/master",
|
||||
"rev": "8adf33b6fdd113c645d83feda28622a0b1ef9f83",
|
||||
"revCount": 144,
|
||||
"type": "git",
|
||||
"url": "https://git.xinyang.life/xin/nur.git"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "https://git.xinyang.life/xin/nur.git"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nur-xin": "nur-xin"
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
39
flake.nix
Normal file
39
flake.nix
Normal file
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, ... }@inputs: with inputs;
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
crossPkgs = import nixpkgs {
|
||||
localSystem = system;
|
||||
crossSystem = {
|
||||
config = "riscv32-none-elf";
|
||||
abi = "ilp32";
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
packages.nemu = pkgs.callPackage ./nemu {};
|
||||
|
||||
devShells.am-kernels = crossPkgs.mkShell {
|
||||
inputsFrom = [
|
||||
self.packages.${system}.nemu
|
||||
];
|
||||
packages = [
|
||||
pkgs.stdenv.cc
|
||||
pkgs.libllvm
|
||||
];
|
||||
shellHook = ''
|
||||
export PROJECT_ROOT=/home/xin/repo/ysyx-workbench
|
||||
export AM_HOME=$PROJECT_ROOT/abstract-machine;
|
||||
export NEMU_HOME=$PROJECT_ROOT/nemu;
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
74
nemu/.config
74
nemu/.config
|
@ -1,74 +0,0 @@
|
|||
#
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# NEMU Configuration Menu
|
||||
#
|
||||
# CONFIG_ISA_x86 is not set
|
||||
# CONFIG_ISA_mips32 is not set
|
||||
CONFIG_ISA_riscv=y
|
||||
# CONFIG_ISA_loongarch32r is not set
|
||||
CONFIG_ISA="riscv32"
|
||||
|
||||
#
|
||||
# ISA-dependent Options for riscv
|
||||
#
|
||||
# CONFIG_RV64 is not set
|
||||
# CONFIG_RVE is not set
|
||||
# end of ISA-dependent Options for riscv
|
||||
|
||||
CONFIG_ENGINE_INTERPRETER=y
|
||||
CONFIG_ENGINE="interpreter"
|
||||
CONFIG_MODE_SYSTEM=y
|
||||
CONFIG_TARGET_NATIVE_ELF=y
|
||||
# CONFIG_TARGET_SHARE is not set
|
||||
# CONFIG_TARGET_AM is not set
|
||||
|
||||
#
|
||||
# Build Options
|
||||
#
|
||||
CONFIG_CC_GCC=y
|
||||
# CONFIG_CC_GPP is not set
|
||||
# CONFIG_CC_CLANG is not set
|
||||
CONFIG_CC="gcc"
|
||||
# CONFIG_CC_O0 is not set
|
||||
# CONFIG_CC_O1 is not set
|
||||
CONFIG_CC_O2=y
|
||||
# CONFIG_CC_O3 is not set
|
||||
CONFIG_CC_OPT="-O2"
|
||||
# CONFIG_CC_LTO is not set
|
||||
# CONFIG_CC_DEBUG is not set
|
||||
CONFIG_CC_ASAN=y
|
||||
# end of Build Options
|
||||
|
||||
#
|
||||
# Testing and Debugging
|
||||
#
|
||||
CONFIG_TRACE=y
|
||||
CONFIG_TRACE_START=0
|
||||
CONFIG_TRACE_END=10000
|
||||
CONFIG_ITRACE=y
|
||||
CONFIG_ITRACE_COND="true"
|
||||
# CONFIG_DIFFTEST is not set
|
||||
CONFIG_DIFFTEST_REF_PATH="none"
|
||||
CONFIG_DIFFTEST_REF_NAME="none"
|
||||
# end of Testing and Debugging
|
||||
|
||||
#
|
||||
# Memory Configuration
|
||||
#
|
||||
CONFIG_MBASE=0x80000000
|
||||
CONFIG_MSIZE=0x8000000
|
||||
CONFIG_PC_RESET_OFFSET=0
|
||||
# CONFIG_PMEM_MALLOC is not set
|
||||
CONFIG_PMEM_GARRAY=y
|
||||
CONFIG_MEM_RANDOM=y
|
||||
# end of Memory Configuration
|
||||
|
||||
# CONFIG_DEVICE is not set
|
||||
|
||||
#
|
||||
# Miscellaneous
|
||||
#
|
||||
CONFIG_TIMER_GETTIMEOFDAY=y
|
||||
# CONFIG_TIMER_CLOCK_GETTIME is not set
|
||||
CONFIG_RT_CHECK=y
|
||||
# end of Miscellaneous
|
|
@ -40,7 +40,9 @@ SRCS-y += $(shell find -L $(DIRS-y) -name "*.c")
|
|||
SRCS = $(filter-out $(SRCS-BLACKLIST-y),$(SRCS-y))
|
||||
|
||||
# Extract compiler and options from menuconfig
|
||||
ifneq ($(CONFIG_CC),)
|
||||
CC = $(call remove_quote,$(CONFIG_CC))
|
||||
endif
|
||||
CFLAGS_BUILD += $(call remove_quote,$(CONFIG_CC_OPT))
|
||||
CFLAGS_BUILD += $(if $(CONFIG_CC_LTO),-flto,)
|
||||
CFLAGS_BUILD += $(if $(CONFIG_CC_DEBUG),-Og -ggdb3,)
|
||||
|
|
49
nemu/default.nix
Normal file
49
nemu/default.nix
Normal file
|
@ -0,0 +1,49 @@
|
|||
{ pkgs,
|
||||
lib,
|
||||
stdenv
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "nemu";
|
||||
version = "2024-03-02";
|
||||
|
||||
src = ./.;
|
||||
|
||||
NEMU_HOME = "/build/nemu";
|
||||
nativeBuildInputs = with pkgs; [
|
||||
gnumake
|
||||
flex
|
||||
bison
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
check
|
||||
readline
|
||||
libllvm
|
||||
];
|
||||
|
||||
configurePhase = ''
|
||||
echo pwd=$(pwd)
|
||||
make alldefconfig
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
make
|
||||
'';
|
||||
|
||||
checkPhase = ''
|
||||
make test
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
make PREFIX=$out install
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "NJU EMUlator, a full system x86/mips32/riscv32/riscv64 emulator for teaching";
|
||||
homepage = "https://github.com/NJU-ProjectN/nemu.git";
|
||||
license = with licenses; [ ];
|
||||
maintainers = with maintainers; [ ];
|
||||
};
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
nur-xin = {
|
||||
url = "git+https://git.xinyang.life/xin/nur.git";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, ... }@inputs: with inputs;
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system} //
|
||||
{ nur.xin = nur-xin.legacyPackages.${system}; };
|
||||
in
|
||||
{
|
||||
devShells.default = with pkgs; mkShell {
|
||||
packages = [
|
||||
clang-tools
|
||||
rnix-lsp
|
||||
bear
|
||||
|
||||
gdb
|
||||
jre
|
||||
|
||||
gtkwave
|
||||
];
|
||||
|
||||
inputsFrom = [ self.packages.${system}.nemu ];
|
||||
};
|
||||
|
||||
packages.nemu = with pkgs; stdenv.mkDerivation rec {
|
||||
pname = "nemu";
|
||||
version = "2024-01-02";
|
||||
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs = [
|
||||
gnumake
|
||||
flex
|
||||
bison
|
||||
pkg-config
|
||||
python3 # for testing
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
check
|
||||
readline
|
||||
libllvm
|
||||
];
|
||||
|
||||
configurePhase = ''
|
||||
echo pwd=$(pwd)
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
make NEMU_HOME=/build/nemu --trace
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
BUILD_DIR=$out make install
|
||||
'';
|
||||
|
||||
checkPhase = ''
|
||||
BUILD_DIR=$out make test
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "NJU EMUlator, a full system x86/mips32/riscv32/riscv64 emulator for teaching";
|
||||
homepage = "https://github.com/NJU-ProjectN/nemu.git";
|
||||
license = with licenses; [ ];
|
||||
maintainers = with maintainers; [ ];
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
@ -48,6 +48,9 @@ menuconfig: $(MCONF) $(CONF) $(FIXDEP)
|
|||
savedefconfig: $(CONF)
|
||||
$(Q)$< $(silent) --$@=configs/defconfig $(Kconfig)
|
||||
|
||||
alldefconfig: $(CONF) $(FIXDEP)
|
||||
$(Q)$(CONF) $(silent) --$@ $(Kconfig)
|
||||
|
||||
%defconfig: $(CONF) $(FIXDEP)
|
||||
$(Q)$< $(silent) --defconfig=configs/$@ $(Kconfig)
|
||||
$(Q)$< $(silent) --syncconfig $(Kconfig)
|
||||
|
@ -60,7 +63,7 @@ help:
|
|||
@echo ' savedefconfig - Save current config as configs/defconfig (minimal config)'
|
||||
|
||||
distclean: clean
|
||||
-@rm -rf $(rm-distclean)
|
||||
-rm -rf $(rm-distclean)
|
||||
|
||||
.PHONY: help distclean
|
||||
|
||||
|
|
1
result
Symbolic link
1
result
Symbolic link
|
@ -0,0 +1 @@
|
|||
/nix/store/3x5nz7zcwq0zhcff1d3l9lpmvmnmx2i5-nemu-2024-03-02
|
Loading…
Reference in a new issue