> compile NEMU

ysyx_22040000 李心杨
Linux calcite 6.6.19 #1-NixOS SMP PREEMPT_DYNAMIC Fri Mar  1 12:35:11 UTC 2024 x86_64 GNU/Linux
 16:07:06  up 4 days  3:13,  2 users,  load average: 1.07, 1.12, 1.07
This commit is contained in:
tracer-ysyx 2024-03-24 16:07:06 +08:00 committed by xinyangli
parent 5e1371248c
commit a210694e82
7 changed files with 35 additions and 9 deletions

View file

@ -76,9 +76,12 @@ add_link_options(
)
# -- Include linker script here. Use this linker script at link time if INCLUDE_LINKER_SCRIPT is set to true
set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/scripts/linker.ld)
set(LINKER_SCRIPT linker.ld)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
add_compile_options(-march=rv32if -mabi=ilp32)
add_link_options(-march=rv32if -mabi=ilp32)
add_subdirectory(klib)
add_subdirectory(am)

View file

@ -14,9 +14,11 @@ target_include_directories(am-${ARCH}
target_link_libraries(am-${ARCH}
PUBLIC klib_interface
INTERFACE m)
if(INCLUDE_LINKER_SCRIPT)
target_link_options(am-${ARCH} INTERFACE -T${LINKER_SCRIPT})
endif()
# TODO: Check
target_link_options(am-${ARCH} INTERFACE
$<BUILD_INTERFACE:-T${CMAKE_SOURCE_DIR}/scripts/${LINKER_SCRIPT}>
$<INSTALL_INTERFACE:-T${CMAKE_INSTALL_LIBDIR}/cmake/am-${ARCH}/${LINKER_SCRIPT}>)
# Interface compile flags
target_link_options(am-${ARCH} INTERFACE
@ -45,3 +47,7 @@ configure_package_config_file(${CMAKE_SOURCE_DIR}/cmake/am-config.cmake.in
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/am-${ARCH}-config.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/am-${ARCH})
# TODO: check
install(FILES ${CMAKE_SOURCE_DIR}/scripts/${LINKER_SCRIPT}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/am-${ARCH})

View file

@ -1,4 +1,5 @@
include(nemu-settings)
include(riscv-settings)
add_library(am-${ISA}-nemu
cte.c
@ -16,6 +17,12 @@ target_link_options(am-${ISA}-nemu PRIVATE
${RISCV_LINK_OPTIONS})
target_include_directories(am-${ISA}-nemu PRIVATE
${NEMU_INCLUDE_DIRECTORIES})
target_link_options(am-${ISA}-nemu INTERFACE
LINKER:--defsym=_pmem_start=0x80000000
LINKER:--defsym=_entry_offset=0x0
LINKER:--gc-sections
LINKER:-e _start
-nostartfiles)
target_compile_definitions(am-${ISA}-nemu PUBLIC
ARCH_H="arch/riscv.h")

View file

@ -8,4 +8,4 @@ set(NEMU_INCLUDE_DIRECTORIES
${CMAKE_SOURCE_DIR}/am/src/platform/nemu/include)
file(GLOB_RECURSE NEMU_SOURCES
${CMAKE_SOURCE_DIR}/am/src/platform/nemu/*.[cS])
set(INCLUDE_LINKER_SCRIPT true)
set(INCLUDE_LINKER_SCRIPT ON)

View file

@ -12,7 +12,10 @@
localSystem = system;
crossSystem = {
config = "riscv32-none-elf";
gcc = {
abi = "ilp32";
arch = "rv32if";
};
};
};
in
@ -40,14 +43,21 @@
packages.am-kernels-cmake = crossPkgs.stdenv.mkDerivation rec {
pname = "am-kernels-cmake";
version = "2024.02.18";
version = "2024.02.19";
src = /home/xin/repo/am-kernels;
src = ./am-kernels;
nativeBuildInputs = [
pkgs.cmake
];
cmakeFlags = [
(pkgs.lib.cmakeFeature "ISA" "riscv")
(pkgs.lib.cmakeFeature "PLATFORM" "nemu")
(pkgs.lib.cmakeFeature "CMAKE_INSTALL_DATADIR" "share")
];
buildInputs = [
# SDL2
self.packages.${system}.abstract-machine

2
result
View file

@ -1 +1 @@
/nix/store/nzfl421lydgznc237s7z6nz93zml4i8p-am-kernels-rv32-riscv32-none-elf-2024.02.18
/nix/store/mpn11vhq7f7zqp9ql02n083x1wkp5jbx-am-kernels-cmake-riscv32-none-elf-2024.02.19