summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/controller/algorithm.cpp
diff options
context:
space:
mode:
authorDave Jones <dave.jones@canonical.com>2023-03-10 11:39:11 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2023-03-21 23:32:10 +0000
commitafc5ea57b496c633a1a16c67cf132df6c5ed9b46 (patch)
treea258f46ad6331ecd899574273575fa6265d37ea4 /src/ipa/raspberrypi/controller/algorithm.cpp
parentd34cefad17918a37e48c2a9fadd63480e6661d6e (diff)
ipa: raspberrypi: Fix crash under LTO
When compiled with LTO (the default on Ubuntu), the global static objects camHelpers and algorithms cause a crash in raspberrypi_ipa_proxy at runtime as they're not allocated by the time the registration routines execute. This is a fairly crude fix which just converts the global static objects into local static objects inside an equivalently named function. Signed-off-by: Dave Jones <dave.jones@canonical.com> Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/ipa/raspberrypi/controller/algorithm.cpp')
-rw-r--r--src/ipa/raspberrypi/controller/algorithm.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/ipa/raspberrypi/controller/algorithm.cpp b/src/ipa/raspberrypi/controller/algorithm.cpp
index 6d91ee29..a957fde5 100644
--- a/src/ipa/raspberrypi/controller/algorithm.cpp
+++ b/src/ipa/raspberrypi/controller/algorithm.cpp
@@ -34,14 +34,23 @@ void Algorithm::process([[maybe_unused]] StatisticsPtr &stats,
/* For registering algorithms with the system: */
-static std::map<std::string, AlgoCreateFunc> algorithms;
-std::map<std::string, AlgoCreateFunc> const &RPiController::getAlgorithms()
+namespace {
+
+std::map<std::string, AlgoCreateFunc> &algorithms()
{
+ static std::map<std::string, AlgoCreateFunc> algorithms;
return algorithms;
}
+} /* namespace */
+
+std::map<std::string, AlgoCreateFunc> const &RPiController::getAlgorithms()
+{
+ return algorithms();
+}
+
RegisterAlgorithm::RegisterAlgorithm(char const *name,
AlgoCreateFunc createFunc)
{
- algorithms[std::string(name)] = createFunc;
+ algorithms()[std::string(name)] = createFunc;
}