aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMotti Gondabi <motti.gondabi@arm.com>2021-12-21 13:19:29 +0200
committerMotti Gondabi <motti.gondabi@arm.com>2021-12-23 16:07:16 +0000
commitf76a502a73ca628e2a2556abeaa60ed17bb68d97 (patch)
treee714aeb4a20c84fa2fe9895bb5b7133c26e23357
parentde60ed90fb9ce1f15e785a9b73b2e644c3dc3413 (diff)
downloadComputeLibrary-f76a502a73ca628e2a2556abeaa60ed17bb68d97.tar.gz
Fix SCons linking error when building for Multi ISA.
When building for Multi ISA the link command throws: 'argument list too long' error since the list string being pass to the linker exceeds the ARG_MAX value. The solution is to split the object list into two distinct static libraries and have them link back together. Prohibit unknown variable use. The script now checks for unknown parameters. Resolves: COMPMID-4921 Change-Id: I97a27e86f90a7cc680a3c487da1c468cd3e1084e Signed-off-by: Motti Gondabi <motti.gondabi@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6847 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Giorgio Arena <giorgio.arena@arm.com> Reviewed-by: SiCong Li <sicong.li@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
-rw-r--r--SConscript46
-rw-r--r--SConstruct27
2 files changed, 45 insertions, 28 deletions
diff --git a/SConscript b/SConscript
index 8d5e60867c..c48a850215 100644
--- a/SConscript
+++ b/SConscript
@@ -52,8 +52,10 @@ def build_bootcode_objs(sources):
# such as the compiler flags and defines.
#
# @return A list of objects for the corresponding architecture.
+#
def build_multi_isa_objs(sources, arch_v8_info):
+ # Get the march
arch_v8 = arch_v8_info[0]
# Create a temp environment
@@ -65,24 +67,20 @@ def build_multi_isa_objs(sources, arch_v8_info):
tmp_env.Append(CPPDEFINES = arch_v8_info[1]['cppdefines'])
if 'sve' in arch_v8:
- # Toggle SVE/SVE2 specific extensions
tmp_env.Append(CPPDEFINES = ['ENABLE_SVE', 'ARM_COMPUTE_ENABLE_SVE'])
if 'sve2' in arch_v8:
tmp_env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_SVE2'])
else:
- # FIXME: The NEON flags should be always defined for CPU.
- # however, build fails when SVE/SVE2 & NEON flags
- # defined together.
tmp_env.Append(CPPDEFINES = ['ENABLE_NEON', 'ARM_COMPUTE_ENABLE_NEON'])
# we must differentiate the file object names
# as we accumulate the set.
- obj = []
+ objs = []
for src in sources:
- obj += tmp_env.SharedObject(target='{}-{}'.format(src, arch_v8), source=src)
+ objs += tmp_env.SharedObject('{}-{}.o'.format(src.replace('.cpp', ''), arch_v8), src)
- Default(obj)
- return obj
+ tmp_env.Default(objs)
+ return objs
def build_objs(sources):
@@ -93,7 +91,7 @@ def build_objs(sources):
def build_library(name, build_env, sources, static=False, libs=[]):
cloned_build_env = build_env.Clone()
- if env['os'] == 'android' and static == False:
+ if env['os'] == 'android' and static == False:
cloned_build_env["LINKFLAGS"].remove('-pie')
cloned_build_env["LINKFLAGS"].remove('-static-libstdc++')
@@ -106,7 +104,7 @@ def build_library(name, build_env, sources, static=False, libs=[]):
obj = cloned_build_env.SharedLibrary(name, source=sources, LIBS = arm_compute_env["LIBS"] + libs)
obj = install_lib(obj)
- Default(obj)
+ build_env.Default(obj)
return obj
@@ -563,22 +561,36 @@ if env['os'] == 'bare_metal':
bootcode_o = build_bootcode_objs(bootcode_files)
Export('bootcode_o')
-# Build static libraries
+# STATIC library build.
+#
+# Multi-ISA: We split the library into 2 static libs: arm_compute-static.a and arm_compute_multi_isa-static.a
+# to avoid 'argument list too long' error which being thrown due to OS string length limitation at link time.
+#
+# For single arch build: No change and we produce a single arm_compute-static.a
if (env['multi_isa']):
- # Available architecture
+ # Get v8 variants
arch_v8s = filedefs['cpu']['arch']
for arch_v8_info in arch_v8s.items():
multi_isa_objs_list += build_multi_isa_objs(lib_files_sve, arch_v8_info)
- arm_compute_a = build_library('arm_compute-static', arm_compute_env, lib_files + multi_isa_objs_list, static=True)
+ arm_compute_a = build_library('arm_compute-static', arm_compute_env, lib_files, static=True)
+ arm_compute_multi_isa_a = build_library('arm_compute_multi_isa-static', arm_compute_env, multi_isa_objs_list, static=True)
+ Export('arm_compute_multi_isa_a')
else:
arm_compute_a = build_library('arm_compute-static', arm_compute_env, lib_files + lib_files_sve, static=True)
+ arm_compute_multi_isa_a = None
+
Export('arm_compute_a')
-# Build shared libraries
+# SHARED library build.
+#
+# Multi-ISA: we leverage the prior static build such that the resulting
+# "libarm_compute.so" is combined from "arm_compute_multi_isa-static.a" and "lib_files" objects.
+#
+# For single arch build: No change.
if env['os'] != 'bare_metal' and not env['standalone']:
if (env['multi_isa']):
- arm_compute_so = build_library('arm_compute', arm_compute_env, lib_files + multi_isa_objs_list, static=False)
+ arm_compute_so = build_library('arm_compute', arm_compute_env, lib_files, static=False, libs=[arm_compute_multi_isa_a])
else:
arm_compute_so = build_library('arm_compute', arm_compute_env, lib_files + lib_files_sve, static=False)
@@ -602,7 +614,7 @@ arm_compute_graph_env = arm_compute_env.Clone()
# Build graph libraries
arm_compute_graph_env.Append(CXXFLAGS = ['-Wno-redundant-move', '-Wno-pessimizing-move'])
-arm_compute_graph_a = build_library('arm_compute_graph-static', arm_compute_graph_env, graph_files, static=True, libs = [ arm_compute_a])
+arm_compute_graph_a = build_library('arm_compute_graph-static', arm_compute_graph_env, graph_files, static=True, libs = [ arm_compute_a, arm_compute_multi_isa_a ])
Export('arm_compute_graph_a')
if env['os'] != 'bare_metal' and not env['standalone']:
@@ -611,7 +623,7 @@ if env['os'] != 'bare_metal' and not env['standalone']:
Export('arm_compute_graph_so')
if env['standalone']:
- alias = arm_compute_env.Alias("arm_compute", [arm_compute_a])
+ alias = arm_compute_env.Alias("arm_compute", [arm_compute_a, arm_compute_multi_isa_a])
else:
alias = arm_compute_env.Alias("arm_compute", [arm_compute_a, arm_compute_so])
diff --git a/SConstruct b/SConstruct
index 2a8403f8ce..28704d3459 100644
--- a/SConstruct
+++ b/SConstruct
@@ -126,6 +126,7 @@ vars.AddVariables(
("build_config", "Operator/Data-type/Data-layout configuration to use for tailored ComputeLibrary builds. Can be a JSON file or a JSON formatted string", "")
)
+
env = Environment(platform="posix", variables=vars, ENV = os.environ)
build_path = env['build_dir']
# If build_dir is a relative path then add a #build/ prefix:
@@ -248,6 +249,13 @@ if 'v7a' in env['estate'] and env['estate'] == '64':
print("ERROR: armv7a architecture has only 32-bit execution state")
Exit(1)
+if 'sve' in env['arch']:
+ env.Append(CPPDEFINES = ['ENABLE_SVE', 'ARM_COMPUTE_ENABLE_SVE'])
+ if 'sve2' in env['arch']:
+ env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_SVE2'])
+else:
+ env.Append(CPPDEFINES = ['ENABLE_NEON', 'ARM_COMPUTE_ENABLE_NEON'])
+
# Add architecture specific flags
prefix = ""
if env['multi_isa']:
@@ -262,17 +270,6 @@ if env['multi_isa']:
else: # NONE "multi_isa" builds
- if 'sve' in env['arch']:
- env.Append(CPPDEFINES = ['ENABLE_SVE', 'ARM_COMPUTE_ENABLE_SVE'])
- if 'sve2' in env['arch']:
- env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_SVE2'])
- else:
- # FIXME: The NEON flags should be always defined for CPU.
- # however, build fails when SVE/SVE2 & NEON flags
- # defined together.
- env.Append(CPPDEFINES = ['ENABLE_NEON', 'ARM_COMPUTE_ENABLE_NEON'])
-
-
if 'v7a' in env['arch']:
env.Append(CXXFLAGS = ['-march=armv7-a', '-mthumb', '-mfpu=neon'])
if (env['os'] == 'android' or env['os'] == 'tizen') and not 'hf' in env['arch']:
@@ -483,3 +480,11 @@ if env['exceptions']:
print("WARNING: Building tests for bare metal and armv7a is not supported")
Return()
SConscript('./tests/SConscript', variant_dir='%s/tests' % build_path, duplicate=0)
+
+# Unknown variables are not allowed
+# Note: we must delay the call of UnknownVariables until after
+# we have applied the Variables object to the construction environment
+unknown = vars.UnknownVariables()
+if unknown:
+ print("Unknown variables: %s" % " ".join(unknown.keys()))
+ Exit(1) \ No newline at end of file