Closed ultd closed 1 year ago
It works fine for me, the only difference is that I have a M1 not pro... Did you installed OpenSSL?
If no your case isn't detected by V that's weird. Try installing it using brew install openssl
.
If yes I don't know.
The C compiler found the openssl header, though they're from a really old release (1.0.2t, from the path). Maybe that's the only issue - need a newer version of openssl (and headers) to have that resolved.
I am also having trouble compiling/running any vweb examples on my M1 MacBookPro, though the symptom is different. V complains
builder error: Your V installation may be out-of-date. Try removing `thirdparty/tcc/` and running `make`
Even though I have a fresh clone & build from github. I can work around this by building v as x86_64 and setting VFLAGS="-d dynamic_boehm"
.
Side note: I have the latest brew install openssl
per the advice in the thread above.
Steps to repro, with "Note:" annotations for clarity
(base) ~/git ⭐ git clone https://github.com/vlang/v v-repro
Cloning into 'v-repro'...
remote: Enumerating objects: 124239, done.
remote: Counting objects: 100% (124239/124239), done.
remote: Compressing objects: 100% (32776/32776), done.
remote: Total 124239 (delta 88772), reused 124051 (delta 88675), pack-reused 0
Receiving objects: 100% (124239/124239), 56.03 MiB | 6.55 MiB/s, done.
Resolving deltas: 100% (88772/88772), done.
(base) ~/git ⭐ cd v-repro
(base) ~/git/v-repro ⭐ ls
CHANGELOG.md Dockerfile.alpine Makefile cmd/ thirdparty/
CODE_OF_CONDUCT.md Dockerfile.cross README.md doc/ tutorials/
CONTRIBUTING.md GNUmakefile ROADMAP.md examples/ v.mod
Dockerfile LICENSE TESTS.md make.bat vlib/
# Note: my computer is an M1 MacBookPro running macOS 12.4
(base) ~/git/v-repro ⭐ uname -a
Darwin gemini.attlocal.net 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64
# Note: Build v as arm64 by default
(base) ~/git/v-repro ⭐ make
/Applications/Xcode.app/Contents/Developer/usr/bin/make fresh_vc
rm -rf ./vc
git clone --depth 1 --quiet --single-branch https://github.com/vlang/vc ./vc
cd ./vc && git clean -xf && git pull --quiet
/Applications/Xcode.app/Contents/Developer/usr/bin/make fresh_tcc
rm -rf ./thirdparty/tcc
git clone --depth 1 --quiet --single-branch --branch thirdparty-macos-arm64 https://github.com/vlang/tccbin ./thirdparty/tcc
cd ./thirdparty/tcc && git clean -xf && git pull --quiet
cc -std=gnu99 -w -o v1.exe ./vc/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
V has been successfully built
V 0.3.0 706a922
(base) ~/git/v-repro ⭐ file v
v: Mach-O 64-bit executable arm64
(base) ~/git/v-repro ⭐ ./v symlink
(base) ~/git/v-repro ⭐ ll `which v`
lrwxr-xr-x 1 jminor admin 27B Jul 17 12:12 /usr/local/bin/v@ -> /Users/jminor/git/v-repro/v
# Note: Most examples work fine
(base) ~/git/v-repro ⭐ v run examples/cli.v
Usage: cli [flags] [commands]
An example of the cli library.
Flags:
-help Prints help information.
-version Prints version information.
-man Prints the auto-generated manpage.
Commands:
greet Prints greeting in different languages.
help Prints help information.
version Prints version information.
man Prints the auto-generated manpage.
# Note: vweb examples fail with builder error:
(base) ~/git/v-repro ⭐ v run examples/vweb/server_sent_events/server.v
builder error: Your V installation may be out-of-date. Try removing `thirdparty/tcc/` and running `make`
# Note: Try using different VFLAGS (per advice on Discord)
(base) ~/git/v-repro ⭐ export VFLAGS="-d dynamic_boehm"
(base) ~/git/v-repro ⭐ v run examples/vweb/server_sent_events/server.v
==================
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
...
==================
(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
(base) ~/git/v-repro ⭐ unset VFLAGS
# Note: Re-build v as x86_64
(base) ~/git/v-repro ⭐ make clean
rm -rf ./thirdparty/tcc
rm -rf ./vc
(base) ~/git/v-repro ⭐ arch -x86_64 make
/Applications/Xcode.app/Contents/Developer/usr/bin/make fresh_vc
rm -rf ./vc
git clone --depth 1 --quiet --single-branch https://github.com/vlang/vc ./vc
cd ./vc && git clean -xf && git pull --quiet
/Applications/Xcode.app/Contents/Developer/usr/bin/make fresh_tcc
rm -rf ./thirdparty/tcc
git clone --depth 1 --quiet --single-branch --branch thirdparty-macos-amd64 https://github.com/vlang/tccbin ./thirdparty/tcc
cd ./thirdparty/tcc && git clean -xf && git pull --quiet
cc -std=gnu99 -w -o v1.exe ./vc/v.c -lm -lpthread
./v1.exe -no-parallel -o v2.exe -d dynamic_boehm cmd/v
./v2.exe -o ./v -d dynamic_boehm cmd/v
rm -rf v1.exe v2.exe
V has been successfully built
V 0.3.0 706a922
(base) ~/git/v-repro ⭐ file v
v: Mach-O 64-bit executable x86_64
(base) ~/git/v-repro ⭐ v version
V 0.3.0 706a922
(base) ~/git/v-repro ⭐ ll `which v`
lrwxr-xr-x 1 jminor admin 27B Jul 17 12:12 /usr/local/bin/v@ -> /Users/jminor/git/v-repro/v
# Note: most examples work fine still
(base) ~/git/v-repro ⭐ v run examples/cli.v
Usage: cli [flags] [commands]
An example of the cli library.
Flags:
-help Prints help information.
-version Prints version information.
-man Prints the auto-generated manpage.
Commands:
greet Prints greeting in different languages.
help Prints help information.
version Prints version information.
man Prints the auto-generated manpage. (base) ~/git/v-repro ⭐ unset VFLAGS
# Note: vweb examples still fail
(base) ~/git/v-repro ⭐ v run examples/vweb/server_sent_events/server.v
builder error: Your V installation may be out-of-date. Try removing `thirdparty/tcc/` and running `make`
# Note: Set VFLAGS...
(base) ~/git/v-repro ⭐ export VFLAGS="-d dynamic_boehm"
# Note: Now it works! Yay!
(base) ~/git/v-repro ⭐ v run examples/vweb/server_sent_events/server.v
[Vweb] Running app on http://localhost:8081/
> sent event: {"time": "2022-07-17 12:14:32", "random_id": "01G86SAVB0NC7VGBW7FQ88FV4B"}
> sent event: {"time": "2022-07-17 12:14:32", "random_id": "01G86SAVB2K197PEDW78GY4GPS"}
> sent event: {"time": "2022-07-17 12:14:33", "random_id": "01G86SAWADJ0VYPEFBS7B4M7WH"}
> sent event: {"time": "2022-07-17 12:14:33", "random_id": "01G86SAWAEZJS21AW68BV8NMX5"}
^C% (base) ~/git/v-repro ⭐
Ah! I think I might have found my problem. V was getting confused since my system has two copies of openssl on it. One in Homebrew's arm64 area /opt/homebrew/opt/openssl
and one in Homebrew's x86_64 area /usr/local/opt/openssl'. When building, V was finding both, but preferring the wrong one. I was able to fix it by editing
vlib/net/openssl/c.v` and commenting out the undesirable location here:
// Brew
//#flag darwin -I/usr/local/opt/openssl/include
//#flag darwin -L/usr/local/opt/openssl/lib
// Brew arm64
#flag darwin -I /opt/homebrew/opt/openssl/include
#flag darwin -L /opt/homebrew/opt/openssl/lib
After rebuilding V (now native arm64) now vweb seems to work fine.
It seems that both the OP and my issue were related to finding the right openssl version & architecture.
openssl is going to be embedded soon in 0.4, so this will be fixed on its own
Glad to hear it :)
ssl is now embedded, should work fine
V doctor:
What did you do?
v -g -o vdbg cmd/v && vdbg v-example.v
What did you expect to see?
The app to run
What did you see instead?