Skip to content
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

Fix wifi cannot configure as default network interface #377

Conversation

ccli8
Copy link

@ccli8 ccli8 commented Oct 24, 2024

Summary of changes

This fixes WiFi cannot configure as default network interface, e.g. "esp8266.provide-default": true. This configuration requires support for weak symbol override. Object files archived in static library don't always participate in linking, dependent on linker and link order. The steps below introduced in this PR pull in the override object file anyway even though it comes from static library:

  1. Add e.g. GCC linker option --undefined=<LINK_FOO>
  2. Add <LINK_FOO> function with extern "C" in override source file

See: https://stackoverflow.com/questions/42588983/what-does-the-gnu-ld-undefined-option-do

NOTE: This provides an alternative to #373 and would be more reasonable.


Pull request type

X[] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

@multiplemonomials
Copy link
Collaborator

multiplemonomials commented Oct 24, 2024

Oh wow this is a nice fix, very clean! Just one question, would you be able to implement this for the other wifi drivers (e.g. in COMPONENT_WHD/whd_mac/interface/whd_interface.cpp and TARGET_WICED/wiced_interface/default_wifi_interface.cpp)? Fine to just this one in this PR but we'd have to do the others in a subsequent PR.

This fixes WiFi doesn't get linked in when configued as default network
interface.
@ccli8
Copy link
Author

ccli8 commented Oct 25, 2024

OK, I would also add this fix to other wifi drivers in this PR.

This requires support for weak symbol override. Object files arcived in
static library don't always participate in linking, dependent on linker
and link order. The steps below pull in the override object file anyway
even though it comes from static library:

1. Add e.g. GCC linker option "--undefined=<LINK_FOO>"
2. Add <LINK_FOO> function with 'extern "C"' in override source file

See: https://stackoverflow.com/questions/42588983/what-does-the-gnu-ld-undefined-option-do
@ccli8 ccli8 force-pushed the support_wifi_override_symbol_pretend_undefined branch from b96ecd6 to aab8e20 Compare October 25, 2024 03:54
@ccli8
Copy link
Author

ccli8 commented Oct 25, 2024

Applied this fix to all wifi drivers under connectivity/drivers/wifi.

@multiplemonomials multiplemonomials merged commit 197e043 into mbed-ce:master Oct 25, 2024
52 checks passed
@ccli8 ccli8 deleted the support_wifi_override_symbol_pretend_undefined branch October 28, 2024 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants