Add local=absolute option to meson for absolute rpaths (#1911)

This commit is contained in:
Florian Märkl 2021-11-09 00:04:34 +01:00 committed by GitHub
parent 4ebc079115
commit d8450b8e75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 3 deletions

View file

@ -534,17 +534,35 @@ if get_option('b_sanitize').contains('undefined')
endif
use_rpath = false
use_rpath_absolute = false
if host_machine.system() != 'windows' and get_option('default_library') == 'shared'
if get_option('local').enabled() or (get_option('local').auto() and get_option('prefix') != '/usr')
if get_option('local') == 'enabled'
use_rpath = true
elif get_option('local') == 'absolute'
use_rpath_absolute = true
elif get_option('local') == 'auto' and get_option('prefix') != '/usr'
if host_machine.system() == 'openbsd'
# OpenBSD's $ORIGIN only works in the way we would need it when running an
# executable by its actual path, but not when run through PATH.
# So let's use absolute rpaths there.
use_rpath_absolute = true
else
use_rpath = true
endif
endif
endif
rpath_exe = ''
rpath_lib = ''
rpath_summary = 'disabled'
if use_rpath
rpath_exe = '$ORIGIN/../' + get_option('libdir')
rpath_lib = '$ORIGIN'
rpath_summary = 'relative'
elif use_rpath_absolute
rpath_exe = get_option('prefix') / get_option('libdir')
rpath_lib = get_option('prefix') / get_option('libdir')
rpath_summary = 'absolute'
endif
# NOTE: this is to workaround an issue on Windows where unit tests don't use
# the right libraries, resulting in tests not being run properly
@ -753,7 +771,7 @@ summary({
'System zlib library': zlib_dep.found() and zlib_dep.type_name() != 'internal',
'System zip library': libzip_dep.found() and libzip_dep.type_name() != 'internal',
'Use ptrace-wrap': use_ptrace_wrap,
'Use RPATH': use_rpath,
'Use RPATH': rpath_summary,
}, section: 'Configuration', bool_yn: true)
summary({

View file

@ -2,7 +2,7 @@ option('packager', type: 'string', value: '', description: 'Extra packager name'
option('packager_version', type: 'string', value: '', description: 'Extra packager version')
option('cli', type: 'feature', value: 'auto', description: 'Build CLI programs (“auto” means they will be built when not a subproject)')
option('static_runtime', type: 'boolean', value: false, description: 'Set to true when you want static libraries/dependencies and runtime in Rizin')
option('local', type: 'feature', value: 'auto', description: 'Adds support for local/side-by-side installation (sets rpath if needed)')
option('local', type: 'combo', choices: ['enabled', 'disabled', 'absolute', 'auto'], value: 'auto', description: 'Adds support for local/side-by-side installation (sets rpath if needed). enabled uses rpaths relative to $ORIGIN, absolute uses absolute paths.')
option('blob', type: 'boolean', value: false, description: 'Compile just one binary which dispatch to the right handlers based on the name used to call it')
option('subprojects_check', type: 'boolean', value: true, description: 'Check if git subprojects are up-to-date. Might be useful to disable this when developing on a different subproject version')
option('portable', type: 'boolean', value: false, description: 'Make rizin installation moveable, by using relative paths instead of absolute ones')