做者 Abel Avram ,譯者 臧秀濤 發佈於 五月 20, 2013
css
經過支持運行LLVM位碼(bitcode),Google加強了對Chrome中原生應用的支持。html
在Google I/O 2013大會上,Google宣佈了預期加入的PNaCl(Portable NaCl,讀做「pinnacle」),繼續推動對Chrome中原生應用的支持。PNaCl修改了原來的工具鏈,與以前爲每種目標平臺編譯C/C++應用不一樣,如今開發者只需生成一份LLVM位碼,以後位碼能夠由任一Chrome客戶端加載,在本地轉換爲原生代碼、驗證和執行。web
目前,x86-3二、x86-64和ARM架構上的Chrome 29已支持PNaCl。在PNaCl完整發布以後,Chrome客戶端可以在任意頁面上運行原生模塊,而無需將其打包爲面向Chrome Web Store的應用。此外,PNaCl模塊無需從新編譯便可在將來的架構上運行。更爲有趣的是,儘管目前只支持C/C++,理論上PNaCl模塊能夠以任何可以編譯爲LLVM位碼的語言編寫,包括ActionScript、Ada、D、Fortran、Haskell、Java字節碼、Objective-C、Python、Ruby、Rust、Scala和C#等,拓寬了能夠在Chrome中運行的遺留的和較新的原生應用的使用範圍,這些應用只須要很小的調整,甚至無需調整。chrome
2010年,4位Google工程師組成的一個團隊在內部提出了PnaCl(PDF),幾位做者想象的是這樣一種解決方案:安全
PNaCl仍然使用原來的NaCl沙盒機制,以保證運行翻譯位碼時的安全性。具體邏輯以下圖所示,客戶端從服務器請求位碼,而後針對本身的架構將其轉換爲原生的可執行代碼。翻譯可能在本地進行(在另外一個NaCI沙盒內),也可能經過另外一個實體遠程執行。服務器
PnaCl開發工具鏈支持Windows、Mac和Linux,SDK能夠從項目網站下載。架構
查看英文原文:PNaCl: Google Adds More Native Support to Chrome via LLVMapp
May 15, 2013ide
Portable Native Client (PNaCl, pronounced "pinnacle"), is an architecture-independent version of Native Client. Traditional C and C++ development uses a "compile → link" workflow that produces a platform- and architecture-dependent executable. In contrast, PNaCl development uses an LLVM compiler infrastructure with a "compile → link → translate" workflow. This workflow produces a "linked" binary that is provided as intermediate representation (IR) bitcode; the bitcode is then translated locally for a specific end-user system architecture. In conjunction with Native Client's POSIX-like environment and the Pepper API for media interfaces, PNaCl provides complete platform independence. With PNaCl, developers can create a single executable for all users. Because translation happens at the client, developers get the benefit of translations for new architectures, as well as new translation optimizations, for free, as such features become available and without the need to rebuild their applications. Once PNaCl is fully released, users will be able to run PNaCl modules on any web page – applications will not need to be deployed through the Chrome Web Store in order to run PNaCl modules.svn
For background information about PNacl, see PNaCl: Portable Native Client Executables (PDF). For current release information, see the release notes.