Skip to content

Commit 0c68892

Browse files
Clarify build directions; make unit tests buildable with system LLVM (#93)
1 parent c793384 commit 0c68892

File tree

2 files changed

+38
-15
lines changed

2 files changed

+38
-15
lines changed

README.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Note: to convert C to LLVM IR to run the tests, you will also need a C compiler
3838
The first step is to compile LLVM on your machine
3939
(this assumes an in-tree build, but out-of-tree will also work):
4040

41-
cd $HOME
41+
4242
git clone https://github.com/llvm/llvm-project.git
4343
cd llvm-project
4444
git checkout release/8.x
@@ -53,14 +53,23 @@ To run tests, you need to build `lli`.
5353
Step 2: Compiling LLVM-CBE
5454
==========================
5555

56-
Next, download and compile llvm-cbe from the same folder if you built LLVM yourself, or where you'd like in the other case:
56+
Now you can download and compile llvm-cbe.
57+
58+
If you built LLVM yourself, put it in the same folder you built LLVM in:
5759

58-
cd $HOME/llvm-project/llvm/projects # Or any place, if you use the LLVM package of your distribution.
60+
cd $HOME/llvm-project/llvm/projects
5961
git clone https://github.com/JuliaComputing/llvm-cbe
6062
cd ../build
6163
cmake ..
6264
make llvm-cbe
6365

66+
If you used your distribution's package, put it wherever you feel like:
67+
68+
git clone https://github.com/JuliaComputing/llvm-cbe
69+
cd llvm-cbe && mkdir build && cd build
70+
cmake ..
71+
make llvm-cbe
72+
6473
Step 3: Usage Examples
6574
======================
6675

@@ -98,6 +107,10 @@ Unit tests:
98107
$ make CBEUnitTests && projects/llvm-cbe/unittests/CWriterTest
99108
```
100109

110+
Note that you need to have passed `-DLLVM_INCLUDE_TESTS=1` to cmake if you used
111+
your distribution's LLVM package. You also will need to install gtest (on Debian
112+
derivatives: `apt install libgtest-dev`).
113+
101114
Other tests:
102115

103116
First, compile llvm-cbe, and install pytest. Then:

unittests/CMakeLists.txt

+22-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
add_custom_target(CBEUnitTests)
22
set_target_properties(CBEUnitTests PROPERTIES FOLDER "Tests")
33

4-
set(LLVM_LINK_COMPONENTS
5-
Analysis
6-
CBackendCodeGen
7-
CBackendInfo
8-
CodeGen
9-
Core
10-
MC
11-
ScalarOpts
12-
Support
13-
Target
14-
TransformUtils
15-
)
4+
if (NOT USE_SYSTEM_LLVM)
5+
set(LLVM_LINK_COMPONENTS
6+
Analysis
7+
CBackendCodeGen
8+
CBackendInfo
9+
CodeGen
10+
Core
11+
MC
12+
ScalarOpts
13+
Support
14+
Target
15+
TransformUtils
16+
)
17+
endif()
1618

1719
add_unittest(CBEUnitTests CWriterTest
1820
TypeNameTest.cpp
1921
)
22+
23+
if(USE_SYSTEM_LLVM)
24+
llvm_map_components_to_libnames(llvm_libs
25+
CBackendCodeGen
26+
CBackendInfo
27+
)
28+
target_link_libraries(CWriterTest PRIVATE LLVM ${llvm_libs})
29+
endif()

0 commit comments

Comments
 (0)