Skip to content

Commit

Permalink
Workaround for dummy linker invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
SeekingMeaning committed Jan 14, 2020
1 parent 8c6ccd0 commit 5195882
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,20 @@ build/lib/libluajit-5.1.a: build/$(LUAJIT_TAR)
release/include/terra/%.h: $(LUAJIT_INCLUDE)/%.h $(LUAJIT_LIB)
cp $(LUAJIT_INCLUDE)/$*.h $@

build/llvm_objects/llvm_list: $(addprefix build/, $(LIBOBJS) $(EXEOBJS))
build/llvm_objects/libs_list: $(addprefix build/, $(LIBOBJS) $(EXEOBJS))
mkdir -p build/llvm_objects
$(CXX) -o /dev/null $(addprefix build/, $(LIBOBJS) $(EXEOBJS)) $(LLVM_LIBRARY_FLAGS) $(SUPPORT_LIBRARY_FLAGS) $(LFLAGS) -Wl,-t 2>&1
#
#
# Copy the filepaths listed above to build/llvm_objects/libs_list
#
#
touch build/llvm_objects/libs_list
exit -1

build/llvm_objects/llvm_list: build/llvm_objects/libs_list
mkdir -p build/llvm_objects/luajit
$(CXX) -o /dev/null $(addprefix build/, $(LIBOBJS) $(EXEOBJS)) $(LLVM_LIBRARY_FLAGS) $(SUPPORT_LIBRARY_FLAGS) $(LFLAGS) -Wl,-t 2>&1 | egrep "lib(LLVM|clang)" > build/llvm_objects/llvm_list
cat build/llvm_objects/libs_list | egrep "lib(LLVM|clang)" > build/llvm_objects/llvm_list
# extract needed LLVM objects based on a dummy linker invocation
< build/llvm_objects/llvm_list $(LUAJIT) src/unpacklibraries.lua build/llvm_objects
# include all luajit objects, since the entire lua interface is used in terra
Expand Down
2 changes: 1 addition & 1 deletion src/unpacklibraries.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local function exe(cmd,...)
cmd = string.format(cmd,...)
local res = { os.execute(cmd) }
if type(res[1]) == 'number' and res[1] ~= 0 or not res[1] then
print('Error during '..cmd..':', table.unpack(res))
print('Error during '..cmd..':', (table.unpack or unpack)(res))
error("command failed: "..cmd)
end
end
Expand Down

0 comments on commit 5195882

Please sign in to comment.