summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKlaus T. Aehlig <aehlig@linta.de>2023-01-25 20:11:22 +0000
committerKlaus Aehlig <klaus.aehlig@huawei.com>2023-01-26 13:03:06 +0100
commit5d590b2ca23d079ebf436dda037fbf0e13605e3a (patch)
tree838b4c6b3b3dbf4f4c97980ee510e32df9cb4d66 /src
parentdaa2de1617c4f71e4502be407409150bf2d0467c (diff)
downloadjustbuild-5d590b2ca23d079ebf436dda037fbf0e13605e3a.tar.gz
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 <aehlig@linta.de>
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/file_system/git_repo.cpp10
1 files changed, 2 insertions, 8 deletions
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 <git2/sys/odb_backend.h>
}
+#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<GitRepo> {
#ifdef BOOTSTRAP_BUILD_TOOL