XNNPACK icon indicating copy to clipboard operation
XNNPACK copied to clipboard

Build crashes on ios_armv7 with bazel

Open junhee-yoo opened this issue 5 years ago • 1 comments

Hi, thank you for your great project.

I'd tried to build XNNPACK e2ebench with ios_armv7 config with commands below:

$ bazel build -c opt --config ios_armv7 :end2end_bench

and bazel build log saids:

console outputs
$ bazel build -c opt --config ios_armv7 :end2end_bench
INFO: Analyzed target //:end2end_bench (24 packages loaded, 1387 targets configured).
INFO: Found 1 target...
ERROR: /Users/jhyoo/workspace/src/XNNPACK/BUILD.bazel:3122:19: C++ compilation of rule '//:tables' failed (Exit 1): wrapped_clang failed: error executing command external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG ... (remaining 37 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox wrapped_clang failed: error executing command external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG ... (remaining 37 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
clang: error: invalid iOS deployment version '--target=armv7-apple-ios', iOS 10 is the maximum deployment target for 32-bit targets [-Winvalid-ios-deployment-target]
Target //:end2end_bench failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 12.155s, Critical Path: 0.37s
INFO: 133 processes: 133 internal.
FAILED: Build did NOT complete successfully

The main reason seems clang: error: invalid iOS deployment version '--target=armv7-apple-ios', iOS 10 is the maximum deployment target for 32-bit . My ios sdk version is 13.7 so I guess local_config_cc put -miphoneos-version-min=13.7 on ios_armv7 build. To avoid this I'd tried:

$ bazel build --ios_minimum_os='10.0' -c opt --config ios_armv7 :end2end_bench

And then I faced compile error because armv7 doesn't support dot product simd command:

console outputs
$ bazel build --ios_minimum_os='10.0' -c opt --config ios_armv7 :end2end_bench
INFO: Build option --ios_minimum_os has changed, discarding analysis cache.
INFO: Analyzed target //:end2end_bench (0 packages loaded, 1387 targets configured).
INFO: Found 1 target...
ERROR: /Users/jhyoo/workspace/src/XNNPACK/BUILD.bazel:3470:19: C++ compilation of rule '//:neondot_ukernels' failed (Exit 1): wrapped_clang failed: error executing command external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG ... (remaining 65 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox wrapped_clang failed: error executing command external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG ... (remaining 65 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
src/qs8-gemm/gen/1x8c4-minmax-neondot.c:62:20: warning: implicit declaration of function 'vdotq_lane_s32' is invalid in C99 [-Wimplicit-function-declaration]
      vacc0x0123 = vdotq_lane_s32(vacc0x0123, vb0123x0123, va0x01234567, 0);
                   ^
src/qs8-gemm/gen/1x8c4-minmax-neondot.c:62:18: error: assigning to 'int32x4_t' (vector of 4 'int32_t' values) from incompatible type 'int'
      vacc0x0123 = vdotq_lane_s32(vacc0x0123, vb0123x0123, va0x01234567, 0);
                 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/qs8-gemm/gen/1x8c4-minmax-neondot.c:63:18: error: assigning to 'int32x4_t' (vector of 4 'int32_t' values) from incompatible type 'int'
      vacc0x4567 = vdotq_lane_s32(vacc0x4567, vb0123x4567, va0x01234567, 0);
                 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/qs8-gemm/gen/1x8c4-minmax-neondot.c:64:18: error: assigning to 'int32x4_t' (vector of 4 'int32_t' values) from incompatible type 'int'
      vacc0x0123 = vdotq_lane_s32(vacc0x0123, vb4567x0123, va0x01234567, 1);
                 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/qs8-gemm/gen/1x8c4-minmax-neondot.c:65:18: error: assigning to 'int32x4_t' (vector of 4 'int32_t' values) from incompatible type 'int'
      vacc0x4567 = vdotq_lane_s32(vacc0x4567, vb4567x4567, va0x01234567, 1);
                 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/qs8-gemm/gen/1x8c4-minmax-neondot.c:79:20: warning: implicit declaration of function 'vdotq_lane_s32' is invalid in C99 [-Wimplicit-function-declaration]
      vacc0x0123 = vdotq_lane_s32(vacc0x0123, vb0123x0123, va0x01234567, 0);
                   ^
src/qs8-gemm/gen/1x8c4-minmax-neondot.c:79:18: error: assigning to 'int32x4_t' (vector of 4 'int32_t' values) from incompatible type 'int'
      vacc0x0123 = vdotq_lane_s32(vacc0x0123, vb0123x0123, va0x01234567, 0);
                 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/qs8-gemm/gen/1x8c4-minmax-neondot.c:80:18: error: assigning to 'int32x4_t' (vector of 4 'int32_t' values) from incompatible type 'int'
      vacc0x4567 = vdotq_lane_s32(vacc0x4567, vb0123x4567, va0x01234567, 0);
                 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/qs8-gemm/gen/1x8c4-minmax-neondot.c:88:20: error: assigning to 'int32x4_t' (vector of 4 'int32_t' values) from incompatible type 'int'
        vacc0x0123 = vdotq_lane_s32(vacc0x0123, vb4567x0123, va0x01234567, 1);
                   ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/qs8-gemm/gen/1x8c4-minmax-neondot.c:89:20: error: assigning to 'int32x4_t' (vector of 4 'int32_t' values) from incompatible type 'int'
        vacc0x4567 = vdotq_lane_s32(vacc0x4567, vb4567x4567, va0x01234567, 1);
                   ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings and 8 errors generated.
Target //:end2end_bench failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 7.145s, Critical Path: 6.64s
INFO: 215 processes: 130 internal, 85 darwin-sandbox.
FAILED: Build did NOT complete successfully

I'm not sure whether ios armv7 is still used popular or not but it was necessary for my work, so I fixed this by adding 'apple_aarch32_copt' on neon dot product targets in BUILD.bazel and add an ios option on ios_armv7 config.

If you're ok, may I make a PR for this?

Thank you. :)

junhee-yoo avatar Oct 30 '20 07:10 junhee-yoo

The problem was older iOS that supported 32 bit didnt have dot product. Newer iOS dropped 32 bit but added dot product for 64 bit. But the older tool chain that still supports 32 bit doesnt support new instructions. So we have to drop dot product and/or 32 bit. An ifdef guard was added so if you build dotproduct kernels on iOS, they'll be empty.

fbarchard avatar Nov 18 '23 00:11 fbarchard