@@ -54,7 +54,8 @@ vars.AddVariables(
5454 BoolVariable ("openmp" , "Enable OpenMP backend" , False ),
5555 BoolVariable ("cppthreads" , "Enable C++11 threads backend" , True ),
5656 PathVariable ("build_dir" , "Specify sub-folder for the build" , "." , PathVariable .PathAccept ),
57- ("extra_cxx_flags" , "Extra CXX flags to be appended to the build command" , "" )
57+ ("extra_cxx_flags" , "Extra CXX flags to be appended to the build command" , "" ),
58+ ("compiler_cache" , "Command to prefix to the C and C++ compiler (e.g ccache)" , "" )
5859)
5960
6061env = Environment (platform = "posix" , variables = vars , ENV = os .environ )
@@ -97,10 +98,10 @@ default_c_compiler = 'gcc' if env['os'] != 'android' else 'clang'
9798cpp_compiler = os .environ .get ('CXX' , default_cpp_compiler )
9899c_compiler = os .environ .get ('CC' , default_c_compiler )
99100
100- if env ['os' ] == 'android' and ( cpp_compiler != 'clang++' or c_compiler != 'clang' ):
101+ if env ['os' ] == 'android' and ( 'clang++' not in cpp_compiler or 'clang' not in c_compiler ):
101102 print "WARNING: Only clang is officially supported to build the Compute Library for Android"
102103
103- if cpp_compiler == 'clang++' :
104+ if 'clang++' in cpp_compiler :
104105 env .Append (CXXFLAGS = ['-Wno-format-nonliteral' ,'-Wno-deprecated-increment-bool' ,'-Wno-vla-extension' ,'-Wno-mismatched-tags' ])
105106else :
106107 env .Append (CXXFLAGS = ['-Wlogical-op' ,'-Wnoexcept' ,'-Wstrict-null-sentinel' ])
@@ -109,7 +110,7 @@ if env['cppthreads']:
109110 env .Append (CPPDEFINES = [('ARM_COMPUTE_CPP_SCHEDULER' , 1 )])
110111
111112if env ['openmp' ]:
112- if cpp_compiler == 'clang++' :
113+ if 'clang++' in cpp_compiler :
113114 print "Clang does not support OpenMP. Use scheduler=cpp."
114115 Exit (1 )
115116
@@ -132,19 +133,20 @@ if env['arch'] == 'armv7a':
132133 env .Append (CXXFLAGS = ['-mfloat-abi=softfp' ])
133134elif env ['arch' ] == 'arm64-v8a' :
134135 env .Append (CXXFLAGS = ['-march=armv8-a' ])
135- env .Append (CPPDEFINES = ['ARM_COMPUTE_AARCH64_V8A' ])
136+ env .Append (CPPDEFINES = ['ARM_COMPUTE_AARCH64_V8A' , 'NO_DOT_IN_TOOLCHAIN' ])
136137 if env ['os' ] == 'linux' :
137138 prefix = "aarch64-linux-gnu-"
138139 elif env ['os' ] == 'bare_metal' :
139140 prefix = "aarch64-elf-"
140141 elif env ['os' ] == 'android' :
141142 prefix = "aarch64-linux-android-"
143+ if 'clang++' in cpp_compiler :
144+ env .Append (CXXFLAGS = ['-no-integrated-as' ])
142145elif env ['arch' ] == 'arm64-v8.2-a' :
143146 env .Append (CXXFLAGS = ['-march=armv8.2-a+fp16' ]) # explicitly enable fp16 extension otherwise __ARM_FEATURE_FP16_VECTOR_ARITHMETIC is undefined
144- env .Append (CPPDEFINES = ['ARM_COMPUTE_AARCH64_V8_2' ])
145- if cpp_compiler == 'clang++' :
146- env .Append (CXXFLAGS = ['-fno-integrated-as' ])
147-
147+ env .Append (CPPDEFINES = ['ARM_COMPUTE_AARCH64_V8_2' ,'NO_DOT_IN_TOOLCHAIN' ])
148+ if 'clang++' in cpp_compiler :
149+ env .Append (CXXFLAGS = ['-no-integrated-as' ])
148150 if env ['os' ] == 'linux' :
149151 prefix = "aarch64-linux-gnu-"
150152 elif env ['os' ] == 'bare_metal' :
@@ -161,8 +163,8 @@ elif env['arch'] == 'x86_64':
161163if env ['build' ] == 'native' :
162164 prefix = ""
163165
164- env ['CC' ] = prefix + c_compiler
165- env ['CXX' ] = prefix + cpp_compiler
166+ env ['CC' ] = env [ 'compiler_cache' ] + " " + prefix + c_compiler
167+ env ['CXX' ] = env [ 'compiler_cache' ] + " " + prefix + cpp_compiler
166168env ['LD' ] = prefix + "ld"
167169env ['AS' ] = prefix + "as"
168170env ['AR' ] = prefix + "ar"
@@ -175,7 +177,7 @@ if not GetOption("help"):
175177 print ("ERROR: Compiler '%s' not found" % env ['CXX' ])
176178 Exit (1 )
177179
178- if cpp_compiler == 'g ++' :
180+ if 'clang ++' not in cpp_compiler :
179181 if env ['arch' ] == 'arm64-v8.2-a' and not version_at_least (compiler_ver , '6.2.1' ):
180182 print "GCC 6.2.1 or newer is required to compile armv8.2-a code"
181183 Exit (1 )
@@ -192,8 +194,6 @@ if not GetOption("help"):
192194if env ['standalone' ]:
193195 env .Append (CXXFLAGS = ['-fPIC' ])
194196 env .Append (LINKFLAGS = ['-static-libgcc' ,'-static-libstdc++' ])
195- if env ['cppthreads' ]:
196- env .Append (LINKFLAGS = ['-lpthread' ])
197197
198198if env ['Werror' ]:
199199 env .Append (CXXFLAGS = ['-Werror' ])
@@ -210,9 +210,17 @@ elif env['os'] == 'bare_metal':
210210
211211if env ['opencl' ]:
212212 if env ['os' ] in ['bare_metal' ] or env ['standalone' ]:
213- print ("Cannot link OpenCL statically, which is required on bare metal" )
213+ print ("Cannot link OpenCL statically, which is required for bare metal / standalone builds " )
214214 Exit (1 )
215215
216+ if env ['gles_compute' ]:
217+ if env ['os' ] in ['bare_metal' ] or env ['standalone' ]:
218+ print ("Cannot link OpenGLES statically, which is required for bare metal / standalone builds" )
219+ Exit (1 )
220+
221+ if env ["os" ] not in ["android" , "bare_metal" ] and (env ['opencl' ] or env ['cppthreads' ]):
222+ env .Append (LIBS = ['pthread' ])
223+
216224if env ['opencl' ] or env ['gles_compute' ]:
217225 if env ['embed_kernels' ]:
218226 env .Append (CPPDEFINES = ['EMBEDDED_KERNELS' ])
@@ -242,7 +250,6 @@ if env['opencl']:
242250
243251if env ['gles_compute' ] and env ['os' ] != 'android' :
244252 env .Append (CPPPATH = ['#/include/linux' ])
245- env .Append (LIBPATH = ["#build/%s/opengles-3.1-stubs" % env ['build_dir' ]])
246253 SConscript ("./opengles-3.1-stubs/SConscript" , variant_dir = "build/%s/opengles-3.1-stubs" % env ['build_dir' ], duplicate = 0 )
247254
248255SConscript ('./SConscript' , variant_dir = '#build/%s' % env ['build_dir' ], duplicate = 0 )
0 commit comments