Skip to content

Instantly share code, notes, and snippets.

@GitMensch
Last active June 19, 2024 12:30
Show Gist options
  • Save GitMensch/b0021e3cfd0957eeed6fbb9ce2973d7d to your computer and use it in GitHub Desktop.
Save GitMensch/b0021e3cfd0957eeed6fbb9ce2973d7d to your computer and use it in GitHub Desktop.
# see https://github.com/gitpod-io/gitpod/issues/8893
sudo apt install -y bison flex libelf-dev libnewt-dev libdw-dev libaudit-dev libiberty-dev libunwind-dev libcap-dev libzstd-dev libnuma-dev libssl-dev python3-dev python3-setuptools binutils-dev gcc-multilib liblzma-dev systemtap-sdt-dev
# you _may_ need asciidoc, too; that's quite a big one
cd /workspace
git clone --depth 1 --filter=blob:none --sparse git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git
cd linux
git sparse-checkout set dir tools scripts
git fetch --depth 1 origin v5.15
make -C tools/perf
# either do a reasonable install or
PERF_EXEC_PATH=/workspace/linux/tools/perf PATH=/workspace/linux//tools/perf:$PATH perf stat list
@GitMensch
Copy link
Author

As an alternative to the git sparse checkout - consider using the pre-packaged perf tarball from https://mirrors.edge.kernel.org/pub/linux/kernel/tools/perf/v5.15.0/

@NobinPegasus
Copy link

@GitMensch
I've downloaded a pre packaged perf tarball of version 6.4.0.
while I try to built.

pegasus@pegasus:~/Documents/perf-6.4.0$ make -C tools/perf/
make: Entering directory '/home/pegasus/Documents/perf-6.4.0/tools/perf'
  BUILD:   Doing 'make -j16' parallel build
Makefile.config:865: Missing python setuptools, the python binding won't be built, please install python3-setuptools or equivalent
Makefile.config:1105: No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-1.8.0-openjdk-devel

  INSTALL libsubcmd_headers
  INSTALL libperf_headers
  INSTALL libapi_headers
  INSTALL libsymbol_headers
  INSTALL libbpf_headers
  CC      scripts/python/Perf-Trace-Util/Context.o
In file included from /home/linuxbrew/.linuxbrew/opt/python@3.12/include/python3.12/Python.h:44,
                 from scripts/python/Perf-Trace-Util/Context.c:14:
/home/linuxbrew/.linuxbrew/opt/python@3.12/include/python3.12/object.h: In function ‘Py_SIZE’:
/home/linuxbrew/.linuxbrew/opt/python@3.12/include/python3.12/object.h:233:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
  233 |     PyVarObject *var_ob = _PyVarObject_CAST(ob);
      |     ^~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/opt/python@3.12/include/python3.12/Python.h:53:
/home/linuxbrew/.linuxbrew/opt/python@3.12/include/python3.12/cpython/longintrepr.h: In function ‘_PyLong_CompactValue’:
/home/linuxbrew/.linuxbrew/opt/python@3.12/include/python3.12/cpython/longintrepr.h:121:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
  121 |     Py_ssize_t sign = 1 - (op->long_value.lv_tag & _PyLong_SIGN_MASK);
      |     ^~~~~~~~~~
  CC      util/scripting-engines/trace-event-python.o
In file included from /home/linuxbrew/.linuxbrew/opt/python@3.12/include/python3.12/Python.h:44,
                 from util/scripting-engines/trace-event-python.c:22:
/home/linuxbrew/.linuxbrew/opt/python@3.12/include/python3.12/object.h: In function ‘Py_SIZE’:
/home/linuxbrew/.linuxbrew/opt/python@3.12/include/python3.12/object.h:233:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
  233 |     PyVarObject *var_ob = _PyVarObject_CAST(ob);
      |     ^~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/opt/python@3.12/include/python3.12/Python.h:53:
/home/linuxbrew/.linuxbrew/opt/python@3.12/include/python3.12/cpython/longintrepr.h: In function ‘_PyLong_CompactValue’:
/home/linuxbrew/.linuxbrew/opt/python@3.12/include/python3.12/cpython/longintrepr.h:121:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
  121 |     Py_ssize_t sign = 1 - (op->long_value.lv_tag & _PyLong_SIGN_MASK);
      |     ^~~~~~~~~~
cc1: all warnings being treated as errors
make[5]: *** [/home/pegasus/Documents/perf-6.4.0/tools/build/Makefile.build:98: scripts/python/Perf-Trace-Util/Context.o] Error 1
make[4]: *** [/home/pegasus/Documents/perf-6.4.0/tools/build/Makefile.build:140: python/Perf-Trace-Util] Error 2
make[3]: *** [/home/pegasus/Documents/perf-6.4.0/tools/build/Makefile.build:140: scripts] Error 2
make[3]: *** Waiting for unfinished jobs....
cc1: all warnings being treated as errors
make[5]: *** [/home/pegasus/Documents/perf-6.4.0/tools/build/Makefile.build:98: util/scripting-engines/trace-event-python.o] Error 1
make[4]: *** [/home/pegasus/Documents/perf-6.4.0/tools/build/Makefile.build:140: scripting-engines] Error 2
make[3]: *** [/home/pegasus/Documents/perf-6.4.0/tools/build/Makefile.build:140: util] Error 2
make[2]: *** [Makefile.perf:675: perf-in.o] Error 2
make[1]: *** [Makefile.perf:235: sub-make] Error 2
make: *** [Makefile:70: all] Error 2
make: Leaving directory '/home/pegasus/Documents/perf-6.4.0/tools/perf'

I already have python3-setuptools and openjdk 8 don't know why is it not finding it

@GitMensch
Copy link
Author

That's obviously not gitpod what this git is about... (in any case: ensure that you have the perf version matching best to your kernel version and possibly try to do a sparse checkout as in this gist, instead of a pre-packaged version).
The errors are about ISO C90 compat because the matching warning is set to an error - add ´-Wno-error=declaration-after-statement` to CFLAGS to work around that. ... but in any case: this is a specific gist, not stackoverflow....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment