mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-30 10:03:48 +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_selinux = get_option('selinux')
|
||||||
want_oss_fuzz = get_option('oss-fuzz')
|
want_oss_fuzz = get_option('oss-fuzz')
|
||||||
want_seccomp = get_option('seccomp')
|
want_seccomp = get_option('seccomp')
|
||||||
|
want_thread_safety = get_option('thread-safety')
|
||||||
|
|
||||||
srcconf.set_quoted('DEFAULT_CGROUP_PATTERN', cgrouppattern)
|
srcconf.set_quoted('DEFAULT_CGROUP_PATTERN', cgrouppattern)
|
||||||
if coverity
|
if coverity
|
||||||
@ -403,6 +404,8 @@ if want_oss_fuzz
|
|||||||
fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
|
fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
srcconf.set10('ENFORCE_THREAD_SAFETY', want_thread_safety)
|
||||||
|
|
||||||
## PAM.
|
## PAM.
|
||||||
pam = cc.find_library('pam', has_headers: 'security/pam_modules.h', required: want_pam_cgroup)
|
pam = cc.find_library('pam', has_headers: 'security/pam_modules.h', required: want_pam_cgroup)
|
||||||
srcconf.set10('HAVE_PAM', pam.found())
|
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')
|
have = cc.has_function('openpty', prefix: '#include <pty.h>', args: '-D_GNU_SOURCE')
|
||||||
srcconf.set10('HAVE_OPENPTY', have)
|
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.
|
## Compiler attributes.
|
||||||
foreach ccattr: [
|
foreach ccattr: [
|
||||||
'fallthrough',
|
'fallthrough',
|
||||||
@ -435,6 +460,7 @@ foreach tuple: [
|
|||||||
['execveat'],
|
['execveat'],
|
||||||
['faccessat'],
|
['faccessat'],
|
||||||
['strchrnul'],
|
['strchrnul'],
|
||||||
|
['strerror_r'],
|
||||||
['fgetln'],
|
['fgetln'],
|
||||||
['fsconfig'],
|
['fsconfig'],
|
||||||
['fsmount'],
|
['fsmount'],
|
||||||
|
@ -77,3 +77,6 @@ option('usernet-db-path', type: 'string', value: 'lxc/nics',
|
|||||||
|
|
||||||
option('oss-fuzz', type : 'boolean', value : 'false',
|
option('oss-fuzz', type : 'boolean', value : 'false',
|
||||||
description : 'build against oss-fuzz')
|
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,13 +304,11 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
|
|||||||
* Helper macro to define errno string.
|
* Helper macro to define errno string.
|
||||||
*/
|
*/
|
||||||
#if HAVE_STRERROR_R
|
#if HAVE_STRERROR_R
|
||||||
#if !HAVE_DECL_STRERROR_R
|
|
||||||
#ifdef STRERROR_R_CHAR_P
|
#ifdef STRERROR_R_CHAR_P
|
||||||
char *strerror_r(int errnum, char *buf, size_t buflen);
|
char *strerror_r(int errnum, char *buf, size_t buflen);
|
||||||
#else
|
#else
|
||||||
int strerror_r(int errnum, char *buf, size_t buflen);
|
int strerror_r(int errnum, char *buf, size_t buflen);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef STRERROR_R_CHAR_P
|
#ifdef STRERROR_R_CHAR_P
|
||||||
#define lxc_log_strerror_r \
|
#define lxc_log_strerror_r \
|
||||||
|
@ -46,6 +46,7 @@ meson setup san_build \
|
|||||||
-Dseccomp=false \
|
-Dseccomp=false \
|
||||||
-Db_lto=false \
|
-Db_lto=false \
|
||||||
-Db_pie=false \
|
-Db_pie=false \
|
||||||
|
-Dthread-safety=false \
|
||||||
-Doss-fuzz=true
|
-Doss-fuzz=true
|
||||||
ninja -C san_build -v
|
ninja -C san_build -v
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user