Skip to content

Commit

Permalink
CMake: Let Meta/serenity.sh run aarch64 make it past cmake
Browse files Browse the repository at this point in the history
This adds just enough scaffolding to make cmake succeed.
The build falls over immediately.
  • Loading branch information
nico authored and linusg committed Aug 28, 2021
1 parent a43ad0e commit bbad475
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ add_link_options(LINKER:-z,text)

if("${SERENITY_ARCH}" STREQUAL "i686")
add_compile_options(-march=i686)
else()
elseif("${SERENITY_ARCH}" STREQUAL "x86_64")
add_compile_options(-march=x86-64)
endif()

Expand Down
50 changes: 30 additions & 20 deletions Kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ else()
add_compile_options(-Os)
endif()

if ("${SERENITY_ARCH}" STREQUAL "i686")
if ("${SERENITY_ARCH}" STREQUAL "aarch64")
set(KERNEL_ARCH aarch64)
elseif ("${SERENITY_ARCH}" STREQUAL "i686")
set(KERNEL_ARCH i386)
elseif("${SERENITY_ARCH}" STREQUAL "x86_64")
set(KERNEL_ARCH x86_64)
Expand Down Expand Up @@ -283,24 +285,26 @@ set(KERNEL_SOURCES
kprintf.cpp
)

set(KERNEL_SOURCES
${KERNEL_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/${KERNEL_ARCH}/ASM_wrapper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/${KERNEL_ARCH}/Boot/ap_setup.S
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/${KERNEL_ARCH}/InterruptEntry.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/${KERNEL_ARCH}/Processor.cpp
)
if ("${SERENITY_ARCH}" STREQUAL "i686" OR "${SERENITY_ARCH}" STREQUAL "x86_64")
set(KERNEL_SOURCES
${KERNEL_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/${KERNEL_ARCH}/ASM_wrapper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/${KERNEL_ARCH}/Boot/ap_setup.S
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/${KERNEL_ARCH}/InterruptEntry.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/${KERNEL_ARCH}/Processor.cpp
)

set(KERNEL_SOURCES
${KERNEL_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/ASM_wrapper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/CPU.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/Interrupts.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/Processor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/ProcessorInfo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/SafeMem.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/TrapFrame.cpp
)
set(KERNEL_SOURCES
${KERNEL_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/ASM_wrapper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/CPU.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/Interrupts.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/Processor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/ProcessorInfo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/SafeMem.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86/common/TrapFrame.cpp
)
endif()

set(AK_SOURCES
../AK/FlyString.cpp
Expand Down Expand Up @@ -351,7 +355,11 @@ set(SOURCES

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option -Wvla -Wnull-dereference")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -ffreestanding -fbuiltin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-80387 -mno-mmx -mno-sse -mno-sse2")

if ("${SERENITY_ARCH}" STREQUAL "i686" OR "${SERENITY_ARCH}" STREQUAL "x86_64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-80387 -mno-mmx -mno-sse -mno-sse2")
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-asynchronous-unwind-tables")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-strong")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
Expand Down Expand Up @@ -508,5 +516,7 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/kernel.map" DESTINATION res)
serenity_install_headers(Kernel)
serenity_install_sources(Kernel)

add_subdirectory(Prekernel)
if (NOT "${SERENITY_ARCH}" STREQUAL "aarch64")
add_subdirectory(Prekernel)
endif()
add_subdirectory(Modules)
5 changes: 4 additions & 1 deletion Userland/DynamicLoader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ file(GLOB ELF_SOURCES "../Libraries/LibELF/*.cpp")
file(GLOB LIBC_SOURCES1 "../Libraries/LibC/*.cpp")
file(GLOB LIBC_SOURCES2 "../Libraries/LibC/*/*.cpp")

if ("${SERENITY_ARCH}" STREQUAL "i686")
if ("${SERENITY_ARCH}" STREQUAL "aarch64")
file(GLOB LIBC_SOURCES3 "../Libraries/LibC/arch/aarch64/*.S")
set(ELF_SOURCES ${ELF_SOURCES} ../Libraries/LibELF/Arch/aarch64/entry.S ../Libraries/LibELF/Arch/aarch64/plt_trampoline.S)
elseif ("${SERENITY_ARCH}" STREQUAL "i686")
file(GLOB LIBC_SOURCES3 "../Libraries/LibC/arch/i386/*.S")
set(ELF_SOURCES ${ELF_SOURCES} ../Libraries/LibELF/Arch/i386/entry.S ../Libraries/LibELF/Arch/i386/plt_trampoline.S)
elseif ("${SERENITY_ARCH}" STREQUAL "x86_64")
Expand Down
7 changes: 6 additions & 1 deletion Userland/Libraries/LibC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ set(LIBC_SOURCES
file(GLOB AK_SOURCES CONFIGURE_DEPENDS "../../../AK/*.cpp")
file(GLOB ELF_SOURCES CONFIGURE_DEPENDS "../LibELF/*.cpp")

if ("${SERENITY_ARCH}" STREQUAL "i686")
if ("${SERENITY_ARCH}" STREQUAL "aarch64")
set(ASM_SOURCES "arch/aarch64/setjmp.S")
set(ELF_SOURCES ${ELF_SOURCES} ../LibELF/Arch/aarch64/entry.S ../LibELF/Arch/aarch64/plt_trampoline.S)
set(CRTI_SOURCE "arch/aarch64/crti.S")
set(CRTN_SOURCE "arch/aarch64/crtn.S")
elseif ("${SERENITY_ARCH}" STREQUAL "i686")
set(ASM_SOURCES "arch/i386/setjmp.S")
set(ELF_SOURCES ${ELF_SOURCES} ../LibELF/Arch/i386/entry.S ../LibELF/Arch/i386/plt_trampoline.S)
set(CRTI_SOURCE "arch/i386/crti.S")
Expand Down
21 changes: 21 additions & 0 deletions Userland/Libraries/LibC/arch/aarch64/crti.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2021, Nico Weber <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*/

.section .init, "ax", @progbits
.p2align 2
.global _init
.type _init, @function
_init:
# FIXME: Possibly incomplete.
ret

.section .fini, "ax", @progbits
.p2align 4
.global _fini
.type _fini, @function
_fini:
# FIXME: Possibly incomplete.
ret
13 changes: 13 additions & 0 deletions Userland/Libraries/LibC/arch/aarch64/crtn.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (c) 2021, Nico Weber <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*/

.section .init, "ax", @progbits
# FIXME: Possibly incomplete.
ret

.section .fini, "ax", @progbits
# FIXME: Possibly incomplete.
ret
15 changes: 15 additions & 0 deletions Userland/Libraries/LibC/arch/aarch64/setjmp.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright (c) 2021, Nico Weber <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*/

.global setjmp
setjmp:
# FIXME: Possibly incomplete.
ret

.global longjmp
longjmp:
# FIXME: Possibly incomplete.
ret
12 changes: 12 additions & 0 deletions Userland/Libraries/LibELF/Arch/aarch64/entry.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright (c) 2021, Nico Weber <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*/

.globl _invoke_entry
.hidden _invoke_entry
.type _invoke_entry,@function
_invoke_entry: # (argc, argv, envp, entry)
# FIXME: Possibly incomplete.
ret
13 changes: 13 additions & 0 deletions Userland/Libraries/LibELF/Arch/aarch64/plt_trampoline.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (c) 2021, Nico Weber <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*/

.p2align 4
.globl _plt_trampoline
.hidden _plt_trampoline
.type _plt_trampoline,@function
_plt_trampoline: # (object, relocation_index)
# FIXME: Possibly incomplete.
ret

0 comments on commit bbad475

Please sign in to comment.