* [PATCH] perf build: Build error in libbpf with EXTRA_CFLAGS="-Wp,-D_FORTIFY_SOURCE=2 -O2"
@ 2018-07-23 13:45 Thomas Richter
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Richter @ 2018-07-23 13:45 UTC (permalink / raw)
To: linux-kernel, linux-perf-users, acme, wangnan0
Cc: brueckner, schwidefsky, heiko.carstens, Thomas Richter
commit a5b8bd47dcc57 ("bpf tools: Collect eBPF programs from their own sections")
cause a compiler error when building the perf tool in the linux-next tree.
I compile it using a FEDORA 28 installation, my gcc compiler version:
gcc (GCC) 8.0.1 20180324 (Red Hat 8.0.1-0.20)
Here is the error message:
[root@p23lp27] # make V=1 EXTRA_CFLAGS="-Wp,-D_FORTIFY_SOURCE=2 -O2"
[...]
make -f /home6/tmricht/linux-next/tools/build/Makefile.build
dir=./util/scripting-engines obj=libperf
libbpf.c: In function ‘bpf_object__elf_collect’:
libbpf.c:811:15: error: ignoring return value of ‘strerror_r’,
declared with attribute warn_unused_result [-Werror=unused-result]
strerror_r(-err, errmsg, sizeof(errmsg));
^
cc1: all warnings being treated as errors
mv: cannot stat './.libbpf.o.tmp': No such file or directory
/home6/tmricht/linux-next/tools/build/Makefile.build:96: recipe for target 'libbpf.o' failed
Fix this by using strerror_r return value in pr_warning statement.
Also fixes a possible initialization issue.
Cc: Wang Nan <wangnan0@huawei.com>
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
---
tools/lib/bpf/libbpf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 955f8eafbf41..c70785ea903c 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -808,9 +808,9 @@ static int bpf_object__elf_collect(struct bpf_object *obj)
if (err) {
char errmsg[STRERR_BUFSIZE];
- strerror_r(-err, errmsg, sizeof(errmsg));
pr_warning("failed to alloc program %s (%s): %s",
- name, obj->path, errmsg);
+ name, obj->path,
+ strerror_r(-err, errmsg, sizeof(errmsg)));
}
} else if (sh.sh_type == SHT_REL) {
void *reloc = obj->efile.reloc;
@@ -2334,7 +2334,7 @@ bpf_perf_event_read_simple(void *mem, unsigned long size,
__u64 data_tail = header->data_tail;
__u64 data_head = header->data_head;
void *base, *begin, *end;
- int ret;
+ int ret = 0;
asm volatile("" ::: "memory"); /* in real code it should be smp_rmb() */
if (data_head == data_tail)
--
2.16.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] perf build: Build error in libbpf with EXTRA_CFLAGS="-Wp,-D_FORTIFY_SOURCE=2 -O2"
2018-07-24 15:10 Thomas Richter
@ 2018-07-25 5:35 ` Daniel Borkmann
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2018-07-25 5:35 UTC (permalink / raw)
To: Thomas Richter, ast, netdev, linux-kernel
Cc: heiko.carstens, brueckner, schwidefsky, wangnan0
On 07/24/2018 05:10 PM, Thomas Richter wrote:
> commit a5b8bd47dcc57 ("bpf tools: Collect eBPF programs from their own sections")
>
> cause a compiler error when building the perf tool in the linux-next tree.
> I compile it using a FEDORA 28 installation, my gcc compiler version:
> gcc (GCC) 8.0.1 20180324 (Red Hat 8.0.1-0.20)
>
> The file that causes the error is tools/lib/bpf/libbpf.c
>
> Here is the error message:
>
> [root@p23lp27] # make V=1 EXTRA_CFLAGS="-Wp,-D_FORTIFY_SOURCE=2 -O2"
> [...]
> make -f /home6/tmricht/linux-next/tools/build/Makefile.build
> dir=./util/scripting-engines obj=libperf
> libbpf.c: In function ‘bpf_object__elf_collect’:
> libbpf.c:811:15: error: ignoring return value of ‘strerror_r’,
> declared with attribute warn_unused_result [-Werror=unused-result]
> strerror_r(-err, errmsg, sizeof(errmsg));
> ^
> cc1: all warnings being treated as errors
> mv: cannot stat './.libbpf.o.tmp': No such file or directory
> /home6/tmricht/linux-next/tools/build/Makefile.build:96: recipe for target 'libbpf.o' failed
>
> Fix this by using strerror_r return value in pr_warning statement.
> Also fixes a possible initialization issue.
>
> Cc: Wang Nan <wangnan0@huawei.com>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
> ---
> tools/lib/bpf/libbpf.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 955f8eafbf41..c70785ea903c 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -808,9 +808,9 @@ static int bpf_object__elf_collect(struct bpf_object *obj)
> if (err) {
> char errmsg[STRERR_BUFSIZE];
>
> - strerror_r(-err, errmsg, sizeof(errmsg));
> pr_warning("failed to alloc program %s (%s): %s",
> - name, obj->path, errmsg);
> + name, obj->path,
> + strerror_r(-err, errmsg, sizeof(errmsg)));
This doesn't build for me. Doing this here won't work since it uses
strerror_r() variant that returns an int (which is posix variant and
not gnu specific one that would return char *):
# make
BUILD: Doing 'make -j4' parallel build
HOSTCC fixdep.o
HOSTLD fixdep-in.o
LINK fixdep
Warning: Kernel ABI header at 'tools/arch/powerpc/include/uapi/asm/unistd.h' differs from latest version at 'arch/powerpc/include/uapi/asm/unistd.h'
Warning: Kernel ABI header at 'tools/arch/x86/lib/memcpy_64.S' differs from latest version at 'arch/x86/lib/memcpy_64.S'
Auto-detecting system features:
... dwarf: [ on ]
... dwarf_getlocations: [ on ]
... glibc: [ on ]
... gtk2: [ OFF ]
... libaudit: [ on ]
... libbfd: [ on ]
... libelf: [ on ]
... libnuma: [ on ]
... numa_num_possible_cpus: [ on ]
... libperl: [ OFF ]
... libpython: [ OFF ]
... libslang: [ on ]
... libcrypto: [ on ]
... libunwind: [ on ]
... libdw-dwarf-unwind: [ on ]
... zlib: [ on ]
... lzma: [ on ]
... get_cpuid: [ on ]
... bpf: [ on ]
Makefile.config:443: No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev
Makefile.config:610: GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev
Makefile.config:637: Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev
Makefile.config:669: No 'python-config' tool was found: disables Python support - please install python-devel/python-dev
Makefile.config:812: No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev
Makefile.config:849: No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel
GEN common-cmds.h
CC fd/array.o
CC event-parse.o
PERF_VERSION = 4.18.rc5.g56801c
CC fs/fs.o
LD fd/libapi-in.o
CC fs/tracing_path.o
CC event-plugin.o
LD fs/libapi-in.o
CC cpu.o
CC debug.o
CC trace-seq.o
CC str_error_r.o
LD libapi-in.o
CC exec-cmd.o
AR libapi.a
CC parse-filter.o
CC parse-utils.o
CC help.o
CC pager.o
Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf.h' differs from latest version at 'include/uapi/linux/bpf.h'
CC kbuffer-parse.o
CC libbpf.o
LD libtraceevent-in.o
LINK libtraceevent.a
libbpf.c: In function ‘bpf_object__elf_collect’:
libbpf.c:81:10: error: format ‘%s’ expects argument of type ‘char *’, but argument 4 has type ‘int’ [-Werror=format=]
(func)("libbpf: " fmt, ##__VA_ARGS__); \
^
libbpf.c:84:30: note: in expansion of macro ‘__pr’
#define pr_warning(fmt, ...) __pr(__pr_warning, fmt, ##__VA_ARGS__)
^~~~
libbpf.c:858:5: note: in expansion of macro ‘pr_warning’
pr_warning("failed to alloc program %s (%s): %s",
^~~~~~~~~~
CC parse-options.o
HOSTCC pmu-events/json.o
CC run-command.o
HOSTCC pmu-events/jsmn.o
cc1: all warnings being treated as errors
> }
> } else if (sh.sh_type == SHT_REL) {
> void *reloc = obj->efile.reloc;
> @@ -2334,7 +2334,7 @@ bpf_perf_event_read_simple(void *mem, unsigned long size,
> __u64 data_tail = header->data_tail;
> __u64 data_head = header->data_head;
> void *base, *begin, *end;
> - int ret;
> + int ret = 0;
>
> asm volatile("" ::: "memory"); /* in real code it should be smp_rmb() */
> if (data_head == data_tail)
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] perf build: Build error in libbpf with EXTRA_CFLAGS="-Wp,-D_FORTIFY_SOURCE=2 -O2"
@ 2018-07-24 15:10 Thomas Richter
2018-07-25 5:35 ` Daniel Borkmann
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Richter @ 2018-07-24 15:10 UTC (permalink / raw)
To: daniel, ast, netdev, linux-kernel
Cc: heiko.carstens, brueckner, schwidefsky, wangnan0, Thomas Richter
commit a5b8bd47dcc57 ("bpf tools: Collect eBPF programs from their own sections")
cause a compiler error when building the perf tool in the linux-next tree.
I compile it using a FEDORA 28 installation, my gcc compiler version:
gcc (GCC) 8.0.1 20180324 (Red Hat 8.0.1-0.20)
The file that causes the error is tools/lib/bpf/libbpf.c
Here is the error message:
[root@p23lp27] # make V=1 EXTRA_CFLAGS="-Wp,-D_FORTIFY_SOURCE=2 -O2"
[...]
make -f /home6/tmricht/linux-next/tools/build/Makefile.build
dir=./util/scripting-engines obj=libperf
libbpf.c: In function ‘bpf_object__elf_collect’:
libbpf.c:811:15: error: ignoring return value of ‘strerror_r’,
declared with attribute warn_unused_result [-Werror=unused-result]
strerror_r(-err, errmsg, sizeof(errmsg));
^
cc1: all warnings being treated as errors
mv: cannot stat './.libbpf.o.tmp': No such file or directory
/home6/tmricht/linux-next/tools/build/Makefile.build:96: recipe for target 'libbpf.o' failed
Fix this by using strerror_r return value in pr_warning statement.
Also fixes a possible initialization issue.
Cc: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
---
tools/lib/bpf/libbpf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 955f8eafbf41..c70785ea903c 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -808,9 +808,9 @@ static int bpf_object__elf_collect(struct bpf_object *obj)
if (err) {
char errmsg[STRERR_BUFSIZE];
- strerror_r(-err, errmsg, sizeof(errmsg));
pr_warning("failed to alloc program %s (%s): %s",
- name, obj->path, errmsg);
+ name, obj->path,
+ strerror_r(-err, errmsg, sizeof(errmsg)));
}
} else if (sh.sh_type == SHT_REL) {
void *reloc = obj->efile.reloc;
@@ -2334,7 +2334,7 @@ bpf_perf_event_read_simple(void *mem, unsigned long size,
__u64 data_tail = header->data_tail;
__u64 data_head = header->data_head;
void *base, *begin, *end;
- int ret;
+ int ret = 0;
asm volatile("" ::: "memory"); /* in real code it should be smp_rmb() */
if (data_head == data_tail)
--
2.16.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-25 5:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-23 13:45 [PATCH] perf build: Build error in libbpf with EXTRA_CFLAGS="-Wp,-D_FORTIFY_SOURCE=2 -O2" Thomas Richter
2018-07-24 15:10 Thomas Richter
2018-07-25 5:35 ` Daniel Borkmann
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).