-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Move chip::Logging::LogV to platform-specific implementation #4741
Move chip::Logging::LogV to platform-specific implementation #4741
Conversation
- Removed mutually exclusive `#defines` - Removed STDIO_WITH_TIMESTAMPS since it is never set/used
…tent). Android remains
This exacerbates a dependency cycle. Logging is needed throughout the codebase. "platform" depends on and uses much of CHIP. I think we need to take a step back and consider how we want ports to work and what's more important - having a semblance of layering, or of reducing the number of places ports need to add their code. I value the layering as it simplifies how much code we need to think about and can test independent parts, but if we want to have a single place that ports add code, it's probably not possible to have much layering. This PR basically implies that all portable code depends on all platform specific code, and vice versa, in a big knot. |
Concrete example - Should an executable that just does If yes, this PR is OK. If no, we need to take another route. |
Agree this is still a mess. I will try to figure it out a bit more. What bothers me is that there are two places where logs are configured: support and platform. On top of this, the support version is filled with I am thinking to have 'platform::logging' independent from the rest. |
platform code is somewhat split today. We have platform code in support, inet, lwip, etc. The premise that all platform code goes in platform/ is currently false; src/platform is this specific "device layer" component not the location of all of the platform specific code. Agree that ifdefs are problematic, external porters can't add ifdefs without forking the code. We need to fix that, and doing something like pigweed's pw_log would make sense here. |
…one, add dependencies for some sample applications
I also feel uneasy about having several platform-specific directories. I could push the logging code back into the platforms themselves. The current state of the code was me going through several refactoring phases. Would that work better? I.e. I have changed the code to things like : Thoughts? @mspang @srickardti |
…ll look into moving platform-specific logging back one by one
@mspang @srickardti - I moved logging back into the platform directories. I kept android and stdio as standalone. |
We've gone full circle now; the cycle I mentioned earlier in the review process is back. Single platform target and acyclic structure are contradictory outcomes given the premises that everything depends on logging and other parts of the "platform" layer depend on a decent chunk of CHIP. That's why I asked for more input - something has to give, we cannot achieve all of the desired outcomes. In my hello world example (#4741 (comment)), we now have that logging necessarily brings in CHIP protocol again. I think it's a shame but if we think that putting all the platform code in one library is more useful, I can accept it. |
public_deps = [] | ||
} | ||
|
||
public_deps += [ "${chip_root}/src/platform/logging:stdio" ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is highly surprising, why? Can you at least at a TODO to move this dependency out of the test suite template?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without it I get
...
.../lib/libnlunit-test.a -ldl -lpthread -lrt -Wl,--end-group -o linux_x64_clang/tests/TestInetEndPoint
ld.lld: error: undefined symbol: chip::Logging::Platform::LogV(char const*, unsigned char, char const*, __va_list_tag*)
>>> referenced by CHIPLogging.cpp:137 (../../src/lib/support/logging/CHIPLogging.cpp:137)
>>> libSupportLayer.CHIPLogging.cpp.o:(chip::Logging::LogV(unsigned char, unsigned char, char const*, __va_list_tag*)) in archive linux_x64_clang/obj/src/lib/support/lib/libSupportLayer.a
I believe the unit test for system may have a customized event loop (not pulling in the device layer) but are lacking a vlog implementation. Previous versions seem to have some hardcoded __attribute__((weak))
vlog implementations, but that seemed really hacky so I killed them.
A future pass should add the logging binding only for the tests that need it. Then again, do any tests without logging make sense? I think we need to follow up and figure if there is a split between tests without a platform layer vs tests with one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you're seeing here is that the way you've avoided the cycle is to remove a dependency that's needed to link (It's not needed to compile.)
Re-adding the dependency at the test suite level fixes the link error, but it is not the right solution from my perspective - target should list all of their link-time dependencies generally speaking. This is what I meant by resolving cycles in a way that allows unit tests to link without additional dependencies - here, stdio is such an "additional dependency".
figure out a way to auto-define dependency on stdio logging.connectedhomeip/build/chip/chip_test_suite.gni Lines 92 to 102 in 8b5882c
This comment was generated by todo based on a
|
Size increase report for "nrfconnect-example-build" from 589eb1b
Full report output
|
Size increase report for "esp32-example-build" from 589eb1b
Full report output
|
Problem
Logging is defined in both libSupport and platform, with many defines configuring where support goes.
Logging in general is platform-dependent.
Summary of Changes