scons: Include libraries when building gem5 as a shared object
While we include shared libraries in the Executable class, we are not doing it when linking the SharedLib. This means the resulting Shared library won't have the library as a dependency (it won't appear in ldd) and the symbols will remain undefined. Any executable will fail to link with the shared library as the executable will contain undefined references. This bug was exposed when I tried to link util/tlm sources with libgem5.so. As I have libpng/libpng-dev installed in my machine, the shared library included libpng headers, but didn't link to the library as scons didn't append "-lpng" to the linking CL. Those png functions thus remained ubdefined symbols. Change-Id: Id9c4a65607a7177f71659f1ac400a67edf7080fd Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/66855 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Gabe Black <gabe.black@gmail.com> Maintainer: Daniel Carvalho <odanrc@yahoo.com.br> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
This commit is contained in:
@@ -376,6 +376,12 @@ class SharedLib(TopLevelBase):
|
||||
def declare(self, env):
|
||||
objs = self.srcs_to_objs(env, self.sources(env))
|
||||
|
||||
libs = self.libs(env)
|
||||
# Higher priority libraries should be earlier in the list.
|
||||
libs.sort(key=lambda l: l.priority, reverse=True)
|
||||
if libs:
|
||||
env.Append(LIBS=list(lib.source for lib in libs))
|
||||
|
||||
date_obj = env.SharedObject(date_source)
|
||||
env.Depends(date_obj, objs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user