From 5d590b2ca23d079ebf436dda037fbf0e13605e3a Mon Sep 17 00:00:00 2001 From: "Klaus T. Aehlig" Date: Wed, 25 Jan 2023 20:11:22 +0000 Subject: Fix boostrapping on less optimizing compilers While compilers are allowed to drop unused functions in anonymous name spaces, and in this way also the open linker symbols referenced there, they are not obliged to do so. Not optimizing away such unused functions when compiled with -DBOOTSTRAP_BUILD_TOOL causes the linking fail in the initial phase of the boostrap process where libgit2 is not yet available (nor really needed). Therefore, ensure that those dead functions are absent in the initial bootstrap phase using appropriate preprocessor directives. Signed-off-by: Klaus T. Aehlig --- src/buildtool/file_system/git_repo.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/buildtool/file_system/git_repo.cpp') diff --git a/src/buildtool/file_system/git_repo.cpp b/src/buildtool/file_system/git_repo.cpp index e7db261a..0aba51a2 100644 --- a/src/buildtool/file_system/git_repo.cpp +++ b/src/buildtool/file_system/git_repo.cpp @@ -23,6 +23,7 @@ extern "C" { #include } +#ifndef BOOTSTRAP_BUILD_TOOL namespace { constexpr std::size_t kWaitTime{2}; // time in ms between tries for git locks @@ -273,13 +274,9 @@ void backend_free(git_odb_backend* /*_backend*/) {} return b; } -#ifndef BOOTSTRAP_BUILD_TOOL - // A backend that can be used to read and create tree objects in-memory. auto const kInMemoryODBParent = CreateInMemoryODBParent(); -#endif // BOOTSTRAP_BUILD_TOOL - struct FetchIntoODBBackend { git_odb_backend parent; git_odb* target_odb; // the odb where the fetch objects will end up into @@ -319,13 +316,9 @@ void fetch_backend_free(git_odb_backend* /*_backend*/) {} return b; } -#ifndef BOOTSTRAP_BUILD_TOOL - // A backend that can be used to fetch from the remote of another repository. auto const kFetchIntoODBParent = CreateFetchIntoODBParent(); -#endif // BOOTSTRAP_BUILD_TOOL - // callback to enable SSL certificate check for remote fetch const auto certificate_check_cb = [](git_cert* /*cert*/, int /*valid*/, @@ -369,6 +362,7 @@ const auto certificate_passthrough_cb = [](git_cert* /*cert*/, } } // namespace +#endif // BOOTSTRAP_BUILD_TOOL auto GitRepo::Open(GitCASPtr git_cas) noexcept -> std::optional { #ifdef BOOTSTRAP_BUILD_TOOL -- cgit v1.2.3