Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/27218 )

Change subject: util: Add some additional flags for files in the m5 util.
......................................................................

util: Add some additional flags for files in the m5 util.

When compiling static objects, disable pie with the -no-pie linker flag.
This is necessary for x86, and doesn't seem to hurt anything for the
other variants.

When compiling shared objects, particularly the assembly files which
can't rely on the compiler to generate position independent code, define
M5OP_PIC so that the assembly code can configure itself correctly.

Change-Id: I80d1ea7a7704666027e74228036af5e0e4b9eac2
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27218
Reviewed-by: Matthew Poremba <matthew.pore...@amd.com>
Maintainer: Gabe Black <gabebl...@google.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M util/m5/src/SConscript
1 file changed, 10 insertions(+), 7 deletions(-)

Approvals:
  Matthew Poremba: Looks good to me, approved
  Gabe Black: Looks good to me, approved
  kokoro: Regressions pass



diff --git a/util/m5/src/SConscript b/util/m5/src/SConscript
index 8c42363..392ac9e 100644
--- a/util/m5/src/SConscript
+++ b/util/m5/src/SConscript
@@ -34,28 +34,31 @@
 jni = 'jni_gem5Op.c'
 lua = 'lua_gem5Op.c'

+static_env = env.Clone()
+static_env.Append(LINKFLAGS=[ '-no-pie', '-static' ])
+
 #
 # The m5 library for use in other C/C++ programs.
 #
-libm5 = env.StaticLibrary('out/m5', [ m5op, m5_mmap ])
+libm5 = static_env.StaticLibrary('out/m5', [ m5op, m5_mmap ])


 #
 # The m5 stand alone command line utility.
 #
-m5_bin_env = env.Clone()
-m5_bin_env.Append(LINKFLAGS=[ '-static' ])
-m5_bin = m5_bin_env.Program('out/m5', [ m5, m5_mmap, libm5 ])
+m5_bin = static_env.Program('out/m5', [ m5, m5_mmap, libm5 ])


# The shared version of the m5 op call sights, used by mutliple targets below.
-m5op_shared = env.SharedObject(m5op)
+shared_env = env.Clone()
+shared_env.Append(ASFLAGS='-DM5OP_PIC')
+m5op_shared = shared_env.SharedObject(m5op)

 if env['HAVE_JAVA']:
     #
     # A wrapper to make the m5 ops available in Java through the JNI.
     #
-    java_env = env.Clone()
+    java_env = shared_env.Clone()
     # SCons provides Java and JavaH builders, but the JavaH builder assumes
# that the javah tool exists. Java has dropped that tool in favor of a -h # option on javac which the Java builder doesn't know how to use. To get
@@ -75,7 +78,7 @@
     #
     # A wrapper to make the m5 ops available in lua version 5.1.
     #
-    lua_env = env.Clone()
+    lua_env = shared_env.Clone()
     # Extract the include paths needed for lua51 using pkg-config.
     lua_env.ParseConfig('pkg-config --cflags lua51')
lib = lua_env.SharedLibrary('out/gem5OpLua', [ lua, m5op_shared, m5_mmap ])

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/27218
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: I80d1ea7a7704666027e74228036af5e0e4b9eac2
Gerrit-Change-Number: 27218
Gerrit-PatchSet: 10
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Earl Ou <shunhsin...@google.com>
Gerrit-Reviewer: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Giacomo Travaglini <giacomo.travagl...@arm.com>
Gerrit-Reviewer: Jason Lowe-Power <power...@gmail.com>
Gerrit-Reviewer: Matthew Poremba <matthew.pore...@amd.com>
Gerrit-Reviewer: Yu-hsin Wang <yuhsi...@google.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
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