1
0
mirror of https://github.com/janet-lang/janet synced 2025-01-03 04:10:27 +00:00

Address #1524 - fix meson cross compilation linking.

In the cross compilation case, we need to resolve our
dependencies on libc twice, once for the build machine and once for the
target machine. This includes pthreads, -libc, and android-spawn.
This commit is contained in:
Calvin Rose 2024-12-03 21:03:38 -06:00
parent 7c44127bcb
commit 5b79b48ae0
2 changed files with 20 additions and 8 deletions

View File

@ -2,6 +2,7 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## ??? - Unreleased ## ??? - Unreleased
- Fix meson cross compilation
- Update timeout documentation for networking APIs: timeouts raise errors and do not return nil. - Update timeout documentation for networking APIs: timeouts raise errors and do not return nil.
- Add `janet_addtimeout_nil(double sec);` to the C API. - Add `janet_addtimeout_nil(double sec);` to the C API.
- Change string hashing. - Change string hashing.

View File

@ -26,8 +26,17 @@ project('janet', 'c',
janet_path = join_paths(get_option('prefix'), get_option('libdir'), 'janet') janet_path = join_paths(get_option('prefix'), get_option('libdir'), 'janet')
header_path = join_paths(get_option('prefix'), get_option('includedir'), 'janet') header_path = join_paths(get_option('prefix'), get_option('includedir'), 'janet')
# Link math library on all systems # Compilers
cc = meson.get_compiler('c') cc = meson.get_compiler('c')
native_cc = meson.get_compiler('c', native : true)
# Native deps
native_m_dep = native_cc.find_library('m', required : false)
native_dl_dep = native_cc.find_library('dl', required : false)
native_android_spawn_dep = native_cc.find_library('android-spawn', required : false)
native_thread_dep = dependency('threads', native : true)
# Deps
m_dep = cc.find_library('m', required : false) m_dep = cc.find_library('m', required : false)
dl_dep = cc.find_library('dl', required : false) dl_dep = cc.find_library('dl', required : false)
android_spawn_dep = cc.find_library('android-spawn', required : false) android_spawn_dep = cc.find_library('android-spawn', required : false)
@ -164,11 +173,18 @@ mainclient_src = [
'src/mainclient/shell.c' 'src/mainclient/shell.c'
] ]
janet_dependencies = [m_dep, dl_dep, android_spawn_dep]
janet_native_dependencies = [native_m_dep, native_dl_dep, native_android_spawn_dep]
if not get_option('single_threaded')
janet_dependencies += thread_dep
janet_native_dependencies += native_thread_dep
endif
# Build boot binary # Build boot binary
janet_boot = executable('janet-boot', core_src, boot_src, janet_boot = executable('janet-boot', core_src, boot_src,
include_directories : incdir, include_directories : incdir,
c_args : '-DJANET_BOOTSTRAP', c_args : '-DJANET_BOOTSTRAP',
dependencies : [m_dep, dl_dep, thread_dep, android_spawn_dep], dependencies : janet_native_dependencies,
native : true) native : true)
# Build janet.c # Build janet.c
@ -181,11 +197,6 @@ janetc = custom_target('janetc',
'JANET_PATH', janet_path 'JANET_PATH', janet_path
]) ])
janet_dependencies = [m_dep, dl_dep, android_spawn_dep]
if not get_option('single_threaded')
janet_dependencies += thread_dep
endif
# Allow building with no shared library # Allow building with no shared library
if cc.has_argument('-fvisibility=hidden') if cc.has_argument('-fvisibility=hidden')
lib_cflags = ['-fvisibility=hidden'] lib_cflags = ['-fvisibility=hidden']
@ -231,7 +242,7 @@ if meson.is_cross_build()
endif endif
janet_nativeclient = executable('janet-native', janetc, mainclient_src, janet_nativeclient = executable('janet-native', janetc, mainclient_src,
include_directories : incdir, include_directories : incdir,
dependencies : janet_dependencies, dependencies : janet_native_dependencies,
c_args : extra_native_cflags, c_args : extra_native_cflags,
native : true) native : true)
else else