Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build xformer #909

Closed
andresovela opened this issue Jul 18, 2024 · 8 comments
Closed

Can't build xformer #909

andresovela opened this issue Jul 18, 2024 · 8 comments

Comments

@andresovela
Copy link
Contributor

andresovela commented Jul 18, 2024

I'm not familiar with Bazel, but running bazel build //:xcore-opt as suggested in the README fails with the following error:

ERROR: /home/andy/dev/projects/xmos/ai_tools/xformer/WORKSPACE:110:21: fetching new_local_repository rule //external:lib_tflmc: /home/andy/dev/projects/xmos/ai_tools/xformer/external/lib_tflmc.BUILD is not a regular file; if you're using a relative or absolute path for `build_file` in your `new_local_repository` rule, please switch to using a label instead
ERROR: no such package '@@lib_tflmc//': /home/andy/dev/projects/xmos/ai_tools/xformer/external/lib_tflmc.BUILD is not a regular file; if you're using a relative or absolute path for `build_file` in your `new_local_repository` rule, please switch to using a label instead
ERROR: /home/andy/dev/projects/xmos/ai_tools/xformer/BUILD:247:10: //:xcore-opt depends on @@lib_tflmc//:tflmc_lib in repository @@lib_tflmc which failed to fetch. no such package '@@lib_tflmc//': /home/andy/dev/projects/xmos/ai_tools/xformer/external/lib_tflmc.BUILD is not a regular file; if you're using a relative or absolute path for `build_file` in your `new_local_repository` rule, please switch to using a label instead
ERROR: Analysis of target '//:xcore-opt' failed; build aborted: Analysis failed

It seems the problem is that for some reason the build system is looking for lib_tflmc.BUILD under ai_tools/xformer/external instead of just ai_tools/xformer.

Note: I'm trying to build using Bazel 7.2.0, I updated .bazelversion to reflect my installed version.

@panickal-xmos
Copy link
Collaborator

You would have to use the supported bazel version. Could you please try building using bazelisk, as that would download the supported bazel version? As in bazelisk build //:xcore-opt.

@andresovela
Copy link
Contributor Author

Using bazelisk I now do not have that problem, but the build still fails with the following error:

ERROR: /home/andy/.cache/bazel/_bazel_andy/8b429239a50f407a9e6918483356d160/external/lib_tflmc/BUILD.bazel:175:11: Compiling lib_tflite_micro/src/tflite-xcore-kernels/xcore_utils.cc failed: (Exit 1): gcc failed: error executing command (from target @lib_tflmc//:tflmc_lib) /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -MD -MF ... (remaining 118 arguments skipped)
In file included from external/lib_tflite_micro/lib_tflite_micro/submodules/flatbuffers/include/flatbuffers/array.h:21,
                 from external/lib_tflite_micro/lib_tflite_micro/submodules/flatbuffers/include/flatbuffers/flatbuffers.h:22,
                 from external/lib_tflite_micro/lib_tflite_micro/submodules/tflite-micro/tensorflow/lite/micro/flatbuffer_utils.h:19,
                 from external/lib_tflite_micro/lib_tflite_micro/submodules/tflite-micro/tensorflow/lite/micro/micro_allocator.h:23,
                 from external/lib_tflite_micro/lib_tflite_micro/submodules/tflite-micro/tensorflow/lite/micro/micro_resource_variable.h:22,
                 from external/lib_tflite_micro/lib_tflite_micro/submodules/tflite-micro/tensorflow/lite/micro/micro_graph.h:21,
                 from external/lib_tflite_micro/lib_tflite_micro/submodules/tflite-micro/tensorflow/lite/micro/micro_context.h:20,
                 from external/lib_tflite_micro/lib_tflite_micro/submodules/tflite-micro/tensorflow/lite/micro/kernels/kernel_util.h:26,
                 from external/lib_tflite_micro/lib_tflite_micro/src/tflite-xcore-kernels/xcore_utils.h:9,
                 from external/lib_tflite_micro/lib_tflite_micro/src/tflite-xcore-kernels/xcore_utils.cc:1:
external/lib_tflite_micro/lib_tflite_micro/submodules/flatbuffers/include/flatbuffers/stl_emulation.h: In member function 'constexpr flatbuffers::span<T, Extent>& flatbuffers::span<T, Extent>::operator=(const flatbuffers::span<T, Extent>&)':
external/lib_tflite_micro/lib_tflite_micro/submodules/flatbuffers/include/flatbuffers/stl_emulation.h:386:12: error: assignment of read-only member 'flatbuffers::span<T, Extent>::count_'
  386 |     count_ = other.count_;
      |     ~~~~~~~^~~~~~~~~~~~~~
Target //:xcore-opt failed to build

@panickal-xmos
Copy link
Collaborator

I'm not sure what's going wrong. A patch has to be applied to lib_tflite_micro repo, which maybe has not been done. Could you please try these steps, https://github.com/xmos/ai_tools/blob/develop/docs/rst/build-from-source.rst ?

@andresovela
Copy link
Contributor Author

I hadn't done that, but now I did and I get the same error.

@andresovela
Copy link
Contributor Author

I was able to compile xformer by manually removing const from the count_ variable the compiler is complaining about. No idea what's the right way to fix this.

@panickal-xmos
Copy link
Collaborator

ERROR: /home/andy/.cache/bazel/_bazel_andy/8b429239a50f407a9e6918483356d160/external/lib_tflmc/BUILD.bazel:175:11: Compiling lib_tflite_micro/src/tflite-xcore-kernels/xcore_utils.cc failed: (Exit 1): gcc failed: error executing command (from target @lib_tflmc//:tflmc_lib) /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -MD -MF ... (remaining 118 arguments skipped)

Hmmm, I wonder if "-std=c++0x" is an issue. You could try a full clean and rebuild with the instructions from the build-from-source.rst . Another option is to look through https://github.com/xmos/ai_tools/blob/develop/.github/workflows/build-and-test.yml in case you notice something that is different.

@andresovela
Copy link
Contributor Author

I did run bazel clean --expunge to do a full clean (not sure what that does, just saw it on StackOverflow) and tried to build again, but I got the same error.

Nothing in particular caught my eye in the build-and-test.yml file.

I did test what I had to test already by manually patching the bad file, so I don't really need to solve this anymore. I'm not sure if you wanna keep the issue open for tracking or if we should close it considering that it apparently only affects me.

@panickal-xmos
Copy link
Collaborator

No worries, I'll close this issue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants