-
Notifications
You must be signed in to change notification settings - Fork 10
/
FAQ.xml
90 lines (86 loc) · 3.36 KB
/
FAQ.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<faq
xmlns:sh="http://www.shell.org"
xmlns:r="http://www.r-project.org"
xmlns:omg="http://www.omegahat.org">
<q>
<para>
I want to compile <omg:pkg>Rllvm</omg:pkg> with a local, non-centrally installed
version of llvm, e.g. a development version that I build in my own account area
and not the one in that is installed /usr/local/. What do I have to do?
</para>
<a>
<para>
The first thing to do is set the environment variable LLVM_CONFIG
to the full path to the local version of llvm-config you want to use,
e.g.
<sh:code>
export LLVM_CONFIG=~/LLVM/build/Debug+Asserts/bin/llvm-config
</sh:code>
Here I have put the source for llvm in LLVM/llvm, and configured
and built it from a directory named build/.
</para>
<para>
If you have a version of llvm installed in /usr/local,
you will need to force the local library directory to come before
/usr/local/lib when building the shared library. R doesn't make
this especially customizable, so we can force it by setting
the Make variable SHLIB_LINK in our own local Makevars
file in <sh:path>${HOME}/.R</sh:path>, i.e. <sh:path>${HOME}/.R./Makevars</sh:path>.
We can do this with
<sh:code>
SHLIB_LINK= $(SHLIB_LD) $(shell $(LLVM_CONFIG) --ldflags) $(SHLIB_LDFLAGS) $(LDFLAGS)
</sh:code>
</para>
<para>
The last step is, of course, to ensure the system loader finds your
local versions of the libraries. You need to set
<sh:var>LD_LIBRARY_PATH</sh:var>, or <sh:var>DYLD_LIBRARY_PATH</sh:var>
on OS X, or <sh:var>PATH</sh:var> on Windows, to point to
the lib/ directory in your build, e.g.
<sh:code>
export DYLD_LIBRARY_PATH=~/LLVM/build/lib/
</sh:code>
</para>
</a>
</q>
<q>
I am getting error messages of the form
<sh:output>
/usr/local/include/llvm/Use.h:43: error: redefinition of ‘class llvm::PointerLikeTypeTraits<llvm::Use**>’
/usr/local/include/llvm/IR/Use.h:43: error: previous definition of ‘class llvm::PointerLikeTypeTraits<llvm::Use**>’
</sh:output>
What's the problem?
<a>
One likely explanation is that you had installed a version of the llvm libraries
and then install llvm 3.3. The layout/organization of the header
files changed in that development branch and now we have the old and
new headers mixed together. I would suggest
moving the llvm header directory (e.g. in /usr/local/include/) aside
and then re-installing llvm 3.3 (or higher).
</a>
</q>
<q>
I get error messages when compiling and/or loading Rllvm's DSO/DLL.
It complains that some symbols are not found.
<a>
One possible explanation of this is that you are using a locally installed
version of LLVM but linking against a different centrally installed set of LLVM libraries.
This happens because R puts -L/usr/local/lib ahead of package link options.
</a>
</q>
<q>
I'm creating a <r:class>Module</r:class> but when <r:func>verifyModule</r:func> is called
(either implicitly or explicitly), <r/> crashes. This happens when I call <r:func>showModule</r:func>.
So how can I see what the instructions are?
<a>
You can get the <r:class>Function</r:class> object of interest from the <r:class>Module</r:class>,
e.g. <r:expr eval="false">f = mod[["myRoutine"]]</r:expr>.
Then you can get its blocks with <r:func>getBlocks</r:func>.
For each block, we can call <r:func>getBlockInstructions</r:func>, and then convert each to a character string.
We can do all of this with
<r:code>
lapply(getBlocks(f), function(b) sapply(getBlockInstructions(b), as, "character"))
</r:code>
</a>
</q>
</faq>