打造一個「你好,世界」風格的程序,看看我是否可以在網絡上使用Swift,通過運行它emscripten獲得asm.js輸出。如何在沒有任何動態庫的情況下編譯swift?
問題是,當我編譯它時,它的位碼試圖鏈接動態庫。似乎它不應該需要這樣做,或者它似乎理解所有這些片段如何組合在一起可以告訴我如何提供它所需的文件(我願意實現它所依賴的某些功能在JavaScript中,如有必要)。
我有環境here更全面的解釋,但是這是最基礎的:
文件:
$ cat f.swift
var message = 1
編譯它位碼:
$ xcrun swiftc -emit-bc f.swift -o f.bc
無法將位碼編譯爲asm.js:
$ emcc f.bc
WARNING: Linking two modules of different data layouts: '/Users/josh/.emscripten_cache/libc.bc' is 'e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-p:32:32:32-v128:32:128-n32-S128' whereas '/Users/josh/deleteme/swift-play/f.bc' is 'e-m:o-i64:64-f80:128-n8:16:32:64-S128'
WARNING: Linking two modules of different target triples: /Users/josh/.emscripten_cache/libc.bc' is 'asmjs-unknown-emscripten' whereas '/Users/josh/deleteme/swift-play/f.bc' is 'x86_64-apple-darwin13.2.0'
Unknown specifier in datalayout string
UNREACHABLE executed at /Users/clb/emscripten-fastcomp/lib/IR/DataLayout.cpp:300!
0 opt 0x00000001086d04ae llvm::sys::PrintStackTrace(__sFILE*) + 46
1 opt 0x00000001086d07bb PrintStackTraceSignalHandler(void*) + 27
2 opt 0x00000001086d0b4c SignalHandler(int) + 412
3 libsystem_platform.dylib 0x00007fff8b0e35aa _sigtramp + 26
4 libsystem_platform.dylib 0x00007fff6492d380 _sigtramp + 3649347056
5 opt 0x00000001086d07eb raise + 27
6 opt 0x00000001086d08a2 abort + 18
7 opt 0x000000010865a7a6 llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 198
8 opt 0x0000000108416b74 llvm::DataLayout::parseSpecifier(llvm::StringRef) + 2804
9 opt 0x0000000108415c57 llvm::DataLayout::init(llvm::StringRef) + 471
10 opt 0x000000010749b47e llvm::DataLayout::DataLayout(llvm::StringRef) + 158
11 opt 0x0000000107482ba5 llvm::DataLayout::DataLayout(llvm::StringRef) + 37
12 opt 0x000000010747943c main + 3756
13 libdyld.dylib 0x00007fff8a2865fd start + 1
Stack dump:
0. Program arguments: /Users/josh/code/emsdk_portable/clang/e1.25.0_64bit/opt /var/folders/7g/mbft22555w3_2nqs_h1kbglw0000gn/T/tmp93OFuV/a.out.bc -strip-debug -internalize -internalize-public-api-list=main,malloc,free -globaldce -pnacl-abi-simplify-preopt -pnacl-abi-simplify-postopt -enable-emscripten-cxx-exceptions -o /var/folders/7g/mbft22555w3_2nqs_h1kbglw0000gn/T/tmp93OFuV/a.out.bc.opt.bc
Traceback (most recent call last):
File "/Users/josh/code/emsdk_portable/emscripten/1.25.0/emcc", line 1224, in <module>
shared.Building.llvm_opt(final, link_opts)
File "/Users/josh/code/emsdk_portable/emscripten/1.25.0/tools/shared.py", line 1357, in llvm_opt
assert os.path.exists(target), 'Failed to run llvm optimizations: ' + output
AssertionError: Failed to run llvm optimizations:
這裏有什麼新進展? – 2016-05-11 01:21:06