Make: Throwing more random shit at the makefiles

Switched to an acutal cross compiler instead of using the linux gcc

Stole more ideas from managarm

Figured out the "right" way to handle warnings and flags in meson

Removed libgcc dependency because it doesnt exist in riscv64-elf-
will need to figure out how to use things like  __builtin_memcpy
properly
This commit is contained in:
Thomas Muller 2022-07-31 22:57:40 -04:00
parent f9ea032b7d
commit 8274a93abb
Signed by: thomas
GPG key ID: AF006EB730564952
5 changed files with 27 additions and 16 deletions

View file

@ -1,9 +1,10 @@
arch_sources = [
files(
'entry.S'
),
files('entry.S'),
kernel_sources
]
arch_cpp_args = kernel_cpp_args
arch_link_args = kernel_link_args
subdir('platform/' + platform)

View file

@ -1,5 +1,5 @@
cxx = meson.get_compiler('cpp')
gcc_dep = cxx.find_library('gcc', required: true)
# gcc_dep = cxx.find_library('gcc', required: true)
objcopy = find_program('riscv64-linux-gnu-objcopy')
mkimage = find_program('mkimage')
@ -11,10 +11,11 @@ elf = executable(
'kernel.elf',
arch_sources,
include_directories: includes,
dependencies: gcc_dep,
# dependencies: gcc_dep,
cpp_args: arch_cpp_args,
link_args: [
arch_link_args,
'-Wl,-T,' + meson.current_source_dir() + '/platform.ld',
'-static'
],
link_depends: files('platform.ld'),
install: true,

View file

@ -8,11 +8,14 @@ kernel_includes = [
include_directories('include')
]
kernel_c_args = []
kernel_cpp_args = []
kernel_link_args = ['-nostdlib']
subdir('drivers/opensbi')
subdir('common/dtb')
includes = [
# arch_includes,
kernel_includes
]

View file

@ -2,8 +2,10 @@ project('riscv-qtech-os', ['c', 'cpp'],
default_options: [
'cpp_std=gnu++20',
'c_std=gnu11',
'c_flags=-Wall -Werror -Wextra',
'cpp_flags=-Wall -Werror -Wextra'
'warning_level=3',
'werror=false',
'buildtype=debugoptimized',
# 'buildtype=release',
]
)
@ -11,6 +13,8 @@ if not meson.is_cross_build()
error('Kernel must be cross compiled')
endif
c = meson.get_compiler('cpp')
cxx = meson.get_compiler('cpp')
arch = host_machine.cpu_family()
platform = 'allwinner-d1'
# platform = 'qemu'

View file

@ -1,6 +1,6 @@
[binaries]
c = 'riscv64-linux-gnu-gcc'
cpp = 'riscv64-linux-gnu-g++'
c = 'riscv64-elf-gcc'
cpp = 'riscv64-elf-g++'
[host_machine]
system = 'riscv-qtech-os'
@ -8,9 +8,11 @@ cpu_family = 'riscv64'
cpu = 'rv64'
endian = 'little'
[built-in options]
[constants]
args = ['-ffreestanding', '-march=rv64gc', '-mabi=lp64d', '-mcmodel=medany']
c_args = '-march=rv64gc -mabi=lp64d -mcmodel=medany -ffreestanding'
c_link_args = '-march=rv64gc -mabi=lp64d -mcmodel=medany -nostdlib'
cpp_args = '-march=rv64gc -mabi=lp64d -mcmodel=medany -ffreestanding'
cpp_link_args = '-march=rv64gc -mabi=lp64d -mcmodel=medany -nostdlib'
[built-in options]
c_args = args
c_link_args = args
cpp_args = args
cpp_link_args = args