systemtap fails to build C due to __NR_compat_clock_getres define errors

Bug #1883343 reported by nyanpasu64
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
systemtap (Ubuntu)
New
Undecided
Unassigned

Bug Description

I'm using a Raspberry Pi 3B running Ubuntu Server 20.04 arm64. If I try to compile a systemtap file which probes "signal.send", I get multiple definition warnings, and compilation fails because stap passes -Werror to the compiler.

ubuntu@pi-ubuntu:~/bin$ cat empty.stap
probe signal.send {
  printf("signalled\n");
}

probe begin {
  printf("hi\n");
}

ubuntu@pi-ubuntu:~/bin$ sudo stap empty.stap
In file included from /tmp/stap8WrZMD/stap_57b83f2353a7c1704daf8d11fb82f111_59444_src.c:36:
/usr/share/systemtap/runtime/linux/compat_unistd.h:1876: error: "__NR_compat_clock_getres" redefined [-Werror]
 1876 | #define __NR_compat_clock_getres __NR_clock_getres
      |
In file included from /tmp/stap8WrZMD/stap_57b83f2353a7c1704daf8d11fb82f111_59444_src.c:35:
./arch/arm64/include/asm/unistd.h:29: note: this is the location of the previous definition
   29 | #define __NR_compat_clock_getres 264
      |
In file included from /tmp/stap8WrZMD/stap_57b83f2353a7c1704daf8d11fb82f111_59444_src.c:36:
/usr/share/systemtap/runtime/linux/compat_unistd.h:1877: error: "__NR_compat_clock_gettime" redefined [-Werror]
 1877 | #define __NR_compat_clock_gettime __NR_clock_gettime
      |
In file included from /tmp/stap8WrZMD/stap_57b83f2353a7c1704daf8d11fb82f111_59444_src.c:35:
./arch/arm64/include/asm/unistd.h:28: note: this is the location of the previous definition
   28 | #define __NR_compat_clock_gettime 263
      |
In file included from /tmp/stap8WrZMD/stap_57b83f2353a7c1704daf8d11fb82f111_59444_src.c:36:
/usr/share/systemtap/runtime/linux/compat_unistd.h:1958: error: "__NR_compat_gettimeofday" redefined [-Werror]
 1958 | #define __NR_compat_gettimeofday __NR_gettimeofday
      |
In file included from /tmp/stap8WrZMD/stap_57b83f2353a7c1704daf8d11fb82f111_59444_src.c:35:
./arch/arm64/include/asm/unistd.h:25: note: this is the location of the previous definition
   25 | #define __NR_compat_gettimeofday 78
      |
cc1: all warnings being treated as errors
make[1]: *** [scripts/Makefile.build:273: /tmp/stap8WrZMD/stap_57b83f2353a7c1704daf8d11fb82f111_59444_src.o] Error 1
make: *** [Makefile:1722: /tmp/stap8WrZMD] Error 2
WARNING: kbuild exited with status: 2
Pass 4: compilation failed. [man error::pass4]
Tip: /usr/share/doc/systemtap/README.Debian should help you get started.

ubuntu@pi-ubuntu:~/bin$ lsb_release -rd
Description: Ubuntu 20.04 LTS
Release: 20.04

ubuntu@pi-ubuntu:~/bin$ apt-cache policy systemtap
systemtap:
  Installed: 4.2-3
  Candidate: 4.2-3
  Version table:
 *** 4.2-3 500
        500 http://ports.ubuntu.com/ubuntu-ports focal/universe arm64 Packages
        100 /var/lib/dpkg/status

ProblemType: Bug
DistroRelease: Ubuntu 20.04
Package: systemtap 4.2-3
ProcVersionSignature: User Name 5.4.0-1012.12-raspi 5.4.41
Uname: Linux 5.4.0-1012-raspi aarch64
ApportVersion: 2.20.11-0ubuntu27.2
Architecture: arm64
CasperMD5CheckResult: skip
Date: Sat Jun 13 03:41:44 2020
ImageMediaBuild: 20200423.1
ProcEnviron:
 TERM=xterm
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=C.UTF-8
 SHELL=/bin/bash
SourcePackage: systemtap
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
nyanpasu64 (nyanpasu64) wrote :
Revision history for this message
Dan Streetman (ddstreet) wrote :

Does the systemtap from this ppa work correctly for you?

https://launchpad.net/~ubuntu-support-team/+archive/ubuntu/systemtap

Revision history for this message
nyanpasu64 (nyanpasu64) wrote :

Same error.

ubuntu@pi-ubuntu:~/bin$ apt-cache policy systemtap
systemtap:
  Installed: 4.3-2-g7a7016a12+20.04.20200612040454
  Candidate: 4.3-2-g7a7016a12+20.04.20200612040454
  Version table:
 *** 4.3-2-g7a7016a12+20.04.20200612040454 500
        500 http://ppa.launchpad.net/ubuntu-support-team/systemtap/ubuntu focal/main arm64 Packages
        100 /var/lib/dpkg/status
     4.2-3 500
        500 http://ports.ubuntu.com/ubuntu-ports focal/universe arm64 Packages

ubuntu@pi-ubuntu:~/bin$ sudo stap empty.stap
In file included from /tmp/stapbLlwIo/stap_3d7839d377ce54c81f0c86b1126e5e95_60512_src.c:31:
/usr/share/systemtap/runtime/linux/compat_unistd.h:1876: error: "__NR_compat_clock_getres" redefined [-Werror]
 1876 | #define __NR_compat_clock_getres __NR_clock_getres
      |
In file included from /tmp/stapbLlwIo/stap_3d7839d377ce54c81f0c86b1126e5e95_60512_src.c:30:
./arch/arm64/include/asm/unistd.h:29: note: this is the location of the previous definition
   29 | #define __NR_compat_clock_getres 264
      |
In file included from /tmp/stapbLlwIo/stap_3d7839d377ce54c81f0c86b1126e5e95_60512_src.c:31:
/usr/share/systemtap/runtime/linux/compat_unistd.h:1877: error: "__NR_compat_clock_gettime" redefined [-Werror]
 1877 | #define __NR_compat_clock_gettime __NR_clock_gettime
      |
In file included from /tmp/stapbLlwIo/stap_3d7839d377ce54c81f0c86b1126e5e95_60512_src.c:30:
./arch/arm64/include/asm/unistd.h:28: note: this is the location of the previous definition
   28 | #define __NR_compat_clock_gettime 263
      |
In file included from /tmp/stapbLlwIo/stap_3d7839d377ce54c81f0c86b1126e5e95_60512_src.c:31:
/usr/share/systemtap/runtime/linux/compat_unistd.h:1958: error: "__NR_compat_gettimeofday" redefined [-Werror]
 1958 | #define __NR_compat_gettimeofday __NR_gettimeofday
      |
In file included from /tmp/stapbLlwIo/stap_3d7839d377ce54c81f0c86b1126e5e95_60512_src.c:30:
./arch/arm64/include/asm/unistd.h:25: note: this is the location of the previous definition
   25 | #define __NR_compat_gettimeofday 78
      |
cc1: all warnings being treated as errors
make[1]: *** [scripts/Makefile.build:273: /tmp/stapbLlwIo/stap_3d7839d377ce54c81f0c86b1126e5e95_60512_src.o] Error 1
make: *** [Makefile:1722: /tmp/stapbLlwIo] Error 2
WARNING: kbuild exited with status: 2
Pass 4: compilation failed. [man error::pass4]

Revision history for this message
Dan Streetman (ddstreet) wrote :

> ./arch/arm64/include/asm/unistd.h:29: note: this is the location of the previous definition

what do you have in your . directory? That's where it's picking up the previous definition...

Revision history for this message
nyanpasu64 (nyanpasu64) wrote :

I had already wiped Ubuntu because of librtlsdr0 not working, so I installed it on a flash drive. I tried doing this procedure again, and got the same error.

. is ~ (/home/ubuntu) and has no such arch directory.

ubuntu@ubuntu:~$ pwd
/home/ubuntu

ubuntu@ubuntu:~$ ls -lA
total 40
-rw------- 1 ubuntu ubuntu 795 Jun 14 06:08 .bash_history
-rw-r--r-- 1 ubuntu ubuntu 220 Feb 25 12:03 .bash_logout
-rw-r--r-- 1 ubuntu ubuntu 3771 Feb 25 12:03 .bashrc
drwx------ 2 ubuntu ubuntu 4096 Jun 14 05:42 .cache
drwx------ 3 ubuntu ubuntu 4096 Jun 14 06:20 .config
drwxrwxr-x 3 ubuntu ubuntu 4096 Jun 14 06:24 .local
-rw-r--r-- 1 ubuntu ubuntu 807 Feb 25 12:03 .profile
drwx------ 2 ubuntu ubuntu 4096 Jun 14 05:38 .ssh
-rw-r--r-- 1 ubuntu ubuntu 0 Jun 14 05:43 .sudo_as_admin_successful
drwxrwxr-x 3 ubuntu ubuntu 4096 Jun 14 06:24 .systemtap
-rw-rw-r-- 1 ubuntu ubuntu 82 Jun 14 06:24 empty.stap

Revision history for this message
nyanpasu64 (nyanpasu64) wrote :

So what is `.`?

Searching for all files named unistd.h, I think it's one of the following 2 (note that both files are identical according to diff):

/usr/src/linux-raspi-headers-5.4.0-1012/arch/arm64/include/asm/unistd.h
/usr/src/linux-raspi-headers-5.4.0-1008/arch/arm64/include/asm/unistd.h

Full find command output at https://gist.github.com/nyanpasu64/53d1341655d4d63fd61e7d0a9de8313e.

I think that systemtap ships with a unistd stub at /usr/share/systemtap/runtime/linux/compat_unistd.h which has conflicts with the real unistd.h.

Revision history for this message
Frank Ch. Eigler (fche) wrote :

I suspect what you'll need is a collection of #if/#endif guards around the definitions of those macros:

diff --git a/runtime/linux/compat_unistd.h b/runtime/linux/compat_unistd.h
index 5a26b77bbccb..45e8b4d6c3d9 100644
--- a/runtime/linux/compat_unistd.h
+++ b/runtime/linux/compat_unistd.h
@@ -1873,7 +1873,11 @@
 #define __NR_compat_chown32 __NR_chown32
 #define __NR_compat_chroot __NR_chroot
 #define __NR_compat_clock_adjtime __NR_clock_adjtime
+
+#ifndef __NR_compat_clock_getres
 #define __NR_compat_clock_getres __NR_clock_getres
+#endif
+
 #define __NR_compat_clock_gettime __NR_clock_gettime
 #define __NR_compat_clock_nanosleep __NR_clock_nanosleep
 #define __NR_compat_clock_settime __NR_clock_settime

etc. for the others you have encountered. Once you have a good set working. please send upstream to <email address hidden>.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.