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

Undefined symbol #690

Open
cpunion opened this issue Aug 9, 2024 · 0 comments
Open

Undefined symbol #690

cpunion opened this issue Aug 9, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@cpunion
Copy link
Contributor

cpunion commented Aug 9, 2024

foo.go:

package foo

type Promise[T any] struct {
}

func (p *Promise[T]) Done() bool {
	return false
}

type promise interface {
	Done() bool
}

func Run[T any](fn func() (co *Promise[T])) (t T) {
	run(fn())
	return
}

func run(p promise) {}

func (p *Promise[TOut]) Async(fn func(resolve func(TOut))) *Promise[TOut] {
	panic("should not executed")
}

main.go:

package main

import (
	"github.com/goplus/llgo/x/foo"
)

func Sleep() (co *foo.Promise[int]) {
	return co.Async(func(resolve func(int)) {
	})
}

func main() {
	foo.Run(func() (co *foo.Promise[int]) {
		return
	})
}

Build:

go run ../../cmd/llgo build -o bar .
# github.com/goplus/llgo/cmd/llgo
ld: warning: reexported library with install name '/opt/homebrew/opt/llvm/lib/libunwind.1.dylib' found at '/opt/homebrew/Cellar/llvm/18.1.8/lib/libunwind.1.0.dylib' couldn't be matched with any parent library and will be linked directly
# github.com/goplus/llgo/x/bar
ld64.lld: error: undefined symbol: github.com/goplus/llgo/x/foo.(*Promise).Done
>>> referenced by /var/folders/f2/88rgt2bx533_m89qy6pqqp8w0000gn/T/ed0bfaba5928eb7298f733aea88d79b885f5aa543956050eb77db72fc0d999c5-d-5fb490.o:(symbol main.init$after+0xf28)
>>> referenced by /var/folders/f2/88rgt2bx533_m89qy6pqqp8w0000gn/T/ed0bfaba5928eb7298f733aea88d79b885f5aa543956050eb77db72fc0d999c5-d-5fb490.o:(symbol main.init$after+0xf24)

ld64.lld: error: undefined symbol: github.com/goplus/llgo/x/foo.(*Promise).Async
>>> referenced by /var/folders/f2/88rgt2bx533_m89qy6pqqp8w0000gn/T/ed0bfaba5928eb7298f733aea88d79b885f5aa543956050eb77db72fc0d999c5-d-5fb490.o:(symbol main.init$after+0xcd8)
>>> referenced by /var/folders/f2/88rgt2bx533_m89qy6pqqp8w0000gn/T/ed0bfaba5928eb7298f733aea88d79b885f5aa543956050eb77db72fc0d999c5-d-5fb490.o:(symbol main.init$after+0xcd4)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
exit status 1
@xushiwei xushiwei added the bug Something isn't working label Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants