coverage: fix build with g++
Guard the coverage-related shenanigans from g++ when building the one
C++ unit test we have, so we don't have to make it C++ compatible:
[1573/2109] Compiling C++ object test-bus-vtable-cc.p/src_libsystemd_sd-bus_test-bus-vtable-cc.cc.o
FAILED: test-bus-vtable-cc.p/src_libsystemd_sd-bus_test-bus-vtable-cc.cc.o
ccache c++ -Itest-bus-vtable-cc. ... -c ../src/libsystemd/sd-bus/test-bus-vtable-cc.cc
In file included from <command-line>:
../src/basic/coverage.h:17:15: error: ‘_Noreturn’ does not name a type
17 | static inline _Noreturn void _coverage__exit(int status) {
| ^~~~~~~~~
../src/basic/coverage.h:46:29: error: conflicting declaration of ‘int _coverage_execveat(int, const char*, char* const*, char* const*, int)’ with ‘C’ linkage
46 | #define execveat(d,p,a,e,f) _coverage_execveat(d, p, a, e, f)
| ^~~~~~~~~~~~~~~~~~
../src/basic/coverage.h:34:19: note: previous declaration with ‘C++’ linkage
34 | static inline int _coverage_execveat(
| ^~~~~~~~~~~~~~~~~~
../src/basic/coverage.h:46:29: error: declaration of ‘int _coverage_execveat(int, const char*, char* const*, char* const*, int) noexcept’ has a different exception specifier
46 | #define execveat(d,p,a,e,f) _coverage_execveat(d, p, a, e, f)
| ^~~~~~~~~~~~~~~~~~
../src/basic/coverage.h:34:19: note: from previous declaration ‘int _coverage_execveat(int, const char*, char* const*, char* const*, int)’
34 | static inline int _coverage_execveat(
| ^~~~~~~~~~~~~~~~~~
../src/basic/coverage.h:58:24: error: conflicting declaration of ‘int _coverage_execvpe(const char*, char* const*, char* const*)’ with ‘C’ linkage
58 | #define execvpe(f,a,e) _coverage_execvpe(f, a, e)
| ^~~~~~~~~~~~~~~~~
../src/basic/coverage.h:48:19: note: previous declaration with ‘C++’ linkage
48 | static inline int _coverage_execvpe(
| ^~~~~~~~~~~~~~~~~
../src/basic/coverage.h:58:24: error: declaration of ‘int _coverage_execvpe(const char*, char* const*, char* const*) noexcept’ has a different exception specifier
58 | #define execvpe(f,a,e) _coverage_execvpe(f, a, e)
| ^~~~~~~~~~~~~~~~~
../src/basic/coverage.h:48:19: note: from previous declaration ‘int _coverage_execvpe(const char*, char* const*, char* const*)’
48 | static inline int _coverage_execvpe(
| ^~~~~~~~~~~~~~~~~
[1582/2109] Compiling C object test-event.p/src_libsystemd_sd-event_test-event.c.o
ninja: build stopped: subcommand failed.
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
14941724ec
commit
9352db7abb
+13
-5
@@ -1,8 +1,14 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
extern void __gcov_dump(void);
|
||||
extern void __gcov_reset(void);
|
||||
/* Use the coverage-related tweaks below only for C stuff as they're not really
|
||||
* C++ compatible, and the only thing that is built with a C++ compiler is
|
||||
* the lone test-bus-vtable-cc unit test.
|
||||
*/
|
||||
#ifndef __cplusplus
|
||||
|
||||
void __gcov_dump(void);
|
||||
void __gcov_reset(void);
|
||||
|
||||
/* When built with --coverage (gcov) we need to explicitly call __gcov_dump()
|
||||
* in places where we use _exit(), since _exit() skips at-exit hooks resulting
|
||||
@@ -12,7 +18,7 @@ extern void __gcov_reset(void);
|
||||
* explicitly on the compiler command line via the -include directive (only
|
||||
* when built with -Db_coverage=true)
|
||||
*/
|
||||
extern void _exit(int);
|
||||
void _exit(int);
|
||||
|
||||
static inline _Noreturn void _coverage__exit(int status) {
|
||||
__gcov_dump();
|
||||
@@ -28,8 +34,8 @@ static inline _Noreturn void _coverage__exit(int status) {
|
||||
* [0] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgcc/libgcov-interface.c;h=b2ee930864183b78c8826255183ca86e15e21ded;hb=HEAD
|
||||
*/
|
||||
|
||||
extern int execveat(int, const char *, char * const [], char * const [], int);
|
||||
extern int execvpe(const char *, char * const [], char * const []);
|
||||
int execveat(int, const char *, char * const [], char * const [], int);
|
||||
int execvpe(const char *, char * const [], char * const []);
|
||||
|
||||
static inline int _coverage_execveat(
|
||||
int dirfd,
|
||||
@@ -56,3 +62,5 @@ static inline int _coverage_execvpe(
|
||||
return r;
|
||||
}
|
||||
#define execvpe(f,a,e) _coverage_execvpe(f, a, e)
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user