mirror of
https://github.com/libfuse/libfuse.git
synced 2024-11-23 04:04:31 +08:00
convert __APPLE__ and __ULIBC__ to HAVE_LIBC_VERSIONED_SYMBOLS
In fact only gnu-libc fully supports symbol versioning, so it is better to have a generic macro for it. This also allows to manually disable symbol version and allows to run tests with that configuration on gnu-libc. That testing will still not catch compat issues, but least ensures the code can compile. Testing for __APPLE__ and __ULIBC__ is now done by meson. More of such checks can be added by people using other libcs.
This commit is contained in:
parent
f212ec0870
commit
3736e0c85f
@ -1907,7 +1907,7 @@ struct fuse_cmdline_opts {
|
||||
* @param opts output argument for parsed options
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
#if (!defined(__UCLIBC__) && !defined(__APPLE__))
|
||||
#if (defined(HAVE_LIBC_VERSIONED_SYMBOLS))
|
||||
int fuse_parse_cmdline(struct fuse_args *args,
|
||||
struct fuse_cmdline_opts *opts);
|
||||
#else
|
||||
@ -1995,7 +1995,7 @@ int fuse_session_loop(struct fuse_session *se);
|
||||
int fuse_session_loop_mt_32(struct fuse_session *se, struct fuse_loop_config *config);
|
||||
#define fuse_session_loop_mt(se, config) fuse_session_loop_mt_32(se, config)
|
||||
#else
|
||||
#if (!defined(__UCLIBC__) && !defined(__APPLE__))
|
||||
#if (defined(HAVE_LIBC_VERSIONED_SYMBOLS))
|
||||
/**
|
||||
* Enter a multi-threaded event loop.
|
||||
*
|
||||
|
@ -34,7 +34,7 @@
|
||||
/**
|
||||
* Compatibility ABI symbol for systems that do not support version symboling
|
||||
*/
|
||||
#if (defined(__UCLIBC__) || defined(__APPLE__))
|
||||
#if (!defined(HAVE_LIBC_VERSIONED_SYMBOLS))
|
||||
/* With current libfuse fuse_parse_cmdline is a macro pointing to the
|
||||
* versioned function. Here in this file we need to provide the ABI symbol
|
||||
* and the redirecting macro is conflicting.
|
||||
|
@ -15,7 +15,7 @@
|
||||
Note: "@@" denotes the default symbol, "@" is binary a compat version.
|
||||
|
||||
*/
|
||||
#ifndef __APPLE__
|
||||
#ifdef HAVE_LIBC_VERSIONED_SYMBOLS
|
||||
# if HAVE_SYMVER_ATTRIBUTE
|
||||
# define FUSE_SYMVER(sym1, sym2) __attribute__ ((symver (sym2)))
|
||||
# else
|
||||
|
74
meson.build
74
meson.build
@ -60,10 +60,6 @@ cfg.set('HAVE_STRUCT_STAT_ST_ATIMESPEC',
|
||||
prefix: include_default,
|
||||
args: args_default))
|
||||
|
||||
# Write the test results into config.h (stored in build directory)
|
||||
configure_file(output: 'config.h',
|
||||
configuration : cfg)
|
||||
|
||||
#
|
||||
# Compiler configuration
|
||||
#
|
||||
@ -90,30 +86,64 @@ if not cc.compiles(code, args: [ '-O0', '-Werror=unused-result' ])
|
||||
add_project_arguments('-Wno-unused-result', language: 'c')
|
||||
endif
|
||||
|
||||
# gcc-10 and newer support the symver attribute which we need to use if we
|
||||
# want to support LTO
|
||||
# recent clang and gcc both support __has_attribute (and if they are too old
|
||||
# to have __has_attribute, then they are too old to support symver)
|
||||
# other compilers might not have __has_attribute, but in those cases
|
||||
# it is safe for this check to fail and for us to fallback to the old _asm_
|
||||
# method for symver. Anyway the attributes not supported by __has_attribute()
|
||||
# unfortunately return true giving a false positive. So let's try to build
|
||||
# using __attribute__ ((symver )) and see the result.
|
||||
code = '''
|
||||
__attribute__ ((symver ("test@TEST")))
|
||||
void foo(void) {
|
||||
}
|
||||
# It is hard to detect if the libc supports versioned symbols. Only gnu-libc
|
||||
# seems to provide that, but then glibc is the main target for libfuse, so
|
||||
# enable it by default
|
||||
versioned_symbols = 1
|
||||
|
||||
# This is an attempt to detect if another libc is used.
|
||||
code = '''
|
||||
int main(void) {
|
||||
#if (defined(__UCLIBC__) || defined(__APPLE__))
|
||||
#error /* libc does not have versioned symbols */
|
||||
#endif
|
||||
return 0;
|
||||
}'''
|
||||
if cc.compiles(code, args: [ '-O0', '-c', '-Werror'])
|
||||
message('Compiler supports symver attribute')
|
||||
add_project_arguments('-DHAVE_SYMVER_ATTRIBUTE', language: 'c')
|
||||
else
|
||||
message('Compiler does not support symver attribute')
|
||||
if not cc.compiles(code, args: [ '-O0' ])
|
||||
versioned_symbols = 0
|
||||
endif
|
||||
|
||||
# The detection can be overriden, which is useful for other (above unhandled)
|
||||
# libcs and also especially useful for testing
|
||||
if get_option('disable-libc-symbol-version')
|
||||
versioned_symbols = 0
|
||||
endif
|
||||
|
||||
if versioned_symbols == 1
|
||||
message('Enabling versioned libc symbols')
|
||||
cfg.set('HAVE_LIBC_VERSIONED_SYMBOLS', 1)
|
||||
|
||||
# gcc-10 and newer support the symver attribute which we need to use if we
|
||||
# want to support LTO
|
||||
# recent clang and gcc both support __has_attribute (and if they are too old
|
||||
# to have __has_attribute, then they are too old to support symver)
|
||||
# other compilers might not have __has_attribute, but in those cases
|
||||
# it is safe for this check to fail and for us to fallback to the old _asm_
|
||||
# method for symver. Anyway the attributes not supported by __has_attribute()
|
||||
# unfortunately return true giving a false positive. So let's try to build
|
||||
# using __attribute__ ((symver )) and see the result.
|
||||
code = '''
|
||||
__attribute__ ((symver ("test@TEST")))
|
||||
void foo(void) {
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
return 0;
|
||||
}'''
|
||||
if cc.compiles(code, args: [ '-O0', '-c', '-Werror'])
|
||||
message('Compiler supports symver attribute')
|
||||
add_project_arguments('-DHAVE_SYMVER_ATTRIBUTE', language: 'c')
|
||||
else
|
||||
message('Compiler does not support symver attribute')
|
||||
endif
|
||||
else
|
||||
message('Disabling versioned libc symbols')
|
||||
endif
|
||||
|
||||
# Write the test results into config.h (stored in build directory)
|
||||
configure_file(output: 'config.h',
|
||||
configuration : cfg)
|
||||
|
||||
# '.' will refer to current build directory, which contains config.h
|
||||
include_dirs = include_directories('include', 'lib', '.')
|
||||
|
||||
|
@ -19,3 +19,6 @@ option('useroot', type : 'boolean', value : true,
|
||||
option('tests', type : 'boolean', value : true,
|
||||
description: 'Compile the test files')
|
||||
|
||||
option('disable-libc-symbol-version', type : 'boolean', value : false,
|
||||
description: 'Disable versioned symbols through libc')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user