langcraft Compiler from LLVM IR to Minecraft datap开源项目

我要开发同款
匿名用户2021年11月09日
46阅读
开发技术C/C++
所属分类开发工具、编译器
授权协议View license

作品详情

LangcraftTheLLVMtargetforMinecraftyou'veneverwanted

LangcraftisacodegeneratortargetingMinecraftDataPacks.Itcancurrentlyrunafairlysubstantialsetofbitcodefileswithoutissue.Theprojecthasabuilt-incommandinterpreterfordebuggingthatsupportsbreakpoints(ish)andinspectingregister/memoryvalues.AllgenerateddatapackscanberuninarealMinecraftJavaEdition1.16+worldinunder5minutes.

Usagecargorun----arg1--arg2./path/to/llvm/bitcode.bc

Validargumentsare:

--help:Displayusageandavailableoptions--out=path/to/dir/:Specifythedirectorythedatapackfilesshouldbeplacedin(defaultis./out)--run:Runthecommandinterpreteronthegeneratedcode--trace-bbs:InsertaprintcommandatthebeginningofeachLLVMbasicblock

TousethegenerateddatapackinMinecraft:

Copytheentireoutputfolder(./outbydefault)tothedatapacks/directoryofaMinecraftworld(usingasuperflatvoidworldisrecommended)Run/functionsetup:setup.ThisonlyhastobedonethefirsttimeaLangcraftdatapackisusedinaworld.Run/functionrust:runIfthedatapackismodifiedwhiletheworldisopen,run/reloadandthengobacktostep3.

Rustcodemustbebuiltasfollows:

Releasemodepanic=abort#![no_std]#![no_main]Haveamainfunctionwith#[no_mangle]Usei686-unknown-linux

rust_interpisaRustprojectalreadyconfiguredtogeneratetheproperbitcode.Theinterpreterbinarytargetasshowninthedemocanbebuiltwith:

shcompile_rust.sh

Andthefiletousewillbe:

rust_interp/target/i686-unknown-linux-gnu/release/deps/interpreter-SOMEHEXSTRING.bc

AnyotherlanguagecapableofgeneratingLLVMbitcodecanbeused,aslongasitcanbebuiltforabare-metal32-bittarget.Foraclangexampleseecompile_c.sh.

NotethatthelatestnightlyversionsofrustcnowuseLLVM11,whichLangcraftcannotparse(yet).Youcansetanearlierversiontouseforadirectorywith:

rustupoverridesetnightly-2020-08-23Demo

AvideoofaLangcraft-compiledinterpretercanbeseenhere.

License

Licensedundereitherof

MITLicenseApacheLicense,Version2.0
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论