Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coroutines C error found. #23587

Open
kuchaguangjie opened this issue Jan 26, 2025 · 4 comments
Open

coroutines C error found. #23587

kuchaguangjie opened this issue Jan 26, 2025 · 4 comments
Labels
Bug This tag is applied to issues which reports bugs. Build V build error on any OS/CPU architecture. Coroutines Problems related to V's coroutine implementation

Comments

@kuchaguangjie
Copy link

kuchaguangjie commented Jan 26, 2025

Describe the bug

coroutine_learn.v:

fn echo() {
	println("echo")
	$if is_coroutine ? {
		println("coroutine")
	}
}

fn main() {
	go echo()
}

run:

v -use-coroutines run ./coroutine_learn.v

output:

coroutines .so not found, downloading...
done!
================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/coroutine_learn.01JJHGK3ZCB9N2GGW5VQ659HW9.tmp.c:5633: warning: implicit declaration of function 'delete_photon_work_pool'
cc: /mnt/star/program/vlang/v0.4.9/thirdparty/tcc/lib/libgc.a: error: 'GC_noop1_ptr' defined twice
cc: tcc: error: undefined symbol 'photon_thread_create_and_migrate_to_work_pool'
cc: tcc: error: undefined symbol 'delete_photon_work_pool'
... (the original output was 5 lines long, and was truncated to 4 lines)
=================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
builder error: 
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

Reproduction Steps

Run the code above on ubuntu 24.04

Expected Behavior

no error

Current Behavior

error

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.9 801600c

Environment details (OS name and version, etc.)

V full version V 0.4.9 d313355.801600c
OS linux, Linux Mint 22
Processor 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-4720HQ CPU @ 2.60GHz
Memory 2.29GB/15.54GB
V executable /mnt/star/program/vlang/v0.4.9/v
V last modified time 2025-01-26 14:38:08
V home dir OK, value: /mnt/star/program/vlang/v0.4.9
VMODULES OK, value: /home/eric/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /mnt/star/git_repos/vlearn/src/learn/coroutine
Git version git version 2.43.0
V git status weekly.2025.04-1-g801600c0
.git/config present true
cc version cc (Ubuntu 13.2.0-23ubuntu4) 13.2.0
gcc version gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0
clang version N/A
tcc version tcc version 0.9.28rc 2024-07-31 HEAD@1cee0908 (x86_64 Linux)
tcc git status N/A
emcc version N/A
glibc version ldd (Ubuntu GLIBC 2.39-0ubuntu8.3) 2.39

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@kuchaguangjie kuchaguangjie added the Bug This tag is applied to issues which reports bugs. label Jan 26, 2025
Copy link

Connected to Huly®: V_0.6-22013

@felipensp felipensp added Build V build error on any OS/CPU architecture. Coroutines Problems related to V's coroutine implementation labels Jan 26, 2025
@kbkpbot
Copy link
Contributor

kbkpbot commented Jan 27, 2025

This bug is because not #include "photonwrapper.h" . Workarounds for this bug :

  1. import coroutines
import coroutines

fn echo() {
        println("echo")
        $if is_coroutine ? {
                println("coroutine")
        }
}

fn main() {
        go echo()
}

or

  1. manually include the file:
#flag -I @VEXEROOT/thirdparty/photon
#flag @VEXEROOT/thirdparty/photon/photonwrapper.so
#include "photonwrapper.h"


fn echo() {
        println("echo")
        $if is_coroutine ? {
                println("coroutine")
        }
}

fn main() {
        go echo()
}

May require a patch for v, when detect used go keyword, include the "photonwrapper.h"

@kuchaguangjie
Copy link
Author

photon
#flag @VEXEROOT/thirdparty/photon/photonwrapper.so

How to install photon and photonwrapper.so properly, on Linux?
Where is @VEXEROOT ?

@jorgeluismireles
Copy link

Where is @VEXEROOT ?

Is the base of V installation. You can see what thing does or try to do --use-coroutines argument around this code:
https://github.com/vlang/v/blob/master/vlib/v/pref/pref.v#L971. For linux the compiler tries to download .h and .so files using wget or curl...

What I noticed is that tcc does not understand #flag @VEXEROOT/thirdparty/photon/photonwrapper.so but instead needs -shared like this:

#flag -shared @VEXEROOT/thirdparty/photon/photonwrapper.so

I think tcc expects common format lxxx.so and seems that https://github.com/vlang/v/blob/master/vlib/coroutines/coroutines.c.v does not do it for tcc.

With -shared for tcc undefined symbols dissapear though, but for me, your code and the examples in got a Terminated by signal 11 (SIGSEGV) result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Build V build error on any OS/CPU architecture. Coroutines Problems related to V's coroutine implementation
Projects
None yet
Development

No branches or pull requests

4 participants