swiftwasm / swiftwasm-package-sdk

This repository is no longer in use, please refer to the main repo https://github.com/swiftwasm/swift
8 stars 3 forks source link

swiftwasm script fails for more than one swift file #1

Open kverrier opened 5 years ago

kverrier commented 5 years ago

Super cool project @zhuowei !

Ran into a little snag trying it out. Looks like the swiftwasm script doesn't support passing in multiple swift files and I get an error about an invalid module name.

$ ./swiftwasm file1.swift file2.swift output.wasm
<unknown>:0: error: module name "swiftwasm-XXXXXXXX" is not a valid identifier; use -module-name flag to specify an alternate name

Haven't look much further into the issue yet. I'll keep tinkering but would love any insights.

zhuowei commented 5 years ago

@kverrier Thanks! Yeah, I haven't tested it with more than one file.

If you want to try, I think you can pass the module name override as the second-last parameter before the output.wasm parameter.

kverrier commented 5 years ago

Thanks for the quick response!

No luck with that flag 😢 ... Looks like swiftc doesn't like -o when generating multiple files. Makes sense since this is outputting multiple object files:

$ ./swiftwasm file1.swift file2.swift -module-name "test" output.wasm
<unknown>:0: error: cannot specify -o when generating multiple output files

I'll experiment with a more traditional Makefile in a small project and report my findings.

zhuowei commented 5 years ago

@kverrier The swiftwasm script's main job is to set up the linker arguments - if you have those you should be ok.

(It's needed because we haven't added the right linker flags to swiftc yet, so it won't call wasm-ld for us)