@@ -164,6 +164,12 @@ parser.add_option("--no-ifaddrs",
164164 dest = "no_ifaddrs" ,
165165 help = "Use on deprecated SunOS systems that do not support ifaddrs.h" )
166166
167+ parser .add_option ("--with-arm-float-abi" ,
168+ action = "store" ,
169+ dest = "arm_float_abi" ,
170+ help = "Specifies which floating-point ABI to use. Valid values are: "
171+ "soft, softfp, hard" )
172+
167173(options , args ) = parser .parse_args ()
168174
169175
@@ -189,8 +195,8 @@ def pkg_config(pkg):
189195 return (libs , cflags )
190196
191197
192- def host_arch_cc ():
193- """Host architecture check using the CC command."""
198+ def cc_macros ():
199+ """Checks predefined macros using the CC command."""
194200
195201 try :
196202 p = subprocess .Popen (CC .split () + ['-dM' , '-E' , '-' ],
@@ -219,6 +225,52 @@ def host_arch_cc():
219225 key = lst [1 ]
220226 val = lst [2 ]
221227 k [key ] = val
228+ return k
229+
230+
231+ def is_arch_armv7 ():
232+ """Check for ARMv7 instructions"""
233+ cc_macros_cache = cc_macros ()
234+ return ('__ARM_ARCH_7__' in cc_macros_cache or
235+ '__ARM_ARCH_7A__' in cc_macros_cache or
236+ '__ARM_ARCH_7R__' in cc_macros_cache or
237+ '__ARM_ARCH_7M__' in cc_macros_cache )
238+
239+
240+ def arm_hard_float_abi ():
241+ """Check for hardfloat or softfloat eabi on ARM"""
242+ # GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify
243+ # the Floating Point ABI used (PCS stands for Procedure Call Standard).
244+ # We use these as well as a couple of other defines to statically determine
245+ # what FP ABI used.
246+ # GCC versions 4.4 and below don't support hard-fp.
247+ # GCC versions 4.5 may support hard-fp without defining __ARM_PCS or
248+ # __ARM_PCS_VFP.
249+
250+ if compiler_version () >= (4 , 6 , 0 ):
251+ return '__ARM_PCS_VFP' in cc_macros ()
252+ elif compiler_version () < (4 , 5 , 0 ):
253+ return False
254+ elif '__ARM_PCS_VFP' in cc_macros ():
255+ return True
256+ elif ('__ARM_PCS' in cc_macros () or
257+ '__SOFTFP' in cc_macros () or
258+ not '__VFP_FP__' in cc_macros ()):
259+ return False
260+ else :
261+ print '''Node.js configure error: Your version of GCC does not report
262+ the Floating-Point ABI to compile for your hardware
263+
264+ Please manually specify which floating-point ABI to use with the
265+ --with-arm-float-abi option.
266+ '''
267+ sys .exit ()
268+
269+
270+ def host_arch_cc ():
271+ """Host architecture check using the CC command."""
272+
273+ k = cc_macros ()
222274
223275 matchup = {
224276 '__x86_64__' : 'x64' ,
@@ -277,11 +329,15 @@ def configure_node(o):
277329 o ['variables' ]['host_arch' ] = host_arch
278330 o ['variables' ]['target_arch' ] = target_arch
279331
280- # V8 on ARM requires that armv7 is set. We don't have a good way to detect
281- # the CPU model right now so we pick a default and hope that it works okay
282- # for the majority of users.
332+ # V8 on ARM requires that armv7 is set. CPU Model detected by
333+ # the presence of __ARM_ARCH_7__ and the like defines in compiler
283334 if target_arch == 'arm' :
284- o ['variables' ]['armv7' ] = 0 # FIXME
335+ if options .arm_float_abi :
336+ hard_float = options .arm_float_abi == 'hard'
337+ else :
338+ hard_float = arm_hard_float_abi ()
339+ o ['variables' ]['v8_use_arm_eabi_hardfloat' ] = b (hard_float )
340+ o ['variables' ]['armv7' ] = 1 if is_arch_armv7 () else 0
285341
286342 # clang has always supported -fvisibility=hidden, right?
287343 cc_version , is_clang = compiler_version ()
0 commit comments