Move dbus_to_terminus_effecter code to platform-mc
In the current state , pldm build breaks when attempting to perform
a debug-optimized build (`-O2` optimization), leading to the following
linker error:
```
undefined reference to `pldm::platform_mc::TerminusManager::getActiveEidByName
(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
```
This issue is not encountered in the CI environment, as CI uses the
`-Og` optimization flag, which does not aggressively inline functions.
Consequently, the reference to `getActiveEidByName()` is resolved
without issue. However, when building the project with default
optimizations (debugoptimized [-O2]), the build fails because the
linker cannot resolve the reference to `getActiveEidByName()`, which is
inlined by the compiler.
To address this problem, there are three potential solutions:
1. Prevent Inlining of the Function:
We could use `__attribute__((noinline))` to prevent the compiler
from inlining `getActiveEidByName()`.
2. Move Source Files into `libpldmresponder`:
We could move the `platform-mc/manager.cpp` and
`platform-mc/terminus_manager.cpp` files into the `libpldmresponder`
so the compiler can resolve the reference directly within the
library.
3. Migrate `dbus_to_terminus_effecter.cpp` to the `platform-mc` folder:
The most appropriate solution appears to be migrating the
`dbus_to_terminus_effecter.cpp` file into the `platform-mc` directory.
This file is not inherently tied to `libpldmresponder` but functions as
a requester. Additionally, there are existing community patches that
allow the system to scale from a single host terminus to multiple
terminii, further justifying this move. So, solution #3 is the most
fitting at this stage. By relocating the `dbus_to_terminus_effecter`
code to the `platform-mc` folder, we can ensure proper modularity,
while also resolving the build issue in a clean and scalable manner.
Tested By:
1. meson build -Doptimization=2 works fine with the patchset.
Change-Id: I0ac8be58253bfb0394500f1d34e8431c6103c924
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
diff --git a/.eslintignore b/.eslintignore
index f045b01..1ebc0f5 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -4,7 +4,7 @@
# The below mentioned json files and directories are purposefully
# made invalid in order to execute the unit tests, thus thse are
# required to be ignored by the json validator.
-/host-bmc/test/host_effecter_jsons/malformed/*
-/host-bmc/test/host_effecter_jsons/no_json/*
+/platform-mc/test/host_effecter_jsons/malformed/*
+/platform-mc/test/host_effecter_jsons/no_json/*
/libpldmresponder/test/pdr_jsons/state_effecter/malformed/*
/libpldmresponder/test/pdr_jsons/state_sensor/malformed/*
diff --git a/.linter-ignore b/.linter-ignore
index 5792d57..bcb64e6 100644
--- a/.linter-ignore
+++ b/.linter-ignore
@@ -1,4 +1,4 @@
-host-bmc/test/host_effecter_jsons/malformed/dbus_to_terminus_effecter.json
-host-bmc/test/host_effecter_jsons/no_json/dummy.json
+platform-mc/test/host_effecter_jsons/malformed/dbus_to_terminus_effecter.json
+platform-mc/test/host_effecter_jsons/no_json/dummy.json
libpldmresponder/test/pdr_jsons/state_effecter/malformed/effecter_pdr.json
libpldmresponder/test/pdr_jsons/state_sensor/malformed/sensor_pdr.json
diff --git a/host-bmc/test/meson.build b/host-bmc/test/meson.build
index 4ae286d..48e0b63 100644
--- a/host-bmc/test/meson.build
+++ b/host-bmc/test/meson.build
@@ -1,8 +1,3 @@
-host_bmc_test_src = declare_dependency(
- sources: ['../dbus_to_terminus_effecters.cpp'],
- include_directories: '../../requester',
-)
-
test_sources = [
'../../common/utils.cpp',
'../utils.cpp',
@@ -17,7 +12,7 @@
'../dbus/pcie_slot.cpp',
]
-tests = ['dbus_to_terminus_effecter_test', 'utils_test', 'custom_dbus_test']
+tests = ['utils_test', 'custom_dbus_test']
foreach t : tests
test(
@@ -30,7 +25,6 @@
dependencies: [
gtest,
gmock,
- host_bmc_test_src,
libpldm_dep,
libpldmutils,
nlohmann_json_dep,
diff --git a/libpldmresponder/meson.build b/libpldmresponder/meson.build
index 14c8bb0..acbb400 100644
--- a/libpldmresponder/meson.build
+++ b/libpldmresponder/meson.build
@@ -26,7 +26,6 @@
'../host-bmc/host_pdr_handler.cpp',
'../host-bmc/utils.cpp',
'../host-bmc/dbus_to_event_handler.cpp',
- '../host-bmc/dbus_to_terminus_effecters.cpp',
'../host-bmc/host_condition.cpp',
'../host-bmc/dbus/asset.cpp',
'../host-bmc/dbus/availability.cpp',
diff --git a/meson.build b/meson.build
index 66286f6..aff9ca1 100644
--- a/meson.build
+++ b/meson.build
@@ -256,6 +256,7 @@
'platform-mc/sensor_manager.cpp',
'platform-mc/numeric_sensor.cpp',
'platform-mc/event_manager.cpp',
+ 'platform-mc/dbus_to_terminus_effecters.cpp',
oem_files,
'requester/mctp_endpoint_discovery.cpp',
implicit_include_directories: false,
diff --git a/host-bmc/dbus_to_terminus_effecters.cpp b/platform-mc/dbus_to_terminus_effecters.cpp
similarity index 100%
rename from host-bmc/dbus_to_terminus_effecters.cpp
rename to platform-mc/dbus_to_terminus_effecters.cpp
diff --git a/host-bmc/dbus_to_terminus_effecters.hpp b/platform-mc/dbus_to_terminus_effecters.hpp
similarity index 100%
rename from host-bmc/dbus_to_terminus_effecters.hpp
rename to platform-mc/dbus_to_terminus_effecters.hpp
diff --git a/host-bmc/test/dbus_to_terminus_effecter_test.cpp b/platform-mc/test/dbus_to_terminus_effecter_test.cpp
similarity index 98%
rename from host-bmc/test/dbus_to_terminus_effecter_test.cpp
rename to platform-mc/test/dbus_to_terminus_effecter_test.cpp
index 6b02074..e6fcd43 100644
--- a/host-bmc/test/dbus_to_terminus_effecter_test.cpp
+++ b/platform-mc/test/dbus_to_terminus_effecter_test.cpp
@@ -1,6 +1,6 @@
#include "common/test/mocked_utils.hpp"
#include "common/utils.hpp"
-#include "host-bmc/dbus_to_terminus_effecters.hpp"
+#include "platform-mc/dbus_to_terminus_effecters.hpp"
#include <nlohmann/json.hpp>
diff --git a/host-bmc/test/host_effecter_jsons/good/dbus_to_terminus_effecter.json b/platform-mc/test/host_effecter_jsons/good/dbus_to_terminus_effecter.json
similarity index 100%
rename from host-bmc/test/host_effecter_jsons/good/dbus_to_terminus_effecter.json
rename to platform-mc/test/host_effecter_jsons/good/dbus_to_terminus_effecter.json
diff --git a/host-bmc/test/host_effecter_jsons/malformed/dbus_to_terminus_effecter.json b/platform-mc/test/host_effecter_jsons/malformed/dbus_to_terminus_effecter.json
similarity index 100%
rename from host-bmc/test/host_effecter_jsons/malformed/dbus_to_terminus_effecter.json
rename to platform-mc/test/host_effecter_jsons/malformed/dbus_to_terminus_effecter.json
diff --git a/host-bmc/test/host_effecter_jsons/no_json/dummy.json b/platform-mc/test/host_effecter_jsons/no_json/dummy.json
similarity index 100%
rename from host-bmc/test/host_effecter_jsons/no_json/dummy.json
rename to platform-mc/test/host_effecter_jsons/no_json/dummy.json
diff --git a/platform-mc/test/meson.build b/platform-mc/test/meson.build
index e8ea6b7..2d722e9 100644
--- a/platform-mc/test/meson.build
+++ b/platform-mc/test/meson.build
@@ -8,6 +8,7 @@
'../sensor_manager.cpp',
'../numeric_sensor.cpp',
'../event_manager.cpp',
+ '../dbus_to_terminus_effecters.cpp',
'../../requester/mctp_endpoint_discovery.cpp',
],
include_directories: ['../../requester', '../../pldmd'],
@@ -20,6 +21,7 @@
'sensor_manager_test',
'numeric_sensor_test',
'event_manager_test',
+ 'dbus_to_terminus_effecter_test',
]
foreach t : tests
diff --git a/pldmd/pldmd.cpp b/pldmd/pldmd.cpp
index 7a62584..bbee013 100644
--- a/pldmd/pldmd.cpp
+++ b/pldmd/pldmd.cpp
@@ -6,6 +6,7 @@
#include "dbus_impl_requester.hpp"
#include "fw-update/manager.hpp"
#include "invoker.hpp"
+#include "platform-mc/dbus_to_terminus_effecters.hpp"
#include "platform-mc/manager.hpp"
#include "requester/handler.hpp"
#include "requester/mctp_endpoint_discovery.hpp"
@@ -48,7 +49,6 @@
#ifdef LIBPLDMRESPONDER
#include "dbus_impl_pdr.hpp"
#include "host-bmc/dbus_to_event_handler.hpp"
-#include "host-bmc/dbus_to_terminus_effecters.hpp"
#include "host-bmc/host_condition.hpp"
#include "host-bmc/host_pdr_handler.hpp"
#include "libpldmresponder/base.hpp"