diff --git a/kernel/arch/riscv64/meson.build b/kernel/arch/riscv64/meson.build index 808c949..be454ed 100644 --- a/kernel/arch/riscv64/meson.build +++ b/kernel/arch/riscv64/meson.build @@ -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) diff --git a/kernel/arch/riscv64/platform/allwinner-d1/meson.build b/kernel/arch/riscv64/platform/allwinner-d1/meson.build index fd529fa..2ca7fd9 100644 --- a/kernel/arch/riscv64/platform/allwinner-d1/meson.build +++ b/kernel/arch/riscv64/platform/allwinner-d1/meson.build @@ -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, diff --git a/kernel/meson.build b/kernel/meson.build index e3f69b0..198f338 100644 --- a/kernel/meson.build +++ b/kernel/meson.build @@ -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 ] diff --git a/meson.build b/meson.build index 6d2d7e0..19fb56f 100644 --- a/meson.build +++ b/meson.build @@ -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' diff --git a/riscv.cross b/riscv.cross index 66ea0d0..bf2ba17 100644 --- a/riscv.cross +++ b/riscv.cross @@ -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