<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 15, 2020 at 6:53 PM Neil Nelson via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<div>
<p>Rarrum,<br>
</p>
<p>Kubuntu 20.04 LTS is available. You may be able to upgrade to
19.10, and then to 20.04 without reinstalling. It can be done on
Xubuntu. A direct upgrade to 20.04 should become available. LLVM
10 then installs from the distribution packages. I put all this on
a VM using KVM/QEMU to keep it isolated from my primary desktop
environment. Building a 20.04 VM after upgrading to 20.04 appears
to give a faster VM. Use llvm's linker lld.</p>
<p>The cmake version for 20.04 is 3.16.3 which should help with
llvm's recommended version.</p></div></blockquote><div><br></div><div>Do you believe the error listed have to do with the CMake version?</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div>
<p>Neil<br>
</p>
<div>On 5/15/20 12:05 AM, Rarrum via
llvm-dev wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">I decided to start playing around with building my
own programming language recently, and to use LLVM to handle the
assembly-level details. I'm on Kubuntu 18.04, and I started out
using LLVM 6.0 from Kubuntu's packages. I put together code for
dealing with my language, then went over the Kaleidoscope
tutorials (which have been extremely helpful btw!). I was able
to successfully get my own compiler to generate IR using LLVM,
use PassManager to write that to a native .o file, use gcc to
link that, and execute a tiny program written in my own
language.<br>
<br>
I also decided it was a good time to learn CMake, so I set up my
project using that. The CMakeLists.txt file I'm using is
essentially just taken from: <a href="https://llvm.org/docs/CMake.html#embedding-llvm-in-your-project" target="_blank">https://llvm.org/docs/CMake.html#embedding-llvm-in-your-project</a>
- though originally it would not link. From scouring the
internet I made 2 changes to get that working: replaced "support
core irreader" with "all", and replaced "${llvm_libs}" with just
"LLVM".<br>
<br>
However as I was starting to play with setting up JIT, I hit
more differences between the version of LLVM in Kubuntu and the
version the examples and documentation were written against. So
I decided to try to update to a newer version of LLVM.. and this
is where I've been stuck for several days now. Here are the
steps I've taken:<br>
<br>
* Uninstalled any llvm packages I could find from Kubuntu's
package manager.<br>
* Followed the getting started guide: <a href="https://llvm.org/docs/GettingStarted.html" target="_blank">https://llvm.org/docs/GettingStarted.html</a>
- I git cloned LLVM, checked out the 10.0.0 tag, ran cmake as
instructed, with the Release type. When that completed
successfully I ran sudo ninja install.<br>
* I then went back to my project and adjusted a couple places to
successfully compile against the new version.<br>
* At this point I put "${llvm_libs}" in the CMakeLists.txt file
back to match the example. However I was getting a massive wall
of link errors.<br>
* I assumed I must have built LLVM incorrectly somehow, so in an
effort to undo that install, I deleted everything I could find
under /usr/local that had LLVM in its name, downloaded the 10.0
release from <a href="https://releases.llvm.org/download.html" target="_blank">https://releases.llvm.org/download.html</a>
for ubuntu 18.04, and extracted that all to /usr/local.<br>
* I can still successfully compile, but not link.<br>
<br>
At this point I'm not sure what to try next. Is there
additional documentation somewhere for how to "install" a
current release of LLVM correctly?<br>
<br>
<br>
For reference here's my final CMakeLists.txt file:<br>
<br>
cmake_minimum_required(VERSION 3.10)<br>
<br>
project(CBreakCompiler)<br>
<br>
set(CMAKE_CXX_STANDARD 17)<br>
set(CMAKE_CXX_STANDARD_REQUIRED True)<br>
add_compile_options(-Wall)<br>
<br>
find_package(LLVM 10.0.0 REQUIRED CONFIG)<br>
<br>
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")<br>
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")<br>
<br>
include_directories(${LLVM_INCLUDE_DIRS})<br>
add_definitions(${LLVM_DEFINITIONS})<br>
<br>
add_executable(CBreakCompiler<br>
src/main.cpp<br>
src/Parser.cpp<br>
src/SourceTokenizer.cpp<br>
src/IRCompiler.cpp<br>
src/CompiledOutput.cpp)<br>
<br>
llvm_map_components_to_libnames(llvm_libs all)<br>
target_link_libraries(CBreakCompiler ${llvm_libs})<br>
<br>
<br>
And a snippet from the cmake output corresponding to those
message lines:<br>
<br>
-- Found LLVM 10.0.0<br>
-- Using LLVMConfig.cmake in: /usr/local/lib/cmake/llvm<br>
<br>
<br>
There are dozens of link errors.. the first few and last few
are:<br>
<br>
CMakeFiles/CBreakCompiler.dir/src/main.cpp.o:(.data.rel+0x0):
undefined reference to `llvm::DisableABIBreakingChecks'<br>
CMakeFiles/CBreakCompiler.dir/src/main.cpp.o: In function
`std::default_delete<llvm::LLVMContext>::operator()(llvm::LLVMContext*)
const':<br>
main.cpp:(.text._ZNKSt14default_deleteIN4llvm11LLVMContextEEclEPS1_[_ZNKSt14default_deleteIN4llvm11LLVMContextEEclEPS1_]+0x1e):
undefined reference to `llvm::LLVMContext::~LLVMContext()'<br>
...<br>
CMakeFiles/CBreakCompiler.dir/src/CompiledOutput.cpp.o:(.<a href="http://data.rel.ro" target="_blank">data.rel.ro</a>+0xe0):
undefined reference to `llvm::raw_ostream::anchor()'<br>
CMakeFiles/CBreakCompiler.dir/src/CompiledOutput.cpp.o:(.<a href="http://data.rel.ro" target="_blank">data.rel.ro</a>+0xf8):
undefined reference to `typeinfo for llvm::raw_pwrite_stream'<br>
CMakeFiles/CBreakCompiler.dir/src/CompiledOutput.cpp.o:(.<a href="http://data.rel.ro" target="_blank">data.rel.ro</a>+0x110):
undefined reference to `typeinfo for llvm::raw_ostream'<br></div></blockquote></div></blockquote><div><br></div><div>Seems like `llvm_map_components_to_libnames` wasn't populated well? </div><div>I'd start by printing `${llvm_libs}` in your CMake to check the output of llvm_map_components_to_libnames, I don't know how the "all" works for external builds? You may have to list the components you need more explicitly instead?</div><div><br></div><div>-- </div><div>Mehdi</div><div><br></div><div><br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><blockquote type="cite"><div dir="ltr">
</div>
<br>
<fieldset></fieldset>
<pre>_______________________________________________
LLVM Developers mailing list
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
</div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div></div></div></div>