diff options
author | Anthony Barbier <anthony.barbier@arm.com> | 2017-06-23 15:42:00 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2017-06-23 16:07:31 +0100 |
commit | dbdab85d6e0f96d3361a9e30310367d89953466c (patch) | |
tree | 0cc80d19fd8192de6eca2d28f7e4062aa9deecbf /SConstruct | |
parent | 664d833b9d7b569db60b0f6d93e80f91f2c07c39 (diff) | |
download | armcl-dbdab85d6e0f96d3361a9e30310367d89953466c.tar.gz armcl-dbdab85d6e0f96d3361a9e30310367d89953466c.tar.bz2 armcl-dbdab85d6e0f96d3361a9e30310367d89953466c.zip |
arm_compute v17.06
Diffstat (limited to 'SConstruct')
-rw-r--r-- | SConstruct | 166 |
1 files changed, 161 insertions, 5 deletions
diff --git a/SConstruct b/SConstruct index 862eec71e..3927e3acc 100644 --- a/SConstruct +++ b/SConstruct @@ -20,7 +20,20 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import SCons import os +import subprocess + +def version_at_least(version, required): + end = min(len(version), len(required)) + + for i in range(0, end, 2): + if int(version[i]) < int(required[i]): + return False + elif int(version[i]) > int(required[i]): + return True + + return True vars = Variables("scons") vars.AddVariables( @@ -29,7 +42,7 @@ vars.AddVariables( EnumVariable("arch", "Target Architecture", "armv7a", allowed_values=("armv7a", "arm64-v8a", "arm64-v8.2-a", "x86_32", "x86_64")), EnumVariable("os", "Target OS", "linux", allowed_values=("linux", "android", "bare_metal")), EnumVariable("build", "Build type", "cross_compile", allowed_values=("native", "cross_compile")), - BoolVariable("examples", "Build example programs", False), + BoolVariable("examples", "Build example programs", True), BoolVariable("Werror", "Enable/disable the -Werror compilation flag", True), BoolVariable("opencl", "Enable OpenCL support", True), BoolVariable("neon", "Enable Neon support", False), @@ -37,16 +50,159 @@ vars.AddVariables( BoolVariable("set_soname", "Set the library's soname and shlibversion (requires SCons 2.4 or above)", False), BoolVariable("openmp", "Enable OpenMP backend", False), BoolVariable("cppthreads", "Enable C++11 threads backend", True), - PathVariable("build_dir", "Specify sub-folder for the build", ".", PathVariable.PathIsDirCreate), + PathVariable("build_dir", "Specify sub-folder for the build", ".", PathVariable.PathAccept), ("extra_cxx_flags", "Extra CXX flags to be appended to the build command", "") ) -env = Environment(platform='posix', variables = vars, ENV = os.environ) +env = Environment(platform="posix", variables=vars, ENV = os.environ) + +SConsignFile('build/.%s' % env['build_dir']) Help(vars.GenerateHelpText(env)) +if env['neon'] and 'x86' in env['arch']: + print "Cannot compile NEON for x86" + Exit(1) + +if env['set_soname'] and not version_at_least(SCons.__version__, "2.4"): + print "Setting the library's SONAME / SHLIBVERSION requires SCons 2.4 or above" + print "Update your version of SCons or use set_soname=0" + Exit(1) + +if env['os'] == 'bare_metal': + if env['cppthreads'] or env['openmp']: + print("ERROR: OpenMP and C++11 threads not supported in bare_metal. Use cppthreads=0 openmp=0") + Exit(1) + +env.Append(CXXFLAGS = ['-Wno-deprecated-declarations','-Wall','-DARCH_ARM', + '-Wextra','-Wno-unused-parameter','-pedantic','-Wdisabled-optimization','-Wformat=2', + '-Winit-self','-Wstrict-overflow=2','-Wswitch-default', + '-fpermissive','-std=gnu++11','-Wno-vla','-Woverloaded-virtual', + '-Wctor-dtor-privacy','-Wsign-promo','-Weffc++','-Wno-format-nonliteral','-Wno-overlength-strings','-Wno-strict-overflow']) +env.Append(CPPDEFINES = ['_GLIBCXX_USE_NANOSLEEP']) + +if os.environ.get('CXX', 'g++') == 'clang++': + env.Append(CXXFLAGS = ['-Wno-format-nonliteral','-Wno-deprecated-increment-bool','-Wno-vla-extension','-Wno-mismatched-tags']) +else: + env.Append(CXXFLAGS = ['-Wlogical-op','-Wnoexcept','-Wstrict-null-sentinel']) + +if env['cppthreads']: + env.Append(CPPDEFINES = [('ARM_COMPUTE_CPP_SCHEDULER', 1)]) + +if env['openmp']: + if os.environ.get('CXX', 'g++') == 'clang++': + print "Clang does not support OpenMP. Use scheduler=cpp." + Exit(1) + + env.Append(CPPDEFINES = [('ARM_COMPUTE_OPENMP_SCHEDULER', 1)]) + env.Append(CXXFLAGS = ['-fopenmp']) + env.Append(LINKFLAGS = ['-fopenmp']) + +prefix = "" +if env['arch'] == 'armv7a': + env.Append(CXXFLAGS = ['-march=armv7-a', '-mthumb', '-mfpu=neon']) + + if env['os'] in ['linux', 'bare_metal']: + prefix = "arm-linux-gnueabihf-" + env.Append(CXXFLAGS = ['-mfloat-abi=hard']) + elif env['os'] == 'android': + prefix = "arm-linux-androideabi-" + env.Append(CXXFLAGS = ['-mfloat-abi=softfp']) +elif env['arch'] == 'arm64-v8a': + env.Append(CXXFLAGS = ['-march=armv8-a']) + + if env['os'] in ['linux', 'bare_metal']: + prefix = "aarch64-linux-gnu-" + elif env['os'] == 'android': + prefix = "aarch64-linux-android-" +elif env['arch'] == 'arm64-v8.2-a': + env.Append(CXXFLAGS = ['-march=armv8.2-a+fp16+simd']) + env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_FP16']) + + if env['os'] in ['linux', 'bare_metal']: + prefix = "aarch64-linux-gnu-" + elif env['os'] == 'android': + prefix = "aarch64-linux-android-" +elif env['arch'] == 'x86_32': + env.Append(CCFLAGS = ['-m32']) + env.Append(LINKFLAGS = ['-m32']) +elif env['arch'] == 'x86_64': + env.Append(CCFLAGS = ['-m64']) + env.Append(LINKFLAGS = ['-m64']) + +if env['build'] == 'native': + prefix = "" + +env['CC'] = prefix + os.environ.get('CC', 'gcc') +env['CXX'] = prefix + os.environ.get('CXX', 'g++') +env['LD'] = prefix + "ld" +env['AS'] = prefix + "as" +env['AR'] = prefix + "ar" +env['RANLIB'] = prefix + "ranlib" + +if not GetOption("help"): + try: + compiler_ver = subprocess.check_output([env['CXX'], "-dumpversion"]).strip() + except OSError: + print("ERROR: Compiler '%s' not found" % env['CXX']) + Exit(1) + + if os.environ.get('CXX','g++') == 'g++': + if env['arch'] == 'arm64-v8.2-a' and not version_at_least(compiler_ver, '6.2.1'): + print "GCC 6.2.1 or newer is required to compile armv8.2-a code" + Exit(1) + elif env['arch'] == 'arm64-v8a' and not version_at_least(compiler_ver, '4.9'): + print "GCC 4.9 or newer is required to compile NEON code for AArch64" + Exit(1) + + if version_at_least(compiler_ver, '6.1'): + env.Append(CXXFLAGS = ['-Wno-ignored-attributes']) + + if compiler_ver == '4.8.3': + env.Append(CXXFLAGS = ['-Wno-array-bounds']) + +if env['Werror']: + env.Append(CXXFLAGS = ['-Werror']) + +if env['os'] == 'android': + env.Append(CPPDEFINES = ['ANDROID']) + env.Append(LINKFLAGS = ['-pie', '-static-libstdc++']) +elif env['os'] == 'bare_metal': + env.Append(LINKFLAGS = ['-static']) + env.Append(CXXFLAGS = ['-fPIC']) + env.Append(CPPDEFINES = ['NO_MULTI_THREADING']) + +if env['opencl']: + if env['os'] == 'bare_metal': + print("Cannot link OpenCL statically, which is required on bare metal") + Exit(1) + + if env['embed_kernels']: + env.Append(CPPDEFINES = ['EMBEDDED_KERNELS']) + +if env['debug']: + env['asserts'] = True + env.Append(CXXFLAGS = ['-O0','-g','-gdwarf-2']) + env.Append(CPPDEFINES = ['ARM_COMPUTE_DEBUG_ENABLED']) +else: + env.Append(CXXFLAGS = ['-O3','-ftree-vectorize']) + +if env['asserts']: + env.Append(CPPDEFINES = ['ARM_COMPUTE_ASSERTS_ENABLED']) + +env.Append(CPPPATH = ['#/include', "#"]) +env.Append(CXXFLAGS = env['extra_cxx_flags']) + Export('vars') Export('env') +Export('version_at_least') -if not GetOption("help"): - SConscript('sconscript', variant_dir='#build/%s/arm_compute' % env['build_dir'], duplicate=0) +SConscript('./SConscript', variant_dir='#build/%s' % env['build_dir'], duplicate=0) + +if env['opencl']: + SConscript("./opencl-1.2-stubs/SConscript", variant_dir="build/%s/opencl-1.2-stubs" % env['build_dir'], duplicate=0) + +if env['examples']: + SConscript('./examples/SConscript', variant_dir='#build/%s/examples' % env['build_dir'], duplicate=0) + +SConscript('./tests/SConscript', variant_dir='#build/%s/tests' % env['build_dir'], duplicate=0) |