Re: [PATCH] perf bench: Share 'start', 'end', 'runtime' global vars

From: Arnaldo Carvalho de Melo
Date: Tue Mar 03 2020 - 10:36:33 EST


Em Tue, Mar 03, 2020 at 04:28:45PM +0100, Thomas Gleixner escreveu:
> Arnaldo Carvalho de Melo <arnaldo.melo@xxxxxxxxx> writes:
>
> > Hi,
> >
> > 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
> >
> > Just prefixing them with 'extern' in all but one (futex-hash.c)
> > seems to be enough, ok?
>
> Don't we have header files for that?

Sure, that was the laziest/quickest way to "fix" that, the other was to
stick a 'static' in front of it.

I'll go see if pushing them to a header file will not clash with other
stuff.

- Arnaldo