Skip to content

Errors building example: undefined symbols #95

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

Closed
ShonFrazier opened this issue Oct 7, 2020 · 8 comments · Fixed by #96
Closed

Errors building example: undefined symbols #95

ShonFrazier opened this issue Oct 7, 2020 · 8 comments · Fixed by #96
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@ShonFrazier
Copy link

When building according to instructions, I get errors like undefined symbol: _create_typed_array. Is this a JavaScriptKit issue, or my own issue? If it's mine, advice appreciated! :)

➤ swift --version
Swift version 5.3-dev (LLVM 0b0ebf2f41, Swift 5084c1851d)
Target: x86_64-apple-darwin19.6.0

➤ make build
cd JavaScriptKitExample && \
	    swift build --triple wasm32-unknown-wasi
[1/4] Compiling _CJavaScriptKit _CJavaScriptKit.c
[2/20] Compiling JavaScriptKit JSBridgedType.swift
[3/20] Compiling JavaScriptKit JSTimer.swift
[4/20] Compiling JavaScriptKit Deprecated.swift
[5/20] Compiling JavaScriptKit JSError.swift
[6/20] Compiling JavaScriptKit XcodeSupport.swift
[7/20] Compiling JavaScriptKit ConstructibleFromJSValue.swift
[8/20] Compiling JavaScriptKit JSObject.swift
[9/20] Compiling JavaScriptKit JSValue.swift
[10/20] Compiling JavaScriptKit JSArray.swift
[11/20] Compiling JavaScriptKit JSFunction.swift
[12/20] Compiling JavaScriptKit JSTypedArray.swift
[13/20] Compiling JavaScriptKit JSString.swift
[14/20] Compiling JavaScriptKit JSDate.swift
[15/20] Compiling JavaScriptKit JSPromise.swift
[16/20] Compiling JavaScriptKit ConvertibleToJSValue.swift
[17/20] Compiling JavaScriptKit JSValueDecoder.swift
[18/21] Merging module JavaScriptKit
[19/22] Wrapping AST for JavaScriptKit for debugging
[20/22] Compiling JavaScriptKitExample main.swift
[redacted]/JavaScriptKit/Example/JavaScriptKitExample/Sources/JavaScriptKitExample/main.swift:3:13: warning: 'JSObjectRef' is deprecated: renamed to 'JSObject'
let alert = JSObjectRef.global.alert.function!
            ^
[redacted]/JavaScriptKit/Example/JavaScriptKitExample/Sources/JavaScriptKitExample/main.swift:3:13: note: use 'JSObject' instead
let alert = JSObjectRef.global.alert.function!
            ^~~~~~~~~~~
            JSObject
[redacted]/JavaScriptKit/Example/JavaScriptKitExample/Sources/JavaScriptKitExample/main.swift:4:16: warning: 'JSObjectRef' is deprecated: renamed to 'JSObject'
let document = JSObjectRef.global.document.object!
               ^
[redacted]/JavaScriptKit/Example/JavaScriptKitExample/Sources/JavaScriptKitExample/main.swift:4:16: note: use 'JSObject' instead
let document = JSObjectRef.global.document.object!
               ^~~~~~~~~~~
               JSObject
[redacted]/JavaScriptKit/Example/JavaScriptKitExample/Sources/JavaScriptKitExample/main.swift:13:26: warning: 'function' is deprecated: Please create JSClosure directly and manage its lifetime manually.
buttonElement.onclick = .function { _ in
                         ^
[21/23] Merging module JavaScriptKitExample
[22/23] Wrapping AST for JavaScriptKitExample for debugging
wasm-ld: error: [redacted]/JavaScriptKit/Example/JavaScriptKitExample/.build/wasm32-unknown-wasi/debug/JavaScriptKit.build/BasicObjects/JSTypedArray.swift.o: undefined symbol: _create_typed_array
wasm-ld: error: [redacted]/JavaScriptKit/Example/JavaScriptKitExample/.build/wasm32-unknown-wasi/debug/JavaScriptKit.build/FundamentalObjects/JSFunction.swift.o: undefined symbol: _call_function
wasm-ld: error: [redacted]/JavaScriptKit/Example/JavaScriptKitExample/.build/wasm32-unknown-wasi/debug/JavaScriptKit.build/FundamentalObjects/JSFunction.swift.o: undefined symbol: _call_function_with_this
wasm-ld: error: [redacted]/JavaScriptKit/Example/JavaScriptKitExample/.build/wasm32-unknown-wasi/debug/JavaScriptKit.build/FundamentalObjects/JSFunction.swift.o: undefined symbol: _call_new
wasm-ld: error: [redacted]/JavaScriptKit/Example/JavaScriptKitExample/.build/wasm32-unknown-wasi/debug/JavaScriptKit.build/FundamentalObjects/JSFunction.swift.o: undefined symbol: _create_function
wasm-ld: error: [redacted]/JavaScriptKit/Example/JavaScriptKitExample/.build/wasm32-unknown-wasi/debug/JavaScriptKit.build/FundamentalObjects/JSObject.swift.o: undefined symbol: _instanceof
wasm-ld: error: [redacted]/JavaScriptKit/Example/JavaScriptKitExample/.build/wasm32-unknown-wasi/debug/JavaScriptKit.build/FundamentalObjects/JSObject.swift.o: undefined symbol: _release
wasm-ld: error: [redacted]/JavaScriptKit/Example/JavaScriptKitExample/.build/wasm32-unknown-wasi/debug/JavaScriptKit.build/FundamentalObjects/JSString.swift.o: undefined symbol: _decode_string
wasm-ld: error: [redacted]/JavaScriptKit/Example/JavaScriptKitExample/.build/wasm32-unknown-wasi/debug/JavaScriptKit.build/FundamentalObjects/JSString.swift.o: undefined symbol: _encode_string
wasm-ld: error: [redacted]/JavaScriptKit/Example/JavaScriptKitExample/.build/wasm32-unknown-wasi/debug/JavaScriptKit.build/FundamentalObjects/JSString.swift.o: undefined symbol: _load_string
wasm-ld: error: [redacted]/JavaScriptKit/Example/JavaScriptKitExample/.build/wasm32-unknown-wasi/debug/JavaScriptKit.build/FundamentalObjects/JSObject.swift.o: undefined symbol: _release
wasm-ld: error: [redacted]/JavaScriptKit/Example/JavaScriptKitExample/.build/wasm32-unknown-wasi/debug/JavaScriptKit.build/FundamentalObjects/JSObject.swift.o: undefined symbol: _release
wasm-ld: error: [redacted]/JavaScriptKit/Example/JavaScriptKitExample/.build/wasm32-unknown-wasi/debug/JavaScriptKit.build/JSValue.swift.o: undefined symbol: _get_prop
wasm-ld: error: [redacted]/JavaScriptKit/Example/JavaScriptKitExample/.build/wasm32-unknown-wasi/debug/JavaScriptKit.build/JSValue.swift.o: undefined symbol: _set_prop
wasm-ld: error: [redacted]/JavaScriptKit/Example/JavaScriptKitExample/.build/wasm32-unknown-wasi/debug/JavaScriptKit.build/JSValue.swift.o: undefined symbol: _get_subscript
wasm-ld: error: [redacted]/JavaScriptKit/Example/JavaScriptKitExample/.build/wasm32-unknown-wasi/debug/JavaScriptKit.build/JSValue.swift.o: undefined symbol: _set_subscript
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)
[22/23] Linking JavaScriptKitExample
make: *** [JavaScriptKitExample] Error 1
@MaxDesiatov
Copy link
Contributor

Apologies for the confusion, it seems like documentation is outdated, it points to an old toolchain that doesn't support the latest code in the main branch. I've created a PR to resolve that.

If you'd like to use something stable, I recommend installing the carton build tool, which installs the toolchain for you automatically. You can then create an empty project with carton init --template basic in a directory of your choosing and run carton dev to launch a development HTTP server. You can then see how JavaScriptKit can be used in the browser by pointing it to http://127.0.0.1:8080/. More details available in README.md of the carton repository.

Does that resolve your issue?

@MaxDesiatov MaxDesiatov added documentation Improvements or additions to documentation question Further information is requested labels Oct 7, 2020
@ShonFrazier
Copy link
Author

I'm already using swiftenv and, AFAICT, I'm using swift-wasm-5.3-SNAPSHOT-2020-10-02-a to build with.

@ShonFrazier
Copy link
Author

It seems that the solution is to step into Example/JavaScriptKitExample and do a swiftenv local ... with the version you want, then change back to Example/ to run the build.

@carson-katri
Copy link
Member

We should maybe include the swiftenv file in that folder then.

@ShonFrazier
Copy link
Author

I'm giving carton a go. I am surprised, however, that it's installing swift-wasm-5.3-SNAPSHOT-2020-09-25-a-osx rather than something newer.

@MaxDesiatov
Copy link
Contributor

carton installs the latest stable toolchain that was available at the corresponding release of carton (that is a few weeks ago). swift-wasm-5.3-SNAPSHOT-2020-09-25-a-osx should be fine if you use the latest stable version of JavaScriptKit instead of its main branch.

@ShonFrazier
Copy link
Author

carton is indeed working for me. thanks for the pointer!

@MaxDesiatov
Copy link
Contributor

Closing as resolved then. Feel free to reopen or to create new issues if needed 🙂

MaxDesiatov added a commit that referenced this issue Oct 21, 2020
The toolchain snapshot suggested in `README.md` is outdated. I think we should recommend using the script to install it automatically.

Resolves #95.

* Mention the `install-toolchain.sh` script in `README.md`

* Update toolchain version, script, and `README.md`

* Update example code in `README.md`

* Update .swift-version

* Update Swift version in README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants