Earl Ou has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/55085 )

Change subject: fastmodel: make gem5 fastmodel build harmonic
......................................................................

fastmodel: make gem5 fastmodel build harmonic

This CL makes fastmodel RPATH relative to $ORIGIN instead of absolute
path. In this way we can move build folder (installing), without
breaking gem5 run.

Change-Id: I8b16d749252b982e45dfe779a5df931015a0e07d
---
M src/arch/arm/fastmodel/SConscript
M src/arch/arm/fastmodel/arm_fast_model.py
2 files changed, 35 insertions(+), 18 deletions(-)



diff --git a/src/arch/arm/fastmodel/SConscript b/src/arch/arm/fastmodel/SConscript
index 63b1b16..12bc5d3 100644
--- a/src/arch/arm/fastmodel/SConscript
+++ b/src/arch/arm/fastmodel/SConscript
@@ -95,9 +95,7 @@
         full_name = Dir(path).File(static_name).get_abspath()
         if os.path.isfile(full_name):
             return File(full_name)
-
-    return name
-
+    raise BuildError("Failed to find FM staic lib: " + name)

 # Adjust the build environment to support building in Fast Models.

@@ -121,16 +119,27 @@
     pvlib_home.Dir('Iris').Dir(pvlib_flavor),
 )
 env.Append(LIBPATH=lib_paths)
-env.Append(RPATH=lib_paths)

-fm_libs = (
+fm_static_libs = (
     'components',
     'pvbus',
     'armctmodel',
     'fmruntime',
     'IrisSupport',
 )
-env.Append(LIBS=list(staticify(env, lib) for lib in fm_libs))
+env.Append(LIBS=list(staticify(env, lib) for lib in fm_static_libs))
+
+fm_shared_libs = (
+    'armctmodel',
+)
+for fm_shared_lib in fm_shared_libs:
+    name = '${SHLIBPREFIX}%s${SHLIBSUFFIX}' % fm_shared_lib
+    env.Execute(Copy(Dir('pvlib').File('lib%s.so' % fm_shared_lib),
+                     pvlib_lib_dir.File('lib%s.so' % fm_shared_lib)))
+env.Append(LIBPATH=Dir('pvlib'))
+env.Append(LIBS=fm_shared_libs)
+env.AddLocalRPATH(Dir('pvlib'))
+
 system_libs = (
     'atomic',
     'dl',
@@ -331,6 +340,13 @@
         # but the difference is probably not significant.
         env.SideEffect(next(license_cycle), lib_nodes[0])

+ # We need a copy of the simulation engine lib alongside the executable
+        # so that the license check works properly.
+        local_engine = Dir(env['BUILDDIR']).File(simulation_engine_name)
+        Depends(lib_nodes[0], local_engine)
+        env.Command(local_engine, simulation_engine_lib,
+                MakeAction("cp ${SOURCE} ${TARGET}", Transform('COPY')))
+
     def prepare_env(self, env):
         env.Append(LIBPATH=self.libpaths)
         env.AddLocalRPATH(*self.rpaths)
diff --git a/src/arch/arm/fastmodel/arm_fast_model.py b/src/arch/arm/fastmodel/arm_fast_model.py
index c9d1113..f11443d 100644
--- a/src/arch/arm/fastmodel/arm_fast_model.py
+++ b/src/arch/arm/fastmodel/arm_fast_model.py
@@ -42,21 +42,9 @@
 # 7.6 of the Fast Models User Guide.

 def scx_initialize(id):
-    # Change our working directory to where the simulation engine library
-    # is so that the fast model code can find it. It looks in the binary
-    # directory and in the current working directory, and we can change
-    # the later. This avoids having to make copies of that library all
-    # over the place.
-    cwd = os.getcwd()
-    os.chdir(os.path.join(buildEnv['PVLIB_HOME'], 'lib',
-                          buildEnv['PVLIB_FLAVOR']))
-
     # Actually run scx_initialize.
     _m5.arm_fast_model.scx_initialize(id)

-    # Restore the previous working directory.
-    os.chdir(cwd)
-
 def scx_load_application(instance, application):
     _m5.arm_fast_model.scx_load_application(instance, application)


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/55085
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I8b16d749252b982e45dfe779a5df931015a0e07d
Gerrit-Change-Number: 55085
Gerrit-PatchSet: 1
Gerrit-Owner: Earl Ou <shunhsin...@google.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to