microsoft / microsoft/onnxruntime
[Build] Failure to build with shared library flatbuffers 23.3.3
- Dominant language
- C++
- Stars
- 21.9k
- Forks
- 4.2k
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 184
Description
### Describe the issue
Trying to build `main` on Arch Linux fails because Arch Linux [packages `flatbuffers` as a shared library](https://github.com/archlinux/svntogit-community/blob/packages/flatbuffers/trunk/PKGBUILD#L36). The flatbuffers target then becomes `flatbuffers::flatbuffers_shared`, not `flatbuffers::flatbuffers` as is used in [onnxruntime](https://github.com/microsoft/onnxruntime/blob/main/cmake/onnxruntime_graph.cmake#L89). As a result, CMake fails to find the target.
Replacing `flatbuffers::flatbuffers` with `flatbuffers::flatbuffers_shared` makes it pass the CMake stage, but fails to build as well:
```
onnxruntime/onnxruntime/core/flatbuffers/schema/ort.fbs.h: In member function ‘bool onnxruntime::fbs::DimensionValue::Verify(flatbuffers::Verifier&) const’:
onnxruntime/onnxruntime/core/flatbuffers/schema/ort.fbs.h:553:31: error: no matching function for call to ‘onnxruntime::fbs::DimensionValue::VerifyField(flatbuffers::Verifier&, onnxruntime::fbs::DimensionValue::FlatBuffersVTableOffset) const’
553 | VerifyField(verifier, VT_DIM_TYPE) &&
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/flatbuffers/flatbuffer_builder.h:33,
from /usr/include/flatbuffers/flatbuffers.h:29,
from onnxruntime/onnxruntime/core/flatbuffers/schema/ort.fbs.h:7:
/usr/include/flatbuffers/table.h:115:8: note: candidate: ‘template bool flatbuffers::Table::VerifyField(const flatbuffers::Verifier&, flatbuffers::voffset_t, size_t) const’
115 | bool VerifyField(const Verifier &verifier, voffset_t field,
| ^~~~~~~~~~~
/usr/include/flatbuffers/table.h:115:8: note: candidate expects 3 arguments, 2 provided
```
There's many more errors like this, possibly because of API changes?
Considering `flatbuffers` is [designed as a header-only library](https://github.com/google/flatbuffers/issues/4697#issuecomment-379299745), maybe it makes sense to include it as a submodule in this repository, same as protobuf?
### Urgency
_No response_
### Target platform
x86_64
### Build script
```
./build.sh --config RelWithDebInfo --build_shared_lib --parallel
```
### Error / output
```
CMake Error at onnxruntime_flatbuffers.cmake:18 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_flatbuffers" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_common.cmake:120 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_common" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_graph.cmake:89 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_graph" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_framework.cmake:100 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_framework" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_util.cmake:19 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_util" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_providers.cmake:284 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_providers" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_optimizer.cmake:106 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_optimizer" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_session.cmake:46 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_session" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime.cmake:100 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target "onnxruntime"
does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:695 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_test_utils" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:723 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnx_test_runner_common" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:47 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_test_all" does not exist.
Call Stack (most recent call first):
onnxruntime_unittests.cmake:798 (AddTest)
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:859 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnx_test_data_proto" does not exist.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:47 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_shared_lib_test" does not exist.
Call Stack (most recent call first):
onnxruntime_unittests.cmake:1251 (AddTest)
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:47 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_global_thread_pools_test" does not exist.
Call Stack (most recent call first):
onnxruntime_unittests.cmake:1276 (AddTest)
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:47 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_api_tests_without_env" does not exist.
Call Stack (most recent call first):
onnxruntime_unittests.cmake:1286 (AddTest)
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:47 (add_dependencies):
The dependency target "flatbuffers::flatbuffers" of target
"onnxruntime_customopregistration_test" does not exist.
Call Stack (most recent call first):
onnxruntime_unittests.cmake:1510 (AddTest)
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime.cmake:211 (target_link_libraries):
Target "onnxruntime" links to:
flatbuffers::flatbuffers
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:55 (target_link_libraries):
Target "onnxruntime_test_all" links to:
flatbuffers::flatbuffers
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
Call Stack (most recent call first):
onnxruntime_unittests.cmake:798 (AddTest)
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:1002 (target_link_libraries):
Target "onnx_test_runner" links to:
flatbuffers::flatbuffers
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
CMake Error at onnxruntime_unittests.cmake:1203 (target_link_libraries):
Target "onnxruntime_perf_test" links to:
flatbuffers::flatbuffers
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
Call Stack (most recent call first):
CMakeLists.txt:1584 (include)
-- Generating done
```
### Visual Studio Version
_No response_
### GCC / Compiler Version
_No response_
Contributor guide
Research direction
Start with build.sh and the CMake entry points named in the report, especially onnxruntime_flatbuffers.cmake, onnxruntime_graph.cmake, and the other files referencing flatbuffers::flatbuffers. Reproduce the RelWithDebInfo shared-library build on Arch Linux, then inspect the generated onnxruntime/core/flatbuffers/schema/ort.fbs.h against the installed headers. Done means the reported build completes with flatbuffers 23.3.3 and the relevant tests build successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100