Skip to content

Commit

Permalink
build: clean up arm build options
Browse files Browse the repository at this point in the history
* default to `-march=armv7` and `-mfpu=neon` when targeting armv7.
  Any Cortex-A capable of running V8 supports at least that.

* remove the `--arm-fpu=...` configure option. It was added to support
  Debian's armel port (armv5, for the purpose of this discussion) but
  V8 (and therefore Node.js) dropped support for armv5 in early 2016.

* remove the `--arm-float-abi=...` configure option. There should never
  be a reason to build in soft or softp mode; armv6 is the bare minimum
  nowadays and supports VFP.

Fixes: nodejs#30786
  • Loading branch information
bnoordhuis committed Apr 9, 2020
1 parent b82d72c commit 64a4910
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 170 deletions.
12 changes: 12 additions & 0 deletions common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
'variables': {
'configuring_node%': 0,
'asan%': 0,
'arm_version%': 0, # ARM architecture version (6 or 7)
'werror': '', # Turn off -Werror in V8 build.
'visibility%': 'hidden', # V8's visibility setting
'target_arch%': 'ia32', # set v8's target architecture
Expand Down Expand Up @@ -268,6 +269,17 @@
'msvs_cygwin_shell': 0, # prevent actions from trying to use cygwin

'conditions': [
[ 'arm_version==7', {
'target_conditions': [
['_toolset=="target"', {
# Any Cortex-A that can run V8 supports at least armv7-a+neon.
'cflags': [
'-march=armv7-a',
'-mfpu=neon', # Implies VFPv3.
],
}],
],
}],
[ 'configuring_node', {
'msvs_configuration_attributes': {
'OutputDirectory': '<(DEPTH)/out/$(Configuration)/',
Expand Down
65 changes: 4 additions & 61 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
'android', 'aix', 'cloudabi')
valid_arch = ('arm', 'arm64', 'ia32', 'mips', 'mipsel', 'mips64el', 'ppc',
'ppc64', 'x32','x64', 'x86', 'x86_64', 's390x')
valid_arm_float_abi = ('soft', 'softfp', 'hard')
valid_arm_fpu = ('vfp', 'vfpv3', 'vfpv3-d16', 'neon')
valid_mips_arch = ('loongson', 'r1', 'r2', 'r6', 'rx')
valid_mips_fpu = ('fp32', 'fp64', 'fpxx')
valid_mips_float_abi = ('soft', 'hard')
Expand Down Expand Up @@ -382,20 +380,6 @@
dest='v8_options',
help='v8 options to pass, see `node --v8-options` for examples.')

parser.add_option('--with-arm-float-abi',
action='store',
dest='arm_float_abi',
choices=valid_arm_float_abi,
help='specifies which floating-point ABI to use ({0}).'.format(
', '.join(valid_arm_float_abi)))

parser.add_option('--with-arm-fpu',
action='store',
dest='arm_fpu',
choices=valid_arm_fpu,
help='ARM FPU mode ({0}) [default: %default]'.format(
', '.join(valid_arm_fpu)))

parser.add_option('--with-mips-arch-variant',
action='store',
dest='mips_arch_variant',
Expand Down Expand Up @@ -883,28 +867,6 @@ def cc_macros(cc=None):
return k


def is_arch_armv7():
"""Check for ARMv7 instructions"""
cc_macros_cache = cc_macros()
return cc_macros_cache.get('__ARM_ARCH') == '7'


def is_arch_armv6():
"""Check for ARMv6 instructions"""
cc_macros_cache = cc_macros()
return cc_macros_cache.get('__ARM_ARCH') == '6'


def is_arm_hard_float_abi():
"""Check for hardfloat or softfloat eabi on ARM"""
# GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify
# the Floating Point ABI used (PCS stands for Procedure Call Standard).
# We use these as well as a couple of other defines to statically determine
# what FP ABI used.

return '__ARM_PCS_VFP' in cc_macros()


def host_arch_cc():
"""Host architecture check using the CC command."""

Expand Down Expand Up @@ -957,29 +919,10 @@ def host_arch_win():


def configure_arm(o):
if options.arm_float_abi:
arm_float_abi = options.arm_float_abi
elif is_arm_hard_float_abi():
arm_float_abi = 'hard'
else:
arm_float_abi = 'default'

arm_fpu = 'vfp'

if is_arch_armv7():
arm_fpu = 'vfpv3'
o['variables']['arm_version'] = '7'
else:
o['variables']['arm_version'] = '6' if is_arch_armv6() else 'default'

o['variables']['arm_thumb'] = 0 # -marm
o['variables']['arm_float_abi'] = arm_float_abi

if options.dest_os == 'android':
arm_fpu = 'vfpv3'
o['variables']['arm_version'] = '7'

o['variables']['arm_fpu'] = options.arm_fpu or arm_fpu
armv7 = options.dest_os == 'android' or cc_macros().get('__ARM_ARCH') == '7'
# ARMv6 is primarily the ARM1176 CPU used in the Broadcom BCM2835 SoC of
# first-gen Raspberry Pis and the Pi Zero. It supports VFP2 but not NEON.
o['variables']['arm_version'] = '7' if armv7 else '6'


def configure_mips(o):
Expand Down
8 changes: 4 additions & 4 deletions deps/zlib/zlib.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
{
'variables': {
'use_system_zlib%': 0,
'arm_fpu%': '',
'llvm_version%': '0.0',
},
'conditions': [
Expand Down Expand Up @@ -64,7 +63,8 @@
'USE_FILE32API'
],
}],
['(target_arch in "ia32 x64 x32" and OS!="ios") or arm_fpu=="neon"', {
['(target_arch in "arm64 ia32 x64 x32" and OS!="ios") or '
'arm_version==7', {
'sources': [
'adler32_simd.c',
'adler32_simd.h',
Expand Down Expand Up @@ -112,7 +112,7 @@
}, {
'sources': [ 'simd_stub.c', ],
}],
['arm_fpu=="neon"', {
['target_arch=="arm64" or arm_version==7', {
'defines': [
'ADLER32_SIMD_NEON',
'INFLATE_CHUNK_SIMD_NEON',
Expand All @@ -136,7 +136,7 @@
['OS=="linux"', {
'defines': [ 'ARMV8_OS_LINUX' ],
}],
['OS="win"', {
['OS=="win"', {
'defines': [ 'ARMV8_OS_WINDOWS' ],
}],
['OS!="android" and OS!="win" and llvm_version=="0.0"', {
Expand Down
108 changes: 3 additions & 105 deletions tools/v8_gypfiles/toolchain.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -176,27 +176,13 @@
'V8_TARGET_ARCH_ARM',
],
'conditions': [
[ 'arm_version==7 or arm_version=="default"', {
# ARMv7 supports NEON+VFP3, ARMv6 only supports VFP2.
[ 'arm_version==7', {
'defines': [
'CAN_USE_ARMV7_INSTRUCTIONS',
],
}],
[ 'arm_fpu=="vfpv3-d16" or arm_fpu=="default"', {
'defines': [
'CAN_USE_VFP3_INSTRUCTIONS',
],
}],
[ 'arm_fpu=="vfpv3"', {
'defines': [
'CAN_USE_VFP3_INSTRUCTIONS',
'CAN_USE_NEON',
'CAN_USE_VFP32DREGS',
],
}],
[ 'arm_fpu=="neon"', {
'defines': [
'CAN_USE_VFP3_INSTRUCTIONS',
'CAN_USE_VFP32DREGS',
'CAN_USE_NEON',
],
}],
[ 'arm_test_noprobe=="on"', {
Expand All @@ -205,94 +191,6 @@
],
}],
],
'target_conditions': [
['_toolset=="host"', {
'conditions': [
['v8_target_arch==host_arch', {
# Host built with an Arm CXX compiler.
'conditions': [
[ 'arm_version==7', {
'cflags': ['-march=armv7-a',],
}],
[ 'arm_version==7 or arm_version=="default"', {
'conditions': [
[ 'arm_fpu!="default"', {
'cflags': ['-mfpu=<(arm_fpu)',],
}],
],
}],
[ 'arm_float_abi!="default"', {
'cflags': ['-mfloat-abi=<(arm_float_abi)',],
}],
[ 'arm_thumb==1', {
'cflags': ['-mthumb',],
}],
[ 'arm_thumb==0', {
'cflags': ['-marm',],
}],
],
}, {
# 'v8_target_arch!=host_arch'
# Host not built with an Arm CXX compiler (simulator build).
'conditions': [
[ 'arm_float_abi=="hard"', {
'defines': [
'USE_EABI_HARDFLOAT=1',
],
}],
[ 'arm_float_abi=="softfp" or arm_float_abi=="default"', {
'defines': [
'USE_EABI_HARDFLOAT=0',
],
}],
],
}],
],
}], # _toolset=="host"
['_toolset=="target"', {
'conditions': [
['v8_target_arch==target_arch', {
# Target built with an Arm CXX compiler.
'conditions': [
[ 'arm_version==7', {
'cflags': ['-march=armv7-a',],
}],
[ 'arm_version==7 or arm_version=="default"', {
'conditions': [
[ 'arm_fpu!="default"', {
'cflags': ['-mfpu=<(arm_fpu)',],
}],
],
}],
[ 'arm_float_abi!="default"', {
'cflags': ['-mfloat-abi=<(arm_float_abi)',],
}],
[ 'arm_thumb==1', {
'cflags': ['-mthumb',],
}],
[ 'arm_thumb==0', {
'cflags': ['-marm',],
}],
],
}, {
# 'v8_target_arch!=target_arch'
# Target not built with an Arm CXX compiler (simulator build).
'conditions': [
[ 'arm_float_abi=="hard"', {
'defines': [
'USE_EABI_HARDFLOAT=1',
],
}],
[ 'arm_float_abi=="softfp" or arm_float_abi=="default"', {
'defines': [
'USE_EABI_HARDFLOAT=0',
],
}],
],
}],
],
}], # _toolset=="target"
],
}], # v8_target_arch=="arm"
['v8_target_arch=="arm64"', {
'defines': [
Expand Down

0 comments on commit 64a4910

Please sign in to comment.