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 = [ arch_sources = [
files( files('entry.S'),
'entry.S'
),
kernel_sources kernel_sources
] ]
arch_cpp_args = kernel_cpp_args
arch_link_args = kernel_link_args
subdir('platform/' + platform) subdir('platform/' + platform)

View file

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

View file

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

View file

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

View file

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