2013-02-22 61 views
4
編譯

我和Emscripten的最新版本,試圖在這裏說明:https://github.com/kripken/gmp.js/blob/master/README.markdown無法獲得GMP LIB與Emscripten

的某文件似乎是正確創建。然後我嘗試編譯針對庫(在調試模式),並且似乎工作:

emcc invocation: /home/marcosscriven/sources/emscripten/emcc -O0 --closure 0 test.c .libs/libgmp.a -o complete.js 
(Emscripten: Running sanity checks) 
emcc: compiling to bitcode 
emcc: compiling source file: test.c 
emcc running: /usr/local/bin/clang -m32 -U__i386__ -U__x86_64__ -U__i386 -U__x86_64 -Ui386 -Ux86_64 -U__SSE__ -U__SSE2__ -U__MMX__ -UX87_DOUBLE_ROUNDING -UHAVE_GCC_ASM_FOR_X87 -DEMSCRIPTEN -U__STRICT_ANSI__ -U__CYGWIN__ -D__STDC__ -Xclang -triple=i386-pc-linux-gnu -D__IEEE_LITTLE_ENDIAN -fno-math-errno -fno-ms-compatibility -nostdinc -Xclang -nobuiltininc -Xclang -nostdsysteminc -Xclang -isystem/home/marcosscriven/sources/emscripten/system/local/include -Xclang -isystem/home/marcosscriven/sources/emscripten/system/include -Xclang -isystem/home/marcosscriven/sources/emscripten/system/include/emscripten -Xclang -isystem/home/marcosscriven/sources/emscripten/system/include/bsd -Xclang -isystem/home/marcosscriven/sources/emscripten/system/include/libc -Xclang -isystem/home/marcosscriven/sources/emscripten/system/include/libcxx -Xclang -isystem/home/marcosscriven/sources/emscripten/system/lib/libcxxabi/include -Xclang -isystem/home/marcosscriven/sources/emscripten/system/include/gfx -Xclang -isystem/home/marcosscriven/sources/emscripten/system/include/net -Xclang -isystem/home/marcosscriven/sources/emscripten/system/include/SDL -U__APPLE__ -U__linux__ -D_LIBCPP_HAS_NO_DELETED_FUNCTIONS -emit-llvm -c test.c -o /tmp/tmp_pOV54/test_0.o 
emcc: copying library file: .libs/libgmp.a 
emcc: will generate JavaScript 
emcc: considering including libcxx: we need set([]) and have set([]) 
emcc: considering including libcxxabi: we need set([]) and have set([]) 
emcc: considering including libc: we need set(['realloc', 'malloc', 'memcpy', 'free']) and have set([]) 
emcc: including libc 
emcc: linking: ['/tmp/tmp_pOV54/test_0.o', '/tmp/tmp_pOV54/libgmp_1.a', '/home/marcosscriven/.emscripten_cache/libc.bc'] 
emcc: llvm-linking: ['/tmp/tmp_pOV54/test_0.o', '/home/marcosscriven/.emscripten_cache/libc.bc'] 
emcc: saving intermediate processing steps to /tmp/emscripten_temp 
emcc: LLVM opts: ['-internalize', '-internalize-public-api-list=main', '-globaldce'] 
emcc: step took 0.01 seconds 
emcc: step took 0.00 seconds 
emcc: LLVM => JS 
emscript: ll=>js 
    emscript: scan took 0.000277042388916 seconds 
    emscript: split took 0.000169038772583 seconds 
    emscript: phase 1 took 0.173984050751 seconds 
    emscript: phase 2 working on 1 chunks (intended chunk size: 1.00 MB, meta: 0.00 MB, forwarded: 0.01 MB, total: 0.01 MB) 
    emscript: phase 2 took 0.206316947937 seconds 
    emscript: phase 2b took 0.000115871429443 seconds 
    emscript: phase 2c took 0.00135588645935 seconds 
    emscript: phase 3 took 0.170216083527 seconds 
emcc: step took 0.60 seconds 
emcc: total time: 1.62 seconds 

然而,當我嘗試運行生成的JavaScript,我得到這個錯誤:

[email protected]:~/sources/gmp-5.0.2$ node complete.js 

/home/marcosscriven/sources/gmp-5.0.2/complete.js:2452 
     ___gmpz_init(((5242892)|0)); 
    ^
TypeError: undefined is not a function 
    at _pidigits (/home/marcosscriven/sources/gmp-5.0.2/complete.js:2452:7) 
    at Object._main (/home/marcosscriven/sources/gmp-5.0.2/complete.js:2429:7) 
    at Object.callMain (/home/marcosscriven/sources/gmp-5.0.2/complete.js:2644:24) 
    at doRun (/home/marcosscriven/sources/gmp-5.0.2/complete.js:2679:20) 
    at run (/home/marcosscriven/sources/gmp-5.0.2/complete.js:2703:12) 
    at Object.<anonymous> (/home/marcosscriven/sources/gmp-5.0.2/complete.js:2725:13) 
    at Module._compile (module.js:449:26) 
    at Object.Module._extensions..js (module.js:467:10) 
    at Module.load (module.js:356:32) 
    at Function.Module._load (module.js:312:12) 

阿龍(Emscripten的創造者),比上Emscripten谷歌集團說,這意味着該功能是不存在的,並與LLVM-VM,它確實出現了檢查:

[email protected]:~/sources/gmp-5.0.2$ !llvm-nm 
llvm-nm .libs/libgmp.a | grep gmpz_init 
00000000 T __gmpz_init 
00000000 T __gmpz_init2 
     U __gmpz_init 
00000000 T __gmpz_inits 
00000000 T __gmpz_init_set 
00000000 T __gmpz_init_set_d 
00000000 T __gmpz_init_set_si 
00000000 T __gmpz_init_set_str 
00000000 T __gmpz_init_set_ui 
     U __gmpz_init 
     U __gmpz_init_set_ui 
     U __gmpz_init2 
     U __gmpz_init_set_ui 
     U __gmpz_init 
     U __gmpz_init_set_str 
     U __gmpz_init 
     U __gmpz_init2 
     U __gmpz_init_set 
     U __gmpz_init 
     U __gmpz_init_set 

所以我完全不知所措!

可能值得注意的是,在使用常規編譯器編譯時,編譯對庫的測試工作正常。

編輯:進一步與此。在這個lib的5.1.1版本中,他們引入了一個新的配置選項'--dissable-assembly',它進行了一個通用的C編譯。

現在的問題是,測試運行時,它永遠不會停止。

有人建議我「禁用」在gmp.h可能,不太可能選擇:

https://github.com/kripken/gmp.js/blob/master/gmp-h.in

,但我看不出如何「禁用」它們的方式。通常有0或1個選項,但我在這裏沒有看到。我甚至不明白這個特定的選擇。

感謝

馬科斯

+0

前導'_'的數量是否匹配? – 2013-02-23 08:29:51

+0

根據Alon(製作Emscripten的人),預計會出現額外的下劃線。 – 2013-02-23 12:49:34

回答

4

我到底該工作。 (事實上​​也適用於MPFR)。

最大的問題是確保使用32位選項和標題。