diff --git a/.gitignore b/.gitignore index 567609b1..55211d45 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ -build/ +*.o +*.a +*.so +terra diff --git a/Makefile b/Makefile index 7b200d7e..6f2f8a8b 100644 --- a/Makefile +++ b/Makefile @@ -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) @@ -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) @@ -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 '\'`" ) + (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 diff --git a/build/.gitignore b/build/.gitignore index e69de29b..d6b7ef32 100644 --- a/build/.gitignore +++ b/build/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/src/tcompiler.cpp b/src/tcompiler.cpp index 1882d7a2..c75ca9af 100644 --- a/src/tcompiler.cpp +++ b/src/tcompiler.cpp @@ -2694,6 +2694,11 @@ static bool SaveAndLink(TerraCompilationUnit * CU, Module * M, std::vectorbegin(),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 diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 00000000..d879cb74 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,13 @@ +add.bc +afile.txt +benchmark_fannkuchredux +benchmark_nbody +dynlib +hello +hello.c +output +output.ll +output2 +output2.bc +renamed +speed