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

[Build] re2 not compiled when statically building with onnxruntime_BUILD_UNIT_TESTS=OFF #22513

Closed
cyanic-selkie opened this issue Oct 19, 2024 · 5 comments
Labels
build build issues; typically submitted using template

Comments

@cyanic-selkie
Copy link

cyanic-selkie commented Oct 19, 2024

Describe the issue

I have compiled onnxruntime with the following command (on linux):

./build.sh --cmake_extra_defines=onnxruntime_BUILD_UNIT_TESTS=OFF --config Release --parallel --compile_no_warning_as_error --skip_submodule_sync --update --build --build_dir build/linux

When linking this to a rust library (via ort), there seems to be an issue where, if the flag --cmake_extra_defines=onnxruntime_BUILD_UNIT_TESTS=OFF is given, re2 isn't compiled (only when building a static library, apparently, it gets built when building the shared library).

Urgency

No response

Target platform

Linux x86_64

Build script

./build.sh --cmake_extra_defines=onnxruntime_BUILD_UNIT_TESTS=OFF --config Release --parallel --compile_no_warning_as_error --skip_submodule_sync --update --build --build_dir build/linux

Error / output

There is no error at build time, linking downstream fails as described above.

Visual Studio Version

No response

GCC / Compiler Version

No response

@cyanic-selkie cyanic-selkie added the build build issues; typically submitted using template label Oct 19, 2024
@cyanic-selkie cyanic-selkie changed the title [Build] [Build] re2 not compiled when statically building with onnxruntime_BUILD_UNIT_TESTS=OFF Oct 19, 2024
@snnn
Copy link
Member

snnn commented Oct 21, 2024

I just checked https://github.com/microsoft/onnxruntime/blob/main/cmake/external/onnxruntime_external_deps.cmake, re2 doesn't seem to be optional. It should always get built. Sorry I have no idea how it would happen.

@snnn
Copy link
Member

snnn commented Oct 21, 2024

Do you have more logs? Can you set FETCHCONTENT_TRY_FIND_PACKAGE_MODE to NEVER?

@cyanic-selkie
Copy link
Author

cyanic-selkie commented Oct 21, 2024

@snnn Setting FETCHCONTENT_TRY_FIND_PACKAGE_MODE to NEVER seemingly didn't change anything. I also double checked that libre2.a simply doesn't exist when I disable tests. In fact, the entire re2-build directory is missing.

Here is the entire build log of the original command I posted.

notests_build.log

Here is the entire build log of the original command I posted without disabling tests.

tests_build.log

Looking at the explicit dependencies, re2 is only an explicit dependency for test related packages, not onnxruntime directly.

Can you reproduce the issue?

@snnn
Copy link
Member

snnn commented Oct 22, 2024

I tried the command on Linux(sorry I don't have a Mac machine). It did not have any problem. I noticed that you didn't generate a dynamic onnxruntime lib. So, your application needs to link to all onnxruntime's internal libraries and their dependencies(including re2). That's a lot.
And since you disabled all executable binaries and all *.dylib targets, there is no link stage. Nothing needs be linked. Therefore re2 even won't get built. This is expected.

@snnn snnn closed this as not planned Won't fix, can't repro, duplicate, stale Oct 22, 2024
@snnn
Copy link
Member

snnn commented Oct 22, 2024

Could you consider using vcpkg? #21348. If vcpkg works, then it can help build all the dependencies and ensure ORT and your app using the dependency versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build issues; typically submitted using template
Projects
None yet
Development

No branches or pull requests

2 participants