Zupt v2.1.1: fix cross-arch build issues, eliminate UB, improve Android/Termux support

- Removed all shipped .o files from tarball (fixes aarch64/Termux linker errors with x86_64 objects)
- Added arch-safety guard in Makefile to auto-detect and remove incompatible .o files
- Switched default compiler from gcc to cc (Termux uses clang)
- Skipped -lpthread on Android (bionic provides pthreads)
- Added Android detection via uname -o
- Fixed Keccak UB: ROL64(x,0) no longer expands to undefined x >> 64
- Achieved zero UBSan/ASAN issues across all PQ crypto paths
- Moved sys/syscall.h include to file scope with proper __linux__ guard

Release stats:
- 73 files, 159KB, zero .o artifacts
- 70/70 tests passing
- Fully clean under ASAN + UBSan

Note: full-disk encryption (--disk) deferred to v2.2.0 (requires raw device I/O, sparse detection, and privilege handling)
This commit is contained in:
Cristian Cezar Moisés 2026-04-06 19:17:37 -03:00
commit 754be4e84e
7 changed files with 66 additions and 10 deletions

View file

@ -1,6 +1,7 @@
# Zupt v2.0.0 — Makefile with VaptVupt codec + Jasmin integration
# Zupt v2.1.1 — Makefile with VaptVupt codec + Jasmin integration
#
# Multi-architecture: builds on x86_64, aarch64, armhf, ppc64le, s390x, riscv64.
# Tested on: Linux, macOS, Windows (MSYS2), Termux (Android aarch64).
# Jasmin CT crypto: x86_64 only (C fallback on all other architectures).
# AVX2 SIMD decode: x86_64 only (NEON on aarch64, scalar elsewhere).
#
@ -16,11 +17,19 @@
# - DESTDIR support for staged installs
# - Man page compressed and installed to $(MANDIR)/man1
CC ?= gcc
CC ?= cc
CFLAGS ?= -Wall -Wextra -O2 -std=c11
CFLAGS += -Iinclude -Isrc
LDFLAGS ?=
LDLIBS ?= -lm -lpthread
LDLIBS ?= -lm
# pthreads: link -lpthread on Linux/BSD, skip on Android/Termux (bionic built-in)
ifeq ($(shell uname -o 2>/dev/null),Android)
# Termux/Android: pthreads built into bionic libc
else
LDLIBS += -lpthread
endif
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/share/man
@ -103,6 +112,29 @@ VV_PLAIN_OBJS = src/vv_ans.o src/vv_huffman.o src/vaptvupt_api.o
ZUPT_OBJS = $(patsubst %.c,%.o,$(ZUPT_SOURCES))
ALL_OBJS = $(ZUPT_OBJS) $(VV_SIMD_OBJS) $(VV_PLAIN_OBJS)
# ═══════════════════════════════════════════════════════════════════
# ARCH-SAFETY GUARD
#
# If pre-compiled .o files from a different architecture are present
# (e.g. x86_64 .o files in an aarch64 build), the linker will fail
# with "incompatible with <arch>". Detect and remove stale objects.
# This happens when tarballs accidentally include build artifacts.
# ═══════════════════════════════════════════════════════════════════
STALE_OBJS := $(wildcard src/*.o jasmin/*.o)
ifneq ($(STALE_OBJS),)
# Check if any existing .o is for the wrong architecture
FIRST_OBJ := $(firstword $(STALE_OBJS))
OBJ_ARCH := $(shell file $(FIRST_OBJ) 2>/dev/null | grep -oE 'x86.64|aarch64|ARM|PowerPC|S/390|RISC-V' | head -1)
HOST_ARCH := $(shell file /bin/sh 2>/dev/null | grep -oE 'x86.64|aarch64|ARM|PowerPC|S/390|RISC-V' | head -1)
ifneq ($(OBJ_ARCH),$(HOST_ARCH))
ifneq ($(OBJ_ARCH),)
$(info [arch] Removing stale $(OBJ_ARCH) objects for $(HOST_ARCH) build)
$(shell rm -f src/*.o jasmin/*.o)
endif
endif
endif
# ═══════════════════════════════════════════════════════════════════
# BUILD RULES
# ═══════════════════════════════════════════════════════════════════