Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
| 3 | # Copyright (c) 2016-2023 Arm Limited. |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 4 | # |
| 5 | # SPDX-License-Identifier: MIT |
| 6 | # |
| 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | # of this software and associated documentation files (the "Software"), to |
| 9 | # deal in the Software without restriction, including without limitation the |
| 10 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 11 | # sell copies of the Software, and to permit persons to whom the Software is |
| 12 | # furnished to do so, subject to the following conditions: |
| 13 | # |
| 14 | # The above copyright notice and this permission notice shall be included in all |
| 15 | # copies or substantial portions of the Software. |
| 16 | # |
| 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | # SOFTWARE. |
| 24 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 25 | import SCons |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 26 | import json |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 27 | import os |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 28 | from subprocess import check_output |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 29 | |
| 30 | def version_at_least(version, required): |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 31 | |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 32 | version_list = version.split('.') |
| 33 | required_list = required.split('.') |
| 34 | end = min(len(version_list), len(required_list)) |
| 35 | for i in range(0, end): |
| 36 | if int(version_list[i]) < int(required_list[i]): |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 37 | return False |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 38 | elif int(version_list[i]) > int(required_list[i]): |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 39 | return True |
| 40 | |
| 41 | return True |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 42 | |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 43 | def read_build_config_json(build_config): |
| 44 | build_config_contents = {} |
| 45 | custom_types = [] |
| 46 | custom_layouts = [] |
| 47 | if os.path.isfile(build_config): |
| 48 | with open(build_config) as f: |
| 49 | try: |
| 50 | build_config_contents = json.load(f) |
| 51 | except: |
| 52 | print("Warning: Build configuration file is of invalid JSON format!") |
| 53 | else: |
| 54 | try: |
| 55 | build_config_contents = json.loads(build_config) |
| 56 | except: |
| 57 | print("Warning: Build configuration string is of invalid JSON format!") |
| 58 | if build_config_contents: |
| 59 | custom_types = build_config_contents.get("data_types", []) |
| 60 | custom_layouts = build_config_contents.get("data_layouts", []) |
| 61 | return custom_types, custom_layouts |
| 62 | |
| 63 | def update_data_type_layout_flags(env, data_types, data_layouts): |
| 64 | # Manage data-types |
| 65 | if any(i in data_types for i in ['all', 'fp16']): |
| 66 | env.Append(CXXFLAGS = ['-DENABLE_FP16_KERNELS']) |
| 67 | if any(i in data_types for i in ['all', 'fp32']): |
| 68 | env.Append(CXXFLAGS = ['-DENABLE_FP32_KERNELS']) |
| 69 | if any(i in data_types for i in ['all', 'qasymm8']): |
| 70 | env.Append(CXXFLAGS = ['-DENABLE_QASYMM8_KERNELS']) |
| 71 | if any(i in data_types for i in ['all', 'qasymm8_signed']): |
| 72 | env.Append(CXXFLAGS = ['-DENABLE_QASYMM8_SIGNED_KERNELS']) |
| 73 | if any(i in data_types for i in ['all', 'qsymm16']): |
| 74 | env.Append(CXXFLAGS = ['-DENABLE_QSYMM16_KERNELS']) |
| 75 | if any(i in data_types for i in ['all', 'integer']): |
| 76 | env.Append(CXXFLAGS = ['-DENABLE_INTEGER_KERNELS']) |
| 77 | |
| 78 | # Manage data-layouts |
| 79 | if any(i in data_layouts for i in ['all', 'nhwc']): |
| 80 | env.Append(CXXFLAGS = ['-DENABLE_NHWC_KERNELS']) |
| 81 | if any(i in data_layouts for i in ['all', 'nchw']): |
| 82 | env.Append(CXXFLAGS = ['-DENABLE_NCHW_KERNELS']) |
| 83 | |
| 84 | return env |
| 85 | |
| 86 | |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 87 | vars = Variables("scons") |
| 88 | vars.AddVariables( |
| 89 | BoolVariable("debug", "Debug", False), |
| 90 | BoolVariable("asserts", "Enable asserts (this flag is forced to 1 for debug=1)", False), |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 91 | BoolVariable("logging", "Enable Logging", False), |
| 92 | EnumVariable("arch", "Target Architecture. The x86_32 and x86_64 targets can only be used with neon=0 and opencl=1.", "armv7a", |
| 93 | allowed_values=("armv7a", "armv7a-hf", "arm64-v8a", "arm64-v8.2-a", "arm64-v8.2-a-sve", "arm64-v8.2-a-sve2", "x86_32", "x86_64", |
| 94 | "armv8a", "armv8.2-a", "armv8.2-a-sve", "armv8.6-a", "armv8.6-a-sve", "armv8.6-a-sve2", "armv8.6-a-sve2-sme2", "armv8r64", "x86")), |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 95 | EnumVariable("estate", "Execution State", "auto", allowed_values=("auto", "32", "64")), |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 96 | EnumVariable("os", "Target OS. With bare metal selected, only Arm® Neon™ (not OpenCL) can be used, static libraries get built and Neon™'s multi-threading support is disabled.", "linux", allowed_values=("linux", "android", "tizen", "macos", "bare_metal", "openbsd","windows")), |
| 97 | EnumVariable("build", "Either build directly on your device (native) or cross compile from your desktop machine (cross-compile). In both cases make sure the compiler is available in your path.", "cross_compile", allowed_values=("native", "cross_compile", "embed_only")), |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 98 | BoolVariable("examples", "Build example programs", True), |
Jenkins | 0e205f7 | 2019-11-28 16:53:35 +0000 | [diff] [blame] | 99 | BoolVariable("gemm_tuner", "Build gemm_tuner programs", True), |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 100 | BoolVariable("Werror", "Enable/disable the -Werror compilation flag", True), |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 101 | BoolVariable("multi_isa", "Build Multi ISA binary version of library. Note works only for armv8.2-a", False), |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 102 | BoolVariable("standalone", "Builds the tests as standalone executables, links statically with libgcc, libstdc++ and libarm_compute", False), |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 103 | BoolVariable("opencl", "Enable OpenCL support", True), |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 104 | BoolVariable("neon", "Enable Arm® Neon™ support", False), |
| 105 | BoolVariable("embed_kernels", "Enable if you want the OpenCL kernels to be built in the library's binaries instead of being read from separate '.cl' / '.cs' files. If embed_kernels is set to 0 then the application can set the path to the folder containing the OpenCL kernel files by calling CLKernelLibrary::init(). By default the path is set to './cl_kernels'.", True), |
| 106 | BoolVariable("compress_kernels", "Compress embedded OpenCL kernels in library binary using zlib. Useful for reducing the binary size. embed_kernels should be enabled", False), |
| 107 | BoolVariable("set_soname", "If enabled the library will contain a SONAME and SHLIBVERSION and some symlinks will automatically be created between the objects. (requires SCons 2.4 or above)", False), |
| 108 | BoolVariable("openmp", "Enable OpenMP backend. Only works when building with g++ and not clang++", False), |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 109 | BoolVariable("cppthreads", "Enable C++11 threads backend", True), |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 110 | PathVariable("build_dir", "Specify sub-folder for the build", ".", PathVariable.PathAccept), |
Jenkins | b9abeae | 2018-11-22 11:58:08 +0000 | [diff] [blame] | 111 | PathVariable("install_dir", "Specify sub-folder for the install", "", PathVariable.PathAccept), |
Jenkins | 514be65 | 2019-02-28 12:25:18 +0000 | [diff] [blame] | 112 | BoolVariable("exceptions", "Enable/disable C++ exception support", True), |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 113 | BoolVariable("high_priority", "Generate a library containing only the high priority operators", False), |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 114 | PathVariable("linker_script", "Use an external linker script", "", PathVariable.PathAccept), |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 115 | PathVariable("external_tests_dir", """Add examples, benchmarks and tests to the tests suite from an external path. In order to use this option, the external tests directory must have the following structure: |
| 116 | EXTERNAL_TESTS_DIR: |
| 117 | └── tests |
| 118 | ├── benchmark |
| 119 | │ ├── CL |
| 120 | │ ├── datasets |
| 121 | │ ├── fixtures |
| 122 | │ └── Neon |
| 123 | └── validation |
| 124 | ├── CL |
| 125 | ├── datasets |
| 126 | ├── fixtures |
| 127 | └── Neon\n""", "", PathVariable.PathAccept), |
| 128 | BoolVariable("experimental_dynamic_fusion", "Build the experimental dynamic fusion files", False), |
| 129 | BoolVariable("experimental_fixed_format_kernels", "Enable fixed format kernels for GEMM", False), |
| 130 | BoolVariable("mapfile", "Generate a map file", False), |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 131 | ListVariable("custom_options", "Custom options that can be used to turn on/off features", "none", ["disable_mmla_fp"]), |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 132 | ListVariable("data_type_support", "Enable a list of data types to support", "all", ["qasymm8", "qasymm8_signed", "qsymm16", "fp16", "fp32", "integer"]), |
| 133 | ListVariable("data_layout_support", "Enable a list of data layout to support", "all", ["nhwc", "nchw"]), |
| 134 | ("toolchain_prefix", "Override the toolchain prefix; used by all toolchain components: compilers, linker, assembler etc. If unspecified, use default(auto) prefixes; if passed an empty string '' prefixes would be disabled", "auto"), |
| 135 | ("compiler_prefix", "Override the compiler prefix; used by just compilers (CC,CXX); further overrides toolchain_prefix for compilers; this is for when the compiler prefixes are different from that of the linkers, archivers etc. If unspecified, this is the same as toolchain_prefix; if passed an empty string '' prefixes would be disabled", "auto"), |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 136 | ("extra_cxx_flags", "Extra CXX flags to be appended to the build command", ""), |
Jenkins | b9abeae | 2018-11-22 11:58:08 +0000 | [diff] [blame] | 137 | ("extra_link_flags", "Extra LD flags to be appended to the build command", ""), |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 138 | ("compiler_cache", "Command to prefix to the C and C++ compiler (e.g ccache)", ""), |
| 139 | ("specs_file", "Specs file to use (e.g. rdimon.specs)", ""), |
| 140 | ("build_config", "Operator/Data-type/Data-layout configuration to use for tailored ComputeLibrary builds. Can be a JSON file or a JSON formatted string", "") |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 141 | ) |
| 142 | |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 143 | |
| 144 | env = Environment(variables=vars, ENV = os.environ) |
| 145 | |
| 146 | |
Jenkins | b9abeae | 2018-11-22 11:58:08 +0000 | [diff] [blame] | 147 | build_path = env['build_dir'] |
| 148 | # If build_dir is a relative path then add a #build/ prefix: |
| 149 | if not env['build_dir'].startswith('/'): |
| 150 | SConsignFile('build/%s/.scons' % build_path) |
| 151 | build_path = "#build/%s" % build_path |
| 152 | else: |
| 153 | SConsignFile('%s/.scons' % build_path) |
| 154 | |
| 155 | install_path = env['install_dir'] |
| 156 | #If the install_dir is a relative path then assume it's from inside build_dir |
| 157 | if not env['install_dir'].startswith('/') and install_path != "": |
| 158 | install_path = "%s/%s" % (build_path, install_path) |
| 159 | |
| 160 | env.Append(LIBPATH = [build_path]) |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 161 | Export('env') |
| 162 | Export('vars') |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 163 | |
Jenkins | b9abeae | 2018-11-22 11:58:08 +0000 | [diff] [blame] | 164 | def install_lib( lib ): |
| 165 | # If there is no install folder, then there is nothing to do: |
| 166 | if install_path == "": |
| 167 | return lib |
| 168 | return env.Install( "%s/lib/" % install_path, lib) |
| 169 | def install_bin( bin ): |
| 170 | # If there is no install folder, then there is nothing to do: |
| 171 | if install_path == "": |
| 172 | return bin |
| 173 | return env.Install( "%s/bin/" % install_path, bin) |
| 174 | def install_include( inc ): |
| 175 | if install_path == "": |
| 176 | return inc |
| 177 | return env.Install( "%s/include/" % install_path, inc) |
| 178 | |
| 179 | Export('install_lib') |
| 180 | Export('install_bin') |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 181 | |
| 182 | Help(vars.GenerateHelpText(env)) |
| 183 | |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 184 | if 'armv7a' in env['arch'] and env['os'] == 'android': |
| 185 | print("WARNING: armv7a on Android is no longer maintained") |
| 186 | |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 187 | if env['linker_script'] and env['os'] != 'bare_metal': |
| 188 | print("Linker script is only supported for bare_metal builds") |
| 189 | Exit(1) |
| 190 | |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 191 | if env['build'] == "embed_only": |
Jenkins | b9abeae | 2018-11-22 11:58:08 +0000 | [diff] [blame] | 192 | SConscript('./SConscript', variant_dir=build_path, duplicate=0) |
Anthony Barbier | 06ea048 | 2018-02-22 15:45:35 +0000 | [diff] [blame] | 193 | Return() |
| 194 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 195 | if env['neon'] and 'x86' in env['arch']: |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 196 | print("Cannot compile Arm® Neon™ for x86") |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 197 | Exit(1) |
| 198 | |
| 199 | if env['set_soname'] and not version_at_least(SCons.__version__, "2.4"): |
ggardet | e2542c9 | 2018-06-29 17:01:01 +0200 | [diff] [blame] | 200 | print("Setting the library's SONAME / SHLIBVERSION requires SCons 2.4 or above") |
| 201 | print("Update your version of SCons or use set_soname=0") |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 202 | Exit(1) |
| 203 | |
| 204 | if env['os'] == 'bare_metal': |
| 205 | if env['cppthreads'] or env['openmp']: |
| 206 | print("ERROR: OpenMP and C++11 threads not supported in bare_metal. Use cppthreads=0 openmp=0") |
| 207 | Exit(1) |
| 208 | |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 209 | if env['opencl'] and env['embed_kernels'] and env['compress_kernels'] and env['os'] not in ['android']: |
| 210 | print("Compressed kernels are supported only for android builds") |
| 211 | Exit(1) |
| 212 | |
Jenkins | 514be65 | 2019-02-28 12:25:18 +0000 | [diff] [blame] | 213 | if not env['exceptions']: |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 214 | if env['opencl']: |
| 215 | print("ERROR: OpenCL is not supported when building without exceptions. Use opencl=0") |
Jenkins | 514be65 | 2019-02-28 12:25:18 +0000 | [diff] [blame] | 216 | Exit(1) |
| 217 | |
| 218 | env.Append(CPPDEFINES = ['ARM_COMPUTE_EXCEPTIONS_DISABLED']) |
| 219 | env.Append(CXXFLAGS = ['-fno-exceptions']) |
| 220 | |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 221 | env.Append(CXXFLAGS = ['-DARCH_ARM', |
| 222 | '-Wextra','-Wdisabled-optimization','-Wformat=2', |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 223 | '-Winit-self','-Wstrict-overflow=2','-Wswitch-default', |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 224 | '-Woverloaded-virtual', '-Wformat-security', |
Jenkins | 0e205f7 | 2019-11-28 16:53:35 +0000 | [diff] [blame] | 225 | '-Wctor-dtor-privacy','-Wsign-promo','-Weffc++','-Wno-overlength-strings']) |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame] | 226 | |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 227 | if not 'windows' in env['os']: |
| 228 | env.Append(CXXFLAGS = ['-Wall','-std=c++14', '-pedantic' ]) |
| 229 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 230 | env.Append(CPPDEFINES = ['_GLIBCXX_USE_NANOSLEEP']) |
| 231 | |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 232 | cpp_tool = {'linux': 'g++', 'android' : 'clang++', |
| 233 | 'tizen': 'g++', 'macos':'clang++', |
| 234 | 'bare_metal':'g++', 'openbsd':'g++','windows':'clang-cl'} |
| 235 | |
| 236 | c_tool = {'linux':'gcc', 'android': 'clang', 'tizen':'gcc', |
| 237 | 'macos':'clang','bare_metal':'gcc', |
| 238 | 'openbsd':'gcc','windows':'clang-cl'} |
| 239 | |
| 240 | default_cpp_compiler = cpp_tool[env['os']] |
| 241 | default_c_compiler = c_tool[env['os']] |
Anthony Barbier | f45d5a9 | 2018-01-24 16:23:15 +0000 | [diff] [blame] | 242 | cpp_compiler = os.environ.get('CXX', default_cpp_compiler) |
| 243 | c_compiler = os.environ.get('CC', default_c_compiler) |
| 244 | |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 245 | if env['os'] == 'android' and ( 'clang++' not in cpp_compiler or 'clang' not in c_compiler ): |
ggardet | e2542c9 | 2018-06-29 17:01:01 +0200 | [diff] [blame] | 246 | print( "WARNING: Only clang is officially supported to build the Compute Library for Android") |
Anthony Barbier | f45d5a9 | 2018-01-24 16:23:15 +0000 | [diff] [blame] | 247 | |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 248 | if 'clang++' in cpp_compiler: |
Jenkins | 0e205f7 | 2019-11-28 16:53:35 +0000 | [diff] [blame] | 249 | env.Append(CXXFLAGS = ['-Wno-vla-extension']) |
| 250 | elif 'armclang' in cpp_compiler: |
| 251 | pass |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 252 | elif not 'windows' in env['os']: |
| 253 | env.Append(CXXFLAGS = ['-Wlogical-op','-Wnoexcept','-Wstrict-null-sentinel','-Wno-misleading-indentation']) |
| 254 | |
| 255 | if cpp_compiler == 'g++': |
| 256 | # Don't strip comments that could include markers |
| 257 | env.Append(CXXFLAGS = ['-C']) |
Jenkins | 7dcb9fa | 2021-02-23 22:45:28 +0000 | [diff] [blame] | 258 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 259 | if env['cppthreads']: |
| 260 | env.Append(CPPDEFINES = [('ARM_COMPUTE_CPP_SCHEDULER', 1)]) |
| 261 | |
| 262 | if env['openmp']: |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 263 | env.Append(CPPDEFINES = [('ARM_COMPUTE_OPENMP_SCHEDULER', 1)]) |
| 264 | env.Append(CXXFLAGS = ['-fopenmp']) |
| 265 | env.Append(LINKFLAGS = ['-fopenmp']) |
| 266 | |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 267 | # Validate and define state |
| 268 | if env['estate'] == 'auto': |
| 269 | if 'v7a' in env['arch']: |
| 270 | env['estate'] = '32' |
| 271 | else: |
| 272 | env['estate'] = '64' |
| 273 | |
| 274 | # Map legacy arch |
| 275 | if 'arm64' in env['arch']: |
| 276 | env['estate'] = '64' |
| 277 | |
| 278 | if 'v7a' in env['estate'] and env['estate'] == '64': |
| 279 | print("ERROR: armv7a architecture has only 32-bit execution state") |
| 280 | Exit(1) |
| 281 | |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 282 | env.Append(CPPDEFINES = ['ENABLE_NEON', 'ARM_COMPUTE_ENABLE_NEON']) |
| 283 | |
| 284 | if 'sve' in env['arch']: |
| 285 | env.Append(CPPDEFINES = ['ENABLE_SVE', 'ARM_COMPUTE_ENABLE_SVE']) |
| 286 | if 'sve2' in env['arch']: |
| 287 | env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_SVE2']) |
| 288 | |
| 289 | if 'sme' in env['arch']: |
| 290 | env.Append(CPPDEFINES = ['ENABLE_SME', 'ARM_COMPUTE_ENABLE_SME']) |
| 291 | if 'sme2' in env['arch']: |
| 292 | env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_SME2']) |
| 293 | |
Jenkins | 0e205f7 | 2019-11-28 16:53:35 +0000 | [diff] [blame] | 294 | # Add architecture specific flags |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 295 | if env['multi_isa']: |
| 296 | # assert arch version is v8 |
| 297 | if 'v8' not in env['arch']: |
| 298 | print("Currently Multi ISA binary is only supported for arm v8 family") |
| 299 | Exit(1) |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 300 | |
| 301 | if 'v8.6-a' in env['arch']: |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 302 | if "disable_mmla_fp" not in env['custom_options']: |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 303 | env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_SVEF32MM']) |
Jenkins | c66f0e0 | 2021-08-20 08:52:20 +0000 | [diff] [blame] | 304 | |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 305 | env.Append(CXXFLAGS = ['-march=armv8.2-a+fp16']) # explicitly enable fp16 extension otherwise __ARM_FEATURE_FP16_VECTOR_ARITHMETIC is undefined |
| 306 | |
| 307 | else: # NONE "multi_isa" builds |
| 308 | |
| 309 | if 'v7a' in env['arch']: |
| 310 | env.Append(CXXFLAGS = ['-march=armv7-a', '-mthumb', '-mfpu=neon']) |
| 311 | if (env['os'] == 'android' or env['os'] == 'tizen') and not 'hf' in env['arch']: |
| 312 | env.Append(CXXFLAGS = ['-mfloat-abi=softfp']) |
| 313 | else: |
| 314 | env.Append(CXXFLAGS = ['-mfloat-abi=hard']) |
| 315 | elif 'v8.6-a' in env['arch']: |
| 316 | if 'armv8.6-a-sve2' in env['arch']: |
| 317 | env.Append(CXXFLAGS = ['-march=armv8.6-a+sve2']) |
| 318 | elif 'armv8.6-a-sve' == env['arch']: |
| 319 | env.Append(CXXFLAGS = ['-march=armv8.6-a+sve']) |
| 320 | elif 'armv8.6-a' == env['arch']: |
| 321 | env.Append(CXXFLAGS = ['-march=armv8.6-a+fp16']) |
| 322 | |
| 323 | env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_I8MM', 'ARM_COMPUTE_ENABLE_BF16','ARM_COMPUTE_ENABLE_FP16']) |
| 324 | if "disable_mmla_fp" not in env['custom_options']: |
| 325 | env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_SVEF32MM']) |
| 326 | elif 'v8' in env['arch']: |
| 327 | # Preserve the V8 archs for non-multi-ISA variants |
| 328 | if 'sve2' in env['arch']: |
| 329 | env.Append(CXXFLAGS = ['-march=armv8.2-a+sve2+fp16+dotprod']) |
| 330 | elif 'sve' in env['arch']: |
| 331 | env.Append(CXXFLAGS = ['-march=armv8.2-a+sve+fp16+dotprod']) |
| 332 | elif 'armv8r64' in env['arch']: |
| 333 | env.Append(CXXFLAGS = ['-march=armv8.4-a']) |
| 334 | elif 'v8.' in env['arch']: |
| 335 | env.Append(CXXFLAGS = ['-march=armv8.2-a+fp16']) # explicitly enable fp16 extension otherwise __ARM_FEATURE_FP16_VECTOR_ARITHMETIC is undefined |
| 336 | else: |
| 337 | env.Append(CXXFLAGS = ['-march=armv8-a']) |
| 338 | |
| 339 | if 'v8.' in env['arch']: |
| 340 | env.Append(CPPDEFINES = ['ARM_COMPUTE_ENABLE_FP16']) |
| 341 | |
| 342 | elif 'x86' in env['arch']: |
| 343 | if env['estate'] == '32': |
| 344 | env.Append(CCFLAGS = ['-m32']) |
| 345 | env.Append(LINKFLAGS = ['-m32']) |
| 346 | else: |
| 347 | env.Append(CXXFLAGS = ['-fPIC']) |
| 348 | env.Append(CCFLAGS = ['-m64']) |
| 349 | env.Append(LINKFLAGS = ['-m64']) |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 350 | |
| 351 | # Define toolchain |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 352 | # The reason why we distinguish toolchain_prefix from compiler_prefix is for cases where the linkers/archivers use a |
| 353 | # different prefix than the compilers. An example is the NDK r20 toolchain |
| 354 | auto_toolchain_prefix = "" |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 355 | if 'x86' not in env['arch']: |
| 356 | if env['estate'] == '32': |
| 357 | if env['os'] == 'linux': |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 358 | auto_toolchain_prefix = "arm-linux-gnueabihf-" if 'v7' in env['arch'] else "armv8l-linux-gnueabihf-" |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 359 | elif env['os'] == 'bare_metal': |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 360 | auto_toolchain_prefix = "arm-eabi-" |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 361 | elif env['os'] == 'android': |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 362 | auto_toolchain_prefix = "arm-linux-androideabi-" |
Jenkins | 6a7771e | 2020-05-28 11:28:36 +0100 | [diff] [blame] | 363 | elif env['os'] == 'tizen': |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 364 | auto_toolchain_prefix = "armv7l-tizen-linux-gnueabi-" |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 365 | elif env['estate'] == '64' and 'v8' in env['arch']: |
| 366 | if env['os'] == 'linux': |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 367 | auto_toolchain_prefix = "aarch64-linux-gnu-" |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 368 | elif env['os'] == 'bare_metal': |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 369 | auto_toolchain_prefix = "aarch64-elf-" |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 370 | elif env['os'] == 'android': |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 371 | auto_toolchain_prefix = "aarch64-linux-android-" |
Jenkins | 6a7771e | 2020-05-28 11:28:36 +0100 | [diff] [blame] | 372 | elif env['os'] == 'tizen': |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 373 | auto_toolchain_prefix = "aarch64-tizen-linux-gnu-" |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 374 | |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 375 | if env['build'] == 'native' or env["toolchain_prefix"] == "": |
| 376 | toolchain_prefix = "" |
| 377 | elif env["toolchain_prefix"] == "auto": |
| 378 | toolchain_prefix = auto_toolchain_prefix |
| 379 | else: |
| 380 | toolchain_prefix = env["toolchain_prefix"] |
Jenkins | 514be65 | 2019-02-28 12:25:18 +0000 | [diff] [blame] | 381 | |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 382 | if env['build'] == 'native' or env["compiler_prefix"] == "": |
| 383 | compiler_prefix = "" |
| 384 | elif env["compiler_prefix"] == "auto": |
| 385 | compiler_prefix = toolchain_prefix |
| 386 | else: |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 387 | compiler_prefix = env["compiler_prefix"] |
| 388 | |
| 389 | env['CC'] = env['compiler_cache']+ " " + compiler_prefix + c_compiler |
| 390 | env['CXX'] = env['compiler_cache']+ " " + compiler_prefix + cpp_compiler |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 391 | env['LD'] = toolchain_prefix + "ld" |
| 392 | env['AS'] = toolchain_prefix + "as" |
| 393 | |
| 394 | if env['os'] == 'windows': |
| 395 | env['AR'] = "llvm-lib" |
| 396 | env['RANLIB'] = "llvm-ranlib" |
| 397 | else: |
| 398 | env['AR'] = toolchain_prefix + "ar" |
| 399 | |
| 400 | env['RANLIB'] = toolchain_prefix + "ranlib" |
| 401 | |
| 402 | print("Using compilers:") |
| 403 | print("CC", env['CC']) |
| 404 | print("CXX", env['CXX']) |
Anthony Barbier | 46d5927 | 2017-05-04 09:15:15 +0100 | [diff] [blame] | 405 | |
| 406 | if not GetOption("help"): |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 407 | try: |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 408 | if env['os'] == 'windows': |
| 409 | compiler_ver = check_output("clang++ -dumpversion").decode().strip() |
| 410 | else: |
| 411 | compiler_ver = check_output(env['CXX'].split() + ["-dumpversion"]).decode().strip() |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 412 | except OSError: |
| 413 | print("ERROR: Compiler '%s' not found" % env['CXX']) |
| 414 | Exit(1) |
| 415 | |
Jenkins | 0e205f7 | 2019-11-28 16:53:35 +0000 | [diff] [blame] | 416 | if 'armclang' in cpp_compiler: |
| 417 | pass |
| 418 | elif 'clang++' not in cpp_compiler: |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 419 | if env['arch'] == 'arm64-v8.2-a' and not version_at_least(compiler_ver, '6.2.1'): |
ggardet | e2542c9 | 2018-06-29 17:01:01 +0200 | [diff] [blame] | 420 | print("GCC 6.2.1 or newer is required to compile armv8.2-a code") |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 421 | Exit(1) |
| 422 | elif env['arch'] == 'arm64-v8a' and not version_at_least(compiler_ver, '4.9'): |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 423 | print("GCC 4.9 or newer is required to compile Arm® Neon™ code for AArch64") |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 424 | Exit(1) |
| 425 | |
| 426 | if version_at_least(compiler_ver, '6.1'): |
| 427 | env.Append(CXXFLAGS = ['-Wno-ignored-attributes']) |
| 428 | |
| 429 | if compiler_ver == '4.8.3': |
| 430 | env.Append(CXXFLAGS = ['-Wno-array-bounds']) |
| 431 | |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 432 | if not version_at_least(compiler_ver, '7.0.0') and env['os'] == 'bare_metal': |
| 433 | env.Append(LINKFLAGS = ['-fstack-protector-strong']) |
| 434 | |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 435 | # Add Android NDK toolchain specific flags |
| 436 | if 'clang++' in cpp_compiler and env['os'] == 'android': |
| 437 | # For NDK >= r21, clang 9 or above is used |
| 438 | if version_at_least(compiler_ver, '9.0.0'): |
| 439 | env['ndk_above_r21'] = True |
| 440 | |
| 441 | if env['openmp']: |
| 442 | env.Append(LINKFLAGS = ['-static-openmp']) |
| 443 | |
| 444 | # For NDK >= r23, clang 12 or above is used. This condition detects NDK < r23 |
| 445 | if not version_at_least(compiler_ver, '12.0.0'): |
| 446 | # System assembler is deprecated and integrated assembler is preferred since r23. |
| 447 | # However integrated assembler has always been suppressed for NDK < r23. |
| 448 | # Thus for backward compatibility, we include this flag only for NDK < r23 |
| 449 | env.Append(CXXFLAGS = ['-no-integrated-as']) |
| 450 | |
| 451 | if env['high_priority'] and env['build_config']: |
| 452 | print("The high priority library cannot be built in conjunction with a user-specified build configuration") |
| 453 | Exit(1) |
| 454 | |
| 455 | if not env['high_priority'] and not env['build_config']: |
| 456 | env.Append(CPPDEFINES = ['ARM_COMPUTE_GRAPH_ENABLED']) |
| 457 | |
| 458 | data_types = [] |
| 459 | data_layouts = [] |
| 460 | |
| 461 | # Set correct data types / layouts to build |
| 462 | if env['high_priority']: |
| 463 | data_types = ['all'] |
| 464 | data_layouts = ['all'] |
| 465 | elif env['build_config']: |
| 466 | data_types, data_layouts = read_build_config_json(env['build_config']) |
| 467 | else: |
| 468 | data_types = env['data_type_support'] |
| 469 | data_layouts = env['data_layout_support'] |
| 470 | |
| 471 | env = update_data_type_layout_flags(env, data_types, data_layouts) |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 472 | |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 473 | if env['standalone']: |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 474 | if not 'windows' in env['os']: |
| 475 | env.Append(CXXFLAGS = ['-fPIC']) |
| 476 | env.Append(LINKFLAGS = ['-static-libgcc','-static-libstdc++']) |
| 477 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 478 | if env['Werror']: |
| 479 | env.Append(CXXFLAGS = ['-Werror']) |
| 480 | |
| 481 | if env['os'] == 'android': |
| 482 | env.Append(CPPDEFINES = ['ANDROID']) |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 483 | env.Append(LINKFLAGS = ['-pie', '-static-libstdc++', '-ldl']) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 484 | elif env['os'] == 'bare_metal': |
| 485 | env.Append(LINKFLAGS = ['-static']) |
| 486 | env.Append(CXXFLAGS = ['-fPIC']) |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 487 | if env['specs_file'] == "": |
| 488 | env.Append(LINKFLAGS = ['-specs=rdimon.specs']) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 489 | env.Append(CPPDEFINES = ['NO_MULTI_THREADING']) |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 490 | env.Append(CPPDEFINES = ['BARE_METAL']) |
Jenkins | 49b8f90 | 2020-11-27 12:49:11 +0000 | [diff] [blame] | 491 | if env['os'] == 'linux' and env['arch'] == 'armv7a': |
| 492 | env.Append(CXXFLAGS = [ '-Wno-psabi' ]) |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 493 | if env['os'] == 'windows': |
| 494 | env.Append(CXXFLAGS = [ '/std:c++14','/EHa']) |
| 495 | env.Append(CXXFLAGS = [ '-Wno-c++98-compat', '-Wno-covered-switch-default','-Wno-c++98-compat-pedantic']) |
| 496 | env.Append(CXXFLAGS = [ '-Wno-shorten-64-to-32', '-Wno-sign-conversion','-Wno-documentation']) |
| 497 | env.Append(CXXFLAGS = [ '-Wno-extra-semi-stmt', '-Wno-float-equal','-Wno-implicit-int-conversion']) |
| 498 | env.Append(CXXFLAGS = [ '-Wno-documentation-pedantic', '-Wno-extra-semi','-Wno-shadow-field-in-constructor']) |
| 499 | env.Append(CXXFLAGS = [ '-Wno-float-conversion', '-Wno-switch-enum','-Wno-comma']) |
| 500 | env.Append(CXXFLAGS = [ '-Wno-implicit-float-conversion', '-Wno-deprecated-declarations','-Wno-old-style-cast']) |
| 501 | env.Append(CXXFLAGS = [ '-Wno-zero-as-null-pointer-constant', '-Wno-inconsistent-missing-destructor-override']) |
| 502 | env.Append(CXXFLAGS = [ '-Wno-asm-operand-widths']) |
| 503 | |
| 504 | |
| 505 | if env['specs_file'] != "": |
| 506 | env.Append(LINKFLAGS = ['-specs='+env['specs_file']]) |
| 507 | |
| 508 | if env['neon']: |
| 509 | env.Append(CPPDEFINES = ['ARM_COMPUTE_CPU_ENABLED']) |
Jenkins | f7399fd | 2021-05-18 15:04:27 +0100 | [diff] [blame] | 510 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 511 | if env['opencl']: |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 512 | env.Append(CPPDEFINES = ['ARM_COMPUTE_OPENCL_ENABLED']) |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame] | 513 | if env['os'] in ['bare_metal'] or env['standalone']: |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 514 | print("Cannot link OpenCL statically, which is required for bare metal / standalone builds") |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 515 | Exit(1) |
| 516 | |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 517 | if env["os"] not in ["windows","android", "bare_metal"] and (env['opencl'] or env['cppthreads']): |
Jenkins | b3a371b | 2018-05-23 11:36:53 +0100 | [diff] [blame] | 518 | env.Append(LIBS = ['pthread']) |
| 519 | |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 520 | if env['os'] == 'openbsd': |
| 521 | env.Append(LIBS = ['c']) |
| 522 | env.Append(CXXFLAGS = ['-fPIC']) |
| 523 | |
| 524 | if env['opencl']: |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 525 | if env['embed_kernels']: |
| 526 | env.Append(CPPDEFINES = ['EMBEDDED_KERNELS']) |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 527 | if env['compress_kernels']: |
| 528 | env.Append(CPPDEFINES = ['ARM_COMPUTE_COMPRESSED_KERNELS']) |
| 529 | env.Append(LIBS = ['z']) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 530 | |
| 531 | if env['debug']: |
| 532 | env['asserts'] = True |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 533 | if not 'windows' in env['os']: |
| 534 | env.Append(CXXFLAGS = ['-O0','-g','-gdwarf-2']) |
| 535 | else: |
| 536 | env.Append(CXXFLAGS = ['-Z7','-MTd','-fms-compatibility','-fdelayed-template-parsing']) |
| 537 | env.Append(LINKFLAGS = ['-DEBUG']) |
| 538 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 539 | env.Append(CPPDEFINES = ['ARM_COMPUTE_DEBUG_ENABLED']) |
| 540 | else: |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 541 | if not 'windows' in env['os']: |
| 542 | env.Append(CXXFLAGS = ['-O3']) |
| 543 | else: |
| 544 | # on windows we use clang-cl which does not support the option -O3 |
| 545 | env.Append(CXXFLAGS = ['-O2']) |
Jenkins | aabef6c | 2022-08-18 12:49:09 +0000 | [diff] [blame] | 546 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 547 | if env['asserts']: |
| 548 | env.Append(CPPDEFINES = ['ARM_COMPUTE_ASSERTS_ENABLED']) |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 549 | if not 'windows' in env['os']: |
| 550 | env.Append(CXXFLAGS = ['-fstack-protector-strong']) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 551 | |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame] | 552 | if env['logging']: |
| 553 | env.Append(CPPDEFINES = ['ARM_COMPUTE_LOGGING_ENABLED']) |
| 554 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 555 | env.Append(CPPPATH = ['#/include', "#"]) |
| 556 | env.Append(CXXFLAGS = env['extra_cxx_flags']) |
Jenkins | b9abeae | 2018-11-22 11:58:08 +0000 | [diff] [blame] | 557 | env.Append(LINKFLAGS = env['extra_link_flags']) |
| 558 | |
| 559 | Default( install_include("arm_compute")) |
| 560 | Default( install_include("support")) |
Jenkins | 4ba87db | 2019-05-23 17:11:51 +0100 | [diff] [blame] | 561 | Default( install_include("utils")) |
| 562 | for dirname in os.listdir("./include"): |
| 563 | Default( install_include("include/%s" % dirname)) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 564 | |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 565 | Export('version_at_least') |
| 566 | |
Renato Grottesi | 39d8017 | 2023-05-08 07:24:49 +0000 | [diff] [blame] | 567 | SConscript('./SConscript', variant_dir=build_path, duplicate=0) |
Jenkins | 91ee4d0 | 2021-11-15 14:37:16 +0000 | [diff] [blame] | 568 | |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 569 | if env['examples'] and (env['build_config'] or env['high_priority']): |
| 570 | print("WARNING: Building examples for selected operators not supported. Use examples=0") |
| 571 | Return() |
| 572 | |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 573 | if env['examples'] and env['exceptions']: |
| 574 | if env['os'] == 'bare_metal' and env['arch'] == 'armv7a': |
| 575 | print("WARNING: Building examples for bare metal and armv7a is not supported. Use examples=0") |
| 576 | Return() |
Jenkins | b9abeae | 2018-11-22 11:58:08 +0000 | [diff] [blame] | 577 | SConscript('./examples/SConscript', variant_dir='%s/examples' % build_path, duplicate=0) |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 578 | |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 579 | if env['exceptions']: |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 580 | if env['build_config'] or env['high_priority']: |
| 581 | print("WARNING: Building tests for selected operators not supported") |
| 582 | Return() |
Jenkins | 36ccc90 | 2020-02-21 11:10:48 +0000 | [diff] [blame] | 583 | if env['os'] == 'bare_metal' and env['arch'] == 'armv7a': |
| 584 | print("WARNING: Building tests for bare metal and armv7a is not supported") |
| 585 | Return() |
Jenkins | b9abeae | 2018-11-22 11:58:08 +0000 | [diff] [blame] | 586 | SConscript('./tests/SConscript', variant_dir='%s/tests' % build_path, duplicate=0) |
Renato Grottesi | 777c45c | 2023-05-08 13:04:07 +0000 | [diff] [blame] | 587 | |
| 588 | # Unknown variables are not allowed |
| 589 | # Note: we must delay the call of UnknownVariables until after |
| 590 | # we have applied the Variables object to the construction environment |
| 591 | unknown = vars.UnknownVariables() |
| 592 | if unknown: |
| 593 | print("Unknown variables: %s" % " ".join(unknown.keys())) |
| 594 | Exit(1) |