mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-27 09:48:32 +00:00
build: support thread-safety enforcement as option
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
This commit is contained in:
parent
de4543d8f8
commit
0c4549a331
26
meson.build
26
meson.build
@ -148,6 +148,7 @@ want_openssl = get_option('openssl')
|
||||
want_selinux = get_option('selinux')
|
||||
want_oss_fuzz = get_option('oss-fuzz')
|
||||
want_seccomp = get_option('seccomp')
|
||||
want_thread_safety = get_option('thread-safety')
|
||||
|
||||
srcconf.set_quoted('DEFAULT_CGROUP_PATTERN', cgrouppattern)
|
||||
if coverity
|
||||
@ -403,6 +404,8 @@ if want_oss_fuzz
|
||||
fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
|
||||
endif
|
||||
|
||||
srcconf.set10('ENFORCE_THREAD_SAFETY', want_thread_safety)
|
||||
|
||||
## PAM.
|
||||
pam = cc.find_library('pam', has_headers: 'security/pam_modules.h', required: want_pam_cgroup)
|
||||
srcconf.set10('HAVE_PAM', pam.found())
|
||||
@ -415,6 +418,28 @@ srcconf.set10('HAVE_STRCHRNUL', have)
|
||||
have = cc.has_function('openpty', prefix: '#include <pty.h>', args: '-D_GNU_SOURCE')
|
||||
srcconf.set10('HAVE_OPENPTY', have)
|
||||
|
||||
have_func_strerror_r = cc.has_function('strerror_r', prefix: '#include <string.h>', args: '-D_GNU_SOURCE')
|
||||
srcconf.set10('HAVE_STRERROR_R', have)
|
||||
|
||||
have_func_strerror_r_char_p = false
|
||||
|
||||
if have_func_strerror_r
|
||||
code = '''
|
||||
#define _GNU_SOURCE
|
||||
#include <string.h>
|
||||
int func (void) {
|
||||
char error_string[256];
|
||||
char *ptr = strerror_r (-2, error_string, 256);
|
||||
char c = *strerror_r (-2, error_string, 256);
|
||||
return c != 0 && ptr != (void*) 0L;
|
||||
}
|
||||
'''
|
||||
|
||||
have_func_strerror_r_char_p = cc.compiles(code, name : 'strerror_r() returns char *')
|
||||
endif
|
||||
|
||||
srcconf.set10('STRERROR_R_CHAR_P', have_func_strerror_r_char_p)
|
||||
|
||||
## Compiler attributes.
|
||||
foreach ccattr: [
|
||||
'fallthrough',
|
||||
@ -435,6 +460,7 @@ foreach tuple: [
|
||||
['execveat'],
|
||||
['faccessat'],
|
||||
['strchrnul'],
|
||||
['strerror_r'],
|
||||
['fgetln'],
|
||||
['fsconfig'],
|
||||
['fsmount'],
|
||||
|
@ -77,3 +77,6 @@ option('usernet-db-path', type: 'string', value: 'lxc/nics',
|
||||
|
||||
option('oss-fuzz', type : 'boolean', value : 'false',
|
||||
description : 'build against oss-fuzz')
|
||||
|
||||
option('thread-safety', type : 'boolean', value : 'true',
|
||||
description : 'whether the build fails when thread-safe logging cannot be guaranteed')
|
||||
|
@ -304,12 +304,10 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
|
||||
* Helper macro to define errno string.
|
||||
*/
|
||||
#if HAVE_STRERROR_R
|
||||
#if !HAVE_DECL_STRERROR_R
|
||||
#ifdef STRERROR_R_CHAR_P
|
||||
char *strerror_r(int errnum, char *buf, size_t buflen);
|
||||
#else
|
||||
int strerror_r(int errnum, char *buf, size_t buflen);
|
||||
#endif
|
||||
#ifdef STRERROR_R_CHAR_P
|
||||
char *strerror_r(int errnum, char *buf, size_t buflen);
|
||||
#else
|
||||
int strerror_r(int errnum, char *buf, size_t buflen);
|
||||
#endif
|
||||
|
||||
#ifdef STRERROR_R_CHAR_P
|
||||
|
@ -46,6 +46,7 @@ meson setup san_build \
|
||||
-Dseccomp=false \
|
||||
-Db_lto=false \
|
||||
-Db_pie=false \
|
||||
-Dthread-safety=false \
|
||||
-Doss-fuzz=true
|
||||
ninja -C san_build -v
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user