linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Daniel Borkmann <daniel@iogearbox.net>,
	Thomas Richter <tmricht@linux.ibm.com>
Cc: Jakub Kicinski <jakub.kicinski@netronome.com>,
	Hendrik Brueckner <brueckner@linux.ibm.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Networking Development Mailing List 
	<netdev@vger.kernel.org>
Subject: libbpf build broken on musl libc (Alpine Linux)
Date: Mon, 10 Sep 2018 14:29:03 -0300	[thread overview]
Message-ID: <20180910172903.GB15516@kernel.org> (raw)

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>

             reply	other threads:[~2018-09-10 17:29 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-10 17:29 Arnaldo Carvalho de Melo [this message]
2018-09-11 10:22 ` libbpf build broken on musl libc (Alpine Linux) 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180910172903.GB15516@kernel.org \
    --to=acme@kernel.org \
    --cc=brueckner@linux.ibm.com \
    --cc=daniel@iogearbox.net \
    --cc=jakub.kicinski@netronome.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tmricht@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).