Skip to content

Commit

Permalink
misc: Replace libgcc with cc-runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
mintsuki committed Nov 7, 2024
1 parent 6a9f25e commit e924909
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
29 changes: 7 additions & 22 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ no_headers = get_option('no_headers')
library_type = get_option('default_library')
build_tests = get_option('build_tests')
build_tests_host_libc = get_option('build_tests_host_libc')
libgcc_dependency = get_option('libgcc_dependency')
internal_conf = configuration_data()
mlibc_conf = configuration_data()

Expand All @@ -39,6 +38,13 @@ if not headers_only
c_compiler = meson.get_compiler('c')
cpp_compiler = meson.get_compiler('cpp')

ccrt_dep = dependency(
'cc-runtime',
fallback: ['cc-runtime', 'ccrt_dep'],
)
libc_deps += ccrt_dep
rtld_deps += ccrt_dep

target_triple = run_command(c_compiler.cmd_array(), '-dumpmachine', check: true).stdout()
use_freestnd_hdrs = get_option('use_freestnd_hdrs').disable_auto_if(
target_triple.to_lower().contains('mlibc'))
Expand Down Expand Up @@ -414,26 +420,6 @@ subdir('options/bsd')
rtlib_deps = []

if not headers_only
if libgcc_dependency
libgcc = meson.get_compiler('c').find_library('gcc', required: false)

compiler_rt_name = 'libclang_rt.builtins-' + host_machine.cpu_family()
compiler_rt = meson.get_compiler('c').find_library(compiler_rt_name, required: false)

if not compiler_rt.found()
compiler_rt_name = 'libclang_rt.builtins'
compiler_rt = meson.get_compiler('c').find_library(compiler_rt_name, required: false)
endif

if libgcc.found()
rtlib_deps += libgcc
elif compiler_rt.found()
rtlib_deps += compiler_rt
else
error('neither libgcc nor ' + compiler_rt_name + ' was found')
endif
endif

ld_cpp_args = [
'-fvisibility=hidden',
'-fvisibility-inlines-hidden',
Expand Down Expand Up @@ -526,7 +512,6 @@ summary_info += {'Linux option': get_option('linux_option')}
summary_info += {'glibc option': get_option('glibc_option')}
summary_info += {'BSD option': get_option('bsd_option')}
summary_info += {'debug allocator': get_option('debug_allocator')}
summary_info += {'libgcc dependency': libgcc_dependency}
summary(summary_info, bool_yn: true, section: 'mlibc options')

if build_tests
Expand Down
1 change: 0 additions & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ option('posix_option', type: 'feature', value : 'auto')
option('linux_option', type: 'feature', value : 'auto')
option('glibc_option', type: 'feature', value : 'auto')
option('bsd_option', type: 'feature', value : 'auto')
option('libgcc_dependency', type : 'boolean', value : true)
option('linux_kernel_headers', type: 'string', value : '')
option('default_library_paths', type: 'array', value: [])
option('debug_allocator', type : 'boolean', value : false,
Expand Down
4 changes: 4 additions & 0 deletions subprojects/cc-runtime.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[wrap-git]
directory = cc-runtime
url = https://github.com/osdev0/cc-runtime.git
revision = trunk

0 comments on commit e924909

Please sign in to comment.