Skip to content

Commit

Permalink
_start function
Browse files Browse the repository at this point in the history
  • Loading branch information
sulincix committed Oct 16, 2023
1 parent 4a0007d commit cee9964
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
22 changes: 19 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ run_command('bash', './tool/mkctx.sh',
run_command('bash', './tool/check.sh', meson.current_build_dir(), check:true)
prep_args = ['-L'+meson.current_build_dir(), '-lymp']
args = prep_args
libc_srcs = []

# disable optimization for test
if not get_option('test')
Expand Down Expand Up @@ -183,6 +184,21 @@ foreach c : conf
args += '-D'+c
endforeach

########### libc files ###########

arch = run_command('uname', '-m',check:true).stdout().strip()

if run_command('[', '-d', 'src/libc/'+arch, ']').returncode() == 0
libc_srcs += run_command('find', 'src/libc/'+arch,'-type','f',check:true).stdout().strip().split('\n')
# do not include glibc or musl stdlib and link with glibc or musl
if run_command('/bin/sh', '-c', 'ldd --version | grep musl').returncode() == 0
prep_args += ['-nostdlib', '-lc.musl']
else
prep_args += ['-nostdlib', '-lc']
endif
endif


########### generate vala sources ###########

generated_sources=[]
Expand All @@ -203,15 +219,15 @@ install_data(meson.current_build_dir() / 'libymp.so', install_dir : get_option('
########### build tools ###########
if get_option('tools')
# ymp cli
executable('ymp-cli', 'src/cli/main.vala', dependencies: deps, link_args: prep_args, link_with: libymp)
executable('ymp-cli', 'src/cli/main.vala',libc_srcs, dependencies: deps, link_args: prep_args, link_with: libymp)
install_data(meson.current_build_dir() / 'ymp-cli', install_dir : get_option('bindir'),rename : 'ymp')
# ymp shell
executable('ymp-shell', 'src/cli/shell.c', dependencies: deps, link_args: prep_args, link_with: libymp)
executable('ymp-shell', 'src/cli/shell.c', libc_srcs, dependencies: deps, link_args: prep_args, link_with: libymp)
install_data(meson.current_build_dir() / 'ymp-shell', install_dir : get_option('bindir'),rename : 'ympsh')
endif
########### build test ###########
if get_option('test')
executable('ymp-test', 'test/test.vala', dependencies: deps, link_args: prep_args, link_with: libymp)
executable('ymp-test', 'test/test.vala', libc_srcs, dependencies: deps, link_args: prep_args, link_with: libymp)
endif

########### build scripts ###########
Expand Down
2 changes: 1 addition & 1 deletion src/libc/x86_64/start.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ _start:
popq %rdi
movq %rsp, %rsi
movq 8(%rsp, %rdi, 8), %rdx
call _libc_start
call __libc_start_main

0 comments on commit cee9964

Please sign in to comment.