mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
Everywhere: Add RISC-V 64 target to the build system
This is a minimal set of changes to allow `serenity.sh build riscv64` to successfully generate the build environment and start building. This includes some, but not all, assembly stubs that will be needed later on; they are currently empty.
This commit is contained in:
parent
c63fe0e1f1
commit
096cecb95e
Notes:
sideshowbarker
2024-07-16 20:08:14 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/096cecb95e Pull-request: https://github.com/SerenityOS/serenity/pull/20483 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/BertalanD
12 changed files with 39 additions and 4 deletions
|
@ -65,7 +65,7 @@ There are some optional features that can be enabled during compilation that are
|
|||
- `INCLUDE_WASM_SPEC_TESTS`: downloads and includes the WebAssembly spec testsuite tests. In order to use this option, you will need to install `prettier` and `wabt`. wabt version 1.0.23 or higher is required to pre-process the WebAssembly spec testsuite.
|
||||
- `INCLUDE_FLAC_SPEC_TESTS`: downloads and includes the xiph.org FLAC test suite.
|
||||
- `SERENITY_TOOLCHAIN`: Specifies whether to use the established GNU toolchain, or the experimental Clang-based toolchain for building SerenityOS. See the [Clang-based toolchain](#clang-based-toolchain) section below.
|
||||
- `SERENITY_ARCH`: Specifies which architecture to build for. Currently supported options are `x86_64`.
|
||||
- `SERENITY_ARCH`: Specifies which architecture to build for. Currently supported options are `x86_64`, `aarch64`, `riscv64`.
|
||||
- `BUILD_<component>`: builds the specified component, e.g. `BUILD_HEARTS` (note: must be all caps). Check the components.ini file in your build directory for a list of available components. Make sure to run `ninja clean` and `rm -rf Build/x86_64/Root` after disabling components. These options can be easily configured by using the `ConfigureComponents` utility. See the [Component Configuration](#component-configuration) section below.
|
||||
- `BUILD_EVERYTHING`: builds all optional components, overrides other `BUILD_<component>` flags when enabled
|
||||
- `SERENITY_CACHE_DIR`: sets the location of a shared cache of downloaded files. Should not need to be set unless managing a distribution package.
|
||||
|
|
|
@ -9,6 +9,8 @@ if ("${SERENITY_ARCH}" STREQUAL "aarch64")
|
|||
set(KERNEL_ARCH aarch64)
|
||||
elseif("${SERENITY_ARCH}" STREQUAL "x86_64")
|
||||
set(KERNEL_ARCH x86_64)
|
||||
elseif("${SERENITY_ARCH}" STREQUAL "riscv64")
|
||||
set(KERNEL_ARCH riscv64)
|
||||
endif()
|
||||
|
||||
set(KERNEL_HEAP_SOURCES
|
||||
|
@ -495,6 +497,14 @@ elseif("${SERENITY_ARCH}" STREQUAL "aarch64")
|
|||
# NOTE: These files cannot use a stack protector and sanitizers, as these will cause accesses to global variables to be inserted
|
||||
# by the compiler. The CPU cannot access global variables without the MMU as the kernel is linked for a virtual address in high memory.
|
||||
set_source_files_properties(${SOURCES_RUNNING_WITHOUT_MMU} PROPERTIES COMPILE_FLAGS "-fno-stack-protector -fno-sanitize=all")
|
||||
elseif("${SERENITY_ARCH}" STREQUAL "riscv64")
|
||||
set(KERNEL_SOURCES
|
||||
${KERNEL_SOURCES}
|
||||
Arch/Processor.cpp
|
||||
kprintf.cpp
|
||||
)
|
||||
|
||||
add_compile_options(-fno-stack-protector -fno-sanitize=all)
|
||||
endif()
|
||||
|
||||
set(AK_SOURCES
|
||||
|
@ -767,7 +777,7 @@ endif()
|
|||
serenity_install_headers(Kernel)
|
||||
serenity_install_sources(Kernel)
|
||||
|
||||
# aarch64 does not need a Prekernel
|
||||
if (NOT "${SERENITY_ARCH}" STREQUAL "aarch64")
|
||||
# Only x86 needs a Prekernel
|
||||
if ("${SERENITY_ARCH}" STREQUAL "x86_64")
|
||||
add_subdirectory(Prekernel)
|
||||
endif()
|
||||
|
|
|
@ -46,6 +46,7 @@ _serenity() {
|
|||
targets=(
|
||||
'x86_64:Target x86_64 or $SERENITY_ARCH (default)'
|
||||
'aarch64:Target aarch64'
|
||||
'riscv64:Target riscv64'
|
||||
'lagom:Target host machine'
|
||||
)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ print_help() {
|
|||
NAME=$(basename "$ARG0")
|
||||
cat <<EOF
|
||||
Usage: $NAME COMMAND [TARGET] [TOOLCHAIN] [ARGS...]
|
||||
Supported TARGETs: aarch64, x86_64, lagom. Defaults to SERENITY_ARCH, or x86_64 if not set.
|
||||
Supported TARGETs: aarch64, x86_64, riscv64, lagom. Defaults to SERENITY_ARCH, or x86_64 if not set.
|
||||
Supported TOOLCHAINs: GNU, Clang. Defaults to SERENITY_TOOLCHAIN, or GNU if not set.
|
||||
Supported COMMANDs:
|
||||
build: Compiles the target binaries, [ARGS...] are passed through to ninja
|
||||
|
@ -122,6 +122,10 @@ is_valid_target() {
|
|||
CMAKE_ARGS+=("-DSERENITY_ARCH=x86_64")
|
||||
return 0
|
||||
fi
|
||||
if [ "$TARGET" = "riscv64" ]; then
|
||||
CMAKE_ARGS+=("-DSERENITY_ARCH=riscv64")
|
||||
return 0
|
||||
fi
|
||||
if [ "$TARGET" = "lagom" ]; then
|
||||
CMAKE_ARGS+=("-DBUILD_LAGOM=ON")
|
||||
if [ "${CMD_ARGS[0]}" = "ladybird" ]; then
|
||||
|
|
|
@ -40,3 +40,8 @@ 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 BOTH)
|
||||
|
||||
# Sets a common default architecture for all toolchains. Be sure to update this in GNUToolchain as well!
|
||||
if("${SERENITY_ARCH}" STREQUAL "riscv64")
|
||||
add_compile_options(-march=rv64gc)
|
||||
endif()
|
||||
|
|
|
@ -37,3 +37,8 @@ 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 BOTH)
|
||||
|
||||
# Sets a common default architecture for all toolchains. Be sure to update this in ClangToolchain as well!
|
||||
if("${SERENITY_ARCH}" STREQUAL "riscv64")
|
||||
add_compile_options(-march=rv64gc)
|
||||
endif()
|
||||
|
|
|
@ -109,6 +109,11 @@ elseif ("${SERENITY_ARCH}" STREQUAL "x86_64")
|
|||
set(ELF_SOURCES ${ELF_SOURCES} ../LibELF/Arch/x86_64/entry.S ../LibELF/Arch/x86_64/plt_trampoline.S)
|
||||
set(CRTI_SOURCE "arch/x86_64/crti.S")
|
||||
set(CRTN_SOURCE "arch/x86_64/crtn.S")
|
||||
elseif ("${SERENITY_ARCH}" STREQUAL "riscv64")
|
||||
set(ASM_SOURCES "arch/riscv64/setjmp.S")
|
||||
set(ELF_SOURCES ${ELF_SOURCES} ../LibELF/Arch/riscv64/entry.S ../LibELF/Arch/riscv64/plt_trampoline.S)
|
||||
set(CRTI_SOURCE "arch/riscv64/crti.S")
|
||||
set(CRTN_SOURCE "arch/riscv64/crtn.S")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option")
|
||||
|
|
1
Userland/Libraries/LibC/arch/riscv64/crti.S
Normal file
1
Userland/Libraries/LibC/arch/riscv64/crti.S
Normal file
|
@ -0,0 +1 @@
|
|||
# Intentionally empty.
|
1
Userland/Libraries/LibC/arch/riscv64/crtn.S
Normal file
1
Userland/Libraries/LibC/arch/riscv64/crtn.S
Normal file
|
@ -0,0 +1 @@
|
|||
# Intentionally empty.
|
1
Userland/Libraries/LibC/arch/riscv64/setjmp.S
Normal file
1
Userland/Libraries/LibC/arch/riscv64/setjmp.S
Normal file
|
@ -0,0 +1 @@
|
|||
# Intentionally empty.
|
1
Userland/Libraries/LibELF/Arch/riscv64/entry.S
Normal file
1
Userland/Libraries/LibELF/Arch/riscv64/entry.S
Normal file
|
@ -0,0 +1 @@
|
|||
# Intentionally empty.
|
1
Userland/Libraries/LibELF/Arch/riscv64/plt_trampoline.S
Normal file
1
Userland/Libraries/LibELF/Arch/riscv64/plt_trampoline.S
Normal file
|
@ -0,0 +1 @@
|
|||
# Intentionally empty.
|
Loading…
Reference in a new issue