{"id":856,"date":"2023-12-11T14:22:42","date_gmt":"2023-12-11T06:22:42","guid":{"rendered":"https:\/\/h4ckm310n.com\/?p=856"},"modified":"2024-12-14T19:36:21","modified_gmt":"2024-12-14T11:36:21","slug":"%e8%ae%b0%e5%bd%95%e4%b8%80%e4%b8%8b%e8%87%aa%e5%b7%b1%e9%85%8d%e7%bd%aedoop%e7%8e%af%e5%a2%83%e7%9a%84%e8%bf%87%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/h4ckm310n.com\/?p=856","title":{"rendered":"\u8bb0\u5f55\u4e00\u4e0b\u81ea\u5df1\u914d\u7f6eDoop\u73af\u5883\u7684\u8fc7\u7a0b"},"content":{"rendered":"<p><!--more--><\/p>\n<h4>\u73af\u5883<\/h4>\n<p>ARM\u67b6\u6784\uff08M2 Pro\uff09<br \/>\nUbuntu 22.04\uff08Docker\u5bb9\u5668\uff09<\/p>\n<h4>Souffle<\/h4>\n<p>\u5728\u5b89\u88c5Doop\u4e4b\u524d\uff0c\u9700\u8981\u5148\u7f16\u8bd1Souffle\uff08\u56e0\u4e3a\u5b98\u65b9\u53ea\u6709X86\u7684\u5305\uff09\u3002\u5148\u5b89\u88c5\u5fc5\u8981\u7684\u5305<\/p>\n<pre>apt install \\\r\n  bison \\\r\n  build-essential \\\r\n  clang \\\r\n  cmake \\\r\n  doxygen \\\r\n  flex \\\r\n  g++ \\\r\n  git \\\r\n  libffi-dev \\\r\n  libncurses5-dev \\\r\n  libsqlite3-dev \\\r\n  make \\\r\n  mcpp \\\r\n  python3 \\\r\n  sqlite \\\r\n  zlib1g-dev\r\n<\/pre>\n<p>\u7f16\u8bd1\uff1a<\/p>\n<pre>git clone https:\/\/github.com\/souffle-lang\/souffle.git\r\ncd souffle\r\ncmake -S . -B build -DCMAKE_INSTALL_PREFIX=\/usr\/local\/\r\ncmake --build build -j8 --target install\r\n<\/pre>\n<h4>Doop<\/h4>\n<p>\u5b89\u88c5JDK\uff0c\u5e76\u4e14\u628aDoop\u7ed9clone\u4e0b\u6765\uff1a<\/p>\n<pre>apt-get install openjdk-8-jdk\r\ngit clone https:\/\/bitbucket.org\/yanniss\/doop.git\r\n<\/pre>\n<p>\u8fdb\u5165Doop\u7684\u76ee\u5f55\uff0c\u4fee\u6539gradle\/wrapper\/gradle-wrapper.properties\u6587\u4ef6\uff0c\u628a\u201cservices.gradle.org\/distributions\u201d\u6539\u4e3a\u201cmirrors.cloud.tencent.com\/gradle\u201d\uff08\u56fd\u5185\u955c\u50cf\uff09\uff0c\u7136\u540e\u4fee\u6539build.gradle\u6587\u4ef6\uff0c\u628ajfrog.io\u90a3\u4e24\u884c\u6ce8\u91ca\u6389\uff08\u56e0\u4e3a\u73b0\u5728\u5931\u6548\u4e86\uff09\uff0c\u540c\u65f6\u53d6\u6d88centauri.di.uoa.gr\u90a3\u51e0\u884c\u7684\u6ce8\u91ca\u3002\uff08\u540e\u6765\u6211\u53d1\u73b0GitHub\u4e0a\u7684\u7248\u672c\u662f\u6709\u8fd9\u6837\u7684\u4fee\u6539\u7684\uff0c\u4e0d\u77e5\u9053\u4e3a\u5565bitbucket\u4e0a\u6ca1\u6709\uff09<\/p>\n<p>\u8fd0\u884c.\/doop\uff0c\u5f00\u59cb\u7f16\u8bd1\u3002<\/p>\n<p>\u5728\u8fd0\u884c\u7684\u65f6\u5019\u53ef\u4ee5\u52a0\u4e0a\u6307\u5b9a\u7684jre\uff08&#8211;use-local-java-platform \/usr\/lib\/jvm\/java-8-openjdk-arm64\/jre\uff09\uff0c\u8fd9\u6837\u53ef\u4ee5\u8282\u7701\u4e0d\u5c11\u4e0b\u8f7d\u7684\u65f6\u95f4\u3002<\/p>\n<h4>Doop\u8fd0\u884c\u65b0\u7248Souffle\u7684\u95ee\u9898<\/h4>\n<p>\u53c2\u7167<a href=\"https:\/\/bitbucket.org\/yanniss\/doop\/src\/master\/docs\/doop-101.md\" target=\"_blank\" rel=\"noopener\">https:\/\/bitbucket.org\/yanniss\/doop\/src\/master\/docs\/doop-101.md<\/a> \u7684\u4f8b\u5b50\uff1a<\/p>\n<pre>.\/doop -a micro -i docs\/doop-101-examples\/Example.jar \\\r\n--use-local-java-platform \/usr\/lib\/jvm\/java-8-openjdk-arm64\/jre \\\r\n-L debug\r\n<\/pre>\n<p>\u53d1\u73b0\u4f1a\u62a5\u9519\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-869\" src=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2023\/12\/doop_souffle241_fact_error.jpeg\" alt=\"\" width=\"1280\" height=\"199\" srcset=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2023\/12\/doop_souffle241_fact_error.jpeg 1280w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2023\/12\/doop_souffle241_fact_error-300x47.jpeg 300w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2023\/12\/doop_souffle241_fact_error-1024x159.jpeg 1024w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2023\/12\/doop_souffle241_fact_error-768x119.jpeg 768w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><br \/>\n\u76f4\u63a5\u8fd0\u884c\u4e0a\u9762\u663e\u793a\u51fa\u9519\u7684souffle\u547d\u4ee4\u4e5f\u662f\u8fd9\u6837\uff0c\u8fd9\u4e2a\u95ee\u9898\u53d1\u751f\u5728Doop\u7684compile()\u65b9\u6cd5\u91cc\uff0c\u540e\u6765\u53d1\u73b0\u9700\u8981\u52a0\u4e0a-F\u6307\u5b9afact\u7684\u6240\u5728\u76ee\u5f55\uff08out\/xxx\/database\/\uff09\u624d\u80fd\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n<p>\u5220\u9664\u65b0\u7248Souffle\uff0c\u7f16\u8bd12.1\u7248\u672c\uff08\u9700\u8981apt install lsb-core\uff0c2.1\u7f16\u8bd1\u4f1a\u8c03\u7528lsb_release\u547d\u4ee4\uff09\uff0c\u518d\u6b21\u8fd0\u884cDoop\uff0c\u8fd9\u6b21\u6ca1\u6709\u51fa\u9519\u3002<\/p>\n<h5>\u539f\u56e0<\/h5>\n<p>\u629b\u51fa\u9519\u8bef\u7684\u4f4d\u7f6e\u662f\u5728\u751f\u6210\u7684analysis-binary.cpp\u4e2d\uff1a<\/p>\n<pre>if (op == \"input\") {\r\n    out &lt;&lt; \"try {\";\r\n    out &lt;&lt; \"std::map&lt;std::string, std::string&gt; directiveMap(\";\r\n    printDirectives(directives);\r\n    out &lt;&lt; \");\\n\";\r\n    out &lt;&lt; R\"_(if (!inputDirectory.empty()) {)_\";\r\n    out &lt;&lt; R\"_(directiveMap[\"fact-dir\"] = inputDirectory;)_\";\r\n    out &lt;&lt; \"}\\n\";\r\n    out &lt;&lt; \"IOSystem::getInstance().getReader(\";\r\n    out &lt;&lt; \"directiveMap, symTable, recordTable\";\r\n    out &lt;&lt; \")-&gt;readAll(*\" &lt;&lt; synthesiser.getRelationName(synthesiser.lookup(io.getRelation()));\r\n    out &lt;&lt; \");\\n\";\r\n    out &lt;&lt; \"} catch (std::exception&amp; e) {std::cerr &lt;&lt; \\\"Error loading \" &lt;&lt; io.getRelation()\r\n        &lt;&lt; \" data: \\\" &lt;&lt; e.what() \"\r\n        \"&lt;&lt; \"\r\n        \"'\\\\n';\\nexit(1);\\n}\\n\";\r\n}\r\n<\/pre>\n<p>\u5bf9\u6bd4\u4e24\u4e2a\u7248\u672cSouffle\u7684\u8fd0\u884c\uff0c\u53d1\u73b0\u57282.1\u91cc\uff0cDoop\u662f\u5728run()\u91cc\u9762\u624d\u8fd0\u884c\u8fd9\u4e2a\u7a0b\u5e8f\uff08\u8fd9\u4e00\u9636\u6bb5\u91cc\u9762\u6709\u52a0-F\uff09\uff0ccompile()\u9636\u6bb5\u53ea\u8fdb\u884c\u7f16\u8bd1\uff1b\u800c\u57282.4.1\u91cc\uff0c\u5728Doop\u7684compile()\u9636\u6bb5\uff0cSouffle\u5728\u7f16\u8bd1\u597d\u4e4b\u540e\u5c31\u76f4\u63a5\u81ea\u5df1\u8fd0\u884c\u8fd9\u4e2a\u7a0b\u5e8f\u4e86\uff0c\u800ccompile()\u9636\u6bb5\u5e76\u6ca1\u6709\u4f20\u5165-F\uff0c\u5bfc\u81f4\u7a0b\u5e8f\u76f4\u63a5\u5728\u5f53\u524d\u76ee\u5f55\uff08.\uff09\u8fd0\u884c\uff0c\u627e\u4e0d\u5230\u5bf9\u5e94\u7684fact\u3002<br \/>\n<figure id=\"attachment_872\" aria-describedby=\"caption-attachment-872\" style=\"width: 1280px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2023\/12\/doop_souffle241_compile_ps.png\" alt=\"\" width=\"1280\" height=\"111\" class=\"size-full wp-image-872\" srcset=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2023\/12\/doop_souffle241_compile_ps.png 1280w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2023\/12\/doop_souffle241_compile_ps-300x26.png 300w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2023\/12\/doop_souffle241_compile_ps-1024x89.png 1024w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2023\/12\/doop_souffle241_compile_ps-768x67.png 768w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><figcaption id=\"caption-attachment-872\" class=\"wp-caption-text\">\u5728Doop\u7684compile()\u9636\u6bb5\uff0csouffle\u76f4\u63a5\u8fd0\u884c\u4e86analysis-binary<\/figcaption><\/figure><\/p>\n<figure id=\"attachment_873\" aria-describedby=\"caption-attachment-873\" style=\"width: 1280px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2023\/12\/doop_souffle241_run_ps.png\" alt=\"\" width=\"1280\" height=\"88\" class=\"size-full wp-image-873\" srcset=\"https:\/\/h4ckm310n.com\/wp-content\/uploads\/2023\/12\/doop_souffle241_run_ps.png 1280w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2023\/12\/doop_souffle241_run_ps-300x21.png 300w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2023\/12\/doop_souffle241_run_ps-1024x70.png 1024w, https:\/\/h4ckm310n.com\/wp-content\/uploads\/2023\/12\/doop_souffle241_run_ps-768x53.png 768w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><figcaption id=\"caption-attachment-873\" class=\"wp-caption-text\">\u5728Doop\u7684run()\u9636\u6bb5\uff0cDoop\u53c8\u8fd0\u884c\u4e86\u4e00\u6b21\u8fd9\u4e2a\u7a0b\u5e8f<\/figcaption><\/figure>\n<h5>\u4ee3\u7801\u533a\u522b<\/h5>\n<p>\u57282.1\u4e2d\uff0cSouffle\u901a\u8fc7\u5224\u65ad\u53c2\u6570\u4e2d\u662f\u5426\u5305\u542bdl-program\u548cswig\u6765\u51b3\u5b9a\u662f\u5426\u8fd0\u884c\u7a0b\u5e8f\uff0c\u5176\u4e2ddl-program\u5c31\u662f\u201c-o\u201d\uff0c\u4e5f\u5c31\u662f\u8f93\u51fa\u7684\u7a0b\u5e8f\u6587\u4ef6\u540d\uff0c\u8fd9\u4e2a\u53c2\u6570\u662f\u5b58\u5728\u7684\uff0c\u6240\u4ee5\u4e0d\u4f1a\u8fd0\u884c\uff1a<\/p>\n<pre>if (!Global::config().has(\"dl-program\") &amp;&amp; !Global::config().has(\"swig\")) {\r\n    executeBinary(baseFilename);\r\n}\r\n<\/pre>\n<p>\u800c\u57282.4.1\u4e2d\uff0cSouffle\u76f4\u63a5\u5224\u65ad\u662f\u5426\u5305\u542bcompile\u53c2\u6570\uff08-c\uff09\uff0c\u8fd9\u5c31\u5bfc\u81f4\u4e86\u7a0b\u5e8f\u7684\u8fd0\u884c\uff1a<\/p>\n<pre>const bool execute_mode = glb.config().has(\"compile\") || glb.config().has(\"compile-many\");\r\nconst bool compile_mode = glb.config().has(\"dl-program\");\r\nconst bool generate_mode = glb.config().has(\"generate\");\r\nconst bool generate_many_mode = glb.config().has(\"generate-many\");\r\nconst bool must_interpret = !execute_mode &amp;&amp; !compile_mode &amp;&amp; !generate_mode &amp;&amp; !generate_many_mode &amp;&amp;\r\n                            !glb.config().has(\"swig\");\r\nconst bool must_execute = execute_mode;\r\nconst bool must_compile = must_execute || compile_mode || glb.config().has(\"swig\");\r\n......\r\nif (must_execute) {\r\n    executeBinaryAndExit(glb, binaryFilename);\r\n}\r\n<\/pre>\n<h5>\u89e3\u51b3\u65b9\u6cd5<\/h5>\n<p>1. \u4fee\u6539Doop\u7684compile()\uff0c\u5728\u539f\u672c\u7684\u547d\u4ee4\u6784\u5efa\u91cc\u52a0\u4e0a-F\u53c2\u6570\uff1a<\/p>\n<pre>String outputOpts = options.translateOnly ? outputCppOpts : \"<strong>-F ${outDir}\/database <\/strong>-c -o ${executablePath}\"\r\n<\/pre>\n<p>2. \u76f4\u63a5\u4fee\u6539Souffle\u5224\u65ad\u662f\u5426\u8fd0\u884c\u7684\u6761\u4ef6\u3002<\/p>\n<p>\u81f3\u4e8e\u662f\u5426\u8fd8\u6709\u5176\u4ed6\u517c\u5bb9\u95ee\u9898\uff0c\u6682\u65f6\u4e0d\u786e\u5b9a\u3002<\/p>\n<h4>\u53c2\u8003<\/h4>\n<p>1. <a href=\"https:\/\/souffle-lang.github.io\/build\" target=\"_blank\" rel=\"noopener\">https:\/\/souffle-lang.github.io\/build<\/a><br \/>\n2. <a href=\"https:\/\/bitbucket.org\/yanniss\/doop\/src\/master\/\" target=\"_blank\" rel=\"noopener\">https:\/\/bitbucket.org\/yanniss\/doop\/src\/master\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"default","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[24,6],"tags":[],"class_list":["post-856","post","type-post","status-publish","format-standard","hentry","category-24","category-6"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"h4ckm310n","author_link":"https:\/\/h4ckm310n.com\/?author=1"},"uagb_comment_info":0,"uagb_excerpt":null,"_links":{"self":[{"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=\/wp\/v2\/posts\/856","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=856"}],"version-history":[{"count":15,"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=\/wp\/v2\/posts\/856\/revisions"}],"predecessor-version":[{"id":875,"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=\/wp\/v2\/posts\/856\/revisions\/875"}],"wp:attachment":[{"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/h4ckm310n.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}