-
Notifications
You must be signed in to change notification settings - Fork 3
[Sim, Tests] Improve sim. Add sim tests. #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
07f03b3
eaf895a
1f5bfe0
c88d17a
f00a942
7422684
8eed710
38bf9a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| --- | ||
| BasedOnStyle: LLVM | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,13 +24,15 @@ jobs: | |
| - name: Run clang-format style check | ||
| uses: jidicula/clang-format-action@v4.14.0 | ||
| with: | ||
| clang-format-version: '19' | ||
| clang-format-version: '20' | ||
| check-path: '.' | ||
|
|
||
| build: | ||
| test: | ||
| needs: formatting-check | ||
| name: Build | ||
| name: Test | ||
| runs-on: ubuntu-22.04 | ||
| container: | ||
| image: ghcr.io/egorshamshura/protea-build:latest | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does the image contain? Add more info |
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
|
|
@@ -44,11 +46,8 @@ jobs: | |
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Ruby | ||
| uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: '3.4.8' | ||
| bundler-cache: true | ||
|
|
||
| - name: Build | ||
| run: ci-extra/build.sh "$CMAKE_PRESET" | ||
|
|
||
| - name: Run tests | ||
| run: ci-extra/test.sh "$CMAKE_PRESET" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| PRESET_NAME=$1 | ||
|
|
||
| cmake -S . \ | ||
| --preset "${PRESET_NAME}" \ | ||
| -DPROTEA_BUILD_TESTS=true \ | ||
| -DQEMU_PATH=qemu-riscv32 \ | ||
| -G Ninja | ||
|
|
||
| cmake --build --preset "${PRESET_NAME}" --target simtests --parallel 12 | ||
|
|
||
| ctest --preset "${PRESET_NAME}" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| option(HARDENED "Should the standard library be hardened" OFF) | ||
| option(SANITIZED "Should the build be sanitized" OFF) | ||
|
|
||
| function(configure_compiler) | ||
| set(isGCC OFF) | ||
| set(isClang OFF) | ||
|
|
||
| if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
| set(isGCC ON) | ||
| elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
| set(isClang ON) | ||
| endif() | ||
|
|
||
| set(compilerOptions "") | ||
| set(compilerDefinitions "") | ||
| set(linkerOptions "") | ||
|
|
||
| if(isClang) | ||
| list(APPEND compilerOptions -stdlib=libc++) | ||
| list(APPEND linkerOptions -stdlib=libc++) | ||
| message(STATUS "Using libc++ as a standard library") | ||
| endif() | ||
|
|
||
| if(HARDENED) | ||
| if(isGCC) | ||
| list(APPEND compilerDefinitions _GLIBCXX_DEBUG) | ||
| message(STATUS "Enabled debug mode for libstdc++") | ||
| elseif(isClang) | ||
| list(APPEND compilerDefinitions _LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG) | ||
| message(STATUS "Enabled hardening mode for libc++") | ||
| else() | ||
| message(STATUS "Hardening is not supported for CXX compiler: '${CMAKE_CXX_COMPILER_ID}'") | ||
| endif() | ||
| endif() | ||
|
|
||
| if(SANITIZED) | ||
| if(isGCC OR isClang) | ||
| list(APPEND compilerOptions | ||
| -fsanitize=undefined,address | ||
| -fno-sanitize-recover=all | ||
| -fno-optimize-sibling-calls | ||
| -fno-omit-frame-pointer | ||
| ) | ||
| list(APPEND linkerOptions | ||
| -fsanitize=undefined,address | ||
| ) | ||
| message(STATUS "Enabled UBSan and ASan") | ||
| else() | ||
| message(WARNING "Sanitized builds are not supported for CXX compiler: '${CMAKE_CXX_COMPILER_ID}'") | ||
| endif() | ||
| endif() | ||
|
|
||
| message(STATUS "Setting global compiler options: ${compilerOptions}") | ||
| message(STATUS "Setting global compiler definitions: ${compilerDefinitions}") | ||
| message(STATUS "Setting global linker options: ${linkerOptions}") | ||
|
|
||
| add_compile_options(${compilerOptions}) | ||
| add_compile_definitions(${compilerDefinitions}) | ||
| add_link_options(${linkerOptions}) | ||
| endfunction() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| if (NOT DEFINED QEMU_PATH) | ||
| set(QEMU_PATH "qemu") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add message
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added status message |
||
| endif() | ||
|
|
||
| message(STATUS "Using QEMU: ${QEMU_PATH}") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| if(NOT EXISTS "@OUTPUT_TESTS_DIR@") | ||
| message(STATUS "Test directory does not exist yet: @OUTPUT_TESTS_DIR@") | ||
| return() | ||
| endif() | ||
|
|
||
| file(GLOB discovered_tests "@OUTPUT_TESTS_DIR@/*") | ||
|
|
||
| if(NOT discovered_tests) | ||
| message(STATUS "No generated tests found in @OUTPUT_TESTS_DIR@") | ||
| endif() | ||
|
|
||
| foreach(test_file IN LISTS discovered_tests) | ||
| if(IS_DIRECTORY "${test_file}") | ||
| continue() | ||
| endif() | ||
|
|
||
| get_filename_component(test_name "${test_file}" NAME) | ||
|
|
||
| add_test( | ||
| "@PROJECT_NAME@.${test_name}" | ||
| "@GENERATED_SIM_BIN_PATH@" --propagate-exit "${test_file}" | ||
| ) | ||
| endforeach() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # RISC-V Cross Compilation Toolchain File Usage: cmake | ||
| # -DCMAKE_TOOLCHAIN_FILE=path/to/this/file.cmake .. | ||
|
|
||
| # Base settings | ||
| set(CMAKE_SYSTEM_NAME Generic) | ||
| set(CMAKE_SYSTEM_PROCESSOR riscv) | ||
| set(CMAKE_LINKER_TYPE DEFAULT) | ||
|
|
||
| # Toolchain prefix (modify this according to your toolchain) Common prefixes: | ||
| # riscv64-unknown-elf-, riscv64-unknown-linux-gnu-, riscv32-unknown-elf- | ||
| set(RISCV_TOOLCHAIN_PREFIX | ||
| "riscv32-unknown-elf-" | ||
| CACHE STRING "RISC-V toolchain prefix") | ||
|
|
||
| # Target architecture (modify these according to your needs) | ||
| set(RISCV_ARCH | ||
| "rv32i" | ||
| CACHE STRING "RISC-V architecture") | ||
| set(RISCV_ABI | ||
| "ilp32" | ||
| CACHE STRING "RISC-V ABI") | ||
|
|
||
| # Cross-compilation tools | ||
| if(DEFINED RISCV_TOOLCHAIN_DIR) | ||
| set(CMAKE_C_COMPILER "${RISCV_TOOLCHAIN_DIR}/${RISCV_TOOLCHAIN_PREFIX}gcc") | ||
| set(CMAKE_CXX_COMPILER "${RISCV_TOOLCHAIN_DIR}/${RISCV_TOOLCHAIN_PREFIX}g++") | ||
| set(CMAKE_ASM_COMPILER "${RISCV_TOOLCHAIN_DIR}/${RISCV_TOOLCHAIN_PREFIX}gcc") | ||
| set(CMAKE_AR "${RISCV_TOOLCHAIN_DIR}/${RISCV_TOOLCHAIN_PREFIX}ar") | ||
| set(CMAKE_RANLIB "${RISCV_TOOLCHAIN_DIR}/${RISCV_TOOLCHAIN_PREFIX}ranlib") | ||
| else() | ||
| set(CMAKE_C_COMPILER "${RISCV_TOOLCHAIN_PREFIX}gcc") | ||
| set(CMAKE_CXX_COMPILER "${RISCV_TOOLCHAIN_PREFIX}g++") | ||
| set(CMAKE_ASM_COMPILER "${RISCV_TOOLCHAIN_PREFIX}gcc") | ||
| set(CMAKE_AR "${RISCV_TOOLCHAIN_PREFIX}ar") | ||
| set(CMAKE_RANLIB "${RISCV_TOOLCHAIN_PREFIX}ranlib") | ||
| endif() | ||
|
|
||
| # Compiler flags Search settings | ||
| set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | ||
| set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | ||
| set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | ||
| set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) | ||
|
|
||
| # Optional: Specify sysroot if needed set(CMAKE_SYSROOT | ||
| # "/path/to/riscv/sysroot") | ||
|
|
||
| # Optional: Additional flags for specific use cases | ||
| set(COMMON_FLAGS | ||
| "-march=${RISCV_ARCH} -mabi=${RISCV_ABI} -Wall -Wextra -nostdlib -nodefaultlibs -nostartfiles -static -fno-builtin" | ||
| ) | ||
| set(CMAKE_C_FLAGS | ||
| "${COMMON_FLAGS}" | ||
| CACHE STRING "C compiler flags") | ||
| set(CMAKE_ASM_FLAGS | ||
| "${COMMON_FLAGS}" | ||
| CACHE STRING "ASM compiler flags") | ||
|
|
||
| set(CMAKE_EXE_LINKER_FLAGS_INIT | ||
| "-nostdlib -nodefaultlibs -nostartfiles -fno-builtin -static" | ||
| CACHE STRING "Linker flags") | ||
|
|
||
| # Test compiler | ||
| if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.6) | ||
| set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) | ||
| endif() |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes to clang format should be discussed, this change is not related to this PR. Consider using either minimal default clang format (e.g. LLVM), or remove this file completely
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Started to use LLVM format