vlang / v

Simple, fast, safe, compiled language for developing maintainable software. Compiles itself in <1s with zero library dependencies. Supports automatic C => V translation. https://vlang.io
MIT License
35.68k stars 2.15k forks source link

`v doctor` Causes a Panic Error #13050

Open ThisNekoGuy opened 2 years ago

ThisNekoGuy commented 2 years ago

V version: 0.2.4 0e1cfd4 (weekly.2021.52.1) OS: Arch Linux

What did you do? Run v doctor after installing V with my own PKGBUILD that should have been fine; it compiles V from the latest release (namely "weekly.2021.52.1" in this occurrence) and avoids compiling with TCC entirely.

vlang-latest.zip

(The "update.sh" is just an automated script I put together to easily detect latest releases and update the PKGBUILD and .SRCINFO for them and it also includes checksum validation.)

V was compiled with my global /etc/makepkg.conf configuration (I compiled with Clang, -O3, and LTO enabled):

#!/hint/bash
#
# /etc/makepkg.conf
#

#########################################################################
# SOURCE ACQUISITION
#########################################################################
#
#-- The download utilities that makepkg should use to acquire sources
#  Format: 'protocol::agent'
DLAGENTS=('file::/usr/bin/curl -gqC - -o %o %u'
          'ftp::/usr/bin/curl -gqfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
          'http::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
          'https::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
          'rsync::/usr/bin/rsync --no-motd -z %u %o'
          'scp::/usr/bin/scp -C %u %o')

# Other common tools:
# /usr/bin/snarf
# /usr/bin/lftpget -c
# /usr/bin/wget
# /usr/bin/axel
# /usr/bin/ruget

#-- The package required by makepkg to download VCS sources
#  Format: 'protocol::package'
VCSCLIENTS=('bzr::bzr'
            'fossil::fossil'
            'git::git'
            'hg::mercurial'
            'svn::subversion')

#########################################################################
# ARCHITECTURE, COMPILE FLAGS
#########################################################################
#
CARCH="x86_64"
CHOST="x86_64-pc-linux-gnu"

#-- Compiler and Linker Flags
export CC=clang
export CXX=clang++
export LD=lld
export CC_LD=lld
export CXX_LD=lld
export AR=llvm-ar
export NM=llvm-nm
export RANLIB=llvm-ranlib
export STRIP=llvm-strip
export OBJCOPY='/usr/bin/llvm-objcopy'

#CPPFLAGS=""
CFLAGS="-march=znver2 -mtune=native -O3 -pipe -fno-plt -minline-all-stringops -fexceptions -Wall \
        -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \
        -fstack-clash-protection -fcf-protection"
CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
LDFLAGS="-Wl,-O3,--sort-common,--as-needed,-z,relro,-z,now"
RUSTFLAGS="-C opt-level=3 -C target-cpu=native"
#-- Make Flags: change this for DistCC/SMP systems
MAKEFLAGS="-j$(nproc)"
#-- Debugging flags
DEBUG_CFLAGS="-g"
DEBUG_CXXFLAGS="-g"

## The "-fvar-tracking-assignments" flag is for GCC
#DEBUG_CFLAGS="-g -fvar-tracking-assignments"
#DEBUG_CXXFLAGS="-g -fvar-tracking-assignments"

#DEBUG_RUSTFLAGS="-C debuginfo=2"

#########################################################################
# BUILD ENVIRONMENT
#########################################################################
#
# Makepkg defaults: BUILDENV=(!distcc !color !ccache check !sign)
#  A negated environment option will do the opposite of the comments below.
#
#-- distcc:   Use the Distributed C/C++/ObjC compiler
#-- color:    Colorize output messages
#-- ccache:   Use ccache to cache compilation
#-- check:    Run the check() function if present in the PKGBUILD
#-- sign:     Generate PGP signature file
#
BUILDENV=(!distcc color !ccache check !sign)
#
#-- If using DistCC, your MAKEFLAGS will also need modification. In addition,
#-- specify a space-delimited list of hosts running in the DistCC cluster.
#DISTCC_HOSTS=""
#
#-- Specify a directory for package building.
#BUILDDIR=/tmp/makepkg

#########################################################################
# GLOBAL PACKAGE OPTIONS
#   These are default values for the options=() settings
#########################################################################
#
# Makepkg defaults: OPTIONS=(!strip docs libtool staticlibs emptydirs !zipman !purge !debug !lto)
#  A negated option will do the opposite of the comments below.
#
#-- strip:      Strip symbols from binaries/libraries
#-- docs:       Save doc directories specified by DOC_DIRS
#-- libtool:    Leave libtool (.la) files in packages
#-- staticlibs: Leave static library (.a) files in packages
#-- emptydirs:  Leave empty directories in packages
#-- zipman:     Compress manual (man and info) pages in MAN_DIRS with gzip
#-- purge:      Remove files specified by PURGE_TARGETS
#-- debug:      Add debugging flags as specified in DEBUG_* variables
#-- lto:        Add compile flags for building with link time optimization
#
OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug lto)

#-- File integrity checks to use. Valid: md5, sha1, sha224, sha256, sha384, sha512, b2
INTEGRITY_CHECK=(sha256)
#-- Options to be used when stripping binaries. See `man strip' for details.
STRIP_BINARIES="--strip-all"
#-- Options to be used when stripping shared libraries. See `man strip' for details.
STRIP_SHARED="--strip-unneeded"
#-- Options to be used when stripping static libraries. See `man strip' for details.
STRIP_STATIC="--strip-debug"
#-- Manual (man and info) directories to compress (if zipman is specified)
MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})
#-- Doc directories to remove (if !docs is specified)
DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
#-- Files to be removed from all packages (if purge is specified)
PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
#-- Directory to store source code in for debug packages
DBGSRCDIR="/usr/src/debug"

#########################################################################
# PACKAGE OUTPUT
#########################################################################
#
# Default: put built package and cached source in build directory
#
#-- Destination: specify a fixed directory where all packages will be placed
#PKGDEST=/home/packages
#-- Source cache: specify a fixed directory where source files will be cached
#SRCDEST=/home/sources
#-- Source packages: specify a fixed directory where all src packages will be placed
#SRCPKGDEST=/home/srcpackages
#-- Log files: specify a fixed directory where all log files will be placed
#LOGDEST=/home/makepkglogs
#-- Packager: name/email of the person or organization building packages
#PACKAGER="John Doe <john@doe.com>"
#-- Specify a key to use for package signing
#GPGKEY=""

#########################################################################
# COMPRESSION DEFAULTS
#########################################################################
#
COMPRESSGZ=(gzip -c -f -n)
COMPRESSBZ2=(bzip2 -c -f)
COMPRESSXZ=(xz -c -z --threads=0 -)
COMPRESSZST=(zstd -c -z -q --threads=0 -)
COMPRESSLRZ=(lrzip -q)
COMPRESSLZO=(lzop -q)
COMPRESSZ=(compress -c -f)
COMPRESSLZ4=(lz4 -q)
COMPRESSLZ=(lzip -c -f)

#########################################################################
# EXTENSION DEFAULTS
#########################################################################
#
PKGEXT='.pkg.tar.zst'
SRCEXT='.src.tar.gz'

#########################################################################
# OTHER
#########################################################################
#
#-- Command used to run pacman as root, instead of trying sudo and su
#PACMAN_AUTH=(doas)

What did you expect to see? This information:

neko-san@ARCH /m/e/test> v --help | grep doctor
   doctor            Display some useful info about your system to help reporting bugs.

What did you see instead?

neko-san@ARCH /m/e/test> v doctor
V panic: No such file or directory
v hash: 0e1cfd4
addr2line: 'v': No such file
v(+0x1642ba) [0x55af814c52ba]
addr2line: 'v': No such file
v(+0x2072) [0x55af81363072]
                                                        | 0x7f0593d7ab25 | /usr/lib/libc.so.6(__libc_start_main+0xd5) 
addr2line: 'v': No such file
v(+0x20ae) [0x55af813630ae]
ThisNekoGuy commented 2 years ago

Doesn't that just add it to /usr/bin/?

JalonSolov commented 2 years ago

The fact that v help (you don't need the -- in front of help) works says V is being found. The problem is that it isn't telling you what wasn't found when you try to run v doctor.

ThisNekoGuy commented 2 years ago

Also, running sudo/doas v symlink didn't solve it:

neko-san@ARCH /m/e/test> doas v symlink
doas (neko-san@ARCH) password: 
neko-san@ARCH /m/e/test> v doctor
V panic: No such file or directory
v hash: 0e1cfd4
addr2line: 'v': No such file
v(+0x1642ba) [0x55f864fcb2ba]
addr2line: 'v': No such file
v(+0x2072) [0x55f864e69072]
                                                        | 0x7f2ac907bb25 | /usr/lib/libc.so.6(__libc_start_main+0xd5) 
addr2line: 'v': No such file
v(+0x20ae) [0x55f864e690ae]
neko-san@ARCH /m/e/test [1]> 
medvednikov commented 2 years ago

Should be fine now. Please try again @ThisNekoGuy

ThisNekoGuy commented 2 years ago

@medvednikov It works; I made an Arch Linux repository that installs V releases as a alpm package: https://gitlab.com/N3k0-san/vlang-latest.sh (I'm new to git though)

the result of v doctor is now this:

neko-san@ARCH ~> v doctor
OS: linux, "Arch Linux"
Processor: 16 cpus, 64bit, little endian, AMD Ryzen 7 3700X 8-Core Processor
CC version: cc (GCC) 12.1.0

getwd: /home/neko-san
vmodules: /home/neko-san/.vmodules
vroot: /usr/lib/vlang
vexe: /usr/lib/vlang/v
vexe mtime: 2022-07-11 23:32:58
is vroot writable: false
is vmodules writable: true
V full version: V 0.3.0 dc68469

Git version: git version 2.37.0
Git vroot status: Error: fatal: not a git repository (or any of the parent directories): .git
.git/config present: false
thirdparty/tcc status: Error: fatal: unsafe repository ('/usr/lib/vlang/thirdparty/tcc' is owned by someone else)
To add an exception for this directory, call:

        git config --global --add safe.directory /usr/lib/vlang/thirdparty/tcc
 Error: fatal: unsafe repository ('/usr/lib/vlang/thirdparty/tcc' is owned by someone else)
To add an exception for this directory, call:

        git config --global --add safe.directory /usr/lib/vlang/thirdparty/tcc

neko-san@ARCH ~> 
JalonSolov commented 2 years ago

How are you installing V? From a .zip file?

The preferred method is to git clone the source, then run make. Otherwise, you'll see the git failures.

Also, the V install dir should also be writeable by you. Installing it as root or other privileged user will cause the tcc error you saw.

ThisNekoGuy commented 2 years ago

Simply put, what it does is run a sub-script that updates an Arch Linux PKGBUILD file that pulls the latest release source from the releases page here, compiles it with make, then installs it globally for every user on the system. It's essentially like installing something from the AUR; the only difference here is that the associated files involved aren't officially on the AUR, but from my gitlab repo.

I'm aware of the issue about the user permissions but the AUR "method" of installation doesn't really have a solution for that. You can sort of look at this like a "dry run" of what it would look like if it were an AUR package.

JalonSolov commented 2 years ago

... and that's one of the reasons there are no official packages, yet. Until issues like that are dealt with, there are too many problems if you don't git clone the source yourself to a directory where you have write permissions.

ThisNekoGuy commented 2 years ago

I didn't say anything about personally having a problem about it; I was only clarifying what I did because you asked

medvednikov commented 2 years ago

This is a 7 month old version of V. Try with the latest one.

ThisNekoGuy commented 2 years ago

This is a 7 month old version of V. Try with the latest one.

0.3 is from 13 days ago; what are you talking about?

medvednikov commented 2 years ago

Sorry, I was looking at the first post.

Dialga commented 1 year ago

Are you still having this issue?