You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
662 B

lttng-tools: musl compile fixes Add two patches to address three distinct build problems spotted by our build bots when compiling lttng-tools: 1) unconditional use of `__GLIBC_PREREQ` On musl based toolchains there is no such macro defined, leading to the following preprocessor error: CC compat-epoll.lo In file included from compat-epoll.c:33:0: poll.h:76:19: error: missing binary operator before token "(" #if __GLIBC_PREREQ(2, 9) 2) undeclared `mode_t` type On musl based toolchains the `mode_t` type is not implicitely defined through other includes, leading to the following compile error: CC hashtable.lo In file included from ../../../src/common/common.h:24:0, from hashtable.c:24: ../../../src/common/runas.h:25:46: error: unknown type name 'mode_t' int run_as_mkdir_recursive(const char *path, mode_t mode, uid_t uid, gid_t gid); ^ ../../../src/common/runas.h:26:36: error: unknown type name 'mode_t' int run_as_mkdir(const char *path, mode_t mode, uid_t uid, gid_t gid); ^ ../../../src/common/runas.h:27:46: error: unknown type name 'mode_t' int run_as_open(const char *path, int flags, mode_t mode, uid_t uid, gid_t gid); ^ 3) multiple definitions The header files declare several `const char *` pointers which are initialized in various `*.c` files later on. Due to a missing `extern` declaration in the header, the final linking of the executables fails with errors such as: CCLD lttng ../../../src/common/.libs/libcommon.a(mi-lttng.o):(.data.rel.ro.local+0x0): multiple definition of `mi_lttng_element_snapshots' commands/enable_events.o:(.bss+0x18): first defined here collect2: error: ld returned 1 exit status This commits addresses these issues with two patches, `100-musl-compat.patch` fixes issue 1 by declaring a fallback dummy declaration of `__GLIBC_PREREQ` and issue 2 by explicitely including `sys/stat.h` which provides `mode_t` according to POSIX. The second patch, `200-use-extern.patch` declares all char pointers in the header file as `extern`, fixing the observed linker errors. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
8 years ago
  1. --- a/src/common/compat/poll.h
  2. +++ b/src/common/compat/poll.h
  3. @@ -55,6 +55,10 @@ static inline void __lttng_poll_free(voi
  4. #include <features.h>
  5. #include <common/compat/fcntl.h>
  6. +#ifndef __GLIBC_PREREQ
  7. +#define __GLIBC_PREREQ(maj, min) (0)
  8. +#endif
  9. +
  10. /* See man epoll(7) for this define path */
  11. #define COMPAT_EPOLL_PROC_PATH "/proc/sys/fs/epoll/max_user_watches"
  12. --- a/src/common/runas.h
  13. +++ b/src/common/runas.h
  14. @@ -21,6 +21,7 @@
  15. #include <unistd.h>
  16. #include <pthread.h>
  17. +#include <sys/stat.h>
  18. int run_as_mkdir_recursive(const char *path, mode_t mode, uid_t uid, gid_t gid);
  19. int run_as_mkdir(const char *path, mode_t mode, uid_t uid, gid_t gid);