gsliepen / tinc

a VPN daemon
http://tinc-vpn.org/
Other
1.97k stars 285 forks source link

Compile error starting "Python script for version detection" #358

Closed lancethepants closed 2 years ago

lancethepants commented 2 years ago

Commit 33f0918cde36accb606271c379bc8e75973e9d59 causing the following build issue while cross-compiling for tomato firmware.

The Meson build system
Version: 0.62.0
Source dir: /home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/tinc
Build dir: /home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/tinc/build
Build type: cross build
Program python3 found: YES (/usr/bin/python3)
Project name: tinc
Project version: 2df5ccc48bcfc8644af949b87c22dd943c0cd76a

C compiler for the host machine: arm-brcm-linux-uclibcgnueabi-gcc (gcc 4.5.3 "arm-brcm-linux-uclibcgnueabi-gcc (Buildroot 2012.02) 4.5.3")
C linker for the host machine: arm-brcm-linux-uclibcgnueabi-gcc ld.bfd 2.21.1
C compiler for the build machine: cc (gcc 8.3.0 "cc (Debian 8.3.0-6) 8.3.0")
C linker for the build machine: cc ld.bfd 2.31.1
Build machine cpu family: x86_64
Build machine cpu: x86_64
Host machine cpu family: arm
Host machine cpu: armv7-a
Target machine cpu family: arm
Target machine cpu: armv7-a
Program python3 found: YES (/usr/bin/python3)
Compiler for C supports arguments -D_GNU_SOURCE: YES
Compiler for C supports arguments -D_FORTIFY_SOURCE=2: YES
Compiler for C supports arguments -fwrapv: YES
Compiler for C supports arguments -fno-strict-overflow: YES
Compiler for C supports arguments -Wreturn-type: YES
Compiler for C supports arguments -Wold-style-definition: YES
Compiler for C supports arguments -Wmissing-declarations: YES
Compiler for C supports arguments -Wmissing-prototypes: YES
Compiler for C supports arguments -Wstrict-prototypes: YES
Compiler for C supports arguments -Wredundant-decls: YES
Compiler for C supports arguments -Wbad-function-cast: YES
Compiler for C supports arguments -Wwrite-strings: YES
Compiler for C supports arguments -fdiagnostics-show-option: YES
Compiler for C supports arguments -fstrict-aliasing: YES
Compiler for C supports arguments -Wmissing-noreturn: YES
Compiler for C supports link arguments -Wl,-z,relro: YES
Compiler for C supports link arguments -Wl,-z,now: YES
Compiler for C supports function attribute malloc: YES
Compiler for C supports function attribute nonnull: YES
Compiler for C supports function attribute warn_unused_result: YES
Library m found: YES
Has header "alloca.h" : YES
Has header "arpa/inet.h" : YES
Has header "arpa/nameser.h" : YES
Has header "dirent.h" : YES
Has header "getopt.h" : YES
Has header "inttypes.h" : YES
Has header "net/ethernet.h" : YES
Has header "net/if.h" : YES
Has header "net/if_arp.h" : YES
Has header "net/if_types.h" : NO
Has header "netdb.h" : YES
Has header "netinet/icmp6.h" : YES
Has header "netinet/if_ether.h" : YES
Has header "netinet/in.h" : YES
Has header "netinet/in6.h" : NO
Has header "netinet/in_systm.h" : YES
Has header "netinet/ip.h" : YES
Has header "netinet/ip6.h" : YES
Has header "netinet/ip_icmp.h" : YES
Has header "netinet/tcp.h" : YES
Has header "resolv.h" : YES
Has header "stddef.h" : YES
Has header "sys/file.h" : YES
Has header "sys/ioctl.h" : YES
Has header "sys/mman.h" : YES
Has header "sys/param.h" : YES
Has header "sys/resource.h" : YES
Has header "sys/socket.h" : YES
Has header "sys/stat.h" : YES
Has header "sys/time.h" : YES
Has header "sys/types.h" : YES
Has header "sys/wait.h" : YES
Has header "syslog.h" : YES
Has header "string.h" : YES
Has header "termios.h" : YES
Has header "unistd.h" : YES
Has header "sys/un.h" : YES
Has header "linux/if_tun.h" : YES
Has header "sys/epoll.h" : YES
Has header "netpacket/packet.h" : YES
Configuring meson_config.h using configuration
Checking for function "asprintf" : NO
Checking for function "daemon" : NO
Checking for function "fchmod" : NO
Checking for function "gettimeofday" : NO
Checking for function "mlockall" : NO
Checking for function "putenv" : NO
Checking for function "strsignal" : NO
Checking for function "unsetenv" : NO
Checking for function "fork" : NO
Checking for function "recvmmsg" : NO
Checking for function "res_init" : YES
Checking for type "struct arphdr" : NO
Checking for type "struct ether_arp" : NO
Checking for type "struct ether_header" : NO
Checking for type "struct icmp" : NO
Checking for type "struct icmp6_hdr" : NO
Checking for type "struct ip" : NO
Checking for type "struct ip6_hdr" : NO
Checking for type "struct nd_neighbor_solicit" : NO
Checking for type "struct nd_opt_hdr" : NO
Checking for function "getopt_long" : NO
Dependency readline skipped: feature readline disabled
Library readline skipped: feature readline disabled
Found pkg-config: /usr/bin/pkg-config (0.29)
Run-time dependency zlib found: YES 1.2.11
Run-time dependency lzo2 found: YES 2.10
Has header "lzo/lzo1x.h" with dependency lzo2: YES
Run-time dependency liblz4 found: YES 1.9.3
Dependency vdeplug skipped: feature vde disabled
Library dl skipped: feature vde disabled
Run-time dependency openssl found: YES 1.1.1m
Configuring config.h using configuration
Library rt found: YES
Program astyle found: NO
Build targets in project: 12

tinc 2df5ccc48bcfc8644af949b87c22dd943c0cd76a

  User defined options
    Cross files  : /home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/meson-cross/arm-cross.txt
    debug        : false
    localstatedir: /var
    optimization : 2
    prefix       : /usr
    sysconfdir   : /etc
    warning_level: 0
    c_args       : -DLINUX26 -DCONFIG_BCMWL5 -DCONFIG_BCMWL6 -DCONFIG_BCMWL6A -DPART_JFFS2_GAP=0UL -pipe -fno-strict-aliasing -DBCMWPA2 -DBCMARM -fno-delete-null-pointer-checks -marm  -DTCONFIG_NVRAM_64K -DLINUX_KERNEL_VERSION=132644 -ffunction-sections -fdata-sections -I/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/zlib/staged/usr/include -I/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/lzo/staged/usr/include -I/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/lz4/staged/usr/include -I/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/openssl-1.1/staged/usr/include
    c_link_args  : -ffunction-sections -fdata-sections -Wl,--gc-sections -L/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/zlib/staged/usr/lib -L/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/lzo/staged/usr/lib -L/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/lz4/staged/usr/lib -L/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/openssl-1.1/staged/usr/lib
    c_std        : gnu99
    crypto       : openssl
    curses       : disabled
    docs         : disabled
    hardening    : true
    lz4          : enabled
    lzo          : enabled
    miniupnpc    : disabled
    readline     : disabled
    systemd      : disabled
    tests        : disabled
    vde          : disabled
    zlib         : enabled

Found ninja-1.8.2 at /usr/bin/ninja

   tinc 98/146
ninja: Entering directory `tinc/build'
[1/84] Compiling C object src/ed25519/libed25519.a.p/ecdsa.c.o
FAILED: src/ed25519/libed25519.a.p/ecdsa.c.o
arm-brcm-linux-uclibcgnueabi-gcc -Isrc/ed25519/libed25519.a.p -Isrc/include -I../src/include -I/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/zlib/staged/usr/include -I/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/lzo/staged/usr/include -I/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/lz4/staged/usr/include -I/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/openssl-1.1/staged/usr/include -D_FILE_OFFSET_BITS=64 -std=gnu99 -O2 -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 -fwrapv -fno-strict-overflow -Wreturn-type -Wold-style-definition -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wbad-function-cast -Wwrite-strings -fdiagnostics-show-option -fstrict-aliasing -Wmissing-noreturn -DLINUX26 -DCONFIG_BCMWL5 -DCONFIG_BCMWL6 -DCONFIG_BCMWL6A -DPART_JFFS2_GAP=0UL -pipe -fno-strict-aliasing -DBCMWPA2 -DBCMARM -fno-delete-null-pointer-checks -marm -DTCONFIG_NVRAM_64K -DLINUX_KERNEL_VERSION=132644 -ffunction-sections -fdata-sections -fPIC -MD -MQ src/ed25519/libed25519.a.p/ecdsa.c.o -MF src/ed25519/libed25519.a.p/ecdsa.c.o.d -o src/ed25519/libed25519.a.p/ecdsa.c.o -c ../src/ed25519/ecdsa.c
In file included from ../src/ed25519/../system.h:24:0,
                 from ../src/ed25519/ecdsa.c:20:
src/include/config.h:146:17: warning: missing terminating " character
src/include/config.h:147:1: warning: missing terminating " character
src/include/config.h:147:1: error: missing terminating " character
In file included from ../src/ed25519/../system.h:40:0,
                 from ../src/ed25519/ecdsa.c:20:
../src/ed25519/../dropin.h:25:12: warning: redundant redeclaration of ‘daemon’ [-Wredundant-decls]
/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3/bin/../arm-brcm-linux-uclibcgnueabi/sysroot/usr/include/unistd.h:924:12: note: previous declaration of ‘daemon’ was here
../src/ed25519/../dropin.h:29:12: warning: redundant redeclaration of ‘asprintf’ [-Wredundant-decls]
/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3/bin/../arm-brcm-linux-uclibcgnueabi/sysroot/usr/include/stdio.h:379:12: note: previous declaration of ‘asprintf’ was here
../src/ed25519/../dropin.h:30:12: warning: redundant redeclaration of ‘vasprintf’ [-Wredundant-decls]
/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3/bin/../arm-brcm-linux-uclibcgnueabi/sysroot/usr/include/stdio.h:371:12: note: previous declaration of ‘vasprintf’ was here
../src/ed25519/../dropin.h:34:12: error: conflicting types for ‘gettimeofday’
/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3/bin/../arm-brcm-linux-uclibcgnueabi/sysroot/usr/include/sys/time.h:73:12: note: previous declaration of ‘gettimeofday’ was here
[3/84] Compiling C object src/ed25519/libed25519.a.p/ecdh.c.o
FAILED: src/ed25519/libed25519.a.p/ecdh.c.o
arm-brcm-linux-uclibcgnueabi-gcc -Isrc/ed25519/libed25519.a.p -Isrc/include -I../src/include -I/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/zlib/staged/usr/include -I/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/lzo/staged/usr/include -I/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/lz4/staged/usr/include -I/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/openssl-1.1/staged/usr/include -D_FILE_OFFSET_BITS=64 -std=gnu99 -O2 -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 -fwrapv -fno-strict-overflow -Wreturn-type -Wold-style-definition -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wbad-function-cast -Wwrite-strings -fdiagnostics-show-option -fstrict-aliasing -Wmissing-noreturn -DLINUX26 -DCONFIG_BCMWL5 -DCONFIG_BCMWL6 -DCONFIG_BCMWL6A -DPART_JFFS2_GAP=0UL -pipe -fno-strict-aliasing -DBCMWPA2 -DBCMARM -fno-delete-null-pointer-checks -marm -DTCONFIG_NVRAM_64K -DLINUX_KERNEL_VERSION=132644 -ffunction-sections -fdata-sections -fPIC -MD -MQ src/ed25519/libed25519.a.p/ecdh.c.o -MF src/ed25519/libed25519.a.p/ecdh.c.o.d -o src/ed25519/libed25519.a.p/ecdh.c.o -c ../src/ed25519/ecdh.c
In file included from ../src/ed25519/../system.h:24:0,
                 from ../src/ed25519/ecdh.c:20:
src/include/config.h:146:17: warning: missing terminating " character
src/include/config.h:147:1: warning: missing terminating " character
src/include/config.h:147:1: error: missing terminating " character
In file included from ../src/ed25519/../system.h:40:0,
                 from ../src/ed25519/ecdh.c:20:
../src/ed25519/../dropin.h:25:12: warning: redundant redeclaration of ‘daemon’ [-Wredundant-decls]
/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3/bin/../arm-brcm-linux-uclibcgnueabi/sysroot/usr/include/unistd.h:924:12: note: previous declaration of ‘daemon’ was here
../src/ed25519/../dropin.h:29:12: warning: redundant redeclaration of ‘asprintf’ [-Wredundant-decls]
/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3/bin/../arm-brcm-linux-uclibcgnueabi/sysroot/usr/include/stdio.h:379:12: note: previous declaration of ‘asprintf’ was here
../src/ed25519/../dropin.h:30:12: warning: redundant redeclaration of ‘vasprintf’ [-Wredundant-decls]
/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3/bin/../arm-brcm-linux-uclibcgnueabi/sysroot/usr/include/stdio.h:371:12: note: previous declaration of ‘vasprintf’ was here
../src/ed25519/../dropin.h:34:12: error: conflicting types for ‘gettimeofday’
/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3/bin/../arm-brcm-linux-uclibcgnueabi/sysroot/usr/include/sys/time.h:73:12: note: previous declaration of ‘gettimeofday’ was here
[4/84] Compiling C object src/ed25519/libed25519.a.p/ecdsagen.c.o
FAILED: src/ed25519/libed25519.a.p/ecdsagen.c.o
arm-brcm-linux-uclibcgnueabi-gcc -Isrc/ed25519/libed25519.a.p -Isrc/include -I../src/include -I/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/zlib/staged/usr/include -I/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/lzo/staged/usr/include -I/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/lz4/staged/usr/include -I/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router/openssl-1.1/staged/usr/include -D_FILE_OFFSET_BITS=64 -std=gnu99 -O2 -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 -fwrapv -fno-strict-overflow -Wreturn-type -Wold-style-definition -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wbad-function-cast -Wwrite-strings -fdiagnostics-show-option -fstrict-aliasing -Wmissing-noreturn -DLINUX26 -DCONFIG_BCMWL5 -DCONFIG_BCMWL6 -DCONFIG_BCMWL6A -DPART_JFFS2_GAP=0UL -pipe -fno-strict-aliasing -DBCMWPA2 -DBCMARM -fno-delete-null-pointer-checks -marm -DTCONFIG_NVRAM_64K -DLINUX_KERNEL_VERSION=132644 -ffunction-sections -fdata-sections -fPIC -MD -MQ src/ed25519/libed25519.a.p/ecdsagen.c.o -MF src/ed25519/libed25519.a.p/ecdsagen.c.o.d -o src/ed25519/libed25519.a.p/ecdsagen.c.o -c ../src/ed25519/ecdsagen.c
In file included from ../src/ed25519/../system.h:24:0,
                 from ../src/ed25519/ecdsagen.c:20:
src/include/config.h:146:17: warning: missing terminating " character
src/include/config.h:147:1: warning: missing terminating " character
src/include/config.h:147:1: error: missing terminating " character
In file included from ../src/ed25519/../system.h:40:0,
                 from ../src/ed25519/ecdsagen.c:20:
../src/ed25519/../dropin.h:25:12: warning: redundant redeclaration of ‘daemon’ [-Wredundant-decls]
/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3/bin/../arm-brcm-linux-uclibcgnueabi/sysroot/usr/include/unistd.h:924:12: note: previous declaration of ‘daemon’ was here
../src/ed25519/../dropin.h:29:12: warning: redundant redeclaration of ‘asprintf’ [-Wredundant-decls]
/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3/bin/../arm-brcm-linux-uclibcgnueabi/sysroot/usr/include/stdio.h:379:12: note: previous declaration of ‘asprintf’ was here
../src/ed25519/../dropin.h:30:12: warning: redundant redeclaration of ‘vasprintf’ [-Wredundant-decls]
/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3/bin/../arm-brcm-linux-uclibcgnueabi/sysroot/usr/include/stdio.h:371:12: note: previous declaration of ‘vasprintf’ was here
../src/ed25519/../dropin.h:34:12: error: conflicting types for ‘gettimeofday’
/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3/bin/../arm-brcm-linux-uclibcgnueabi/sysroot/usr/include/sys/time.h:73:12: note: previous declaration of ‘gettimeofday’ was here
[6/84] Compiling C object src/ed25519/libed25519.a.p/fe.c.o
ninja: build stopped: subcommand failed.
make[4]: *** [Makefile:3103: tinc] Error 1
make[4]: Leaving directory '/home/lance/freshtomato-tinc/release/src-rt-6.x.4708/router'
make[3]: *** [Makefile:151: all] Error 2
make[3]: Leaving directory '/home/lance/freshtomato-tinc/release/src-rt-6.x.4708'
make[2]: *** [Makefile:1229: bin] Error 2
make[2]: Leaving directory '/home/lance/freshtomato-tinc/release/src-rt-6.x.4708'
make[1]: *** [Makefile:1243: z] Error 2
make[1]: Leaving directory '/home/lance/freshtomato-tinc/release/src-rt-6.x.4708'
make: *** [Makefile:1278: r7000z] Error 2
lancethepants commented 2 years ago

Both src/meson_config.h and src/include/config.h the line #define VERSION the closing " is on the next line down.

lancethepants commented 2 years ago

I am cloning and then deleting .git directory, so not sure if that's causing the issue. VERSION does have a value, looks like a sha1, just the terminating " is on the following line.

lancethepants commented 2 years ago

Hmmm, not deleting .git it now doesn't result in the issue. Now show 1.1pre18 instead of sha1.

hg commented 2 years ago

GitHub is buggy again, so I'm posting this as a new comment.

Working without .git isn't really supported, there's no other way to detect what version you're building.

We could create a separate file in the source tree (VERSION?) and use it as a fallback, but then @gsliepen will have to remember to update it on each release.

I'm guessing you put tinc's source inside another git repository, and the script is using that repository as its own. Could you try this patch?

diff --git a/version.py b/version.py
index ff491bb5..d9a84d59 100755
--- a/version.py
+++ b/version.py
@@ -1,12 +1,15 @@
 #!/usr/bin/env python3

-from sys import argv, exit
+from os import environ, path
+from sys import argv
 import subprocess as subp

 prefix = "release-"

 cmd = [
     "git",
+    "--git-dir",
+    path.join(environ['MESON_SOURCE_ROOT'], '.git'),
     "describe",
     "--always",
     "--tags",
@@ -23,4 +26,3 @@ if not result.returncode and version and version.startswith(prefix):
     version = version[len(prefix):].strip()

 print(version if version else "unknown", end="")
-exit(not version)

It's not ideal (what if someone renames the .git directory or moves it somewhere?), but there are limits on what the project can support.

We could also maybe add the toolchain you're using into CI, so it's tested more frequently.

gsliepen commented 2 years ago

I think it's better to first os.chdir(environ['MESON_SOURCE_ROOT']), then call git describe --always --tags so git can do its own best to find the .git directory.

hg commented 2 years ago

Depends on whether you'd like to see tinc use commit hashes from the repository above it as its own version.

I guess it probably makes some sense if you're building firmware as a whole unit? What do other projects used do in that situation?

The patch above forces it to stay it its own directory (so if git directory is missing, you get unknown instead of 2df5ccc48bcfc8644af949b87c22dd943c0cd76a).

lancethepants commented 2 years ago

Yes, tinc gets put inside another source repo, kinda goofy they way it's done. That patch does allow it to compile and gives "unknown" as the version. In actuality we probably will only be doing actual tarball (pre)-releases. How will a tarball of an actual (pre)-release work, just the hardcoded version of that release?