DKMS building error

DKMS make.log for wireguard-0.0.20181218 for kernel 4.4.154-72-rockchip-g6520deb (aarch64)
Sun Jan 20 20:17:25 CST 2019
make: Entering directory ‘/usr/src/linux-headers-4.4.154-72-rockchip-g6520deb’
 LD      /var/lib/dkms/wireguard/0.0.20181218/build/built-in.o
 CC [M]  /var/lib/dkms/wireguard/0.0.20181218/build/noise.o
 CC [M]  /var/lib/dkms/wireguard/0.0.20181218/build/main.o
 CC [M]  /var/lib/dkms/wireguard/0.0.20181218/build/device.o
 CC [M]  /var/lib/dkms/wireguard/0.0.20181218/build/timers.o
 CC [M]  /var/lib/dkms/wireguard/0.0.20181218/build/peer.o
 CC [M]  /var/lib/dkms/wireguard/0.0.20181218/build/queueing.o
/bin/sh: 1: ./scripts/recordmcount: Exec format error
scripts/Makefile.build:277: recipe for target ‘/var/lib/dkms/wireguard/0.0.20181218/build/main.o’ failed
make[1]: *** [/var/lib/dkms/wireguard/0.0.20181218/build/main.o] Error 2
make[1]: *** Waiting for unfinished jobs…
/bin/sh: 1: ./scripts/recordmcount: Exec format error
scripts/Makefile.build:277: recipe for target ‘/var/lib/dkms/wireguard/0.0.20181218/build/queueing.o’ failed
make[1]: *** [/var/lib/dkms/wireguard/0.0.20181218/build/queueing.o] Error 2
/bin/sh: 1: ./scripts/recordmcount: Exec format error
scripts/Makefile.build:277: recipe for target ‘/var/lib/dkms/wireguard/0.0.20181218/build/peer.o’ failed
make[1]: *** [/var/lib/dkms/wireguard/0.0.20181218/build/peer.o] Error 2
/bin/sh: 1: ./scripts/recordmcount: Exec format error
scripts/Makefile.build:277: recipe for target ‘/var/lib/dkms/wireguard/0.0.20181218/build/device.o’ failed
make[1]: *** [/var/lib/dkms/wireguard/0.0.20181218/build/device.o] Error 2
/bin/sh: 1: ./scripts/recordmcount: Exec format error
scripts/Makefile.build:277: recipe for target ‘/var/lib/dkms/wireguard/0.0.20181218/build/timers.o’ failed
make[1]: *** [/var/lib/dkms/wireguard/0.0.20181218/build/timers.o] Error 2
/bin/sh: 1: ./scripts/recordmcount: Exec format error
scripts/Makefile.build:277: recipe for target ‘/var/lib/dkms/wireguard/0.0.20181218/build/noise.o’ failed
make[1]: *** [/var/lib/dkms/wireguard/0.0.20181218/build/noise.o] Error 2
Makefile:1474: recipe for target ‘module/var/lib/dkms/wireguard/0.0.20181218/build’ failed
make: *** [module/var/lib/dkms/wireguard/0.0.20181218/build] Error 2
make: Leaving directory ‘/usr/src/linux-headers-4.4.154-72-rockchip-g6520deb’

file /usr/src/linux-headers-4.4.154-72-rockchip-g6520deb/scripts
/usr/src/linux-headers-4.4.154-72-rockchip-g6520deb/scripts/recordmcount: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=8bf6e966ec087c96bbe4e5e69b93e7eaa7c148d

*[HowToCrossBuildAnOfficialDebianKernelPackage](https://wiki.debian.org/HowToCrossBuildAnOfficialDebianKernelPackage)

According to upper debian official cross-kernel-package building instructions, some env variable are not exported in Radxa vendor kernel building instructions.

I think you are building on ROCK Pi 4 or cross compiling?

I am trying to install wireguard on ubuntu on RockPI-4B with linux-headers-4.4.154-72-rockchip-g6520deb provided in Radxa repo.

quickfix

sudo -i
apt-get install libssl-dev build-essential -y
export HEADER_DIR=/usr/src/linux-headers-$(uname -r)
find “$HEADER_DIR/scripts” -type f | while read i; do if file -b $i | egrep -q “^ELF.*x86-64”; then rm “$i”; fi; done
cd $HEADER_DIR/scripts
gcc mkkrnlimg.c -o “$HEADER_DIR/scripts/mkkrnlimg”
gcc kallsyms.c -o “$HEADER_DIR/scripts/kallsyms”
gcc pnmtologo.c -o “$HEADER_DIR/scripts/pnmtologo”
gcc conmakehash.c -o “$HEADER_DIR/scripts/conmakehash”
gcc resource_tool.c -o “$HEADER_DIR/scripts/resource_tool”
gcc ./basic/bin2c.c -o “$HEADER_DIR/scripts/basic/bin2c”
gcc recordmcount.c -o “$HEADER_DIR/scripts/recordmcount”
gcc -I…/tools/include sortextable.c -o “$HEADER_DIR/scripts/sortextable”
gcc unifdef.c -o “$HEADER_DIR/scripts/unifdef”
gcc ./basic/fixdep.c -o “$HEADER_DIR/scripts/basic/fixdep”
gcc extract-cert.c -o “$HEADER_DIR/scripts/extract-cert” -lssl -lcrypto
gcc ./mod/modpost.c ./mod/file2alias.c ./mod/sumversion.c -o “$HEADER_DIR/scripts/mod/modpost”
gcc ./mod/mk_elfconfig.c -o “$HEADER_DIR/scripts/mod/mk_elfconfig”
gcc -I…/include asn1_compiler.c -o “$HEADER_DIR/scripts/asn1_compiler”
ln -f ./genksyms/parse.tab.c_shipped ./genksyms/parse.tab.c;
ln -f ./genksyms/parse.tab.h_shipped ./genksyms/parse.tab.h;
ln -f ./genksyms/lex.lex.c_shipped ./genksyms/lex.lex.c;
ln -f ./genksyms/keywords.hash.c_shipped ./genksyms/keywords.hash.c;
gcc ./genksyms/genksyms.c ./genksyms/parse.tab.c ./genksyms/lex.lex.c -o “$HEADER_DIR/scripts/genksyms/genksyms”

1 Like

sudo dpkg-reconfigure wireguard-dkms

-------- Uninstall Beginning --------
Module:  wireguard
Version: 0.0.20181218
Kernel:  4.4.154-72-rockchip-g6520deb (aarch64)

Status: Before uninstall, this module version was ACTIVE on this kernel.

wireguard.ko:

  • Uninstallation
      - Deleting from: /lib/modules/4.4.154-72-rockchip-g6520deb/updates/dkms/
  • Original module
      - No original module was found for this module on this kernel.
      - Use the dkms install command to reinstall any previous module version.

depmod…

DKMS: uninstall completed.


Deleting module version: 0.0.20181218
completely from the DKMS tree.

Done.
Loading new wireguard-0.0.20181218 DKMS files…
Building for 4.4.154-72-rockchip-g6520deb
Building initial module for 4.4.154-72-rockchip-g6520deb

Done.

wireguard:
Running module version sanity check.

  • Original module
      - No original module exists within this kernel
  • Installation
      - Installing to /lib/modules/4.4.154-72-rockchip-g6520deb/updates/dkms/

depmod…

DKMS: install completed.

Although upper quick-fix works,
the linux-header package in repo should be fixed anyway.

2 Likes

This Helped, Thanx @trulyliu
The repo should be fixed though.

Since I used this fix a couple
of times, I had to fix the formatting of Discourse. Here it goes:

sudo -i

apt-get install libssl-dev build-essential -y
export HEADER_DIR=/usr/src/linux-headers-$(uname -r)
find "$HEADER_DIR/scripts" -type f | while read i; do if file -b $i | egrep -q "^ELF.*x86-64"; then rm "$i"; fi; done

cd $HEADER_DIR/scripts

gcc mkkrnlimg.c -o "$HEADER_DIR/scripts/mkkrnlimg"
gcc kallsyms.c -o "$HEADER_DIR/scripts/kallsyms"
gcc pnmtologo.c -o "$HEADER_DIR/scripts/pnmtologo"
gcc conmakehash.c -o "$HEADER_DIR/scripts/conmakehash"
gcc resource_tool.c -o "$HEADER_DIR/scripts/resource_tool"
gcc ./basic/bin2c.c -o "$HEADER_DIR/scripts/basic/bin2c"
gcc recordmcount.c -o "$HEADER_DIR/scripts/recordmcount"
gcc -I../tools/include sortextable.c -o "$HEADER_DIR/scripts/sortextable"
gcc unifdef.c -o "$HEADER_DIR/scripts/unifdef"
gcc ./basic/fixdep.c -o "$HEADER_DIR/scripts/basic/fixdep"
gcc extract-cert.c -o "$HEADER_DIR/scripts/extract-cert" -lssl -lcrypto
gcc ./mod/modpost.c ./mod/file2alias.c ./mod/sumversion.c -o "$HEADER_DIR/scripts/mod/modpost"
gcc ./mod/mk_elfconfig.c -o "$HEADER_DIR/scripts/mod/mk_elfconfig"
gcc  -I../include asn1_compiler.c -o "$HEADER_DIR/scripts/asn1_compiler"

ln -f ./genksyms/parse.tab.c_shipped ./genksyms/parse.tab.c;
ln  -f ./genksyms/parse.tab.h_shipped ./genksyms/parse.tab.h;
ln -f ./genksyms/lex.lex.c_shipped ./genksyms/lex.lex.c;
ln -f ./genksyms/keywords.hash.c_shipped ./genksyms/keywords.hash.c;
gcc ./genksyms/genksyms.c ./genksyms/parse.tab.c ./genksyms/lex.lex.c -o "$HEADER_DIR/scripts/genksyms/genksyms"

# Rebuild dkms Package (ex.)
sudo dpkg-reconfigure wireguard-dkms

This is because the kernel package is cross-compiled on x86. We will fix this.

1 Like

Hi,

I’m having issues installing wireguard on RockPI 4b, Ubuntu 20.04

I ran the script above, but the apt install wireguard-dkms is still failing with

DKMS make.log for wireguard-1.0.20200611 for kernel 4.4.154-111-rockchip-g39b306a41b2d (aarch64)
Fri Nov 13 23:42:41 CET 2020
make: Entering directory '/usr/src/linux-headers-4.4.154-111-rockchip-g39b306a41b2d'
  CC [M]  /var/lib/dkms/wireguard/1.0.20200611/build/main.o
  LD      /var/lib/dkms/wireguard/1.0.20200611/build/built-in.o
  CC [M]  /var/lib/dkms/wireguard/1.0.20200611/build/noise.o
  CC [M]  /var/lib/dkms/wireguard/1.0.20200611/build/device.o
  CC [M]  /var/lib/dkms/wireguard/1.0.20200611/build/peer.o
  CC [M]  /var/lib/dkms/wireguard/1.0.20200611/build/timers.o
  CC [M]  /var/lib/dkms/wireguard/1.0.20200611/build/queueing.o
In file included from include/linux/phy.h:22,
                 from include/net/dsa.h:19,
                 from include/linux/netdevice.h:44,
                 from include/net/ip_tunnels.h:5,
                 from include/net/udp_tunnel.h:4,
                 from /var/lib/dkms/wireguard/1.0.20200611/build/compat/udp_tunnel/udp_tunnel_partial_compat.h:143,
                 from /var/lib/dkms/wireguard/1.0.20200611/build/compat/compat.h:76,
                 from <command-line>:
include/linux/module.h:130:6: warning: ‘init_module’ specifies less restrictive attribute than its target ‘mod_init’: ‘cold’ [-Wmissing-attributes]
error, forbidden warning:module.h:130
  130 |  int init_module(void) __attribute__((alias(#initfn)));
      |      ^~~~~~~~~~~
/var/lib/dkms/wireguard/1.0.20200611/build/main.c:61:1: note: in expansion of macro ‘module_init’
   61 | module_init(mod_init);
      | ^~~~~~~~~~~
/var/lib/dkms/wireguard/1.0.20200611/build/main.c:20:19: note: ‘init_module’ target declared here
   20 | static int __init mod_init(void)
      |                   ^~~~~~~~
In file included from include/linux/phy.h:22,
                 from include/net/dsa.h:19,
                 from include/linux/netdevice.h:44,
                 from include/net/ip_tunnels.h:5,
                 from include/net/udp_tunnel.h:4,
                 from /var/lib/dkms/wireguard/1.0.20200611/build/compat/udp_tunnel/udp_tunnel_partial_compat.h:143,
                 from /var/lib/dkms/wireguard/1.0.20200611/build/compat/compat.h:76,
                 from <command-line>:
include/linux/module.h:136:7: warning: ‘cleanup_module’ specifies less restrictive attribute than its target ‘mod_exit’: ‘cold’ [-Wmissing-attributes]
error, forbidden warning:module.h:136
  136 |  void cleanup_module(void) __attribute__((alias(#exitfn)));
      |       ^~~~~~~~~~~~~~
/var/lib/dkms/wireguard/1.0.20200611/build/main.c:62:1: note: in expansion of macro ‘module_exit’
   62 | module_exit(mod_exit);
      | ^~~~~~~~~~~
/var/lib/dkms/wireguard/1.0.20200611/build/main.c:55:20: note: ‘cleanup_module’ target declared here
   55 | static void __exit mod_exit(void)
      |                    ^~~~~~~~
make[1]: *** [scripts/Makefile.build:277: /var/lib/dkms/wireguard/1.0.20200611/build/main.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1474: _module_/var/lib/dkms/wireguard/1.0.20200611/build] Error 2
make: Leaving directory '/usr/src/linux-headers-4.4.154-111-rockchip-g39b306a41b2d'

Could you help solving this ?

Hi, @andrey_avtomonov

Before installing wireguard, you need to do some extra steps.

sudo su
apt-get install -y libssl-dev build-essential 
cd /usr/src/linux-headers-$(uname -r)
make scripts

And then install wireguard.