linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* libbpf build broken on musl libc (Alpine Linux)
@ 2018-09-10 17:29 Arnaldo Carvalho de Melo
  2018-09-11 10:22 ` Jakub Kicinski
  0 siblings, 1 reply; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-09-10 17:29 UTC (permalink / raw)
  To: Daniel Borkmann, Thomas Richter
  Cc: Jakub Kicinski, Hendrik Brueckner, Linux Kernel Mailing List,
	Linux Networking Development Mailing List

Hi guys,

	Ingo updated tip/perf/core and this made me notice that perf is
not building on systems using !glibc, like Alpine Linux, that uses musl
libc. This ends up as:

  # dm
   1 alpine:3.4                    : FAIL gcc (Alpine 5.3.0) 5.3.0
   2 alpine:3.5                    : FAIL gcc (Alpine 6.2.1) 6.2.1 20160822
   3 alpine:3.6                    : FAIL gcc (Alpine 6.3.0) 6.3.0
   4 alpine:3.7                    : FAIL gcc (Alpine 6.4.0) 6.4.0
   5 alpine:3.8                    : FAIL gcc (Alpine 6.4.0) 6.4.0
   6 alpine:edge                   : FAIL gcc (Alpine 6.4.0) 6.4.0
   7 amazonlinux:1                 : Ok   gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28)
   8 amazonlinux:2                 : Ok   gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
   9 android-ndk:r12b-arm          : Ok   arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease)
  10 android-ndk:r15c-arm          : Ok   arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease)
  11 centos:5                      : Ok   gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55)
  12 centos:6                      : Ok   gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
  13 centos:7                      : Ok   gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28)
  14 debian:7                      : Ok   gcc (Debian 4.7.2-5) 4.7.2
  15 debian:8                      : Ok   gcc (Debian 4.9.2-10+deb8u1) 4.9.2
  17 debian:9                      : Ok   gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
  18 debian:experimental           : Ok   gcc (Debian 8.2.0-4) 8.2.0
<still building on the other containers, 65 in total>

  CC       /tmp/build/perf/libbpf.o
  CC       /tmp/build/perf/event-plugin.o
  CC       /tmp/build/perf/parse-options.o
libbpf.c: In function 'bpf_object__elf_init':
libbpf.c:472:15: error: initialization makes pointer from integer without a cast [-Werror=int-conversion]
    char *cp = strerror_r(errno, errmsg, sizeof(errmsg));
               ^
libbpf.c: In function 'bpf_object__elf_collect':
libbpf.c:813:16: error: initialization makes pointer from integer without a cast [-Werror=int-conversion]
     char *cp = strerror_r(-err, errmsg,
                ^
libbpf.c: In function 'bpf_object__create_maps':
libbpf.c:1143:7: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
    cp = strerror_r(errno, errmsg, sizeof(errmsg));
       ^
libbpf.c:1158:7: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
    cp = strerror_r(errno, errmsg, sizeof(errmsg));
       ^
libbpf.c: In function 'load_program':
libbpf.c:1342:5: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
  cp = strerror_r(errno, errmsg, sizeof(errmsg));
     ^
libbpf.c: In function 'check_path':
libbpf.c:1657:6: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
   cp = strerror_r(errno, errmsg, sizeof(errmsg));
      ^
libbpf.c: In function 'bpf_program__pin_instance':
libbpf.c:1693:6: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
   cp = strerror_r(errno, errmsg, sizeof(errmsg));
      ^
libbpf.c: In function 'make_dir':
libbpf.c:1711:6: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
   cp = strerror_r(-err, errmsg, sizeof(errmsg));
      ^
libbpf.c: In function 'bpf_map__pin':
libbpf.c:1773:6: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
   cp = strerror_r(errno, errmsg, sizeof(errmsg));
      ^
  CC       /tmp/build/perf/trace-seq.o
  CC       /tmp/build/perf/parse-filter.o
  CC       /tmp/build/perf/parse-utils.o
cc1: all warnings being treated as errors
mv: can't rename '/tmp/build/perf/.libbpf.o.tmp': No such file or directory

This is handled in tools/perf/ by using tools/lib/str_error_r.c, that
was introduced with the cset at the end of this message.

After lunch I'll work on a patch to fix this, 

Thanks,

- Arnaldo

commit c8b5f2c96d1bf6cefcbe12f67dce0b892fe20512
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Date:   Wed Jul 6 11:56:20 2016 -0300

    tools: Introduce str_error_r()
    
    The tools so far have been using the strerror_r() GNU variant, that
    returns a string, be it the buffer passed or something else.
    
    But that, besides being tricky in cases where we expect that the
    function using strerror_r() returns the error formatted in a provided
    buffer (we have to check if it returned something else and copy that
    instead), breaks the build on systems not using glibc, like Alpine
    Linux, where musl libc is used.
    
    So, introduce yet another wrapper, str_error_r(), that has the GNU
    interface, but uses the portable XSI variant of strerror_r(), so that
    users rest asured that the provided buffer is used and it is what is
    returned.
    
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Wang Nan <wangnan0@huawei.com>
    Link: http://lkml.kernel.org/n/tip-d4t42fnf48ytlk8rjxs822tf@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

diff --git a/tools/include/linux/string.h b/tools/include/linux/string.h
index e26223f1f287..b466d0228b57 100644
--- a/tools/include/linux/string.h
+++ b/tools/include/linux/string.h
@@ -12,4 +12,6 @@ int strtobool(const char *s, bool *res);
 extern size_t strlcpy(char *dest, const char *src, size_t size);
 #endif
 
+char *str_error_r(int errnum, char *buf, size_t buflen);
<SNIP>

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-09-19 11:37 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-10 17:29 libbpf build broken on musl libc (Alpine Linux) Arnaldo Carvalho de Melo
2018-09-11 10:22 ` Jakub Kicinski
2018-09-11 12:15   ` Arnaldo Carvalho de Melo
2018-09-11 21:24     ` Alexei Starovoitov
2018-09-13 18:32       ` [RFC/fix] " Arnaldo Carvalho de Melo
2018-09-13 18:56         ` Alexei Starovoitov
2018-09-13 19:44           ` Arnaldo Carvalho de Melo
2018-09-17 15:16           ` Arnaldo Carvalho de Melo
2018-09-18  0:52             ` Alexei Starovoitov
2018-09-18  2:39               ` Jakub Kicinski
2018-09-18  4:18                 ` Alexei Starovoitov
2018-09-18 13:15               ` Arnaldo Carvalho de Melo
2018-09-19 11:36             ` [tip:perf/urgent] tools lib bpf: Provide wrapper for strerror_r to build in !_GNU_SOURCE systems tip-bot for Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).