<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>&#32780;&#20170;&#36808;&#27493;&#20174;&#22836;&#36234; - Home</title>
  <id>tag:leeseon.com,2009:mephisto/</id>
  <generator uri="http://mephistoblog.com" version="0.8.0">Mephisto Drax</generator>
  <link href="http://leeseon.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://leeseon.com/" rel="alternate" type="text/html"/>
  <updated>2009-01-05T15:05:10Z</updated>
  <entry xml:base="http://leeseon.com/">
    <author>
      <name>leeseon</name>
    </author>
    <id>tag:leeseon.com,2009-01-02:33</id>
    <published>2009-01-02T18:36:00Z</published>
    <updated>2009-01-05T15:05:10Z</updated>
    <category term="just for fun"/>
    <category term="wordpress theme"/>
    <link href="http://leeseon.com/2009/1/2/port_inove_wordpress_theme_to_mephisto" rel="alternate" type="text/html"/>
    <title>&#33258;&#24049;&#31227;&#26893;&#20102;&#19968;&#20010;&#27604;&#36739;&#21916;&#27426;&#30340;wordpress&#20027;&#39064;&#29992;&#29992;</title>
<content type="html">
            &lt;p&gt;一直垂涎于Wordpress有很多好看的theme可以用，mephisto这两年的更新与发展也太慢了，看来rails的blog系统，相对于PHP来说还真的有一些小众的感觉。&lt;/p&gt;


	&lt;p&gt;等着别人port我看基本是没戏，自己动手吧，虽然不难，但是有一点啰嗦，加上我的CSS知识也很一般，好在做port这种事其实与CSS基本无关，对于mephisto来说，其实要了解的主要是liquid与mephisto自己的一点变量而已。&lt;/p&gt;


	&lt;p&gt;截了以前的样子，留个记录吧&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://www.slide.com/s/Zm5xneBv1z8bWbV7FtDfAKCYPCJl5_u0?referrer=hlnk&quot;&gt;&lt;img title=&quot;免费无限存放图片在slide.com!&quot; src=&quot;http://widget.slide.com/rdr/1/1/1/W/250000000c9da7f3/1/231/z_ZiBIoh6T-vmw_b8qKm1ZZWrx3ijB2n.jpg&quot; alt=&quot;免费无限存放图片在slide.com!&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://leeseon.com/">
    <author>
      <name>leeseon</name>
    </author>
    <id>tag:leeseon.com,2009-01-01:32</id>
    <published>2009-01-01T13:27:00Z</published>
    <updated>2009-01-05T14:40:18Z</updated>
    <category term="new year"/>
    <category term="wish"/>
    <category term="&#23637;&#26395;"/>
    <category term="&#24863;&#24819;"/>
    <category term="&#24895;&#26223;"/>
    <link href="http://leeseon.com/2009/1/1/wishes_in_the_new_year" rel="alternate" type="text/html"/>
    <title>&#26032;&#24180;&#26032;&#27668;&#35937;</title>
<content type="html">
            &lt;p&gt;2008年混杂着奥运的狂喜与自然灾害及金融危机呼啸而过，时间真的是过的越来越快，果然是：”我觉察他去的匆匆了，伸出手遮挽时，他又从遮挽着的手边过去“。&lt;/p&gt;


	&lt;p&gt;此去经年是我最爱在元旦时留下的标题，而今又是“流光容易把人抛，红了樱桃，绿了芭蕉“了、、、然掩而叹息亦不能改变我又老去了一岁，在过去的一年中我又一事无成的事实。&lt;/p&gt;


	&lt;p&gt;看来历史总是重复的基本上也是对的吧，不过人总会不满足于现状，在回首看看逝去的一年，心中不由的生出的恐惧与懊恼，追悔不及自然是有的，但是后悔是不能解决问题的，真的问题是需要解决问题，让自己成长，能在自己曾经的时光废墟中立起来，也算是新年新气象吧。&lt;/p&gt;


	&lt;p&gt;特此立酸文志之，只需要在明年的元旦再看时不再心中有悔，此愿足矣！&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://leeseon.com/">
    <author>
      <name>leeseon</name>
    </author>
    <id>tag:leeseon.com,2008-11-19:31</id>
    <published>2008-11-19T16:08:00Z</published>
    <updated>2009-01-05T14:07:19Z</updated>
    <category term="apple advertisement"/>
    <category term="mac"/>
    <link href="http://leeseon.com/2008/11/19/so_cool_apple_advertisement" rel="alternate" type="text/html"/>
    <title>&#22826;&#37239;&#30340;&#24191;&#21578;&#20102;</title>
<content type="html">
            &amp;lt;object&gt;
&amp;lt;param /&gt;
&amp;lt;/object&gt;
          </content>  </entry>
  <entry xml:base="http://leeseon.com/">
    <author>
      <name>leeseon</name>
    </author>
    <id>tag:leeseon.com,2008-11-10:30</id>
    <published>2008-11-10T15:48:00Z</published>
    <updated>2008-11-12T13:59:42Z</updated>
    <category term="emacs"/>
    <category term="no pirated"/>
    <category term="textmate"/>
    <category term="viusal c++ express"/>
    <category term="windows"/>
    <link href="http://leeseon.com/2008/11/10/from_textmate_to_emacs" rel="alternate" type="text/html"/>
    <title>&#20174;Textmate&#21040;Emacs</title>
<content type="html">
            &lt;p&gt;虽然Textmate一直是俺的最爱，但是出了ruby及os x之外，使用Textmate有时成了一种奢望，就说rubinius吧，这个*nix only的项目，现在也没有办法在cgywin上编译通过，在我打过多处补丁之后，发现这几乎对我来说是一项不可能完成的任务。不太懂*nix下的线程与信号的说，这个以后俺再补补，争取出个windows上原生线程的port。&lt;/p&gt;


	&lt;p&gt;为了在*nix（ubuntu与mac os x)下读读它，并跟踪一下它的运行，我只好祭出emacs了，好在它可以整合emacs code browser及cscope，而且还能同时使用图形化的gdb界面。看来Ｃ++还是用emacs好了。&lt;/p&gt;


	&lt;p&gt;其实我也一直很叶公好龙滴，虽然早就耳闻emacs的好，但是在ubuntu下俺就用gedit来偷懒，dreamhost上用不太熟的vi来混混，windows上还是主要依赖于VS、notepad++，有时也拿intype来找一下textmate的感觉。&lt;/p&gt;


	&lt;p&gt;最近又因为公司里不许安装Ｄ版，而且VS公司又不肯买，在这点的Jole测试上公司应该是零分的:( 还说是因为印度那边用VC++ Express一直都很好，而且因为金融危机的问题，公司不肯再在软件上投入更多的预算，真是服了公司的目光短浅及印度人的忍耐力、、、、&lt;/p&gt;


	&lt;p&gt;不过我是被Visual Assist X给宠坏了，不让我使用alt+o, alt+shift+s, alt+shift+o我是没有办法习惯了,而且我曾经花美金买到绝版的ref++及现在refactor!等等的插件都再也办法用了:( 不能装插件的vc express是一个让我无法适应的IDE。&lt;/p&gt;


	&lt;p&gt;好在emacs还有一个windows的版本，在配完cedet之后，与VAX相同的功能也都回来了，只是emacs下的重构功能我还没有试过，而且那个是要收费滴&lt;/p&gt;


	&lt;p&gt;经过了几天与emacs的搏斗之后，才发现emacs的难学只是听起来吓人的，慢慢的，还不等你记住，你的手指也开始记住了它的习惯了。而且使用它与*nix下的工具合作起来真的是很爽的，而且这样你在三个平台之下都有了一个统一的IDE感觉真的很爽，不过不知为什么，我居然没有想过用eclipse与netbean呢？我也不知道，可能我天生爱受虐，或者喜欢虐键盘，总对用quicksilver与launchy调出一个emacs疯狂打上一些古怪组合键感觉良好。不知你是否有同好？呵呵&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://leeseon.com/">
    <author>
      <name>leeseon</name>
    </author>
    <id>tag:leeseon.com,2008-10-05:29</id>
    <published>2008-10-05T07:25:00Z</published>
    <updated>2008-10-07T14:08:04Z</updated>
    <category term="bytecode"/>
    <category term="jit"/>
    <category term="llvm"/>
    <category term="rubinius"/>
    <link href="http://leeseon.com/2008/10/5/rubinius-and-llvm-jit" rel="alternate" type="text/html"/>
    <title>Rubinius&#19982;LLVM</title>
<content type="html">
            &lt;p&gt;一直对&lt;a href=&quot;http://rubini.us/&quot;&gt;Rubinius&lt;/a&gt;所宣称的“Ruby In Ruby”很以为然，而且龙书中之也提到一个语言成熟的标志之一就是能“自举”--即使用自已来实现自己。以此为标准，Fortran、Basic、Javascript、Perl、PHP之类应该都算是不举，而LISP、C/C++、Smalltalk早就是很举的，Python、Java与Ruby现在是半举，并在让自己摆脱ED的印象之中，而&lt;a href=&quot;http://rubini.us/&quot;&gt;Rubinius&lt;/a&gt;自然是Rubyist的春药罗&lt;/p&gt;
&lt;p&gt;这两天读到&lt;a href=&quot;http://blog.fallingsnow.net/2008/05/23/simple-vm-jit-with-llvm/&quot;&gt;Simple VM JIT with LLVM&lt;/a&gt; 觉得很是有趣，不过奇怪的是居然这个网站也被盾了，如果你从来没有tor过，或者gladder过，建议你赶紧找一个翻过墙去看看。不过顺便也谈谈我的读后感吧，算是学习笔记了。&lt;/p&gt;
&lt;p&gt;Rubinius与YARV一样是一个虚拟机(VM)，它如同Python一样，先将源代码编译成Bytecode文件，在执行时优先执行Bytecode。这样能提高ruby的执行效率。说到VM自然不能不说它的bc了，一个VM无非就是拿一些bc来执行了事而已，其实PC也是这样的，只是一个实一个虚而已。&lt;/p&gt;
&lt;p&gt;Evan为了举例说明，首先杜撰了一个足够tiny的VM：&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;只操作整数&lt;/li&gt; 
&lt;li&gt;被编号的寄存器&lt;/li&gt;  
&lt;li&gt;只有三条指令&lt;/li&gt;  
&lt;li&gt;
&lt;ol&gt;
&lt;li&gt;&lt;b&gt;0 - set(reg, val)&lt;/b&gt;　将第reg号寄存器设为整数值val &lt;/li&gt; 
&lt;li&gt;&lt;strong&gt;1 - add(result, reg, val)&lt;/strong&gt;&amp;nbsp; 将第reg寄存器与val相加，并将结果放入result寄存器 &lt;/li&gt; 
&lt;li&gt;&lt;b&gt;2 - show(reg)&lt;/b&gt; 将寄存器reg中的内容打印出来&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;因此下面这字节&lt;/p&gt;&lt;pre&gt;  [ 0, 0, 3,
    1, 0, 0, 4,
    2, 0 ]&lt;/pre&gt;
&lt;p&gt;就表明将3与4相加并打印出来这样一个简单的功能，结果嘛如果不出意思自然是7&lt;/p&gt;
&lt;p&gt;用C实现这个VM最平铺直叙的方法就是直接写就好了，如下&lt;/p&gt;&lt;pre class=&quot;blackboard&quot;&gt;&lt;span class=&quot;Storage&quot;&gt;void&lt;/span&gt; add(&lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt;* ops, &lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt;* registers) {
  registers[ops[&lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;]] = registers[ops[&lt;span class=&quot;Constant&quot;&gt;2&lt;/span&gt;]] + ops[&lt;span class=&quot;Constant&quot;&gt;3&lt;/span&gt;];
}

&lt;span class=&quot;Storage&quot;&gt;void&lt;/span&gt; set(&lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt;* ops, &lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt;* registers) {
  registers[ops[&lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;]] = ops[&lt;span class=&quot;Constant&quot;&gt;2&lt;/span&gt;];
}

&lt;span class=&quot;Storage&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;sh&lt;span class=&quot;Entity&quot;&gt;ow&lt;/span&gt;&lt;/span&gt;(&lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt;* ops, &lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt;* registers) {
  &lt;span class=&quot;Support&quot;&gt;printf&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;=&amp;gt; &lt;span class=&quot;StringInterpolation&quot;&gt;%d&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;, registers[ops[&lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;]]);
}

&lt;span class=&quot;Storage&quot;&gt;void&lt;/span&gt; run(&lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt;* ops, &lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt;* registers) {
  &lt;span class=&quot;Keyword&quot;&gt;switch&lt;/span&gt;(*ops) {
  &lt;span class=&quot;Keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;:
	set(ops, registers);
	ops += &lt;span class=&quot;Constant&quot;&gt;3&lt;/span&gt;;
    &lt;span class=&quot;Keyword&quot;&gt;break&lt;/span&gt;;
  &lt;span class=&quot;Keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;:
	add(ops, registers);
	ops += &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;;
    &lt;span class=&quot;Keyword&quot;&gt;break&lt;/span&gt;;
  &lt;span class=&quot;Keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;2&lt;/span&gt;:
	show(ops, registers);
    &lt;span class=&quot;Keyword&quot;&gt;return&lt;/span&gt;;
  }
}
&lt;/pre&gt;
&lt;p&gt;随后Evan还另给出一个去除switch的直接的不能再直接的版本：&lt;/p&gt;
&lt;pre class=&quot;blackboard&quot;&gt;&lt;span class=&quot;Storage&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;my_progr&lt;span class=&quot;Entity&quot;&gt;am&lt;/span&gt;&lt;/span&gt;() {
  &lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt; registers[&lt;span class=&quot;Constant&quot;&gt;2&lt;/span&gt;] = {&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;};
  &lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt; program[&lt;span class=&quot;Constant&quot;&gt;10&lt;/span&gt;] = [ &lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;3&lt;/span&gt;,
                      &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;,
                      &lt;span class=&quot;Constant&quot;&gt;2&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt; ]

  &lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt;* ops = (&lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt;*)program;

  set(ops, registers);
  ops += &lt;span class=&quot;Constant&quot;&gt;3&lt;/span&gt;;
  add(ops, registers);
  ops += &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;;
  show(ops, registers);
  ops += &lt;span class=&quot;Constant&quot;&gt;2&lt;/span&gt;;
}
&lt;/pre&gt;
&lt;p&gt;其实两者的功能是一样的，唯一的区别是前者更通用一点，可以在运行时执行，而后者比较象使用Bytecode直接翻译过来的样子。&lt;/p&gt;
&lt;p&gt;而且的确是这样，处理这样将Bytecode执行的一种最最静态的方法，就是写一个bc的C代码生成器(C code emitter)，将bc一次解析并产生一个类似第二段代码后几句的c代码文件，然后编译执行即可。&lt;/p&gt;
&lt;p&gt;不过这种方法最大的缺点就是太静态了，所以的东西已经在编译时就定了，这当然不是Rubinius可以使用的方式，至于如第一段代码那样，一个更动态一点的方法，就是写一个解释器，在运行时解析代码并动态执行。其实这就有点类似YARV的方式。&lt;br /&gt;除此之外有没有别的什么方法还执行bc呢？自然是有的，而且早就有很多人使用过了，那就是JIT(Just-in-time compilation)嘛:　JIT是一个不那么纯编译也不那么纯解释的方法，bc在被执行前，先被转成目标机器上的原生指令，然后再执行，因为这一过程是即时的生成的，因此可以在其中增加一个优化的环节。而且因为代码是即时生成的，因此它可以对生成的代码做一些caching，所以它要比一句一句“忠实”执行的解释器快，而且因为JIT能获得更多的运行时信息，如CPU的架构及代码执行统计信息，因此能够生成一些CPU“特化”的代码及运行时的优化工作，所以JIT也是很有可能比静态编译要快的。&lt;/p&gt;
&lt;p&gt;其实说了这么多也不过是为了引入今天所要谈的主角-----&lt;a href=&quot;http://llvm.org/&quot;&gt;LLVM&lt;/a&gt;: LLVM并不是一个编译器，而仅仅只是一个编译器的基础设施(infrastructure)，这个比较绕，其实它最有趣是提供了一套语言无关的中间层的优化与分析工具集。晕，其实这样说依然很绕:( 不过如果看一看Evan的例子之后可能会明白一些&lt;/p&gt;
&lt;p&gt;首先就算是JIT也是需要将Bytecode的语义，即set/add/show指令提供给LLVM滴，先将这三个函数放入一个ops.c文件中，再用到llvm-gcc工具了，它利用gcc的前端，将C代码转换成LLVM的bc文件&lt;/p&gt;
&lt;p&gt;命令如下&lt;/p&gt;
&lt;p&gt;&lt;code&gt;llvm-gcc -emit-llvm -O3 -c ops.c&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;这会生成一个ops.o的bc文件&lt;/p&gt;
&lt;p&gt;使用&lt;code&gt;llvm-dis &amp;lt; ops.o&lt;/code&gt;　命令查看，会看到与bc文件相对应的LLVM汇编指令&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class=&quot;blackboard&quot;&gt;@.&lt;span class=&quot;Entity&quot;&gt;str&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; internal constant [&lt;span class=&quot;Constant&quot;&gt;7&lt;/span&gt; x i8] c&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;=&amp;gt; %dA0&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;

define void &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;add&lt;/span&gt;(i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;ops, i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;registers) nounwind  {
entry:
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp1 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;ops, i32 &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp2 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; load i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp1, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp4 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;ops, i32 &lt;span class=&quot;Constant&quot;&gt;2&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp5 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; load i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp4, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp7 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;registers, i32 &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp5		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp8 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; load i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp7, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp10 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;ops, i32 &lt;span class=&quot;Constant&quot;&gt;3&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp11 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; load i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp10, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp12 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; add i32 &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp11, &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp8		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp14 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;registers, i32 &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp2		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	store i32 &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp12, i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp14, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;
	ret void
}

define void &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;set&lt;/span&gt;(i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;ops, i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;registers) nounwind  {
entry:
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp1 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;ops, i32 &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp2 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; load i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp1, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp4 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;ops, i32 &lt;span class=&quot;Constant&quot;&gt;2&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp5 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; load i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp4, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp7 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;registers, i32 &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp2		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	store i32 &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp5, i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp7, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;
	ret void
}

declare i32 &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;printf&lt;/span&gt;(i8&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt;, ...) nounwind 

define void &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;show&lt;/span&gt;(i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;ops, i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;registers) nounwind  {
entry:
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp1 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;ops, i32 &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp2 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; load i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp1, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp4 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;registers, i32 &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp2		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp5 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; load i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp4, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp7 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; tail call i32 (i8&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt;, ...)&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;printf&lt;/span&gt;( i8&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; getelementptr ([&lt;span class=&quot;Constant&quot;&gt;7&lt;/span&gt; x i8]&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; @.&lt;span class=&quot;Entity&quot;&gt;str&lt;/span&gt;, i32 &lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;, i32 &lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;), i32 &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp5 ) nounwind 		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=0]&lt;/span&gt;
	ret void
}
&lt;/pre&gt;
&lt;p&gt;无它，这个ops.o主要是拿来给LLVM使用的，在运行时生成相应的语义调用&lt;/p&gt;
&lt;p&gt;然后使用LLVM的C++ API来生成一段与第二段代码相应的LLVM代码&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class=&quot;blackboard&quot;&gt;Function* &lt;span class=&quot;Entity&quot;&gt;crea&lt;span class=&quot;Entity&quot;&gt;te&lt;/span&gt;&lt;/span&gt;(Module** out) {
  std::string error;
  Module* jit;

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; Load in the bitcode file containing the functions for each&lt;/span&gt;
  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; bytecode operation.&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt;(MemoryBuffer* buffer = MemoryBuffer::getFile(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;ops.o&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;, &amp;amp;error)) {
    jit = ParseBitcodeFile(buffer, &amp;amp;error);
    &lt;span class=&quot;Keyword&quot;&gt;delete&lt;/span&gt; buffer;
  }

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; Pull out references to them.&lt;/span&gt;
  Function* set =  jit-&amp;gt;getFunction(std::string(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;set&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;));
  Function* add =  jit-&amp;gt;getFunction(std::string(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;add&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;));
  Function* show = jit-&amp;gt;getFunction(std::string(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;show&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;));

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; Now, begin building our new function, which calls the&lt;/span&gt;
  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; above functions.&lt;/span&gt;
  Function* body = cast&amp;lt;Function&amp;gt;(jit-&amp;gt;getOrInsertFunction(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;body&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;,
        Type::VoidTy,
        PointerType::getUnqual(Type::Int32Ty),
        PointerType::getUnqual(Type::Int32Ty), (Type*)&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;));

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; Our function will be passed the ops pointer and the&lt;/span&gt;
  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; registers pointer, just like before.&lt;/span&gt;
  Function::arg_iterator args = body-&amp;gt;arg_begin();
  Value* ops = args++;
  ops-&amp;gt;setName(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;ops&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;);
  Value* registers = args++;
  registers-&amp;gt;setName(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;registers&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;);

  BasicBlock *bb = BasicBlock::Create(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;entry&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;, body);

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; Set up our arguments to be passed to set.&lt;/span&gt;
  std::vector&amp;lt;Value*&amp;gt; params;
  params.push_back(ops);
  params.push_back(registers);

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; Call out to set, passing ops and registers down&lt;/span&gt;
  CallInst* call = CallInst::Create(set, params.begin(), params.end(), &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;, bb);
  ConstantInt* const_3 = ConstantInt::get(APInt(&lt;span class=&quot;Constant&quot;&gt;32&lt;/span&gt;,  &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;3&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;10&lt;/span&gt;));
  ConstantInt* const_4 = ConstantInt::get(APInt(&lt;span class=&quot;Constant&quot;&gt;32&lt;/span&gt;,  &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;4&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;10&lt;/span&gt;));

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; add 3 to the ops pointer.&lt;/span&gt;
  GetElementPtrInst* ptr1 = GetElementPtrInst::Create(ops, const_3, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;tmp3&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;, bb);

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; Setup and call add, notice we pass down the updated ops pointer&lt;/span&gt;
  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; rather than the original, so that we've moved down.&lt;/span&gt;
  std::vector&amp;lt;Value*&amp;gt; params2;
  params2.push_back(ptr1);
  params2.push_back(registers);
  CallInst* call2 = CallInst::Create(add, params2.begin(), params2.end(), &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;, bb);

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; Push the ops pointer down another 4.&lt;/span&gt;
  GetElementPtrInst* ptr2 = GetElementPtrInst::Create(ops, const_4, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;tmp3&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;, bb);

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; Setup and call show.&lt;/span&gt;
  std::vector&amp;lt;Value*&amp;gt; params3;
  params3.push_back(ptr2);
  params3.push_back(registers);
  CallInst* call3 = CallInst::Create(show, params3.begin(), params3.end(), &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;, bb);

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; And we're done!&lt;/span&gt;
  ReturnInst::Create(bb);

  *out = jit;
  &lt;span class=&quot;Keyword&quot;&gt;return&lt;/span&gt; body;
}

&lt;/pre&gt;
&lt;p&gt;然后调用之&lt;/p&gt;&lt;pre class=&quot;blackboard&quot;&gt;&lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;ma&lt;span class=&quot;Entity&quot;&gt;in&lt;/span&gt;&lt;/span&gt;() {
  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; The registers.&lt;/span&gt;
  &lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt; registers[&lt;span class=&quot;Constant&quot;&gt;2&lt;/span&gt;] = {&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;};

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; Our program.&lt;/span&gt;
  &lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt; program[&lt;span class=&quot;Constant&quot;&gt;20&lt;/span&gt;] = {&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;3&lt;/span&gt;,
                     &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;,
                     &lt;span class=&quot;Constant&quot;&gt;2&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;};

  &lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt;* ops = (&lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt;*)program;

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; Create our function and give us the Module and Function back.&lt;/span&gt;
  Module* jit;
  Function* func = create(&amp;amp;jit);

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; Add in optimizations. These were taken from a list that 'opt', LLVMs optimization tool, uses.&lt;/span&gt;
  PassManager p;

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;/*&lt;/span&gt; Comment out optimize&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;  p.add(new TargetData(jit));&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;  p.add(createVerifierPass());&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;  p.add(createLowerSetJmpPass());&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;  p.add(createRaiseAllocationsPass());&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;  p.add(createCFGSimplificationPass());&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;  p.add(createPromoteMemoryToRegisterPass());&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;  p.add(createGlobalOptimizerPass());&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;  p.add(createGlobalDCEPass());&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;  p.add(createFunctionInliningPass());&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;  &lt;span class=&quot;Comment&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; Run these optimizations on our Module&lt;/span&gt;
  p.run(*jit);

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; Setup for JIT&lt;/span&gt;
  ExistingModuleProvider* mp = &lt;span class=&quot;Keyword&quot;&gt;new&lt;/span&gt; ExistingModuleProvider(jit);
  ExecutionEngine* engine = ExecutionEngine::create(mp);

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; Show us what we've created!&lt;/span&gt;
  std::cout &amp;lt;&amp;lt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;Created&lt;/span&gt;
&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &amp;lt;&amp;lt; *jit;

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; Have our function JIT'd into machine code and return. We cast it to a particular C function pointer signature so we can call in nicely.&lt;/span&gt;
  &lt;span class=&quot;Storage&quot;&gt;void&lt;/span&gt; (*fp)(&lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt;*, &lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt;*) = (&lt;span class=&quot;Storage&quot;&gt;void&lt;/span&gt; (*)(&lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt;*, &lt;span class=&quot;Storage&quot;&gt;int&lt;/span&gt;*))engine-&amp;gt;getPointerToFunction(func);

  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;//&lt;/span&gt; Call what we've created!&lt;/span&gt;
  fp(ops, registers);
}
&lt;/pre&gt;
&lt;p&gt;最后的结果会是这样&lt;/p&gt;
&lt;pre class=&quot;blackboard&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;snip same &lt;span class=&quot;Variable&quot;&gt;LLVM&lt;/span&gt; as before&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;

define void &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;body&lt;/span&gt;(i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;ops, i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;registers) {
entry:
call void &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;set&lt;/span&gt;( i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;ops, i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;registers )
&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp3 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;ops, i32 &lt;span class=&quot;Constant&quot;&gt;3&lt;/span&gt; ;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
call void &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;add&lt;/span&gt;( i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp3, i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;registers )
&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp31 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;ops, i32 &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt; ;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
call void &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;show&lt;/span&gt;( i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp31, i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;registers )
ret void
}
=&amp;gt; &lt;span class=&quot;Constant&quot;&gt;7&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;bc被执行了，不是吗？而且上面的那个boby就如同是&lt;span class=&quot;Entity&quot;&gt;my_progr&lt;span class=&quot;Entity&quot;&gt;am最后几行代码最直白的翻译，不同这处只是它是用API来产生的而已。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;Entity&quot;&gt;&lt;span class=&quot;Entity&quot;&gt;不过等等，最有趣的在后面，如果将LLVM的优化功能全部打开了之后，我们能得到什么？&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;Entity&quot;&gt;&lt;span class=&quot;Entity&quot;&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class=&quot;blackboard&quot;&gt;define void &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;body&lt;/span&gt;(i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;ops, i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;registers) {
entry:
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp1.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;ops, i32 &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp2.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; load i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp1.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt;, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp4.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;ops, i32 &lt;span class=&quot;Constant&quot;&gt;2&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp5.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; load i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp4.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt;, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp7.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;registers, i32 &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp2.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	store i32 &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp5.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt;, i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp7.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt;, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp3 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;ops, i32 &lt;span class=&quot;Constant&quot;&gt;3&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=3]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp1.&lt;span class=&quot;Entity&quot;&gt;i7&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp3, i32 &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp2.&lt;span class=&quot;Entity&quot;&gt;i8&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; load i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp1.&lt;span class=&quot;Entity&quot;&gt;i7&lt;/span&gt;, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp4.&lt;span class=&quot;Entity&quot;&gt;i9&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp3, i32 &lt;span class=&quot;Constant&quot;&gt;2&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp5.&lt;span class=&quot;Entity&quot;&gt;i10&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; load i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp4.&lt;span class=&quot;Entity&quot;&gt;i9&lt;/span&gt;, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp7.&lt;span class=&quot;Entity&quot;&gt;i11&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;registers, i32 &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp5.&lt;span class=&quot;Entity&quot;&gt;i10&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp8.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; load i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp7.&lt;span class=&quot;Entity&quot;&gt;i11&lt;/span&gt;, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp10.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp3, i32 &lt;span class=&quot;Constant&quot;&gt;3&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp11.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; load i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp10.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt;, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp12.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; add i32 &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp11.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt;, &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp8.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp14.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;registers, i32 &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp2.&lt;span class=&quot;Entity&quot;&gt;i8&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	store i32 &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp12.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt;, i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp14.&lt;span class=&quot;Entity&quot;&gt;i&lt;/span&gt;, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp31 &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;ops, i32 &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp1.&lt;span class=&quot;Entity&quot;&gt;i2&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp31, i32 &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp2.&lt;span class=&quot;Entity&quot;&gt;i3&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; load i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp1.&lt;span class=&quot;Entity&quot;&gt;i2&lt;/span&gt;, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp4.&lt;span class=&quot;Entity&quot;&gt;i4&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; getelementptr i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;registers, i32 &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp2.&lt;span class=&quot;Entity&quot;&gt;i3&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp5.&lt;span class=&quot;Entity&quot;&gt;i5&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; load i32&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp4.&lt;span class=&quot;Entity&quot;&gt;i4&lt;/span&gt;, align &lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=1]&lt;/span&gt;
	&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp7.&lt;span class=&quot;Entity&quot;&gt;i6&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; call i32 (i8&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt;, ...)&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;printf&lt;/span&gt;( i8&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; getelementptr ([&lt;span class=&quot;Constant&quot;&gt;7&lt;/span&gt; x i8]&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; @.&lt;span class=&quot;Entity&quot;&gt;str&lt;/span&gt;, i32 &lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;, i32 &lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;), i32 &lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;tmp5.&lt;span class=&quot;Entity&quot;&gt;i5&lt;/span&gt; ) nounwind 		;  [&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;uses=0]&lt;/span&gt;
	ret void
}
=&amp;gt; &lt;span class=&quot;Constant&quot;&gt;7&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;对，函数被LLVM给Inline化了，强吧！Evan称之为使用核能做饭，呵呵。&lt;/p&gt;
&lt;p&gt;嗯，的确是很趣，那么我们从中又能学到什么呢？使用LLVM强大的中间层基础设施，可以为rubinius的bc执行带来强大的JIT功能。至于rubinius真的是怎样做到，让我读读rubinius的代码之后再接着谈吧:)&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://leeseon.com/">
    <author>
      <name>leeseon</name>
    </author>
    <id>tag:leeseon.com,2008-09-06:28</id>
    <published>2008-09-06T18:50:00Z</published>
    <updated>2008-10-07T14:08:51Z</updated>
    <category term="dreamhost"/>
    <category term="leeseon"/>
    <category term="promo code"/>
    <link href="http://leeseon.com/2008/9/6/dreamhost_promo_code_leeseon" rel="alternate" type="text/html"/>
    <title>&#20570;&#19979;&#24191;&#21578;&#21543;Promo Code: LEESEON</title>
<content type="html">
            &lt;p&gt;无意间发现&lt;a href=&quot;http://www.dreamhost.com/r.cgi?282910&quot;&gt;DreamHost&lt;/a&gt; 最近在搞优惠活动，凡是在9月10号之前注册的用户，都能享受无限的(之前是500G)磁盘空间与无限的带宽(之前是5T)。呵呵，其实这当然是有一点噱头的成份在里面，毕竟500G与5T(每周都会涨的)我是根本没有用完过，不过如果你认为你一定能用完，或者你梦想远大，或者只为了YY，那你可以赶紧注册一个噢!&lt;/p&gt;


	&lt;p&gt;当然当然最重要的就是，呵呵，使用我的PROMO &lt;span class=&quot;caps&quot;&gt;CODE&lt;/span&gt;：&lt;strong&gt;&lt;span class=&quot;caps&quot;&gt;LEESEON&lt;/span&gt;&lt;/strong&gt; 噢，这个是能打折滴，以前是$97，现在也就只有$50了，看来老外滑头起来也是不差的&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://www.slide.com/s/7XR8siYX7j9pX-H9gIIpX48muIiuRz1-?referrer=hlnk&quot;&gt;&lt;img title=&quot;免费无限存放图片在slide.com!&quot; src=&quot;http://widget.slide.com/rdr/1/1/1/W/2500000003fc4baa/1/118/dGJLfAwY3D9FeEigRy1f-cnKep93ZREK.jpg&quot; alt=&quot;免费无限存放图片在slide.com!&quot; /&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;自然自然无利不起早嘛，听说使用我的Promo Code我是能赚钱滴&#8212;俺从来没有拿到过:(,不过还是要佩服一下这种有点象传销一般的病毒式商业运作方式&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://leeseon.com/">
    <author>
      <name>leeseon</name>
    </author>
    <id>tag:leeseon.com,2008-09-06:27</id>
    <published>2008-09-06T15:28:00Z</published>
    <updated>2008-09-06T17:45:56Z</updated>
    <category term="edge rails"/>
    <category term="mephisto"/>
    <category term="mephisto 0.8"/>
    <link href="http://leeseon.com/2008/9/6/mephisto0-8_error_maybe_from_edge_rails" rel="alternate" type="text/html"/>
    <title>mephisto0.8&#20986;&#38169;&#20102;:(</title>
<content type="html">
            &lt;p&gt;好久没有写blog了，最近才发现游戏公司忙起来还真的不是一般的忙，现在对那著名的“对EA的血泪控诉”也开始是感同身受了啊，唉!&lt;/p&gt;


&lt;p&gt;好在最近闲下来了一点，而且发现自己的gmail里面堆满了从dreamhost发过来的Cron Daemon的错误提示，提示我mephisto的/admin出错了。&lt;/p&gt;


&lt;p&gt;本来没有当回事，估计是因为dreamhost的rails升级到2.1.0引起的，当时我使用mephisto0.8，因为正好系统中有rails 2.0.2一时偷懒没有将rails freeze起来，心想应该freeze一下就没有问题了。二话不说，开工，运行&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;
rake rails:freeze:gems VERSION=2.0.2
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;本以为重启一下服务就能好了，谁知出了一堆错，提示我 &#8220;undefined method &#8216;install_gem_spec_stubs&#8217;&#8221;&lt;/p&gt;

&lt;p&gt;查了一下文档，不对啊，install_gem_spec_stubs可是rails2.1.0中的函数啊，怎么会出现在mephisto 0.8之中，怪啊，不过即然如此，拿2.0.2试试便知，运行&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;
rails _2.0.2_ testrails
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;打开config/boot.rb看了看，根本不用比较工具就能发现mephisto0.8的文件中的确是多出一行，注掉即可&lt;/p&gt;

&lt;pre class=&quot;blackboard&quot;&gt;  &lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;VendorBoot&lt;span class=&quot;Superclass&quot;&gt; &lt;span class=&quot;Superclass&quot;&gt;&amp;lt;&lt;/span&gt; Boot&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;load_initializer&lt;/span&gt;
      &lt;span class=&quot;Keyword&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;Variable&quot;&gt;RAILS_ROOT&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;}&lt;/span&gt;&lt;/span&gt;/vendor/rails/railties/lib/initializer&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;      &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;Rails::Initializer.run(:install_gem_spec_stubs)&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;想想，可能是因为使用edge rails来生成的mephisto 0.8的原始文件的吧&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://leeseon.com/">
    <author>
      <name>leeseon</name>
    </author>
    <id>tag:leeseon.com,2008-07-06:26</id>
    <published>2008-07-06T18:24:00Z</published>
    <updated>2008-07-06T19:18:00Z</updated>
    <category term="capistrano"/>
    <category term="deployment"/>
    <category term="rails"/>
    <category term="source control"/>
    <link href="http://leeseon.com/2008/7/6/capistrano_deploy_and_source_control_practice" rel="alternate" type="text/html"/>
    <title>Capistrano&#37197;&#32622;&#21450;&#29256;&#26412;&#25511;&#21046;&#23454;&#36341;</title>
<content type="html">
            &lt;p&gt;以前一直都将&lt;a href=&quot;http://www.capify.org/&quot;&gt;Capistrano&lt;/a&gt; 的deploy.rb的文件放在SVN中，最近需要将代码共享给别人一同开发，这才发现了有一个问题，就是我的空间帐号与数据库的密码是不希望让人知道，毕竟知道的人越少越好嘛。&lt;/p&gt;


	&lt;p&gt;而且最近做了一件傻事，就是以前我都是将&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
ENV[&quot;GEM_HOME&quot;]=&quot;/home/yourusername/.gems&quot; 
ENV[&quot;GEM_PATH&quot;]=&quot;/home/yourusername/.gems:/usr/lib/ruby/gems/1.8&quot; 
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;这样的配置放在dispatch.fcgi中，现在因为使用了&lt;a href=&quot;http://www.modrails.com/&quot;&gt;Phusion Passenger&lt;/a&gt; (mod_rails)之后，这一段的内容放在了config/enviroment.rb之中，所以在windows上运行rake test时，出现了找不到gems的错误，一时没有想到了这样的问题，还费了半天的功夫:(&lt;/p&gt;


	&lt;p&gt;于是鉴于这些问题，deploy.rb原则上不需要放在版本控制中的，而且database.yml与enviroment.rb也不需要放在版本控制之中，这些文件可以另外保存，与rails代码分开，放在另一个版本控制之中，并且放在share_dir中，在部署时拷贝到相应的目录之中。&lt;/p&gt;


	&lt;p&gt;想做到这样，只需要在deploy.rb中增加一个任务&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;before &quot;deploy:restart&quot;, 'deploy:copy_config'
desc &quot;Copy the configuration file &quot; 
task :copy_config, :roles =&amp;gt; :app, :except =&amp;gt; { :no_release =&amp;gt;  true  }   do
  run &quot;cp -f #{shared_dir}/environment.rb #{current_path}/config/environment.rb&quot; 
  run &quot;cp -f #{shared_dir}/database.yml #{current_path}/config/database.yml&quot; 
end&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;即可&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://leeseon.com/">
    <author>
      <name>leeseon</name>
    </author>
    <id>tag:leeseon.com,2008-07-06:25</id>
    <published>2008-07-06T15:35:00Z</published>
    <updated>2008-07-09T14:58:32Z</updated>
    <category term="dreamhost"/>
    <category term="rails"/>
    <category term="Ruby"/>
    <category term="ruby"/>
    <category term="shell"/>
    <link href="http://leeseon.com/2008/7/6/new_dreamhost_ruby_and_rails_shell" rel="alternate" type="text/html"/>
    <title>&#26356;&#26032;&#20102;&#19968;&#19979;&#33050;&#26412;</title>
<content type="html">
            &lt;p&gt;自从&lt;a href=&quot;http://leeseon.com/2008/5/9/the_simplest_way_install_ruby_gems_rails_on_dreamhost&quot;&gt;上回&lt;/a&gt; 之后，ruby、rails与gems也都开始更新了，于是也更新了一下安装脚本，如下：&lt;/p&gt;


&lt;div class=&quot;jssc&quot;&gt;&lt;ul&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;mkdir ~/.gems
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;echo &lt;span class=&quot;cchar&quot;&gt;&#8216;export &lt;span class=&quot;caps&quot;&gt;GEM&lt;/span&gt;_HOME=&#8221;$HOME/.gems&#8221;&#8217;&lt;/span&gt; &amp;gt;&amp;gt; .bash_profile
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;echo &lt;span class=&quot;cchar&quot;&gt;&#8216;export &lt;span class=&quot;caps&quot;&gt;GEM&lt;/span&gt;_PATH=&#8221;$GEM_HOME:/usr/lib/ruby/gems/1.8&#8221;&#8217;&lt;/span&gt; &amp;gt;&amp;gt; .bash_profile
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;echo &lt;span class=&quot;cchar&quot;&gt;&#8216;export &lt;span class=&quot;caps&quot;&gt;PATH&lt;/span&gt;=&#8221;$HOME/.gems/bin:$PATH&#8221;&#8217;&lt;/span&gt; &amp;gt;&amp;gt; .bash_profile
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;echo &lt;span class=&quot;cchar&quot;&gt;&#8216;export &lt;span class=&quot;caps&quot;&gt;PATH&lt;/span&gt;=&#8221;$HOME/local/bin:$PATH&#8221;&#8217;&lt;/span&gt; &amp;gt;&amp;gt; .bash_profile
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;. ~/.bash_profile
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;echo $PATH
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;touch ~/.gemrc
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;echo gemhome:/home/$(whoami)/.gems &amp;gt;&amp;gt; ~/.gemrc
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;echo gempath: &amp;gt;&amp;gt; ~/.gemrc
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;echo -/home/$(whoami)/.gems &amp;gt;&amp;gt; ~/.gemrc
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;echo -/usr/lib/ruby/gems/1.8 &amp;gt;&amp;gt; ~/.gemrc
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span class=&quot;ccomment&quot;&gt;# setup directories
&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;mkdir -p ~/local/usr/src/ruby
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;cd ~/local/usr/src/ruby
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span class=&quot;ccomment&quot;&gt;# Install readline
&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;wget &lt;span class=&quot;htmlstring&quot;&gt;ftp://ftp.cwru.edu/pub/bash/readline-5.2.tar.gz&lt;/span&gt;
&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;tar zxvf readline-5.2.tar.gz
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;cd readline-5.2
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;./configure&#8212;prefix=$HOME/local
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;make
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;make install
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;cd ..
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span class=&quot;ccomment&quot;&gt;# install ruby
&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;wget &lt;span class=&quot;htmlstring&quot;&gt;ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p22.tar.bz2&lt;/span&gt;
&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;tar jxvf ruby-1.8.7-p22.tar.bz2
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;cd ruby-1.8.7-p22
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;./configure&#8212;prefix=$HOME/local&#8212;with-readline-dir=$HOME/local/
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;make
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;make install
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;cd ..
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span class=&quot;ccomment&quot;&gt;# fix path
&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;export &lt;span class=&quot;caps&quot;&gt;PATH&lt;/span&gt;=$HOME/local/bin:$PATH
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span class=&quot;ccomment&quot;&gt;# get rubygems
&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;wget &lt;span class=&quot;htmlstring&quot;&gt;http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz&lt;/span&gt;
&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;tar zxvf rubygems-1.2.0.tgz
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;cd rubygems-1.2.0
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;$HOME/local/bin/ruby setup.rb config&#8212;prefix=$HOME/local
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;$HOME/local/bin/ruby setup.rb setup
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;$HOME/local/bin/ruby setup.rb install
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;cd ..
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span class=&quot;ccomment&quot;&gt;# Install &lt;span class=&quot;caps&quot;&gt;RAILS&lt;/span&gt;
&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;gem install rails
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span class=&quot;ccomment&quot;&gt;# Install FastCGI
&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;curl -O &lt;span class=&quot;htmlstring&quot;&gt;http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz&lt;/span&gt;
&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;tar xzvf fcgi-2.4.0.tar.gz
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;cd fcgi-2.4.0
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;./configure&#8212;prefix=$HOME/local
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;make
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;make install
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;cd ..
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span class=&quot;ccomment&quot;&gt;# Install FastCGI &amp;amp; MySQL gem packages
&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;gem install fcgi&#8212;&#8212;with-fcgi-dir=$HOME/local
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;div&gt;gem install mysql&#8212;&#8212;with-mysql-config
&lt;/div&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span class=&quot;ccomment&quot;&gt;# gem  update&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;

	&lt;p&gt;关于脚本的解释可以看&lt;a href=&quot;http://leeseon.com/2008/5/10/the_simplest_way_install_ruby_gems_rails_on_dreamhost_2&quot;&gt;以前&lt;/a&gt; 的说明，这次仅仅只是版本上的更新而已，不再多做说明&lt;/p&gt;


	&lt;p&gt;文件依然放在&lt;a href=&quot;http://leeseon.com/private/allinstall.sh&quot;&gt;http://leeseon.com/private/allinstall.sh&lt;/a&gt; 处&lt;/p&gt;


	&lt;p&gt;也同样可以使用&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
curl http://leeseon.com/private/allinstall.sh | sh
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;来执行，无它、、、&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://leeseon.com/">
    <author>
      <name>leeseon</name>
    </author>
    <id>tag:leeseon.com,2008-06-22:24</id>
    <published>2008-06-22T17:19:00Z</published>
    <updated>2008-06-22T17:29:07Z</updated>
    <category term="news"/>
    <category term="rails"/>
    <category term="Ruby"/>
    <category term="ruby"/>
    <link href="http://leeseon.com/2008/6/22/rails_ruby_community_faster_and_faster" rel="alternate" type="text/html"/>
    <title>Rails/Ruby&#31038;&#21306;&#36234;&#26469;&#36234;&#24555;&#20102;</title>
<content type="html">
            &lt;p&gt;Rails在6.1号就已经发布2.1了，这个号称参与人数最多，代码更改行数最多的版本，就这么漫不经心地来了。最近gems也发布1.2了，而且中文版本的《what&#8217;s new in rails 2.1》也基本上在网络上翻译好了，rails的社区参与度与活跃度也最来最高了，这样的rails/ruby社区怎能不越来越快？&lt;/p&gt;


	&lt;p&gt;最近依然在忙碌中度过，上来写写博文只能算是应个景儿，有点对不起自己了:(&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://leeseon.com/">
    <author>
      <name>leeseon</name>
    </author>
    <id>tag:leeseon.com,2008-06-05:23</id>
    <published>2008-06-05T15:53:00Z</published>
    <updated>2008-06-05T16:05:42Z</updated>
    <category term="Joke"/>
    <category term="joke"/>
    <category term="news"/>
    <category term="rails"/>
    <category term="Ruby"/>
    <category term="ruby"/>
    <link href="http://leeseon.com/2008/6/5/running_on_rails" rel="alternate" type="text/html"/>
    <title>running on rails-----&#22312;&#38081;&#36712;&#19978;&#22868;&#36305;&#36895;&#24230;&#33258;&#28982;&#23601;&#20250;&#24555;:P</title>
<content type="html">
            &lt;p&gt;最近一直忙于工作，居然有两周没有写blog了，不过也不是完全没有时间写，只是因为实在是没有什么时间来实践rails上的一些新东东，觉得言之无物:(&lt;/p&gt;


	&lt;p&gt;不过ruby/rails社区最近却是如大事连连：先是rails 2.1的发布，还有就是ironruby在rubinius之后也宣布可以运行rails了，这个所有ruby实现都视之为重要目标的里程碑。&lt;/p&gt;


	&lt;p&gt;一旦运行上了轨道，后面自然是一发而不可收拾噢，虽然我对ironruby的兴趣缺缺的说&lt;/p&gt;


	&lt;p&gt;只是偶然发现ruby on rails的这个名字真的很有趣，以至于我自己能生造出Running On Rails这样古怪的半通不通的双关来，算是玩笑吧:P&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://leeseon.com/">
    <author>
      <name>leeseon</name>
    </author>
    <id>tag:leeseon.com,2008-05-19:22</id>
    <published>2008-05-19T16:28:00Z</published>
    <updated>2008-05-19T16:43:01Z</updated>
    <category term="news"/>
    <category term="rails"/>
    <category term="rubinius"/>
    <link href="http://leeseon.com/2008/5/19/rubinius_supports_rails" rel="alternate" type="text/html"/>
    <title>Rubinius&#24320;&#22987;&#25903;&#25345;rails&#20102;</title>
<content type="html">
            &lt;p&gt;不是我不明白，只是这个世界变得快!&lt;/p&gt;


	&lt;p&gt;最近因为地震的原因，在网上看新闻的时侯比较多，对于ruby的新进展的了解要慢了几拍：&lt;/p&gt;


	&lt;p&gt;昨天才知道dreamhost已经开始支持mod_rails了，还写下了一篇&lt;a href=&quot;http://leeseon.com/2008/5/18/mod_rails-on-dreamhost&quot;&gt;酸溜溜的blog&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;今天也是通过从InfoQ订阅的新闻中得知Rubinius开始支持rails了，好消息啊，这是续它支持gems与merb之后又一重大的里程碑啊，贺之！看来以后新的rails的基于rubinius的host主机很可能会出现了，最有可能的自然是&lt;a href=&quot;http://engineyard.com/&quot;&gt;engineyard&lt;/a&gt; 了，只是不希望太贵噢，这样我还能试试，不过想来可能性不大:(&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://leeseon.com/">
    <author>
      <name>leeseon</name>
    </author>
    <id>tag:leeseon.com,2008-05-19:21</id>
    <published>2008-05-19T14:44:00Z</published>
    <updated>2008-05-19T16:16:08Z</updated>
    <category term="capistrano"/>
    <category term="dreamhost"/>
    <category term="mod_rails"/>
    <link href="http://leeseon.com/2008/5/19/capistrino-on-dreamhost-with-mod_rails" rel="alternate" type="text/html"/>
    <title>&#20351;&#29992;Capistrano&#22312;Dreamhost&#19978;&#37096;&#32626;mod_rails</title>
<content type="html">
            &lt;p&gt;虽然以前&lt;a href=&quot;http://capify.org/&quot;&gt;Capistrno&lt;/a&gt; 在windows下不能使用，但是自从2.0以后，其实就是可以使用的了。而且现在的2.3还加入了对git的支持。&lt;/p&gt;


	&lt;p&gt;而且从&lt;a href=&quot;http://www.infoq.com/cn/news/2008/05/rails-deployment-roundup&quot;&gt;InfoQ&lt;/a&gt; 上得知&lt;a href=&quot;http://tomcopeland.blogs.com/juniordeveloper/2008/05/mod_rails-and-c.html&quot;&gt;Tom Copeland&lt;/a&gt; 已经使用Capistrano来更新mod_rails了,的确如它所说，只是给这个应用程序建立了一个“restart.txt”文件，就会导致Passenger Phusion/mod_rails重启这个应用程序。的确很简单明了不是吗？&lt;/p&gt;


	&lt;p&gt;最终的deploy.rb文件看起来会象下面这样&lt;/p&gt;

&lt;div class=&quot;jssc&quot;&gt;
  &lt;ul&gt;
    &lt;li class=&quot;alt&quot;&gt;
      &lt;div&gt;
        
set&amp;nbsp;:scm,&amp;nbsp;:subversion      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;div&gt;
        
set&amp;nbsp;:repository,&amp;nbsp;        &lt;span class=&quot;cstring&quot;&gt;
&amp;quot;http://yoursvn/trunk&amp;quot;        &lt;/span&gt;
      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li class=&quot;alt&quot;&gt;
      &lt;div&gt;
        
set&amp;nbsp;:svn_username,&amp;nbsp;        &lt;span class=&quot;cstring&quot;&gt;
&amp;quot;svnuser&amp;quot;        &lt;/span&gt;
      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;div&gt;
        
set&amp;nbsp;:svn_password,&amp;nbsp;        &lt;span class=&quot;cstring&quot;&gt;
&amp;quot;svnpassword&amp;quot;        &lt;/span&gt;
      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li class=&quot;alt&quot;&gt;
      &lt;div&gt;
        
&amp;nbsp;      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;div&gt;
        
role&amp;nbsp;:app,&amp;nbsp;        &lt;span class=&quot;cstring&quot;&gt;
&amp;quot;www.yourdomain.com&amp;quot;        &lt;/span&gt;
      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li class=&quot;alt&quot;&gt;
      &lt;div&gt;
        
role&amp;nbsp;:web,&amp;nbsp;        &lt;span class=&quot;cstring&quot;&gt;
&amp;quot;www.yourdomain.com&amp;quot;        &lt;/span&gt;
      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;div&gt;
        
role&amp;nbsp;:db,&amp;nbsp;&amp;nbsp;        &lt;span class=&quot;cstring&quot;&gt;
&amp;quot;www.yourdomain.com&amp;quot;        &lt;/span&gt;
,&amp;nbsp;:primary&amp;nbsp;=&amp;gt;&amp;nbsp;        &lt;span class=&quot;ckeywords&quot;&gt;
true        &lt;/span&gt;
      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li class=&quot;alt&quot;&gt;
      &lt;div&gt;
        
&amp;nbsp;      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;div&gt;
        
set&amp;nbsp;:deploy_to,&amp;nbsp;        &lt;span class=&quot;cstring&quot;&gt;
&amp;quot;/home/yourusername/&amp;quot;        &lt;/span&gt;
      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li class=&quot;alt&quot;&gt;
      &lt;div&gt;
        
set&amp;nbsp;:user,&amp;nbsp;        &lt;span class=&quot;cstring&quot;&gt;
&amp;quot;yourusername&amp;quot;        &lt;/span&gt;
      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;div&gt;
        
set&amp;nbsp;:password,&amp;nbsp;        &lt;span class=&quot;cstring&quot;&gt;
&amp;quot;yourpassword&amp;quot;        &lt;/span&gt;
      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li class=&quot;alt&quot;&gt;
      &lt;div&gt;
        
&amp;nbsp;      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;div&gt;
        
set&amp;nbsp;:use_sudo,&amp;nbsp;        &lt;span class=&quot;ckeywords&quot;&gt;
false        &lt;/span&gt;
      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li class=&quot;alt&quot;&gt;
      &lt;div&gt;
        
&amp;nbsp;      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;div&gt;
        
namespace&amp;nbsp;:deploy&amp;nbsp;        &lt;span class=&quot;ckeywords&quot;&gt;
do        &lt;/span&gt;
      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li class=&quot;alt&quot;&gt;
      &lt;div&gt;
        
&amp;nbsp;&amp;nbsp;desc&amp;nbsp;        &lt;span class=&quot;cstring&quot;&gt;
&amp;quot;restarting&amp;nbsp;mod_rails&amp;nbsp;with&amp;nbsp;restart.txt&amp;quot;        &lt;/span&gt;
      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;div&gt;
        
&amp;nbsp;&amp;nbsp;task&amp;nbsp;:restart,&amp;nbsp;:roles&amp;nbsp;=&amp;gt;&amp;nbsp;:app,&amp;nbsp;:except&amp;nbsp;=&amp;gt;&amp;nbsp;{&amp;nbsp;:no_release&amp;nbsp;=&amp;gt;&amp;nbsp;        &lt;span class=&quot;ckeywords&quot;&gt;
true        &lt;/span&gt;
&amp;nbsp;}&amp;nbsp;        &lt;span class=&quot;ckeywords&quot;&gt;
do        &lt;/span&gt;
      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li class=&quot;alt&quot;&gt;
      &lt;div&gt;
        
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;run&amp;nbsp;        &lt;span class=&quot;cstring&quot;&gt;
&amp;quot;touch&amp;nbsp;#{current_path}/tmp/restart.txt&amp;quot;        &lt;/span&gt;
      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;div&gt;
        
&amp;nbsp;&amp;nbsp;end      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li class=&quot;alt&quot;&gt;
      &lt;div&gt;
        
&amp;nbsp;      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;div&gt;
        
&amp;nbsp;&amp;nbsp;[:start,&amp;nbsp;:stop].each&amp;nbsp;        &lt;span class=&quot;ckeywords&quot;&gt;
do        &lt;/span&gt;
&amp;nbsp;|t|      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li class=&quot;alt&quot;&gt;
      &lt;div&gt;
        
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;desc&amp;nbsp;        &lt;span class=&quot;cstring&quot;&gt;
&amp;quot;#{t}&amp;nbsp;task&amp;nbsp;is&amp;nbsp;a&amp;nbsp;no-op&amp;nbsp;with&amp;nbsp;mod_rails&amp;quot;        &lt;/span&gt;
      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;div&gt;
        
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;task&amp;nbsp;t,&amp;nbsp;:roles&amp;nbsp;=&amp;gt;&amp;nbsp;:app&amp;nbsp;        &lt;span class=&quot;ckeywords&quot;&gt;
do        &lt;/span&gt;
&amp;nbsp;;&amp;nbsp;end      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li class=&quot;alt&quot;&gt;
      &lt;div&gt;
        
&amp;nbsp;&amp;nbsp;end      &lt;/div&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;div&gt;
        
end      &lt;/div&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;
          </content>  </entry>
  <entry xml:base="http://leeseon.com/">
    <author>
      <name>leeseon</name>
    </author>
    <id>tag:leeseon.com,2008-05-18:20</id>
    <published>2008-05-18T09:27:00Z</published>
    <updated>2008-06-09T16:04:52Z</updated>
    <category term="dreamhost"/>
    <category term="mod_rails"/>
    <link href="http://leeseon.com/2008/5/18/mod_rails-on-dreamhost" rel="alternate" type="text/html"/>
    <title>dreamhost&#30495;&#30340;&#24320;&#22987;&#25903;&#25345;mod_rails&#20102;</title>
<content type="html">
            &lt;p&gt;呵呵，这个当然是好事，只可惜我&lt;a href=&quot;http://leeseon.com/2008/5/9/the_simplest_way_install_ruby_gems_rails_on_dreamhost&quot;&gt;一语成谶&lt;/a&gt; ， 正好在&lt;a href=&quot;http://www.dreamhost.com&quot;&gt;DreamHost&lt;/a&gt; 支持mod_rails的两天之前写了两篇关于怎样在dreamhost上安装ruby、rails与gems的&lt;a href=&quot;http://leeseon.com/2008/5/10/the_simplest_way_install_ruby_gems_rails_on_dreamhost_2&quot;&gt;blog&lt;/a&gt;,  当然现在这些东东已经过期了，不再有用了，看来以后有什么心得就需要立刻记下来，第一为了免得稍纵即逝错过了最想记录下来的冲动时刻，第二也许我早点写出来，可能会对大家更有用，起码能让后来者少起点弯路（有点自以为的是地想）。当然做我们这么行，知识的过期是再正常不过的了，不过当年在那儿探索的苦恼与成功之后的喜悦是不可能忘却的，而且从中学到的一些东西也并不是全无用处，比如虽然有了mod_rails但是当你需要自己的gems时，还是可以自己装一份来用的嘛，只是不会再遇到我所遇到的那些莫名的
&lt;strong&gt;
FastCGI: comm with (dynamic) server &#8221;/home/u/domain/public/dispatch.fcgi&#8221; aborted: (first read) idle timeout (60 sec)
&lt;/strong&gt;
的挫折了，这自然是好事噢，有点不甘心地说:P&lt;/p&gt;


	&lt;p&gt;嗯，如dreamhost所说一般以domain的控制面板上多了一个Ruby on Rails Passenger的选项，勾上就好了，简单得不行了吧，不过有一点要注意，dispatch.fcgi中的代码将会永远用不到了，所以如果如我一般自己安装了gems的并有dispatch.fcgi中配置了gems的路径的话，就需要将&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
ENV[&quot;GEM_HOME&quot;]=&quot;/home/yourusername/.gems&quot; 
ENV[&quot;GEM_PATH&quot;]=&quot;/home/yourusername/.gems:/usr/lib/ruby/gems/1.8&quot; 
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;移到config/enviroment.rb中的ENV[&#8216;RAILS_ENV&#8217;] ||= &#8216;production&#8217;之后就好了，否则可能会看到一个mod_rails提示的出错页面，无它，很简单的，不错&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://leeseon.com/">
    <author>
      <name>leeseon</name>
    </author>
    <id>tag:leeseon.com,2008-05-10:16</id>
    <published>2008-05-10T18:03:00Z</published>
    <updated>2008-06-07T19:28:11Z</updated>
    <category term="dreamhost"/>
    <category term="gems"/>
    <category term="rails"/>
    <category term="Ruby"/>
    <category term="ruby"/>
    <link href="http://leeseon.com/2008/5/10/the_simplest_way_install_ruby_gems_rails_on_dreamhost_2" rel="alternate" type="text/html"/>
    <title>&#22312;DreamHost&#19978;&#23433;&#35013;Ruby&#12289;Gems&#19982;Rails&#30340;&#26368;&#31616;&#21333;&#26041;&#27861;&#20043;&#32493;</title>
<content type="html">
            &lt;p&gt;昨天只是泛泛谈了一下&lt;a href=&quot;http://leeseon.com/2008/5/9/the_simplest_way_install_ruby_gems_rails_on_dreamhost&quot;&gt;在DreamHost上安装Ruby、Gems与Rails的最简单方法&lt;/a&gt; 似乎有点 意犹未尽，决定写个续集，呵呵:)&lt;/p&gt;


	&lt;p&gt;好吧从哪儿说起呢？嗯，看我注释过的脚本吧，注释应该已经算是说得比较明白了，无它!&lt;/p&gt;

&lt;div class=&quot;jssc&quot;&gt;
		&lt;ul&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				&lt;span class=&quot;ccomment&quot;&gt;#修改.bash_profile，设置环境变量GEM_HOME与GEM_PATH
				&lt;/span&gt;&lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				&lt;span class=&quot;ccomment&quot;&gt;#并将~/.gems/bin与~/local/bin加入到查找路径的前端 
				&lt;/span&gt;&lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				echo&amp;nbsp; &lt;span class=&quot;cchar&quot;&gt;&#39;export GEM_HOME=&amp;quot;$HOME/.gems&amp;quot;&#39;
				&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;gt; .bash_profile &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				echo&amp;nbsp; &lt;span class=&quot;cchar&quot;&gt;&#39;export GEM_PATH=&amp;quot;$GEM_HOME:/usr/lib/ruby/gems/1.8&amp;quot;&#39;
				&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;gt; .bash_profile &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				echo&amp;nbsp; &lt;span class=&quot;cchar&quot;&gt;&#39;export PATH=&amp;quot;$HOME/.gems/bin:$PATH&amp;quot;&#39;
				&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;gt; .bash_profile &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				echo&amp;nbsp; &lt;span class=&quot;cchar&quot;&gt;&#39;export PATH=&amp;quot;$HOME/local/bin:$PATH&amp;quot;&#39;
				&lt;/span&gt;&amp;nbsp;&amp;gt;&amp;gt; .bash_profile &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
&amp;nbsp;&amp;nbsp; &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				&lt;span class=&quot;ccomment&quot;&gt;#执行.bash_profile使变量生效 &lt;/span&gt;&lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				. ~/.bash_profile &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				&lt;span class=&quot;ccomment&quot;&gt;#显示PATH变量，仅仅只是为了测试 &lt;/span&gt;&lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				echo $PATH &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
&amp;nbsp;&amp;nbsp; &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				&lt;span class=&quot;ccomment&quot;&gt;#生成gems所需的目录及.gemrc文件，并填充相应内容 &lt;/span&gt;
			&lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				mkdir ~/.gems &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				touch ~/.gemrc &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				echo gemhome:/home/$(whoami)/.gems &amp;gt;&amp;gt; ~/.gemrc &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				echo gempath: &amp;gt;&amp;gt; ~/.gemrc &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				echo -/home/$(whoami)/.gems &amp;gt;&amp;gt; ~/.gemrc &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				echo -/usr/lib/ruby/gems/1.8&amp;nbsp;&amp;gt;&amp;gt; ~/.gemrc &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
&amp;nbsp;&amp;nbsp; &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				&lt;span class=&quot;ccomment&quot;&gt;# setup directories &lt;/span&gt;&lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				mkdir -p ~/local/usr/src/ruby &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				cd ~/local/usr/src/ruby &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
&amp;nbsp;&amp;nbsp; &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				&lt;span class=&quot;ccomment&quot;&gt;# Install readline &lt;/span&gt;&lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				wget &lt;span class=&quot;htmlstring&quot;&gt;ftp://ftp.cwru.edu/pub/bash/readline-5.2.tar.gz
				&lt;/span&gt;&lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				tar zxvf readline-5&lt;span&gt;&lt;/span&gt;.2.tar.gz &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				cd readline-5.2&lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				./configure --prefix=$HOME/local &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				make &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				make install &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				cd .. &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
&amp;nbsp;&amp;nbsp; &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				&lt;span class=&quot;ccomment&quot;&gt;# install ruby &lt;/span&gt;&lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				wget  &lt;span class=&quot;htmlstring&quot;&gt;ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p114.tar.gz
				&lt;/span&gt;&lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				tar zxvf ruby-1.8.6-p114.tar.gz &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				cd ruby-1.8.6-p114 &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				./configure --prefix=$HOME/local --with-readline-dir=$HOME/local/
			&lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				make &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				make install &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				cd .. &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
&amp;nbsp;&amp;nbsp; &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				&lt;span class=&quot;ccomment&quot;&gt;# fix path &lt;/span&gt;&lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				export PATH=$HOME/local/bin:$PATH &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
&amp;nbsp;&amp;nbsp; &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				&lt;span class=&quot;ccomment&quot;&gt;# get rubygems &lt;/span&gt;&lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				wget  &lt;span class=&quot;htmlstring&quot;&gt;http://rubyforge.org/frs/download.php/35283/rubygems-1.1.1.tgz
				&lt;/span&gt;&lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				tar zxvf rubygems- 1.1.1.tgz
			&lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				cd rubygems-1.1.1&lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				$HOME/local/bin/ruby setup.rb config --prefix=$HOME/local &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				$HOME/local/bin/ruby setup.rb setup &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				$HOME/local/bin/ruby setup.rb install &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				cd .. &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
&amp;nbsp;&amp;nbsp; &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				&lt;span class=&quot;ccomment&quot;&gt;# Install RAILS &lt;/span&gt;&lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				gem install rails &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
&amp;nbsp;&amp;nbsp; &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				&lt;span class=&quot;ccomment&quot;&gt;# Install FastCGI &lt;/span&gt;&lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				curl -O &lt;span class=&quot;htmlstring&quot;&gt;http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
				&lt;/span&gt;&lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				tar xzvf fcgi-2.4.0.tar.gz &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				cd fcgi-2.4.0&lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				./configure --prefix=$HOME/local &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				make &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				make install &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				cd .. &lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
&amp;nbsp;&amp;nbsp; &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				&lt;span class=&quot;ccomment&quot;&gt;# Install FastCGI &amp;amp; MySQL gem packages
				&lt;/span&gt;&lt;/div&gt;
			&lt;/li&gt;
			&lt;li&gt;
			&lt;div&gt;
				gem install fcgi -- --with-fcgi-dir=$HOME/local &lt;/div&gt;
			&lt;/li&gt;
			&lt;li class=&quot;alt&quot;&gt;
			&lt;div&gt;
				gem install mysql -- --with-mysql-config &lt;/div&gt;
			&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/div&gt;
          </content>  </entry>
</feed>
