[VTA] Fix TSIM compile error in Linux (add missing -fPIC flag) (#3876)
authorLiangfu Chen <liangfu.chen@harman.com>
Tue, 3 Sep 2019 16:31:32 +0000 (00:31 +0800)
committerThierry Moreau <moreau@uw.edu>
Tue, 3 Sep 2019 16:31:31 +0000 (09:31 -0700)
* [VTA] Fix TSIM compile error in Linux (add missing -fPIC flag);

* [VTA] Fix TSIM compile error in Linux (add missing -fPIC flag);

* fix indentation problem;

vta/hardware/chisel/Makefile

index f8bb55d..6cd2802 100644 (file)
@@ -82,7 +82,6 @@ cxx_flags += -I$(tvm_dir)/3rdparty/dlpack/include
 ld_flags = -fPIC -shared
 
 cxx_objs = $(verilator_build_dir)/verilated.o $(verilator_build_dir)/verilated_dpi.o $(verilator_build_dir)/tsim_device.o
-cxx_objs += $(patsubst %.cpp,%.o,$(wildcard $(verilator_build_dir)/*.cpp))
 
 ifneq ($(USE_TRACE), 0)
   verilator_opt += --trace
@@ -108,13 +107,16 @@ default: lib
 lib: $(lib_path)
 
 $(verilator_build_dir)/%.o: %.cpp
-       $(CXX) -c $(cxx_flags) $^ -o $@
+       $(CXX) -fPIC $(cxx_flags) -c $^ -o $@
 
 $(verilator_build_dir)/tsim_device.o: tsim_device.cc
-       $(CXX) -c $(cxx_flags) $^ -o $@
+       $(CXX) -fPIC $(cxx_flags) -c $^ -o $@
 
 $(lib_path): $(verilator_build_dir)/V$(TOP_TEST).cpp $(cxx_objs)
-       $(CXX) $(cxx_flags) $(ld_flags) $(cxx_objs) -o $@
+       for f in $(shell find $(verilator_build_dir)/*.cpp); do \
+               $(CXX) -fPIC $(cxx_flags) -c $${f} -o $${f}.o ; \
+       done
+       $(CXX) $(ld_flags) $(cxx_flags) $(cxx_objs) $(patsubst %.cpp,%.cpp.o,$(shell find $(verilator_build_dir)/*.cpp)) -o $@
 
 verilator: $(verilator_build_dir)/V$(TOP_TEST).cpp
 $(verilator_build_dir)/V$(TOP_TEST).cpp: $(chisel_build_dir)/$(TOP_TEST).$(CONFIG).v