From: Gabe Black Date: Wed, 25 Mar 2020 06:49:25 +0000 (-0700) Subject: util: Add some additional flags for files in the m5 util. X-Git-Tag: v20.0.0.0~160 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=da21567d2cfb0a4279d3a6c8ebe2aa01fa7b7306;p=gem5.git 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 Maintainer: Gabe Black Tested-by: kokoro --- diff --git a/util/m5/src/SConscript b/util/m5/src/SConscript index 8c4236397..392ac9e33 100644 --- a/util/m5/src/SConscript +++ b/util/m5/src/SConscript @@ -34,28 +34,31 @@ m5 = 'm5.c' 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 @@ if env['HAVE_LUA51']: # # 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 ])