Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debian multiarch compatibility #122

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
build/
*.o
*.a
*.so
terra
19 changes: 11 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ CLANG ?= $(CLANG_PREFIX)/bin/clang

#path to the compiler you want to use to compile libterra
#can be any c/c++ compiler
TERRA_CXX ?= $(CLANG)++
TERRA_CC ?= $(CLANG)
TERRA_LINK ?= $(CLANG)++
TERRA_CXX ?= $(CLANG)++ $(TARGET_ARCH)
TERRA_CC ?= $(CLANG) $(TARGET_ARCH)
TERRA_LINK ?= $(CLANG)++ $(TARGET_ARCH)

CUDA_HOME ?= /usr/local/cuda
ENABLE_CUDA ?= $(shell test -e /usr/local/cuda && echo 1 || echo 0)
Expand Down Expand Up @@ -137,10 +137,10 @@ BIN2C = build/bin2c
#put any install-specific stuff in here
-include Makefile.inc

.PHONY: all clean purge test release
.PHONY: all clean purge test release tests
all: $(EXECUTABLE) $(DYNLIBRARY)

test: $(EXECUTABLE)
test tests: $(EXECUTABLE)
(cd tests; ./run)

build/%.o: src/%.cpp $(PACKAGE_DEPS)
Expand All @@ -158,16 +158,19 @@ endif

$(LUAJIT_LIB): build/$(LUAJIT_TAR)
(cd build; tar -xf $(LUAJIT_TAR))
(cd $(LUAJIT_DIR); make CC=$(CC) STATIC_CC="$(CC) -fPIC")
# Terra does not work on x86 32bit.
(cd $(LUAJIT_DIR); test ! -n "`$(CC) -E -dM src/lj_arch.h | grep '\<LJ_TARGET_X86\>'`" )
(cd $(LUAJIT_DIR); make CC="$(CC)" STATIC_CC="$(CC) -fPIC")
cp $(addprefix $(LUAJIT_DIR)/src/,$(LUAHEADERS)) release/include/terra

build/dep_objects/llvm_list: $(LUAJIT_LIB) $(addprefix build/, $(LIBOBJS))
mkdir -p build/dep_objects/luajit
$(TERRA_LINK) -o /dev/null $(addprefix build/, $(LIBOBJS) $(EXEOBJS)) $(LLVM_LIBRARY_FLAGS) $(SUPPORT_LIBRARY_FLAGS) $(LFLAGS) -Wl,-t | egrep "lib(LLVM|clang)" > build/dep_objects/llvm_list
$(TERRA_LINK) -o /dev/null $(addprefix build/, $(LIBOBJS) $(EXEOBJS)) $(LLVM_LIBRARY_FLAGS) $(SUPPORT_LIBRARY_FLAGS) $(LFLAGS) -Wl,-t | egrep "lib(LLVM|clang)" > build/dep_objects/llvm_list.tmp
# extract needed LLVM objects based on a dummy linker invocation
< build/dep_objects/llvm_list $(LUAJIT_DIR)/src/luajit src/unpacklibraries.lua build/dep_objects
< build/dep_objects/llvm_list.tmp $(LUAJIT_DIR)/src/luajit src/unpacklibraries.lua build/dep_objects
# include all luajit objects, since the entire lua interface is used in terra
cd build/dep_objects/luajit; ar x ../../../$(LUAJIT_LIB)
mv build/dep_objects/llvm_list.tmp build/dep_objects/llvm_list

$(LIBRARY): $(addprefix build/, $(LIBOBJS)) build/dep_objects/llvm_list
mkdir -p release/lib
Expand Down
2 changes: 2 additions & 0 deletions build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
5 changes: 5 additions & 0 deletions src/tcompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2694,6 +2694,11 @@ static bool SaveAndLink(TerraCompilationUnit * CU, Module * M, std::vector<const
cmd.insert(cmd.end(),linkargs->begin(),linkargs->end());

#ifndef _WIN32
#if defined(__amd64__)
cmd.push_back("-m64");
#elif defined(__i386__)
#error "Only AMD64 target currently supported on x86"
#endif
cmd.push_back("-o");
cmd.push_back(filename);
#else
Expand Down
13 changes: 13 additions & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
add.bc
afile.txt
benchmark_fannkuchredux
benchmark_nbody
dynlib
hello
hello.c
output
output.ll
output2
output2.bc
renamed
speed