@@ -40,7 +40,10 @@ vars.AddVariables(
4040 BoolVariable ("debug" , "Debug" , False ),
4141 BoolVariable ("asserts" , "Enable asserts (this flag is forced to 1 for debug=1)" , False ),
4242 BoolVariable ("logging" , "Logging (this flag is forced to 1 for debug=1)" , False ),
43- EnumVariable ("arch" , "Target Architecture" , "armv7a" , allowed_values = ("armv7a" , "arm64-v8a" , "arm64-v8.2-a" , "arm64-v8.2-a-sve" , "x86_32" , "x86_64" )),
43+ EnumVariable ("arch" , "Target Architecture" , "armv7a" ,
44+ allowed_values = ("armv7a" , "arm64-v8a" , "arm64-v8.2-a" , "arm64-v8.2-a-sve" , "x86_32" , "x86_64" ,
45+ "armv8a" , "armv8.2-a" , "armv8.2-a-sve" , "armv8.6-a" , "x86" )),
46+ EnumVariable ("estate" , "Execution State" , "auto" , allowed_values = ("auto" , "32" , "64" )),
4447 EnumVariable ("os" , "Target OS" , "linux" , allowed_values = ("linux" , "android" , "bare_metal" )),
4548 EnumVariable ("build" , "Build type" , "cross_compile" , allowed_values = ("native" , "cross_compile" , "embed_only" )),
4649 BoolVariable ("examples" , "Build example programs" , True ),
@@ -57,7 +60,9 @@ vars.AddVariables(
5760 PathVariable ("build_dir" , "Specify sub-folder for the build" , "." , PathVariable .PathAccept ),
5861 PathVariable ("install_dir" , "Specify sub-folder for the install" , "" , PathVariable .PathAccept ),
5962 BoolVariable ("exceptions" , "Enable/disable C++ exception support" , True ),
63+ PathVariable ("linker_script" , "Use an external linker script" , "" , PathVariable .PathAccept ),
6064 ("toolchain_prefix" , "Override the toolchain prefix" , "" ),
65+ ("compiler_prefix" , "Override the compiler prefix" , "" ),
6166 ("extra_cxx_flags" , "Extra CXX flags to be appended to the build command" , "" ),
6267 ("extra_link_flags" , "Extra LD flags to be appended to the build command" , "" ),
6368 ("compiler_cache" , "Command to prefix to the C and C++ compiler (e.g ccache)" , "" )
@@ -101,6 +106,10 @@ Export('install_bin')
101106
102107Help (vars .GenerateHelpText (env ))
103108
109+ if env ['linker_script' ] and env ['os' ] != 'bare_metal' :
110+ print ("Linker script is only supported for bare_metal builds" )
111+ Exit (1 )
112+
104113if env ['build' ] == "embed_only" :
105114 SConscript ('./SConscript' , variant_dir = build_path , duplicate = 0 )
106115 Return ()
@@ -130,7 +139,7 @@ if not env['exceptions']:
130139env .Append (CXXFLAGS = ['-Wall' ,'-DARCH_ARM' ,
131140 '-Wextra' ,'-pedantic' ,'-Wdisabled-optimization' ,'-Wformat=2' ,
132141 '-Winit-self' ,'-Wstrict-overflow=2' ,'-Wswitch-default' ,
133- '-fpermissive' , '- std=gnu++11' ,'-Woverloaded-virtual' , '-Wformat-security' ,
142+ '-std=gnu++11' ,'-Woverloaded-virtual' , '-Wformat-security' ,
134143 '-Wctor-dtor-privacy' ,'-Wsign-promo' ,'-Weffc++' ,'-Wno-overlength-strings' ])
135144
136145env .Append (CPPDEFINES = ['_GLIBCXX_USE_NANOSLEEP' ])
@@ -162,57 +171,79 @@ if env['openmp']:
162171 env .Append (CXXFLAGS = ['-fopenmp' ])
163172 env .Append (LINKFLAGS = ['-fopenmp' ])
164173
174+ # Validate and define state
175+ if env ['estate' ] == 'auto' :
176+ if 'v7a' in env ['arch' ]:
177+ env ['estate' ] = '32'
178+ else :
179+ env ['estate' ] = '64'
180+
181+ # Map legacy arch
182+ if 'arm64' in env ['arch' ]:
183+ env ['estate' ] = '64'
184+
185+ if 'v7a' in env ['estate' ] and env ['estate' ] == '64' :
186+ print ("ERROR: armv7a architecture has only 32-bit execution state" )
187+ Exit (1 )
188+
165189# Add architecture specific flags
166190prefix = ""
167- if env [ 'arch' ] == 'armv7a' :
191+ if 'v7a' in env [ 'arch' ] :
168192 env .Append (CXXFLAGS = ['-march=armv7-a' , '-mthumb' , '-mfpu=neon' ])
169-
170- if env ['os' ] == 'linux' :
171- prefix = "arm-linux-gnueabihf-"
172- env .Append (CXXFLAGS = ['-mfloat-abi=hard' ])
173- elif env ['os' ] == 'bare_metal' :
174- prefix = "arm-eabi-"
175- env .Append (CXXFLAGS = ['-mfloat-abi=hard' ])
176- elif env ['os' ] == 'android' :
177- prefix = "arm-linux-androideabi-"
193+ if env ['os' ] == 'android' :
178194 env .Append (CXXFLAGS = ['-mfloat-abi=softfp' ])
179- elif env ['arch' ] == 'arm64-v8a' :
180- env .Append (CXXFLAGS = ['-march=armv8-a' ])
181- env .Append (CPPDEFINES = ['ARM_COMPUTE_AARCH64_V8A' ])
182- if env ['os' ] == 'linux' :
183- prefix = "aarch64-linux-gnu-"
184- elif env ['os' ] == 'bare_metal' :
185- prefix = "aarch64-elf-"
186- elif env ['os' ] == 'android' :
187- prefix = "aarch64-linux-android-"
188- elif 'arm64-v8.2-a' in env ['arch' ]:
189- if env ['arch' ] == 'arm64-v8.2-a-sve' :
190- env .Append (CXXFLAGS = ['-march=armv8.2-a+sve+fp16+dotprod' ])
191195 else :
196+ env .Append (CXXFLAGS = ['-mfloat-abi=hard' ])
197+ elif 'v8' in env ['arch' ]:
198+ if 'sve' in env ['arch' ]:
199+ env .Append (CXXFLAGS = ['-march=armv8.2-a+sve+fp16+dotprod' ])
200+ elif 'v8.2-a' in env ['arch' ]:
192201 env .Append (CXXFLAGS = ['-march=armv8.2-a+fp16' ]) # explicitly enable fp16 extension otherwise __ARM_FEATURE_FP16_VECTOR_ARITHMETIC is undefined
193- if env ['os' ] == 'linux' :
194- prefix = "aarch64-linux-gnu-"
195- elif env ['os' ] == 'bare_metal' :
196- prefix = "aarch64-elf-"
197- elif env ['os' ] == 'android' :
198- prefix = "aarch64-linux-android-"
199- env .Append (CPPDEFINES = ['ARM_COMPUTE_AARCH64_V8_2' ])
200- elif env ['arch' ] == 'x86_32' :
201- env .Append (CCFLAGS = ['-m32' ])
202- env .Append (LINKFLAGS = ['-m32' ])
203- elif env ['arch' ] == 'x86_64' :
204- env .Append (CXXFLAGS = ['-fPIC' ])
205- env .Append (CCFLAGS = ['-m64' ])
206- env .Append (LINKFLAGS = ['-m64' ])
202+ else :
203+ env .Append (CXXFLAGS = ['-march=armv8-a' ])
204+
205+ if 'v8.6-a' in env ['arch' ]:
206+ env .Append (CXXFLAGS = ['-DV8P6' ])
207+
208+ elif 'x86' in env ['arch' ]:
209+ if env ['estate' ] == '32' :
210+ env .Append (CCFLAGS = ['-m32' ])
211+ env .Append (LINKFLAGS = ['-m32' ])
212+ else :
213+ env .Append (CXXFLAGS = ['-fPIC' ])
214+ env .Append (CCFLAGS = ['-m64' ])
215+ env .Append (LINKFLAGS = ['-m64' ])
216+
217+ # Define toolchain
218+ prefix = ""
219+ if 'x86' not in env ['arch' ]:
220+ if env ['estate' ] == '32' :
221+ if env ['os' ] == 'linux' :
222+ prefix = "arm-linux-gnueabihf-" if 'v7' in env ['arch' ] else "armv8l-linux-gnueabihf-"
223+ elif env ['os' ] == 'bare_metal' :
224+ prefix = "arm-eabi-"
225+ elif env ['os' ] == 'android' :
226+ prefix = "arm-linux-androideabi-"
227+ elif env ['estate' ] == '64' and 'v8' in env ['arch' ]:
228+ if env ['os' ] == 'linux' :
229+ prefix = "aarch64-linux-gnu-"
230+ elif env ['os' ] == 'bare_metal' :
231+ prefix = "aarch64-elf-"
232+ elif env ['os' ] == 'android' :
233+ prefix = "aarch64-linux-android-"
207234
208235if env ['build' ] == 'native' :
209236 prefix = ""
210237
211238if env ["toolchain_prefix" ] != "" :
212239 prefix = env ["toolchain_prefix" ]
213240
214- env ['CC' ] = env ['compiler_cache' ]+ " " + prefix + c_compiler
215- env ['CXX' ] = env ['compiler_cache' ]+ " " + prefix + cpp_compiler
241+ compiler_prefix = prefix
242+ if env ["compiler_prefix" ] != "" :
243+ compiler_prefix = env ["compiler_prefix" ]
244+
245+ env ['CC' ] = env ['compiler_cache' ]+ " " + compiler_prefix + c_compiler
246+ env ['CXX' ] = env ['compiler_cache' ]+ " " + compiler_prefix + cpp_compiler
216247env ['LD' ] = prefix + "ld"
217248env ['AS' ] = prefix + "as"
218249env ['AR' ] = prefix + "ar"
@@ -250,7 +281,7 @@ if env['Werror']:
250281
251282if env ['os' ] == 'android' :
252283 env .Append (CPPDEFINES = ['ANDROID' ])
253- env .Append (LINKFLAGS = ['-pie' , '-static-libstdc++' ])
284+ env .Append (LINKFLAGS = ['-pie' , '-static-libstdc++' , '-ldl' ])
254285elif env ['os' ] == 'bare_metal' :
255286 env .Append (LINKFLAGS = ['-static' ])
256287 env .Append (LINKFLAGS = ['-specs=rdimon.specs' ])
@@ -302,17 +333,20 @@ for dirname in os.listdir("./include"):
302333
303334Export ('version_at_least' )
304335
305- if env ['opencl' ]:
306- SConscript ("./opencl-1.2-stubs/SConscript" , variant_dir = "%s/opencl-1.2-stubs" % build_path , duplicate = 0 )
307336
308337if env ['gles_compute' ] and env ['os' ] != 'android' :
309338 env .Append (CPPPATH = ['#/include/linux' ])
310- SConscript ("./opengles-3.1-stubs/SConscript" , variant_dir = "%s/opengles-3.1-stubs" % build_path , duplicate = 0 )
311339
312340SConscript ('./SConscript' , variant_dir = build_path , duplicate = 0 )
313341
314- if env ['examples' ] and env ['os' ] != 'bare_metal' and env ['exceptions' ]:
342+ if env ['examples' ] and env ['exceptions' ]:
343+ if env ['os' ] == 'bare_metal' and env ['arch' ] == 'armv7a' :
344+ print ("WARNING: Building examples for bare metal and armv7a is not supported. Use examples=0" )
345+ Return ()
315346 SConscript ('./examples/SConscript' , variant_dir = '%s/examples' % build_path , duplicate = 0 )
316347
317- if env ['os' ] != 'bare_metal' and env ['exceptions' ]:
348+ if env ['exceptions' ]:
349+ if env ['os' ] == 'bare_metal' and env ['arch' ] == 'armv7a' :
350+ print ("WARNING: Building tests for bare metal and armv7a is not supported" )
351+ Return ()
318352 SConscript ('./tests/SConscript' , variant_dir = '%s/tests' % build_path , duplicate = 0 )
0 commit comments