diff --git a/webrtc/build/arm_neon.gypi b/webrtc/build/arm_neon.gypi index 9d8f71c8b1..9070080fc3 100644 --- a/webrtc/build/arm_neon.gypi +++ b/webrtc/build/arm_neon.gypi @@ -24,11 +24,19 @@ '-mfpu=vfpv3-d16', ], 'conditions': [ - # "-mfpu=neon" is not requried for arm64 in GCC. + # "-mfpu=neon" is not required for arm64 in GCC. ['target_arch!="arm64"', { 'cflags': [ '-mfpu=neon', ], }], + # Disable LTO on NEON targets due to compiler bug. + # TODO(fdegans): Enable this. See crbug.com/408997. + ['use_lto==1', { + 'cflags!': [ + '-flto', + '-ffat-lto-objects', + ], + }], ], } diff --git a/webrtc/build/common.gypi b/webrtc/build/common.gypi index 26b0de367a..0ab88c63d4 100644 --- a/webrtc/build/common.gypi +++ b/webrtc/build/common.gypi @@ -121,6 +121,9 @@ # enable schannel on windows. 'use_legacy_ssl_defaults%': 0, + # Determines whether NEON code will be built. + 'build_with_neon%': 0, + 'conditions': [ ['build_with_chromium==1', { # Exclude pulse audio on Chromium since its prerequisites don't require @@ -152,6 +155,9 @@ ['target_arch=="arm" or target_arch=="arm64"', { 'prefer_fixed_point%': 1, }], + ['(target_arch=="arm" and (arm_neon==1 or arm_neon_optional==1)) or target_arch=="arm64"', { + 'build_with_neon%': 1, + }], ['OS!="ios" and (target_arch!="arm" or arm_version>=7) and target_arch!="mips64el"', { 'rtc_use_openmax_dl%': 1, }, { diff --git a/webrtc/build/webrtc.gni b/webrtc/build/webrtc.gni index d03a4ed8c9..fa059965dd 100644 --- a/webrtc/build/webrtc.gni +++ b/webrtc/build/webrtc.gni @@ -105,10 +105,10 @@ declare_args() { rtc_use_openmax_dl = false } - # WebRTC builds ARM v7 Neon instruction set optimized code for both iOS and - # Android, which is why we currently cannot use the variables in - # //build/config/arm.gni (since it disables Neon for Android). - rtc_build_armv7_neon = current_cpu == "arm" && arm_version >= 7 + # Determines whether NEON code will be built. + rtc_build_with_neon = (current_cpu == "arm" && + (arm_use_neon == 1 || arm_optionally_use_neon == 1)) || + current_cpu == "arm64" } # Make it possible to provide custom locations for some libraries (move these diff --git a/webrtc/common_audio/BUILD.gn b/webrtc/common_audio/BUILD.gn index 3d4a3321a0..b01b31816b 100644 --- a/webrtc/common_audio/BUILD.gn +++ b/webrtc/common_audio/BUILD.gn @@ -130,14 +130,13 @@ source_set("common_audio") { ] if (arm_version >= 7) { - deps += [ ":common_audio_neon" ] sources += [ "signal_processing/filter_ar_fast_q12_armv7.S" ] } else { sources += [ "signal_processing/filter_ar_fast_q12.c" ] } } - if (current_cpu == "arm64") { + if (rtc_build_with_neon) { deps += [ ":common_audio_neon" ] } @@ -211,7 +210,7 @@ if (current_cpu == "x86" || current_cpu == "x64") { } } -if (rtc_build_armv7_neon || current_cpu == "arm64") { +if (rtc_build_with_neon) { source_set("common_audio_neon") { sources = [ "fir_filter_neon.cc", @@ -221,20 +220,24 @@ if (rtc_build_armv7_neon || current_cpu == "arm64") { "signal_processing/min_max_operations_neon.c", ] - configs += [ "..:common_config" ] - public_configs = [ "..:common_inherited_config" ] - - if (!arm_use_neon) { + if (current_cpu != "arm64") { + # Enable compilation for the NEON instruction set. This is needed + # since //build/config/arm.gni only enables NEON for iOS, not Android. + # This provides the same functionality as webrtc/build/arm_neon.gypi. configs -= [ "//build/config/compiler:compiler_arm_fpu" ] cflags = [ "-mfpu=neon" ] } - # Disable LTO in audio_processing_neon target due to compiler bug. + # Disable LTO on NEON targets due to compiler bug. + # TODO(fdegans): Enable this. See crbug.com/408997. if (rtc_use_lto) { cflags -= [ "-flto", "-ffat-lto-objects", ] } + + configs += [ "..:common_config" ] + public_configs = [ "..:common_inherited_config" ] } } diff --git a/webrtc/common_audio/common_audio.gyp b/webrtc/common_audio/common_audio.gyp index 36e6a65ebd..884a8afcf8 100644 --- a/webrtc/common_audio/common_audio.gyp +++ b/webrtc/common_audio/common_audio.gyp @@ -136,6 +136,9 @@ ['target_arch=="ia32" or target_arch=="x64"', { 'dependencies': ['common_audio_sse2',], }], + ['build_with_neon==1', { + 'dependencies': ['common_audio_neon',], + }], ['target_arch=="arm"', { 'sources': [ 'signal_processing/complex_bit_reverse_arm.S', @@ -147,7 +150,6 @@ ], 'conditions': [ ['arm_version>=7', { - 'dependencies': ['common_audio_neon',], 'sources': [ 'signal_processing/filter_ar_fast_q12_armv7.S', ], @@ -157,9 +159,6 @@ }], ], # conditions }], - ['target_arch=="arm64"', { - 'dependencies': ['common_audio_neon',], - }], ['target_arch=="mipsel" and mips_arch_variant!="r6"', { 'sources': [ 'signal_processing/include/spl_inl_mips.h', @@ -212,7 +211,7 @@ }, ], # targets }], - ['target_arch=="arm" and arm_version>=7 or target_arch=="arm64"', { + ['build_with_neon==1', { 'targets': [ { 'target_name': 'common_audio_neon', @@ -225,15 +224,6 @@ 'signal_processing/downsample_fast_neon.c', 'signal_processing/min_max_operations_neon.c', ], - 'conditions': [ - # Disable LTO in common_audio_neon target due to compiler bug - ['use_lto==1', { - 'cflags!': [ - '-flto', - '-ffat-lto-objects', - ], - }], - ], }, ], # targets }], diff --git a/webrtc/modules/audio_coding/BUILD.gn b/webrtc/modules/audio_coding/BUILD.gn index 50438f99b6..15ea369005 100644 --- a/webrtc/modules/audio_coding/BUILD.gn +++ b/webrtc/modules/audio_coding/BUILD.gn @@ -528,6 +528,7 @@ source_set("isac_fix") { "codecs/isac/fix/source/initialize.c", "codecs/isac/fix/source/isacfix.c", "codecs/isac/fix/source/lattice.c", + "codecs/isac/fix/source/lattice_c.c", "codecs/isac/fix/source/lpc_masking_model.c", "codecs/isac/fix/source/lpc_masking_model.h", "codecs/isac/fix/source/lpc_tables.c", @@ -566,27 +567,19 @@ source_set("isac_fix") { "../../system_wrappers", ] - if (current_cpu == "arm64") { + if (rtc_build_with_neon) { deps += [ ":isac_neon" ] } - if (rtc_build_armv7_neon) { - deps += [ ":isac_neon" ] - - # Enable compilation for the ARM v7 Neon instruction set. This is needed - # since //build/config/arm.gni only enables Neon for iOS, not Android. - # This provides the same functionality as webrtc/build/arm_neon.gypi. - # TODO(kjellander): Investigate if this can be moved into webrtc.gni or - # //build/config/arm.gni instead, to reduce code duplication. - # Remove the -mfpu=vfpv3-d16 cflag. - configs -= [ "//build/config/compiler:compiler_arm_fpu" ] - cflags = [ "-mfpu=neon" ] - + if (current_cpu == "arm" && arm_version >= 7) { sources += [ "codecs/isac/fix/source/lattice_armv7.S", "codecs/isac/fix/source/pitch_filter_armv6.S", ] - sources -= [ "codecs/isac/fix/source/pitch_filter_c.c" ] + sources -= [ + "codecs/isac/fix/source/lattice_c.c", + "codecs/isac/fix/source/pitch_filter_c.c", + ] } if (current_cpu == "mipsel") { @@ -597,7 +590,10 @@ source_set("isac_fix") { "codecs/isac/fix/source/pitch_estimator_mips.c", "codecs/isac/fix/source/transform_mips.c", ] - sources -= [ "codecs/isac/fix/source/pitch_estimator_c.c" ] + sources -= [ + "codecs/isac/fix/source/lattice_c.c", + "codecs/isac/fix/source/pitch_estimator_c.c", + ] if (mips_dsp_rev > 0) { sources += [ "codecs/isac/fix/source/filterbanks_mips.c" ] } @@ -609,13 +605,9 @@ source_set("isac_fix") { sources -= [ "codecs/isac/fix/source/pitch_filter_c.c" ] } } - - if (!rtc_build_armv7_neon && current_cpu != "mipsel") { - sources += [ "codecs/isac/fix/source/lattice_c.c" ] - } } -if (rtc_build_armv7_neon || current_cpu == "arm64") { +if (rtc_build_with_neon) { source_set("isac_neon") { sources = [ "codecs/isac/fix/source/entropy_coding_neon.c", @@ -623,26 +615,23 @@ if (rtc_build_armv7_neon || current_cpu == "arm64") { "codecs/isac/fix/source/lattice_neon.c", "codecs/isac/fix/source/transform_neon.c", ] - - if (rtc_build_armv7_neon) { - # Enable compilation for the ARM v7 Neon instruction set. This is needed - # since //build/config/arm.gni only enables Neon for iOS, not Android. - # This provides the same functionality as webrtc/build/arm_neon.gypi. - # TODO(kjellander): Investigate if this can be moved into webrtc.gni or - # //build/config/arm.gni instead, to reduce code duplication. - # Remove the -mfpu=vfpv3-d16 cflag. - configs -= [ "//build/config/compiler:compiler_arm_fpu" ] - cflags = [ "-mfpu=neon" ] - } - if (current_cpu != "arm64" || !is_clang) { # Disable AllpassFilter2FixDec16Neon function due to a clang bug. - # Refer more details at: + # For more details refer to: # https://code.google.com/p/webrtc/issues/detail?id=4567 sources += [ "codecs/isac/fix/source/filterbanks_neon.c" ] } - # Disable LTO in audio_processing_neon target due to compiler bug. + if (current_cpu != "arm64") { + # Enable compilation for the NEON instruction set. This is needed + # since //build/config/arm.gni only enables NEON for iOS, not Android. + # This provides the same functionality as webrtc/build/arm_neon.gypi. + configs -= [ "//build/config/compiler:compiler_arm_fpu" ] + cflags = [ "-mfpu=neon" ] + } + + # Disable LTO on NEON targets due to compiler bug. + # TODO(fdegans): Enable this. See crbug.com/408997. if (rtc_use_lto) { cflags -= [ "-flto", diff --git a/webrtc/modules/audio_coding/codecs/isac/isacfix.gypi b/webrtc/modules/audio_coding/codecs/isac/isacfix.gypi index a85adbe43e..68aa8d09c6 100644 --- a/webrtc/modules/audio_coding/codecs/isac/isacfix.gypi +++ b/webrtc/modules/audio_coding/codecs/isac/isacfix.gypi @@ -89,13 +89,8 @@ 'fix/source/lattice_c.c', 'fix/source/pitch_filter_c.c', ], - 'conditions': [ - ['arm_neon==1 or arm_neon_optional==1', { - 'dependencies': [ 'isac_neon' ], - }], - ], }], - ['target_arch=="arm64"', { + ['build_with_neon==1', { 'dependencies': ['isac_neon', ], }], ['target_arch=="mipsel" and mips_arch_variant!="r6"', { @@ -131,7 +126,7 @@ }, ], 'conditions': [ - ['target_arch=="arm" and arm_version>=7 or target_arch=="arm64"', { + ['build_with_neon==1', { 'targets': [ { 'target_name': 'isac_neon', @@ -147,18 +142,11 @@ 'fix/source/transform_neon.c', ], 'conditions': [ - # Disable LTO in isac_neon target due to compiler bug - ['use_lto==1', { - 'cflags!': [ - '-flto', - '-ffat-lto-objects', - ], - }], - # Disable AllpassFilter2FixDec16Neon function due to a clang - # bug. Refer more details at: + # Disable AllpassFilter2FixDec16Neon function due to a clang bug. + # For more details refer to: # https://code.google.com/p/webrtc/issues/detail?id=4567 ['target_arch!="arm64" or clang==0', { - 'sources': ['fix/source/filterbanks_neon.c',], + 'sources': ['fix/source/filterbanks_neon.c',], }] ], }, diff --git a/webrtc/modules/audio_processing/BUILD.gn b/webrtc/modules/audio_processing/BUILD.gn index ce750b636c..907f22b655 100644 --- a/webrtc/modules/audio_processing/BUILD.gn +++ b/webrtc/modules/audio_processing/BUILD.gn @@ -180,7 +180,7 @@ source_set("audio_processing") { deps += [ ":audio_processing_sse2" ] } - if (rtc_build_armv7_neon || current_cpu == "arm64") { + if (rtc_build_with_neon) { deps += [ ":audio_processing_neon" ] } @@ -242,7 +242,7 @@ if (current_cpu == "x86" || current_cpu == "x64") { } } -if (rtc_build_armv7_neon || current_cpu == "arm64") { +if (rtc_build_with_neon) { source_set("audio_processing_neon") { sources = [ "aec/aec_core_neon.c", @@ -251,32 +251,28 @@ if (rtc_build_armv7_neon || current_cpu == "arm64") { "ns/nsx_core_neon.c", ] - configs += [ "../..:common_config" ] - public_configs = [ "../..:common_inherited_config" ] - - deps = [ - "../../common_audio", - ] - - # Enable compilation for the ARM v7 Neon instruction set. This is needed - # since //build/config/arm.gni only enables Neon for iOS, not Android. - # This provides the same functionality as webrtc/build/arm_neon.gypi. - # TODO(kjellander): Investigate if this can be moved into webrtc.gni or - # //build/config/arm.gni instead, to reduce code duplication. - # Remove the -mfpu=vfpv3-d16 cflag. - configs -= [ "//build/config/compiler:compiler_arm_fpu" ] - - # "-mfpu=neon" is not requried for arm64 in GCC. if (current_cpu != "arm64") { + # Enable compilation for the NEON instruction set. This is needed + # since //build/config/arm.gni only enables NEON for iOS, not Android. + # This provides the same functionality as webrtc/build/arm_neon.gypi. + configs -= [ "//build/config/compiler:compiler_arm_fpu" ] cflags = [ "-mfpu=neon" ] } - # Disable LTO in audio_processing_neon target due to compiler bug. + # Disable LTO on NEON targets due to compiler bug. + # TODO(fdegans): Enable this. See crbug.com/408997. if (rtc_use_lto) { cflags -= [ "-flto", "-ffat-lto-objects", ] } + + configs += [ "../..:common_config" ] + public_configs = [ "../..:common_inherited_config" ] + + deps = [ + "../../common_audio", + ] } } diff --git a/webrtc/modules/audio_processing/audio_processing.gypi b/webrtc/modules/audio_processing/audio_processing.gypi index a4f9b39a93..f0d56691c0 100644 --- a/webrtc/modules/audio_processing/audio_processing.gypi +++ b/webrtc/modules/audio_processing/audio_processing.gypi @@ -186,7 +186,7 @@ ['target_arch=="ia32" or target_arch=="x64"', { 'dependencies': ['audio_processing_sse2',], }], - ['(target_arch=="arm" and arm_version>=7) or target_arch=="arm64"', { + ['build_with_neon==1', { 'dependencies': ['audio_processing_neon',], }], ['target_arch=="mipsel" and mips_arch_variant!="r6"', { @@ -249,7 +249,7 @@ }, ], }], - ['(target_arch=="arm" and arm_version>=7) or target_arch=="arm64"', { + ['build_with_neon==1', { 'targets': [{ 'target_name': 'audio_processing_neon', 'type': 'static_library', @@ -263,15 +263,6 @@ 'aecm/aecm_core_neon.c', 'ns/nsx_core_neon.c', ], - 'conditions': [ - # Disable LTO in audio_processing_neon target due to compiler bug - ['use_lto==1', { - 'cflags!': [ - '-flto', - '-ffat-lto-objects', - ], - }], - ], }], }], ],