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.81k stars 2.17k forks source link

Nix Derivation: libgc.a #16386

Closed tengkuizdihar closed 5 months ago

tengkuizdihar commented 2 years ago

V version:
OS: NixOS

What did you do? Mind you I'm not too familiar with the C buildsystem.

I'm trying to build vlang with a nix derivation but I'm having trouble with linking libgc.a. After some discussion, we decided to link libgc of our own instead of using what's provided locally via thirdparty/tcc. Is there a way to do that? This piece of code tells me that you can use gc.o instead. I think I need to disable tinyc (how?) in the buildsystem.

What did you expect to see? v is able to build build-tools, vdoc, vvet, etc.

What did you see instead?

@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/26d9lsj6vlg0gq43wsj4blxl3kx4qa2k-source
source root is source
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
no configure script, doing nothing
@nix { "action": "setPhase", "phase": "buildPhase" }
building
build flags: SHELL=/nix/store/9zm6br2ri10a0b71dll2wrim5bnhg6b6-bash-5.1-p16/bin/bash local=1 VC=/nix/store/1gvh3kcvg5lhzx47vgi8m40zpcyyr8yj-source
ldd: /bin/ls: $No such file or directory
Using local vc
Using local tcc
The executable './thirdparty/tcc/tcc.exe' does not work.
gcc  -std=gnu99 -w -o v1.exe /nix/store/1gvh3kcvg5lhzx47vgi8m40zpcyyr8yj-source/v.c -lm -lpthread
./v1.exe -no-parallel -o v2.exe  cmd/v
./v2.exe -o ./v  cmd/v
rm -rf v1.exe v2.exe
==================
/nix/store/0q9hm42fapihzj1d64nxqmbml7fpb2d6-binutils-2.38/bin/ld: cannot find /build/source/thirdparty/tcc/lib/libgc.a: No such file or directory
collect2: error: ld returned 1 exit status
...
==================
(Use `v -cg` to print the entire error message)

builder error:
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang

make: *** [GNUmakefile:112: all] Error 1
xiaojin20 commented 1 year ago

cp /data/data/com.termux/files/usr/var/lib/proot-distro/installed-rootfs/ubuntu/usr/lib/aarch64-linux-gnu/libgc.a ./

tengkuizdihar commented 1 year ago

can you elaborate?

On Mon, 6 Feb 2023, 11:34 xiaojin20, @.***> wrote:

cp /data/data/com.termux/files/usr/var/lib/proot-distro/installed-rootfs/ubuntu/usr/lib/aarch64-linux-gnu/libgc.a ./

— Reply to this email directly, view it on GitHub https://github.com/vlang/v/issues/16386#issuecomment-1418505070, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFIOKCS6RICJ5RLOMWMZGFLWWB5O7ANCNFSM6AAAAAAR5GHYPQ . You are receiving this because you authored the thread.Message ID: @.***>

xiaojin20 commented 1 year ago

安装aarch64-linux-gnu,重aarch64-linux-gnu安装路径复制,libgc.a

tengkuizdihar commented 1 year ago

ok, just did a translation for that, but you do realize I'm not on Ubuntu but on Nixos right? using the nix ecosystems?

xiaojin20 commented 1 year ago

用find命令 全系统, 搜索libgc.a 这文件在安装gcc时,是默认安装的。

happysalada commented 1 year ago

@tengkuizdihar hey, I ran into the same error, and found the libgc.a file I'm now going through another error, my efforts so far are at https://github.com/NixOS/nixpkgs/pull/231959 If you have any ideas, feel free to post anything.

tengkuizdihar commented 5 months ago

its on nixpkgs now.

ghost commented 4 months ago

If anyone still wanna build from source (works on termux android and all derivative):

  1. Run make (as usual)
  2. Examine the make output, as soon as it says cc -std=gnu99 -w -o v1.exe ./vc/v.c -lm -lpthread,
  3. Hit CTRL-Z
  4. cd v/thirdparty
  5. git clone https://github.com/vlang/tccbin --branch thirdparty-linux-aarch64 tcc. Customize this to your device. See here for available branches.
  6. fg
  7. Profit. This fixed no libgc.a error for me (You still need working cc installed tho)