<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 9/22/11 4:04 PM, Jinwook Shin wrote:
<blockquote cite="mid:CAA0ECBE.14270%25jinshin@microsoft.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<div>Thanks John. I appreciate your help. <br>
</div>
</blockquote>
<br>
De nada.<br>
<br>
<blockquote cite="mid:CAA0ECBE.14270%25jinshin@microsoft.com"
type="cite">
<div><br>
</div>
<div>I have taken the libLTO approach and it worked like a charm
:) For those who wanted to achieve the same thing, below are the
steps I've taken. </div>
<div><br>
</div>
<div>John -- a small question: I thought I wouldn't need to touch
Makefiles at all, but that wasn't the case. Could you take a
look at Step 4) and tell me what you think? Thanks! <br>
</div>
</blockquote>
<br>
A properly written project will allow the person compiling the
software to easily change the compiler and the compiler/linker flags
used.<br>
<br>
For example, autoconf-based configure scripts usually use the
following environment variables:<br>
<br>
CC - C compiler<br>
CXX - C++ compiler<br>
CFLAGS - compiler flags<br>
LDFLAGS - linker flags<br>
<br>
So, you would do the following in sh/ksh syntax:<br>
<br>
CC=llvm-gcc<br>
CXX=llvm-g++<br>
CFLAGS="-emit-llvm"<br>
export CC<br>
export CXX<br>
export CFLAGS<br>
./configure<br>
<br>
<br>
<blockquote cite="mid:CAA0ECBE.14270%25jinshin@microsoft.com"
type="cite">
<div><br>
</div>
<div>1) Create your own libLTO and add your pass to it. Do a code
diff between /safecode/tools/LTO/LTOCodeGenerator.cpp
and /llvm/tools/lto/LTOCodeGenerator.cpp to figure out what
changes are needed to do this.</div>
<div>2) Make a backup copy of the original linker
/usr/lib/libLTO.dylib.</div>
<div>3) Copy your libLTO.dylib to /usr/lib.</div>
<div>4) Open Makefiles in your target project and change CC and
CFLAGS as follows: </div>
<div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>CC=llvm-gcc</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>CFLAGS=-emit-llvm
…</div>
</div>
<div>5) Build the project with LLVM.</div>
</blockquote>
<br>
-- John T.<br>
<br>
</body>
</html>