AOMediaCodec / iamf-tools

Tools to work with IAMF
https://aomediacodec.github.io/iamf-tools/
Other
18 stars 8 forks source link

Can't build the project with bazel #5

Closed rafalfaro18 closed 1 month ago

rafalfaro18 commented 7 months ago

I keep getting errors about invalid numeric arguments in Windows:

PS D:\Code\IAMF\iamf-tools> bazel build -c opt //iamf/cli:encoder_main
INFO: Analyzed target //iamf/cli:encoder_main (1 packages loaded, 514 targets configured).
ERROR: C:/users/pc/_bazel_pc/t63pxre5/external/com_google_absl/absl/base/BUILD.bazel:60:11: Compiling absl/base/log_severity.cc failed: (Exit 2): cl.exe failed: error executing CppCompile command (from target @@com_google_absl//absl/base:log_severity) C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.39.33519\bin\HostX64\x64\cl.exe ... (remaining 1 argument skipped)
cl : Command line error D8021 : invalid numeric argument '/Wno-sign-compare'
Target //iamf/cli:encoder_main failed to build
Use --verbose_failures to see the command lines of failed build steps.
rafalfaro18 commented 7 months ago

I also tried building in WSL instead after much debugging I eventually get this error about ambiguous NoDestructor overload:

ERROR: /home/rafalfaro/iamf-tools/iamf/cli/adm_to_user_metadata/adm/BUILD:43:11: Compiling iamf/cli/adm_to_user_metadata/adm/xml_to_adm.cc failed: (Exit 1): gcc failed: error executing CppCompile command (from target //iamf/cli/adm_to_user_metadata/adm:xml_to_adm) /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 39 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
iamf/cli/adm_to_user_metadata/adm/xml_to_adm.cc: In function 'bool iamf_tools::adm_to_user_metadata::{anonymous}::IsLoudspeakerLayoutValid(absl::string_view)':
iamf/cli/adm_to_user_metadata/adm/xml_to_adm.cc:199:8: error: call of overloaded 'NoDestructor(<brace-enclosed initializer list>)' is ambiguous
  199 |       });
      |        ^
In file included from iamf/cli/adm_to_user_metadata/adm/xml_to_adm.cc:24:
external/com_google_absl/absl/base/no_destructor.h:137:3: note: candidate: 'absl::NoDestructor<T>::NoDestructor(const absl::NoDestructor<T>&) [with T = absl::flat_hash_set<std::__cxx11::basic_string<char> >]' (deleted)
  137 |   NoDestructor(const NoDestructor&) = delete;
      |   ^~~~~~~~~~~~
external/com_google_absl/absl/base/no_destructor.h:133:22: note: candidate: 'constexpr absl::NoDestructor<T>::NoDestructor(T&&) [with T = absl::flat_hash_set<std::__cxx11::basic_string<char> >]'
  133 |   explicit constexpr NoDestructor(T&& x)
      |                      ^~~~~~~~~~~~
external/com_google_absl/absl/base/no_destructor.h:132:22: note: candidate: 'constexpr absl::NoDestructor<T>::NoDestructor(const T&) [with T = absl::flat_hash_set<std::__cxx11::basic_string<char> >]'
  132 |   explicit constexpr NoDestructor(const T& x) : impl_(x) {}
      |                      ^~~~~~~~~~~~
iamf/cli/adm_to_user_metadata/adm/xml_to_adm.cc: In function 'bool iamf_tools::adm_to_user_metadata::{anonymous}::IsHoaLayoutValid(absl::string_view)':
iamf/cli/adm_to_user_metadata/adm/xml_to_adm.cc:211:8: error: call of overloaded 'NoDestructor(<brace-enclosed initializer list>)' is ambiguous
  211 |       });
      |        ^
external/com_google_absl/absl/base/no_destructor.h:137:3: note: candidate: 'absl::NoDestructor<T>::NoDestructor(const absl::NoDestructor<T>&) [with T = absl::flat_hash_set<std::__cxx11::basic_string<char> >]' (deleted)
  137 |   NoDestructor(const NoDestructor&) = delete;
      |   ^~~~~~~~~~~~
external/com_google_absl/absl/base/no_destructor.h:133:22: note: candidate: 'constexpr absl::NoDestructor<T>::NoDestructor(T&&) [with T = absl::flat_hash_set<std::__cxx11::basic_string<char> >]'
  133 |   explicit constexpr NoDestructor(T&& x)
      |                      ^~~~~~~~~~~~
external/com_google_absl/absl/base/no_destructor.h:132:22: note: candidate: 'constexpr absl::NoDestructor<T>::NoDestructor(const T&) [with T = absl::flat_hash_set<std::__cxx11::basic_string<char> >]'
  132 |   explicit constexpr NoDestructor(const T& x) : impl_(x) {}
      |                      ^~~~~~~~~~~~
Target //iamf/cli:encoder_main failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 15.515s, Critical Path: 15.07s
INFO: 216 processes: 26 internal, 190 linux-sandbox.
ERROR: Build did NOT complete successfully
rafalfaro18 commented 7 months ago

I think you may have not tested this project in while in a fresh windows or linux computer, in a fresh install of bazel. You may have been testing with the machine that already has all the dependencies or some specific setup that is not in the documentation for this project.

rafalfaro18 commented 7 months ago

I also tried building in WSL instead after much debugging I eventually get this error about ambiguous NoDestructor overload:

ERROR: /home/rafalfaro/iamf-tools/iamf/cli/adm_to_user_metadata/adm/BUILD:43:11: Compiling iamf/cli/adm_to_user_metadata/adm/xml_to_adm.cc failed: (Exit 1): gcc failed: error executing CppCompile command (from target //iamf/cli/adm_to_user_metadata/adm:xml_to_adm) /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 39 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
iamf/cli/adm_to_user_metadata/adm/xml_to_adm.cc: In function 'bool iamf_tools::adm_to_user_metadata::{anonymous}::IsLoudspeakerLayoutValid(absl::string_view)':
iamf/cli/adm_to_user_metadata/adm/xml_to_adm.cc:199:8: error: call of overloaded 'NoDestructor(<brace-enclosed initializer list>)' is ambiguous
  199 |       });
      |        ^
In file included from iamf/cli/adm_to_user_metadata/adm/xml_to_adm.cc:24:
external/com_google_absl/absl/base/no_destructor.h:137:3: note: candidate: 'absl::NoDestructor<T>::NoDestructor(const absl::NoDestructor<T>&) [with T = absl::flat_hash_set<std::__cxx11::basic_string<char> >]' (deleted)
  137 |   NoDestructor(const NoDestructor&) = delete;
      |   ^~~~~~~~~~~~
external/com_google_absl/absl/base/no_destructor.h:133:22: note: candidate: 'constexpr absl::NoDestructor<T>::NoDestructor(T&&) [with T = absl::flat_hash_set<std::__cxx11::basic_string<char> >]'
  133 |   explicit constexpr NoDestructor(T&& x)
      |                      ^~~~~~~~~~~~
external/com_google_absl/absl/base/no_destructor.h:132:22: note: candidate: 'constexpr absl::NoDestructor<T>::NoDestructor(const T&) [with T = absl::flat_hash_set<std::__cxx11::basic_string<char> >]'
  132 |   explicit constexpr NoDestructor(const T& x) : impl_(x) {}
      |                      ^~~~~~~~~~~~
iamf/cli/adm_to_user_metadata/adm/xml_to_adm.cc: In function 'bool iamf_tools::adm_to_user_metadata::{anonymous}::IsHoaLayoutValid(absl::string_view)':
iamf/cli/adm_to_user_metadata/adm/xml_to_adm.cc:211:8: error: call of overloaded 'NoDestructor(<brace-enclosed initializer list>)' is ambiguous
  211 |       });
      |        ^
external/com_google_absl/absl/base/no_destructor.h:137:3: note: candidate: 'absl::NoDestructor<T>::NoDestructor(const absl::NoDestructor<T>&) [with T = absl::flat_hash_set<std::__cxx11::basic_string<char> >]' (deleted)
  137 |   NoDestructor(const NoDestructor&) = delete;
      |   ^~~~~~~~~~~~
external/com_google_absl/absl/base/no_destructor.h:133:22: note: candidate: 'constexpr absl::NoDestructor<T>::NoDestructor(T&&) [with T = absl::flat_hash_set<std::__cxx11::basic_string<char> >]'
  133 |   explicit constexpr NoDestructor(T&& x)
      |                      ^~~~~~~~~~~~
external/com_google_absl/absl/base/no_destructor.h:132:22: note: candidate: 'constexpr absl::NoDestructor<T>::NoDestructor(const T&) [with T = absl::flat_hash_set<std::__cxx11::basic_string<char> >]'
  132 |   explicit constexpr NoDestructor(const T& x) : impl_(x) {}
      |                      ^~~~~~~~~~~~
Target //iamf/cli:encoder_main failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 15.515s, Critical Path: 15.07s
INFO: 216 processes: 26 internal, 190 linux-sandbox.
ERROR: Build did NOT complete successfully

I was able to compile by doing these changes: image I know it's less efficient but hopefully it doesn't change the result.

jwcullen commented 7 months ago

Hi, thanks for working through this.

Invalid numeric arguments on MSVC/Windows

Currently this project is supported on Linux, but Windows/MSVC may come in the future. Contributions will be considered according to CONTRIBUTING.md

WSL NoDestructor issue:

It looks like it may be getting confused with the string literals. The original NoDestructor version may work if string literals are wrapped in std::string(). Something like the below snippet and similar for the issue in IsLoudspeakerLayoutValid().

  static const absl::NoDestructor<absl::flat_hash_set<std::string>>
      kValidHoaLayouts({
         std::string("0001"),  // First-order ambisonics.
         std::string("0002"),  // Second-order ambisonics.
         std::string("0003"),  // Third-order ambisonics.
      });

Can you help gather some information about your compiler settings? Please run these commands in WSL

For the second command I am mainly curious about the flags passed to gcc. The original error message had "39 arguments skipped".

Compiling iamf/cli/adm_to_user_metadata/adm/xml_to_adm.cc failed: (Exit 1): gcc failed: error executing CppCompile command (from target //iamf/cli/adm_to_user_metadata/adm:xml_to_adm) /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 39 arguments skipped)

jwcullen commented 7 months ago

@rafalfaro18, does it work at 57d81681 on WSL without any manual modifications?

I ran into the "NoDestructor" issue when configuring a GitHub Actions CI build. I made a slight change to those sections. I expect the changes will also work in your WSL environment.

rafalfaro18 commented 7 months ago

I'll test tonight and let you know.

rafalfaro18 commented 7 months ago

57d8168

Does compile without modifications. I think I just installed sudo apt-get install libexpat1-dev besides cmake.

rafalfaro18 commented 7 months ago

gcc --version

gcc --version                                                                                                      
gcc (Debian 12.2.0-14) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
rafalfaro18 commented 7 months ago

57d8168

Does compile without modifications. I think I just installed sudo apt-get install libexpat1-dev besides cmake.

60d7fab also builds without changes.

jwcullen commented 7 months ago

Thanks for working through this. I made a separate issue to track native windows/MSVC builds. Now we have newly added CI which has a very minimal config for Linux.

I'll investigate if libexpat1-dev and cmake are required. We try to pull in all dependencies in WORKSPACE and build them with bazel build files. They may or may not be required.

jwcullen commented 7 months ago

Ok looks like libexpat1-dev may be required because it provides expat_config.h. So for now that is a pre-requisite. We may be able to update the build to generate it at build time though.