We recently started building with Poky Kirkstone (quite a leap from our ancient and venerable branch of Sumo) which includes a newer set of tools in the toolchain:
binutils 2.30 -> 2.38 gcc 7.3.3 -> 11.2.0 glibc 2.27 -> 2.35
This uncovered some issues while cross-compiling on the 4.x kernels. The following patches help in building the 4.19 branch again.
These backports are already applied all the way down to 5.4.
Arnaldo Carvalho de Melo (2): perf bench: Share some global variables to fix build with gcc 10 perf tests bp_account: Make global variable static
Ben Hutchings (1): libtraceevent: Fix build with binutils 2.35
tools/lib/traceevent/Makefile | 2 +- tools/perf/bench/bench.h | 4 ++++ tools/perf/bench/futex-hash.c | 12 ++++++------ tools/perf/bench/futex-lock-pi.c | 11 +++++------ tools/perf/tests/bp_account.c | 2 +- 5 files changed, 17 insertions(+), 14 deletions(-)
From: Ben Hutchings ben@decadent.org.uk
[ Upstream commit 39efdd94e314336f4acbac4c07e0f37bdc3bef71 ]
In binutils 2.35, 'nm -D' changed to show symbol versions along with symbol names, with the usual @@ separator. When generating libtraceevent-dynamic-list we need just the names, so strip off the version suffix if present.
Signed-off-by: Ben Hutchings ben@decadent.org.uk Tested-by: Salvatore Bonaccorso carnil@debian.org Reviewed-by: Steven Rostedt rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Cc: stable@vger.kernel.org Signed-off-by: Arnaldo Carvalho de Melo acme@redhat.com Signed-off-by: Daniel Díaz daniel.diaz@linaro.org --- tools/lib/traceevent/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile index 05f8a0f27121a..b7f7e4e541d7b 100644 --- a/tools/lib/traceevent/Makefile +++ b/tools/lib/traceevent/Makefile @@ -263,7 +263,7 @@ define do_generate_dynamic_list_file xargs echo "U w W" | tr 'w ' 'W\n' | sort -u | xargs echo`;\ if [ "$$symbol_type" = "U W" ];then \ (echo '{'; \ - $(NM) -u -D $1 | awk 'NF>1 {print "\t"$$2";"}' | sort -u;\ + $(NM) -u -D $1 | awk 'NF>1 {sub("@.*", "", $$2); print "\t"$$2";"}' | sort -u;\ echo '};'; \ ) > $2; \ else \
From: Arnaldo Carvalho de Melo acme@redhat.com
[ Upstream commit e4d9b04b973b2dbce7b42af95ea70d07da1c936d ]
Noticed with gcc 10 (fedora rawhide) that those variables were not being declared as static, so end up with:
ld: /tmp/build/perf/bench/epoll-wait.o:/git/perf/tools/perf/bench/epoll-wait.c:93: multiple definition of `end'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here ld: /tmp/build/perf/bench/epoll-wait.o:/git/perf/tools/perf/bench/epoll-wait.c:93: multiple definition of `start'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here ld: /tmp/build/perf/bench/epoll-wait.o:/git/perf/tools/perf/bench/epoll-wait.c:93: multiple definition of `runtime'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here ld: /tmp/build/perf/bench/epoll-ctl.o:/git/perf/tools/perf/bench/epoll-ctl.c:38: multiple definition of `end'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here ld: /tmp/build/perf/bench/epoll-ctl.o:/git/perf/tools/perf/bench/epoll-ctl.c:38: multiple definition of `start'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here ld: /tmp/build/perf/bench/epoll-ctl.o:/git/perf/tools/perf/bench/epoll-ctl.c:38: multiple definition of `runtime'; /tmp/build/perf/bench/futex-hash.o:/git/perf/tools/perf/bench/futex-hash.c:40: first defined here make[4]: *** [/git/perf/tools/build/Makefile.build:145: /tmp/build/perf/bench/perf-in.o] Error 1
Prefix those with bench__ and add them to bench/bench.h, so that we can share those on the tools needing to access those variables from signal handlers.
Acked-by: Thomas Gleixner tglx@linutronix.de Cc: Adrian Hunter adrian.hunter@intel.com Cc: Davidlohr Bueso dave@stgolabs.net Cc: Jiri Olsa jolsa@kernel.org Cc: Namhyung Kim namhyung@kernel.org Link: http://lore.kernel.org/lkml/20200303155811.GD13702@kernel.org Signed-off-by: Arnaldo Carvalho de Melo acme@redhat.com Signed-off-by: Daniel Díaz daniel.diaz@linaro.org --- tools/perf/bench/bench.h | 4 ++++ tools/perf/bench/futex-hash.c | 12 ++++++------ tools/perf/bench/futex-lock-pi.c | 11 +++++------ 3 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/tools/perf/bench/bench.h b/tools/perf/bench/bench.h index 6c9fcd757f310..b3e418afc21a2 100644 --- a/tools/perf/bench/bench.h +++ b/tools/perf/bench/bench.h @@ -2,6 +2,10 @@ #ifndef BENCH_H #define BENCH_H
+#include <sys/time.h> + +extern struct timeval bench__start, bench__end, bench__runtime; + /* * The madvise transparent hugepage constants were added in glibc * 2.13. For compatibility with older versions of glibc, define these diff --git a/tools/perf/bench/futex-hash.c b/tools/perf/bench/futex-hash.c index 9aa3a674829b3..ee9b280651093 100644 --- a/tools/perf/bench/futex-hash.c +++ b/tools/perf/bench/futex-hash.c @@ -35,7 +35,7 @@ static unsigned int nfutexes = 1024; static bool fshared = false, done = false, silent = false; static int futex_flag = 0;
-struct timeval start, end, runtime; +struct timeval bench__start, bench__end, bench__runtime; static pthread_mutex_t thread_lock; static unsigned int threads_starting; static struct stats throughput_stats; @@ -101,8 +101,8 @@ static void toggle_done(int sig __maybe_unused, { /* inform all threads that we're done for the day */ done = true; - gettimeofday(&end, NULL); - timersub(&end, &start, &runtime); + gettimeofday(&bench__end, NULL); + timersub(&bench__end, &bench__start, &bench__runtime); }
static void print_summary(void) @@ -112,7 +112,7 @@ static void print_summary(void)
printf("%sAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n", !silent ? "\n" : "", avg, rel_stddev_stats(stddev, avg), - (int) runtime.tv_sec); + (int)bench__runtime.tv_sec); }
int bench_futex_hash(int argc, const char **argv) @@ -159,7 +159,7 @@ int bench_futex_hash(int argc, const char **argv)
threads_starting = nthreads; pthread_attr_init(&thread_attr); - gettimeofday(&start, NULL); + gettimeofday(&bench__start, NULL); for (i = 0; i < nthreads; i++) { worker[i].tid = i; worker[i].futex = calloc(nfutexes, sizeof(*worker[i].futex)); @@ -202,7 +202,7 @@ int bench_futex_hash(int argc, const char **argv) pthread_mutex_destroy(&thread_lock);
for (i = 0; i < nthreads; i++) { - unsigned long t = worker[i].ops/runtime.tv_sec; + unsigned long t = worker[i].ops / bench__runtime.tv_sec; update_stats(&throughput_stats, t); if (!silent) { if (nfutexes == 1) diff --git a/tools/perf/bench/futex-lock-pi.c b/tools/perf/bench/futex-lock-pi.c index 8e9c4753e3040..017609ae35906 100644 --- a/tools/perf/bench/futex-lock-pi.c +++ b/tools/perf/bench/futex-lock-pi.c @@ -35,7 +35,6 @@ static bool silent = false, multi = false; static bool done = false, fshared = false; static unsigned int nthreads = 0; static int futex_flag = 0; -struct timeval start, end, runtime; static pthread_mutex_t thread_lock; static unsigned int threads_starting; static struct stats throughput_stats; @@ -62,7 +61,7 @@ static void print_summary(void)
printf("%sAveraged %ld operations/sec (+- %.2f%%), total secs = %d\n", !silent ? "\n" : "", avg, rel_stddev_stats(stddev, avg), - (int) runtime.tv_sec); + (int)bench__runtime.tv_sec); }
static void toggle_done(int sig __maybe_unused, @@ -71,8 +70,8 @@ static void toggle_done(int sig __maybe_unused, { /* inform all threads that we're done for the day */ done = true; - gettimeofday(&end, NULL); - timersub(&end, &start, &runtime); + gettimeofday(&bench__end, NULL); + timersub(&bench__end, &bench__start, &bench__runtime); }
static void *workerfn(void *arg) @@ -183,7 +182,7 @@ int bench_futex_lock_pi(int argc, const char **argv)
threads_starting = nthreads; pthread_attr_init(&thread_attr); - gettimeofday(&start, NULL); + gettimeofday(&bench__start, NULL);
create_threads(worker, thread_attr, cpu); pthread_attr_destroy(&thread_attr); @@ -209,7 +208,7 @@ int bench_futex_lock_pi(int argc, const char **argv) pthread_mutex_destroy(&thread_lock);
for (i = 0; i < nthreads; i++) { - unsigned long t = worker[i].ops/runtime.tv_sec; + unsigned long t = worker[i].ops / bench__runtime.tv_sec;
update_stats(&throughput_stats, t); if (!silent)
From: Arnaldo Carvalho de Melo acme@redhat.com
[ Upstream commit cff20b3151ccab690715cb6cf0f5da5cccb32adf ]
To fix the build with newer gccs, that without this patch exit with:
LD /tmp/build/perf/tests/perf-in.o ld: /tmp/build/perf/tests/bp_account.o:/git/perf/tools/perf/tests/bp_account.c:22: multiple definition of `the_var'; /tmp/build/perf/tests/bp_signal.o:/git/perf/tools/perf/tests/bp_signal.c:38: first defined here make[4]: *** [/git/perf/tools/build/Makefile.build:145: /tmp/build/perf/tests/perf-in.o] Error 1
First noticed in fedora:rawhide/32 with:
[perfbuilder@a5ff49d6e6e4 ~]$ gcc --version gcc (GCC) 10.0.1 20200216 (Red Hat 10.0.1-0.8)
Reported-by: Jiri Olsa jolsa@kernel.org Cc: Adrian Hunter adrian.hunter@intel.com Cc: Namhyung Kim namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo acme@redhat.com Signed-off-by: Daniel Díaz daniel.diaz@linaro.org --- tools/perf/tests/bp_account.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/tests/bp_account.c b/tools/perf/tests/bp_account.c index a20cbc4454269..624e4ef73d1c0 100644 --- a/tools/perf/tests/bp_account.c +++ b/tools/perf/tests/bp_account.c @@ -22,7 +22,7 @@ #include "perf.h" #include "cloexec.h"
-volatile long the_var; +static volatile long the_var;
static noinline int test_function(void) {
On Mon, May 30, 2022 at 04:53:22PM -0500, Daniel Díaz wrote:
We recently started building with Poky Kirkstone (quite a leap from our ancient and venerable branch of Sumo) which includes a newer set of tools in the toolchain:
binutils 2.30 -> 2.38 gcc 7.3.3 -> 11.2.0 glibc 2.27 -> 2.35
This uncovered some issues while cross-compiling on the 4.x kernels. The following patches help in building the 4.19 branch again.
These backports are already applied all the way down to 5.4.
Arnaldo Carvalho de Melo (2): perf bench: Share some global variables to fix build with gcc 10 perf tests bp_account: Make global variable static
Ben Hutchings (1): libtraceevent: Fix build with binutils 2.35
tools/lib/traceevent/Makefile | 2 +- tools/perf/bench/bench.h | 4 ++++ tools/perf/bench/futex-hash.c | 12 ++++++------ tools/perf/bench/futex-lock-pi.c | 11 +++++------ tools/perf/tests/bp_account.c | 2 +- 5 files changed, 17 insertions(+), 14 deletions(-)
-- 2.32.0
All now queued up, thanks.
greg k-h
linux-stable-mirror@lists.linaro.org