{"id":388168,"date":"2024-06-29T07:46:42","date_gmt":"2024-06-29T07:46:42","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=388168"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=388168","title":{"rendered":"<span>\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f JIT \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u0421\/\u0421++ \u0432 LLVM \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Clang<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/-t\/i5\/p5\/-ti5p5kcsikrghmf-1px2ayno_4.png\" data-src=\"https:\/\/habrastorage.org\/webt\/-t\/i5\/p5\/-ti5p5kcsikrghmf-1px2ayno_4.png\"\/><\/p>\n<p>  \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u0434\u043b\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u0435\u0433\u043e \u043a\u0430\u043a <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A2%D1%80%D0%B0%D0%BD%D1%81%D0%BF%D0%B0%D0%B9%D0%BB%D0%B5%D1%80\">\u0442\u0440\u0430\u043d\u0441\u043f\u0430\u0439\u043b\u0435\u0440<\/a> \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 \u0421++, \u0432\u043e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u043a\u0430\u0447\u0430\u043b\u0430. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0437\u043e\u0432\u0430 gcc, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439, \u0442\u0430\u043a \u0435\u0449\u0435 \u0435\u0433\u043e \u043c\u043e\u0436\u0435\u0442 \u0438 \u043d\u0435 \u0431\u044b\u0442\u044c \u043d\u0430 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 Windows). \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u044b\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u044b\u043b\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441, \u043a\u043e\u0433\u0434\u0430 \u044f \u043d\u0430\u0447\u0430\u043b \u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u043a \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438, \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u0444\u043e\u043d\u043e\u0432\u044b\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c gcc \u043d\u0438\u043a\u0443\u0434\u0430 \u043d\u0435 \u0433\u043e\u0434\u0438\u0442\u0441\u044f.<\/p>\n<p>  \u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e, \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0435 \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 LLVM, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u043a\u043e\u0433\u0434\u0430 \u043d\u0438\u0431\u0443\u0434\u044c \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c, \u0430 \u0440\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0443\u0436\u0435 \u0441\u0435\u0439\u0447\u0430\u0441. \u0418 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e C++ \u043a\u043e\u0434\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a Clang, \u043d\u043e \u0442\u0443\u0442 \u0432\u044b\u043b\u0435\u0437\u043b\u043e \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c. <\/p>\n<p>  \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Clang \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 \u043a \u0432\u0435\u0440\u0441\u0438\u0438 \u0438 \u0432\u0441\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u043c\u043d\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0431\u044b\u043b\u0438 \u0441\u0442\u0430\u0440\u044b\u043c\u0438 \u0438 \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u0438\u0441\u044c \u0432 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 (\u0421lang 12), \u0430 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 C-style \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432 \u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f*.<\/p>\n<p>  \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e Clang \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b. \u0418\u0437 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0439 \u0432\u044b\u0445\u043e\u0434\u0438\u043b\u043e, \u0447\u0442\u043e \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0432\u0432\u043e\u0434 \u0444\u0430\u0439\u043b\u043e\u043c**.<\/p>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u044e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441\u0432\u043e\u0438\u0445 \u0438\u0437\u044b\u0441\u043a\u0430\u043d\u0438\u0439 \u0432 \u0432\u0438\u0434\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0421++ \u043a\u043e\u0434\u0430 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0435\u0433\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b \u043f\u043e\u0434 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e Clang 12. \u041f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043a \u043a\u043e\u0434\u0443 \u044f \u043f\u0435\u0440\u0435\u0432\u0435\u043b \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u043b \u043f\u0435\u0440\u0435\u0434 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0435\u0439, \u0430 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<ul>\n<li>*) \u041a\u0430\u0436\u0435\u0442\u0441\u044f \u0432 14 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c C \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432.<\/li>\n<li>**) \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, Clang \u043c\u043e\u0436\u0435\u0442 (\u0438\u043b\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u0435\u0442) \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0438 \u044d\u0442\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c.<\/li>\n<\/ul>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h2>\u041d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 LLVM<\/h2>\n<p>  \u041a\u0430\u043a \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Clang \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 \u043a \u0432\u0435\u0440\u0441\u0438\u0438 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u043a\u043e\u0434, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f LLVM 7, \u043c\u043e\u0436\u0435\u0442 \u0443\u0436\u0435 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u043b\u044f LLVM 8 \u0438\u043b\u0438 6 (\u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f 12.1 \u0438 \u043d\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u0443\u0436\u0435 13 \u0432\u0435\u0440\u0441\u0438\u044f LLVM). <\/p>\n<p>  \u0410 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 C-style \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <a href=\"https:\/\/clang.llvm.org\/docs\/LibTooling.html\">libtooling<\/a> \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f AST, \u0430 \u043d\u0435 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e LLVM.<\/p>\n<h4>\u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u044d\u0442\u0430\u043f\u043e\u0432 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f:<\/h4>\n<p>  <\/p>\n<ul>\n<li>\u0420\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0421\/\u0421++ \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c\u0438 \u043e\u043f\u0446\u0438\u044f\u043c\u0438 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c AST (<a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%90%D0%B1%D1%81%D1%82%D1%80%D0%B0%D0%BA%D1%82%D0%BD%D0%BE%D0%B5_%D1%81%D0%B8%D0%BD%D1%82%D0%B0%D0%BA%D1%81%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%BE%D0%B5_%D0%B4%D0%B5%D1%80%D0%B5%D0%B2%D0%BE\">Abstract Syntax Tree<\/a>)<\/li>\n<li>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c AST \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Intermediate_representation\">Intermediate Representation<\/a>).<\/li>\n<li>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c IR \u0432 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0439 \u043a\u043e\u0434 (<a href=\"https:\/\/ru.wikipedia.org\/wiki\/JIT-%D0%BA%D0%BE%D0%BC%D0%BF%D0%B8%D0%BB%D1%8F%D1%86%D0%B8%D1%8F\">JIT LLVM<\/a>).<\/li>\n<li>\u0414\u0430\u043b\u0435\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 LLVM \u043c\u043e\u0434\u0443\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u0440\u0430\u043d\u0438\u0442 \u0432\u0441\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0440\u0435\u0434\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/li>\n<li>\u0418 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0442\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c\u0443 \u0432\u044b\u0437\u043e\u0432\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043b\u0438.<\/li>\n<\/ul>\n<p>  <\/p>\n<h2>\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043a\u043e\u0434\u0430<\/h2>\n<p>  \u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0438\u0437 \u043d\u0438\u0445 \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u043e \u0432 \u0444\u0430\u0439\u043b <i>#include \u00abllvm_precomp.h\u00bb<\/i>. \u0414\u0430\u043b\u0435\u0435 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <i>InitializeLLVM()<\/i> \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f LLVM.<\/p>\n<p>  <s>\u041f\u0435\u0440\u0432\u043e\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0435\u0440\u0435\u0436\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 clang \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b. \u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u043e\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0432\u0432\u043e\u0434 \u0444\u0430\u0439\u043b\u043e\u043c.<\/s><\/p>\n<p>  \u041f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0431\u044b\u043b \u0441\u0434\u0435\u043b\u0430\u043d \u0434\u043b\u044f Clang 6 \u0438\u043b\u0438 7 \u0432\u0435\u0440\u0441\u0438\u0438, \u0433\u0434\u0435 \u0442\u0430\u043a\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0430, \u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0435\u0440\u0435\u0436\u0435\u043d\u0438\u0435 \u0443\u0436\u0435 \u043d\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e.<\/p>\n<p>  \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u044d\u0442\u043e \u043e\u043f\u0446\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u0418\u0445 \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u0430\u043a \u0438 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u0444\u043b\u0430\u0433\u0430\u043c\u0438 \u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u0443\u0442\u044f\u043c\u0438. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0432 \u0421lang \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u0441\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<p>  \u041d\u043e \u0441\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u044d\u0442\u043e \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c! \u041d\u0443\u0436\u043d\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432\u0441\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f \u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u043f\u0430\u0440\u0441\u0435\u0440\u0430 Clang \u0438 \u0432\u0441\u0435\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b JIT \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u0434\u043b\u044f C\/C++ \u043a\u043e\u0434\u0430.<\/p>\n<p>  \u0410\u0432\u0442\u043e\u0440 \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 (\u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0432 \u043a\u043e\u043d\u0446\u0435) \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u00ab\u043f\u0440\u0438\u0447\u0435\u0441\u0430\u043b\u00bb \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u0442.\u043a. \u0435\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e <i>unique_ptrs<\/i> \u043d\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b <i>IntrusiveRefCntPtr<\/i>, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 LLVM (\u044d\u0442\u043e \u0431\u044b\u043b\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f). \u0415\u0449\u0435 \u043e\u043d \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u0421\u0435\u0439\u0447\u0430\u0441 \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <i>nv_add<\/i> \u0438 <i>nv_sub<\/i>.<\/p>\n<p>  \u0423 \u043c\u0435\u043d\u044f \u0442\u043e\u0436\u0435 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430, \u0442.\u043a. \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Clang \u043e\u043f\u044f\u0442\u044c \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u0441\u044f \u0438 \u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0433\u0434\u0435 \u0440\u0430\u043d\u044c\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u044b \u043d\u0430 <i>IntrusiveRefCntPtr<\/i>. \u0425\u043e\u0442\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043a\u0430\u043a \u0432 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u0445.<\/p>\n<pre><code class=\"cpp\">clang::IntrusiveRefCntPtr&lt;clang::DiagnosticOptions> DiagOpts = new clang::DiagnosticOptions;     clang::TextDiagnosticPrinter *textDiagPrinter = new clang::TextDiagnosticPrinter(llvm::outs(), &amp;*DiagOpts);  clang::IntrusiveRefCntPtr&lt;clang::DiagnosticIDs> pDiagIDs; clang::DiagnosticsEngine *pDiagnosticsEngine = new clang::DiagnosticsEngine(pDiagIDs, &amp;*DiagOpts, textDiagPrinter);<\/code><\/pre>\n<p>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0442\u0443\u0442 \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043a\u043e\u0441\u044f\u043a, \u0442.\u043a. \u043f\u0440\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u0430\u0434\u0430\u043b\u043e \u0441 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438 <i>Segmentation fault<\/i> \u0438\u043b\u0438 <i>Double free or corrupt<\/i>, \u043d\u043e \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u043e\u0433\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u00ab\u043d\u0430\u0443\u0447\u043d\u043e\u0433\u043e \u0442\u044b\u043a\u0430\u00bb \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0431\u044b\u043b \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0438\u0434\u0435\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Triple, \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f \u0438\u0437 \u0442\u0440\u0435\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0438 \u0446\u0435\u043b\u0435\u0432\u0443\u044e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0443. \u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e <b>x86_64-pc-linux-gnu<\/b>. \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0438\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u0441 \u043e\u043f\u0446\u0438\u044f\u043c\u0438 \u043a\u0430\u043a \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435. <\/p>\n<p>  \u0421\u0435\u0439\u0447\u0430\u0441 Clang \u0443\u0436\u0435 \u0443\u043c\u0435\u0435\u0442 \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438, \u0442\u043e\u0447\u043d\u0435\u0435 \u0438\u0437 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430, \u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u043c\u0435\u043d \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043c\u0438\u043d\u0443\u0441, \u0430 \u0441\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 pipe: <\/p>\n<pre><code class=\"cpp\">    \/\/ Send code through a pipe to stdin     int codeInPipe[2];     pipe2(codeInPipe, O_NONBLOCK);     write(codeInPipe[1], (void *) func_text, strlen(func_text));     close(codeInPipe[1]); \/\/ We need to close the pipe to send an EOF     dup2(codeInPipe[0], STDIN_FILENO); ...     itemcstrs.push_back(\"-\"); \/\/ Read code from stdin <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0432 \u043a\u043e\u0434\u0435 \u0438\u0434\u0435\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u043f\u0446\u0438\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u0438 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f AST.<\/p>\n<pre><code class=\"cpp\">if(!compilerInstance.ExecuteAction(*action)) { }<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430<\/h2>\n<p>  \u0412\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0431\u0443\u0434\u044c\u0442\u0435 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u044b \u0441 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f!<\/p>\n<p>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 LLVM, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438, \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438. \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432\u0441\u0435, \u0447\u0442\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e JIT, \u0434\u043e\u043b\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e\u0441\u043b\u0435 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u043e \u044f\u0432\u043d\u043e.<\/p>\n<p>  \u0412\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f IR. \u0418 \u044d\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e. <\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u044c LLVM \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f. <\/p>\n<pre><code class=\"cpp\">std::unique_ptr&lt;llvm::Module> module = action->takeModule();     if(!module) {         ...     }<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u044b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438. \u041a\u043e\u0434 \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u0435\u043d, \u043d\u043e \u044d\u0442\u043e LLVM\u2026 \u0438 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043f\u0440\u0438\u0447\u0438\u043d, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 API \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0432\u0438\u0434\u043e\u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 \u043a \u0432\u0435\u0440\u0441\u0438\u0438. <\/p>\n<pre><code class=\"cpp\">     llvm::PassBuilder passBuilder;     llvm::LoopAnalysisManager loopAnalysisManager(codeGenOptions.DebugPassManager);     llvm::FunctionAnalysisManager functionAnalysisManager(codeGenOptions.DebugPassManager);     llvm::CGSCCAnalysisManager cGSCCAnalysisManager(codeGenOptions.DebugPassManager);     llvm::ModuleAnalysisManager moduleAnalysisManager(codeGenOptions.DebugPassManager);      passBuilder.registerModuleAnalyses(moduleAnalysisManager);     passBuilder.registerCGSCCAnalyses(cGSCCAnalysisManager);     passBuilder.registerFunctionAnalyses(functionAnalysisManager);     passBuilder.registerLoopAnalyses(loopAnalysisManager);     passBuilder.crossRegisterProxies(loopAnalysisManager, functionAnalysisManager, cGSCCAnalysisManager, moduleAnalysisManager);      llvm::ModulePassManager modulePassManager = passBuilder.buildPerModuleDefaultPipeline(llvm::PassBuilder::OptimizationLevel::O3);     modulePassManager.run(*module, moduleAnalysisManager);<\/code><\/pre>\n<p>  \u0418 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c JIT-\u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0438 \u0438\u0441\u043a\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u043d\u0443\u0436\u043d\u0443\u044e \u043d\u0430\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u0418\u043c\u0435\u0439\u0442\u0435 \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u043c\u043e\u0434\u0443\u043b\u044c LLVM \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u0432\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0435\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435! <\/p>\n<pre><code class=\"cpp\">    llvm::EngineBuilder builder(std::move(module));     builder.setMCJITMemoryManager(std::make_unique&lt;llvm::SectionMemoryManager>());     builder.setOptLevel(llvm::CodeGenOpt::Level::Aggressive);     auto executionEngine = builder.create();      if(!executionEngine) {         ...     }     reinterpret_cast&lt;Function> (executionEngine->getFunctionAddress(function)); <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438<\/h2>\n<p>  \u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043d\u044b \u043d\u0430 <a href=\"https:\/\/bitbucket.org\/afteri-ru\/cpp-jit-llvm\/src\/master\/\">bitbucket<\/a> (\u0442.\u043a. github.com \u0445\u043e\u0447\u0435\u0442 \u043b\u0438\u0431\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438\u043b\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0434\u0432\u0443\u0445\u0444\u0430\u043a\u0442\u043e\u0440\u043d\u0443\u044e \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432). \u0421 \u043f\u0435\u0440\u0432\u044b\u043c \u043d\u0435 \u0445\u043e\u0447\u0443 \u0437\u0430\u043c\u043e\u0440\u0430\u0447\u0430\u0442\u044c\u0441\u044f, \u0430 \u0432\u0442\u043e\u0440\u043e\u0435 \u043b\u0435\u043d\u044c \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c.<\/p>\n<blockquote><p>remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.<br \/>  remote: Please see <a href=\"https:\/\/github.blog\/2020-12-15-token-authentication-requirements-for-git-operations\/\">github.blog\/2020-12-15-token-authentication-requirements-for-git-operations<\/a> for more information.<br \/>  fatal: \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e: The requested URL returned error: 403<\/p><\/blockquote>\n<p>  <\/p>\n<h2>\u0421\u0431\u043e\u0440\u043a\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430<\/h2>\n<p>  \u0421\u0431\u043e\u0440\u043a\u0443 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432 \u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434 linux \u0441 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c Clang 12. \u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0441\u0431\u043e\u0440\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u0434\u0440\u0435\u0432\u043d\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 NetBeans, \u043d\u043e \u0432\u0441\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b make.<\/p>\n<h2>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b<\/h2>\n<p>  <a href=\"https:\/\/blog.audio-tk.com\/2018\/09\/18\/compiling-c-code-in-memory-with-clang\/\">Compiling C++ code in memory with clang<\/a> \u0438 <a href=\"https:\/\/wiki.nervtech.org\/doku.php?id=blog:2020:0410_dynamic_cpp_compilation\">\u0435\u0451 \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u043a\u0430<\/a> \u0441 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0432\u0435\u0440\u0441\u0438\u0438 Clang. \u0415\u0449\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0432 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u043a\u043e\u0434\u0430 \u0438\u0437 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0448\u0435\u043b <a href=\"https:\/\/stackoverflow.com\/questions\/34828480\/generate-assembly-from-c-code-in-memory-using-libclang\">\u0442\u0443\u0442<\/a>.<\/p>\n<h2>\u0417.\u042b.<\/h2>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435.<\/p>\n<p>  \u041f\u0438\u0448\u0438\u0442\u0435, \u0435\u0441\u043b\u0438 \u0431\u0443\u0434\u0443\u0442 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0438\u043b\u0438 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f.<\/p>\n<h2>\u0417.\u0417.\u042b.<\/h2>\n<p>  \u0411\u043e\u043b\u0435\u0435 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043f\u0440\u043e <a href=\"https:\/\/habr.com\/ru\/articles\/803787\/\">\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e JIT \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e C++ \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 ORCv2<\/a>.<\/p>\n<h3>\u0410 \u0432\u043e\u043e\u0431\u0449\u0435, \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0430\u044f JIT \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u0421++ \u043a\u043e\u0434\u0430, \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0443\u0442\u043e!<\/h3>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 JIT \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u0421\/\u0421++<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &lt;sstream> #include &lt;iostream> #include &lt;fstream> #include &lt;unistd.h> #include &lt;fcntl.h>  #include \"llvm_precomp.h\"   \/\/#define NV_LLVM_VERBOSE 1  bool LLVMinit = false;  #define ERROR_MSG(msg) std::cout &lt;&lt; \"[ERROR]: \"&lt;&lt;msg&lt;&lt; std::endl; #define DEBUG_MSG(msg) std::cout &lt;&lt; \"[DEBUG]: \"&lt;&lt;msg&lt;&lt; std::endl;  void InitializeLLVM() {     if(LLVMinit) {         return;     }      \/\/ We have not initialized any pass managers for any device yet.     \/\/ Run the global LLVM pass initialization functions.     llvm::InitializeNativeTarget();     llvm::InitializeNativeTargetAsmPrinter();     llvm::InitializeNativeTargetAsmParser();      auto&amp; Registry = *llvm::PassRegistry::getPassRegistry();      llvm::initializeCore(Registry);     llvm::initializeScalarOpts(Registry);     llvm::initializeVectorization(Registry);     llvm::initializeIPO(Registry);     llvm::initializeAnalysis(Registry);     llvm::initializeTransformUtils(Registry);     llvm::initializeInstCombine(Registry);     llvm::initializeInstrumentation(Registry);     llvm::initializeTarget(Registry);       LLVMinit = true; }  int main(int argc, char *argv[]) {      InitializeLLVM();      const char * func_text = \\ \"int nv_add(int a, int b) {\\n\\     printf(\\\"call nv_add(%d, %d)\\\\n\\\", a, b);\\n\\     return a + b;\\n\\ }\\n\\ \\n\\ int nv_sub(int a, int b) {\\n\\     printf(\\\"call nv_sub(%d, %d)\\\\n\\\", a, b);\\n\\     return a - b;\\n\\ }\\n\\ \";       DEBUG_MSG(\"Running clang compilation...\");       clang::CompilerInstance compilerInstance;     auto&amp; compilerInvocation = compilerInstance.getInvocation();       \/\/ \u0414\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b Clang     clang::IntrusiveRefCntPtr&lt;clang::DiagnosticOptions> DiagOpts = new clang::DiagnosticOptions;     clang::TextDiagnosticPrinter *textDiagPrinter =             new clang::TextDiagnosticPrinter(llvm::outs(), &amp;*DiagOpts);      clang::IntrusiveRefCntPtr&lt;clang::DiagnosticIDs> pDiagIDs;      clang::DiagnosticsEngine *pDiagnosticsEngine =             new clang::DiagnosticsEngine(pDiagIDs, &amp;*DiagOpts, textDiagPrinter);        \/\/ \u0426\u0435\u043b\u0435\u0432\u0430\u044f \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0430     std::stringstream ss;     ss &lt;&lt; \"-triple=\" &lt;&lt; llvm::sys::getDefaultTargetTriple();          std::cout &lt;&lt; llvm::sys::getDefaultTargetTriple();          std::istream_iterator&lt;std::string> begin(ss);     std::istream_iterator&lt;std::string> end;     std::istream_iterator&lt;std::string> i = begin;     std::vector&lt;const char*> itemcstrs;     std::vector&lt;std::string> itemstrs;     while(i != end) {         itemstrs.push_back(*i);         ++i;     }      for (unsigned idx = 0; idx &lt; itemstrs.size(); idx++) {         \/\/ note: if itemstrs is modified after this, itemcstrs will be full         \/\/ of invalid pointers! Could make copies, but would have to clean up then...         itemcstrs.push_back(itemstrs[idx].c_str());     }      \/\/ \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438     \/\/ Send code through a pipe to stdin     int codeInPipe[2];     pipe2(codeInPipe, O_NONBLOCK);     write(codeInPipe[1], (void *) func_text, strlen(func_text));     close(codeInPipe[1]); \/\/ We need to close the pipe to send an EOF     dup2(codeInPipe[0], STDIN_FILENO);      itemcstrs.push_back(\"-\"); \/\/ Read code from stdin      clang::CompilerInvocation::CreateFromArgs(compilerInvocation, llvm::ArrayRef&lt;const char *>(itemcstrs.data(), itemcstrs.size()), *pDiagnosticsEngine);      auto* languageOptions = compilerInvocation.getLangOpts();     auto&amp; preprocessorOptions = compilerInvocation.getPreprocessorOpts();     auto&amp; targetOptions = compilerInvocation.getTargetOpts();     auto&amp; frontEndOptions = compilerInvocation.getFrontendOpts(); #ifdef NV_LLVM_VERBOSE     frontEndOptions.ShowStats = true; #endif     auto&amp; headerSearchOptions = compilerInvocation.getHeaderSearchOpts(); #ifdef NV_LLVM_VERBOSE     headerSearchOptions.Verbose = true; #endif     auto&amp; codeGenOptions = compilerInvocation.getCodeGenOpts();       targetOptions.Triple = llvm::sys::getDefaultTargetTriple();     compilerInstance.createDiagnostics(textDiagPrinter, false);      llvm::LLVMContext context;     std::unique_ptr&lt;clang::CodeGenAction> action = std::make_unique&lt;clang::EmitLLVMOnlyAction>(&amp;context);      if(!compilerInstance.ExecuteAction(*action)) {         ERROR_MSG(\"Cannot execute action with compiler instance.\");     }      \/\/ Runtime LLVM Module     std::unique_ptr&lt;llvm::Module> module = action->takeModule();     if(!module) {         ERROR_MSG(\"Cannot retrieve IR module.\");     }      \/\/ \u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f IR     llvm::PassBuilder passBuilder;     llvm::LoopAnalysisManager loopAnalysisManager(codeGenOptions.DebugPassManager);     llvm::FunctionAnalysisManager functionAnalysisManager(codeGenOptions.DebugPassManager);     llvm::CGSCCAnalysisManager cGSCCAnalysisManager(codeGenOptions.DebugPassManager);     llvm::ModuleAnalysisManager moduleAnalysisManager(codeGenOptions.DebugPassManager);      passBuilder.registerModuleAnalyses(moduleAnalysisManager);     passBuilder.registerCGSCCAnalyses(cGSCCAnalysisManager);     passBuilder.registerFunctionAnalyses(functionAnalysisManager);     passBuilder.registerLoopAnalyses(loopAnalysisManager);     passBuilder.crossRegisterProxies(loopAnalysisManager, functionAnalysisManager, cGSCCAnalysisManager, moduleAnalysisManager);      llvm::ModulePassManager modulePassManager = passBuilder.buildPerModuleDefaultPipeline(llvm::PassBuilder::OptimizationLevel::O3);     modulePassManager.run(*module, moduleAnalysisManager);      llvm::EngineBuilder builder(std::move(module));     builder.setMCJITMemoryManager(std::make_unique&lt;llvm::SectionMemoryManager>());     builder.setOptLevel(llvm::CodeGenOpt::Level::Aggressive);      std::string createErrorMsg;      builder.setEngineKind(llvm::EngineKind::JIT);     builder.setVerifyModules(true);     builder.setErrorStr(&amp;createErrorMsg);      std::string triple = llvm::sys::getDefaultTargetTriple();     DEBUG_MSG(\"Using target triple: \" &lt;&lt; triple);     auto executionEngine = builder.create();      if(!executionEngine) {         ERROR_MSG(\"Cannot create execution engine.'\" &lt;&lt; createErrorMsg &lt;&lt; \"'\");     }      DEBUG_MSG(\"Retrieving nv_add\/nv_sub functions...\");     typedef int(*AddFunc)(int, int);     typedef int(*SubFunc)(int, int);      AddFunc add = reinterpret_cast&lt;AddFunc> (executionEngine->getFunctionAddress(\"nv_add\"));     if(!add) {         ERROR_MSG(\"Cannot retrieve Add function.\");     } else {         int res = add(40, 2);         DEBUG_MSG(\"The meaning of life is: \" &lt;&lt; res &lt;&lt; \"!\");     }      SubFunc sub = reinterpret_cast&lt;SubFunc> (executionEngine->getFunctionAddress(\"nv_sub\"));     if(!sub) {         ERROR_MSG(\"Cannot retrieve Sub function.\");     } else {         int res = sub(50, 8);         DEBUG_MSG(\"The meaning of life is really: \" &lt;&lt; res &lt;&lt; \"!\");     }      DEBUG_MSG(\"Done running clang compilation.\");      return 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  <a href=\"https:\/\/timeweb.com\/ru\/?utm_source=habr&amp;utm_medium=banner&amp;utm_campaign=10S&amp;utm_content=low\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/wo\/qf\/6c\/woqf6cweprtwtuq2m7jch92h5wk.png\" data-src=\"https:\/\/habrastorage.org\/webt\/wo\/qf\/6c\/woqf6cweprtwtuq2m7jch92h5wk.png\"\/><\/a><\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/572878\/\"> https:\/\/habr.com\/ru\/articles\/572878\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/-t\/i5\/p5\/-ti5p5kcsikrghmf-1px2ayno_4.png\" data-src=\"https:\/\/habrastorage.org\/webt\/-t\/i5\/p5\/-ti5p5kcsikrghmf-1px2ayno_4.png\"\/><\/p>\n<p>  \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u0434\u043b\u044f \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u044f \u0441\u0434\u0435\u043b\u0430\u043b \u0435\u0433\u043e \u043a\u0430\u043a <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A2%D1%80%D0%B0%D0%BD%D1%81%D0%BF%D0%B0%D0%B9%D0%BB%D0%B5%D1%80\">\u0442\u0440\u0430\u043d\u0441\u043f\u0430\u0439\u043b\u0435\u0440<\/a> \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 \u0421++, \u0432\u043e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u043a\u0430\u0447\u0430\u043b\u0430. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0437\u043e\u0432\u0430 gcc, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439, \u0442\u0430\u043a \u0435\u0449\u0435 \u0435\u0433\u043e \u043c\u043e\u0436\u0435\u0442 \u0438 \u043d\u0435 \u0431\u044b\u0442\u044c \u043d\u0430 \u0446\u0435\u043b\u0435\u0432\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 Windows). \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u044b\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u044b\u043b\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441, \u043a\u043e\u0433\u0434\u0430 \u044f \u043d\u0430\u0447\u0430\u043b \u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u043a \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438, \u0441\u0442\u0430\u043b\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441 \u0444\u043e\u043d\u043e\u0432\u044b\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c gcc \u043d\u0438\u043a\u0443\u0434\u0430 \u043d\u0435 \u0433\u043e\u0434\u0438\u0442\u0441\u044f.<\/p>\n<p>  \u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e, \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0435 \u043e\u0442\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 LLVM, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u043a\u043e\u0433\u0434\u0430 \u043d\u0438\u0431\u0443\u0434\u044c \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c, \u0430 \u0440\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0443\u0436\u0435 \u0441\u0435\u0439\u0447\u0430\u0441. \u0418 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e C++ \u043a\u043e\u0434\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a Clang, \u043d\u043e \u0442\u0443\u0442 \u0432\u044b\u043b\u0435\u0437\u043b\u043e \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c. <\/p>\n<p>  \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Clang \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 \u043a \u0432\u0435\u0440\u0441\u0438\u0438 \u0438 \u0432\u0441\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u043c\u043d\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0431\u044b\u043b\u0438 \u0441\u0442\u0430\u0440\u044b\u043c\u0438 \u0438 \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u0438\u0441\u044c \u0432 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 (\u0421lang 12), \u0430 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u0439 C-style \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432 \u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f*.<\/p>\n<p>  \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e Clang \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0438\u0437 \u043f\u0430\u043c\u044f\u0442\u0438, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b. \u0418\u0437 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0439 \u0432\u044b\u0445\u043e\u0434\u0438\u043b\u043e, \u0447\u0442\u043e \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u0432\u0432\u043e\u0434 \u0444\u0430\u0439\u043b\u043e\u043c**.<\/p>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u044e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441\u0432\u043e\u0438\u0445 \u0438\u0437\u044b\u0441\u043a\u0430\u043d\u0438\u0439 \u0432 \u0432\u0438\u0434\u0435 \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0421++ \u043a\u043e\u0434\u0430 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0435\u0433\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435\u043c \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b \u043f\u043e\u0434 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e Clang 12. \u041f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u043a \u043a\u043e\u0434\u0443 \u044f \u043f\u0435\u0440\u0435\u0432\u0435\u043b \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u043b \u043f\u0435\u0440\u0435\u0434 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0435\u0439, \u0430 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<ul>\n<li>*) \u041a\u0430\u0436\u0435\u0442\u0441\u044f \u0432 14 \u0432\u0435\u0440\u0441\u0438\u0438 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c C \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432.<\/li>\n<li>**) \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, Clang \u043c\u043e\u0436\u0435\u0442 (\u0438\u043b\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u0435\u0442) \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0438 \u044d\u0442\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c.<\/li>\n<\/ul>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-388168","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/388168","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=388168"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/388168\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=388168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=388168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=388168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}