terralang / terra

Terra is a low-level system programming language that is embedded in and meta-programmed by the Lua programming language.
terralang.org
Other
2.71k stars 197 forks source link

Build fails on Arch Linux #308

Open elliottslaughter opened 5 years ago

elliottslaughter commented 5 years ago

With the following Dockerfile:

FROM archlinux/base:latest

RUN pacman -Syu --noconfirm && \
    pacman -S --noconfirm base-devel git wget clang llvm && \
    pacman -Scc --noconfirm

RUN git clone -b master https://github.com/zdevito/terra.git && \
    make -C terra

I get the following error:

# extract needed LLVM objects based on a dummy linker invocation
< build/llvm_objects/llvm_list build/bin/luajit-2.0.5 src/unpacklibraries.lua build/llvm_objects
ar: invalid option -- 'n'
Usage: ar [emulation options] [-]{dmpqrstx}[abcDfilMNoOPsSTuvV] [--plugin <name>] [member-name] [count] archive-file file...
       ar -M [<mri-script]
elliottslaughter commented 5 years ago

The reason this fails is that the current Arch packages for LLVM and Clang 6.0 do not include static libraries for Clang. Therefore, I don't think it will be possible to build Terra with the current Arch packages, without teaching Terra to first build from dynamic libraries.

SaphireLattice commented 5 years ago

I have managed to build Terra main binary on arch. It works pretty ok, all tests passed except for the single one. Of course that test is "dynlib" that itself assumes the same thing as the Terra Makefile: that clang and LLVM are static. (edit: nevermind, it just couldn't find the luajit lib because of hacking around with the compiler commands manually instead of letting makefile do stuff by itself... after I also additionally compiled the terra.so with dynamic link th clang and LLVM like in below command)

But yeah, it can be build on Arch, on dynamic libraries, while making every single test work. It just needs a whack into build statements. Namely, my resulting working statement ended up as


g++ -o release/bin/terra -g -Wl,-export-dynamic -Wl,--whole-archive build/terra.o -Wl,--no-whole-archive  -lcurses  -lz -ldl -pthread -lclangFrontend -lclangDriver -lclangSerialization -lclangCodeGen -lclangParse -lclangSema -lclangAnalysis -lclangEdit -lclangAST -lclangLex -lclangBasic build/lib/libluajit-5.1.a -lLLVM build/lctype.o build/linenoise.o build/lj_strscan.o build/llex.o build/lobject.o build/lparser.o build/lstring.o build/lzio.o build/main.o build/tcompiler.o build/tcuda.o build/tcwrapper.o build/tdebug.o build/tinline.o build/tinternalizedfiles.o build/tkind.o build/tllvmutil.o build/treadnumber.o build/lib/libluajit-5.1.a```
elliottslaughter commented 5 years ago

We may theoretically be able to make this work out of the box now with CMake. I'm not sure that FindClang.cmake is robust enough to handle Clang's dynamic libraries, but I'm sure that can be fixed with some effort.