Subject: libbpf build failure on debian:9 with clang

From: Arnaldo Carvalho de Melo <[email-masked]>
Date: Wed, 31 Oct 2018 11:12:08 -0300

17    40.66 debian:9                      : FAIL gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516

The failure was with clang tho:

clang version 3.8.1-24 (tags/RELEASE_381/final)

With:

  gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1) 

it built without any warnings/errors.

  CC       /tmp/build/perf/libbpf.o
libbpf.c:2201:36: error: comparison of constant -22 with expression of type 'const enum bpf_attach_type' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
                if (section_names[i].attach_type == -EINVAL)
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~
1 error generated.
  CC       /tmp/build/perf/help.o
mv: cannot stat '/tmp/build/perf/.libbpf.o.tmp': No such file or directory
/git/linux/tools/build/Makefile.build:96: recipe for target '/tmp/build/perf/libbpf.o' failed
make[4]: *** [/tmp/build/perf/libbpf.o] Error 1

This is the cset:

commit 956b620fcf0b64de403cd26a56bc41e6e4826ea6
Author: Andrey Ignatov <[email-masked]>
Date:   Wed Sep 26 15:24:53 2018 -0700

    libbpf: Introduce libbpf_attach_type_by_name

------------------------

Tests are continuing, so far:

   1    43.53 alpine:3.4                    : Ok   gcc (Alpine 5.3.0) 5.3.0
   2    58.62 alpine:3.5                    : Ok   gcc (Alpine 6.2.1) 6.2.1 20160822
   3    51.62 alpine:3.6                    : Ok   gcc (Alpine 6.3.0) 6.3.0
   4    51.68 alpine:3.7                    : Ok   gcc (Alpine 6.4.0) 6.4.0
   5    49.38 alpine:3.8                    : Ok   gcc (Alpine 6.4.0) 6.4.0
   6    79.07 alpine:edge                   : Ok   gcc (Alpine 6.4.0) 6.4.0
   7    63.35 amazonlinux:1                 : Ok   gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28)
   8    59.65 amazonlinux:2                 : Ok   gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
   9    47.39 android-ndk:r12b-arm          : Ok   arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease)
  10    50.64 android-ndk:r15c-arm          : Ok   arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease)
  11    28.75 centos:5                      : Ok   gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55)
  12    33.26 centos:6                      : Ok   gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
  13    43.16 centos:7                      : Ok   gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28)
  14    73.61 clearlinux:latest             : FAIL gcc (Clear Linux OS for Intel Architecture) 8.2.1 20180502
  15    45.56 debian:7                      : Ok   gcc (Debian 4.7.2-5) 4.7.2
  16    45.53 debian:8                      : Ok   gcc (Debian 4.9.2-10+deb8u1) 4.9.2
  17    40.66 debian:9                      : FAIL gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
  18   113.19 debian:experimental           : Ok   gcc (Debian 8.2.0-8) 8.2.0
  19    41.48 debian:experimental-x-arm64   : Ok   aarch64-linux-gnu-gcc (Debian 8.2.0-7) 8.2.0
  20    41.51 debian:experimental-x-mips    : Ok   mips-linux-gnu-gcc (Debian 8.2.0-7) 8.2.0
  21    40.09 debian:experimental-x-mips64  : Ok   mips64-linux-gnuabi64-gcc (Debian 8.1.0-12) 8.1.0
  22    42.17 debian:experimental-x-mipsel  : Ok   mipsel-linux-gnu-gcc (Debian 8.2.0-7) 8.2.0
  23    40.02 fedora:20                     : Ok   gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7)
  24    45.47 fedora:21                     : Ok   gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)
  25    41.64 fedora:22                     : Ok   gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
  26    43.60 fedora:23                     : Ok   gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
  27    44.04 fedora:24                     : Ok   gcc (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1)
  28    37.21 fedora:24-x-ARC-uClibc        : Ok   arc-linux-gcc (ARCompact ISA Linux uClibc toolchain 2017.09-rc2) 7.1.1 20170710

The problem with clearlinux is unrelated:

clang-7: error: unknown argument: '-fno-semantic-interposition'
clang-7: error: unsupported argument '4' to option 'flto='
clang-7: error: optimization flag '-ffat-lto-objects' is not supported [-Werror,-Wignored-optimization-argument]