Skip to content

Commit df28d42

Browse files
authored
Fix build issues with cellular (#397)
* Cellular: Add back weak CellularInterface::get_default_instance The enables the cellular call flow below: 1. Weak CellularInterface::get_default_instance (NetworkInterfaceDefaults.cpp) 2. Weak CellularInterface::get_target_default_instance (NetworkInterfaceDefaults.cpp) 3. Weak CellularContext::get_default_instance (CellularContext.cpp) 4. Weak CellularDevice::get_default_instance (CellularDevice.cpp) 5. Weak CellularDevice::get_target_default_instance (CellularDevice.cpp) So that cellular modem driver can override CellularDevice::get_default_instance or CellularDevice::get_target_default_instance to provide actual default instance. * Cellular: Fix overriding CellularDevice::get_default_instance failure With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in the object file implemening CellularDevice::get_default_instance anyway for being able to override weak symbol successfully even though from static library. See: https://stackoverflow.com/questions/42588983/what-does-the-gnu-ld-undefined-option-do * Cellular: Fix ThisThread::sleep_until link error ATHandler::cmd_start (ATHandler.c) calls ThisThread::sleep_until, which has parameter abs_time, whose type is Clock::time_point. Clock::time_point type has different definitions dependent on MBED_CONF_RTOS_PRESENT defined or not (rtos/Kernel.h). For cellular application whose executable cmake target always links mbed-os rather than mbed-baremetal, mbed-cellular must also link mbed-rtos-flags to be consistent with executable, so that both have MBED_CONF_RTOS_PRESENT defined.
1 parent 2564b2c commit df28d42

File tree

20 files changed

+246
-4
lines changed

20 files changed

+246
-4
lines changed

connectivity/cellular/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ target_link_libraries(mbed-cellular
3939
PUBLIC
4040
mbed-netsocket-api
4141
mbed-core-flags
42+
mbed-rtos-flags
4243
mbed-randlib
4344
)

connectivity/drivers/cellular/Altair/COMPONENT_ALTAIR_ALT1250/PPP/ALT1250_PPP.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,19 @@ CellularDevice *CellularDevice::get_default_instance()
118118
static ALT1250_PPP device(&serial, MBED_CONF_ALT1250_PPP_RST, PIN_OUTPUT, OpenDrainNoPull, 1);
119119
return &device;
120120
}
121+
122+
/*
123+
* With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in this
124+
* object file anyway for being able to override weak symbol successfully
125+
* even though from static library. See:
126+
* https://stackoverflow.com/questions/42588983/what-does-the-gnu-ld-undefined-option-do
127+
*
128+
* NOTE: For C++ name mangling, 'extern "C"' is necessary to match the
129+
* <LINK_FOO> symbol correctly.
130+
*/
131+
extern "C"
132+
void LINK_ALT1250_PPP_CPP(void)
133+
{
134+
}
121135
#endif
122136

connectivity/drivers/cellular/Altair/COMPONENT_ALTAIR_ALT1250/PPP/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,15 @@ target_sources(mbed-cellular
1212
ALT1250_PPP_CellularContext.cpp
1313
ALT1250_PPP_CellularNetwork.cpp
1414
)
15+
16+
# Link override object file coming from static library anyway
17+
#
18+
# NOTE: This linker option is to pretend undefined symbol and won't cause
19+
# undefined symbol error even though the override object file actually
20+
# doesn't provide such symbol definition.
21+
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
22+
target_link_options(mbed-cellular
23+
INTERFACE
24+
LINKER:--undefined=LINK_ALT1250_PPP_CPP
25+
)
26+
endif()

connectivity/drivers/cellular/COMPONENT_STMOD_CELLULAR/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,15 @@ target_sources(mbed-cellular
1010
PRIVATE
1111
STModCellular.cpp
1212
)
13+
14+
# Link override object file coming from static library anyway
15+
#
16+
# NOTE: This linker option is to pretend undefined symbol and won't cause
17+
# undefined symbol error even though the override object file actually
18+
# doesn't provide such symbol definition.
19+
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
20+
target_link_options(mbed-cellular
21+
INTERFACE
22+
LINKER:--undefined=LINK_STMODCELLULAR_CPP
23+
)
24+
endif()

connectivity/drivers/cellular/COMPONENT_STMOD_CELLULAR/STModCellular.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,19 @@ CellularDevice *CellularDevice::get_default_instance()
179179
static STModCellular device(&serial);
180180
return &device;
181181
}
182+
183+
/*
184+
* With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in this
185+
* object file anyway for being able to override weak symbol successfully
186+
* even though from static library. See:
187+
* https://stackoverflow.com/questions/42588983/what-does-the-gnu-ld-undefined-option-do
188+
*
189+
* NOTE: For C++ name mangling, 'extern "C"' is necessary to match the
190+
* <LINK_FOO> symbol correctly.
191+
*/
192+
extern "C"
193+
void LINK_STMODCELLULAR_CPP(void)
194+
{
195+
}
182196
#endif
183197

connectivity/drivers/cellular/GEMALTO/COMPONENT_GEMALTO_CINTERION/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,15 @@ target_sources(mbed-cellular
1313
GEMALTO_CINTERION_CellularInformation.cpp
1414
GEMALTO_CINTERION_CellularStack.cpp
1515
)
16+
17+
# Link override object file coming from static library anyway
18+
#
19+
# NOTE: This linker option is to pretend undefined symbol and won't cause
20+
# undefined symbol error even though the override object file actually
21+
# doesn't provide such symbol definition.
22+
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
23+
target_link_options(mbed-cellular
24+
INTERFACE
25+
LINKER:--undefined=LINK_GEMALTO_CINTERION_CPP
26+
)
27+
endif()

connectivity/drivers/cellular/GEMALTO/COMPONENT_GEMALTO_CINTERION/GEMALTO_CINTERION.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,18 @@ CellularDevice *CellularDevice::get_default_instance()
214214
static GEMALTO_CINTERION device(&serial);
215215
return &device;
216216
}
217+
218+
/*
219+
* With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in this
220+
* object file anyway for being able to override weak symbol successfully
221+
* even though from static library. See:
222+
* https://stackoverflow.com/questions/42588983/what-does-the-gnu-ld-undefined-option-do
223+
*
224+
* NOTE: For C++ name mangling, 'extern "C"' is necessary to match the
225+
* <LINK_FOO> symbol correctly.
226+
*/
227+
extern "C"
228+
void LINK_GEMALTO_CINTERION_CPP(void)
229+
{
230+
}
217231
#endif

connectivity/drivers/cellular/GENERIC/COMPONENT_GENERIC_AT3GPP/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,15 @@ target_sources(mbed-cellular
1010
PRIVATE
1111
GENERIC_AT3GPP.cpp
1212
)
13+
14+
# Link override object file coming from static library anyway
15+
#
16+
# NOTE: This linker option is to pretend undefined symbol and won't cause
17+
# undefined symbol error even though the override object file actually
18+
# doesn't provide such symbol definition.
19+
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
20+
target_link_options(mbed-cellular
21+
INTERFACE
22+
LINKER:--undefined=LINK_GENERIC_AT3GPP_CPP
23+
)
24+
endif()

connectivity/drivers/cellular/GENERIC/COMPONENT_GENERIC_AT3GPP/GENERIC_AT3GPP.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,18 @@ CellularDevice *CellularDevice::get_default_instance()
6161
static GENERIC_AT3GPP device(&serial);
6262
return &device;
6363
}
64+
65+
/*
66+
* With e.g. GCC linker option "--undefined=<LINK_FOO>", pull in this
67+
* object file anyway for being able to override weak symbol successfully
68+
* even though from static library. See:
69+
* https://stackoverflow.com/questions/42588983/what-does-the-gnu-ld-undefined-option-do
70+
*
71+
* NOTE: For C++ name mangling, 'extern "C"' is necessary to match the
72+
* <LINK_FOO> symbol correctly.
73+
*/
74+
extern "C"
75+
void LINK_GENERIC_AT3GPP_CPP(void)
76+
{
77+
}
6478
#endif

connectivity/drivers/cellular/MultiTech/DragonflyNano/COMPONENT_MULTITECH_DRAGONFLY_NANO_CELLULAR/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,16 @@ target_sources(mbed-cellular
1414

1515
if("MTS_DRAGONFLY_L471QG" IN_LIST MBED_TARGET_LABELS)
1616
add_subdirectory(TARGET_MTS_DRAGONFLY_L471QG)
17-
endif()
17+
endif()
18+
19+
# Link override object file coming from static library anyway
20+
#
21+
# NOTE: This linker option is to pretend undefined symbol and won't cause
22+
# undefined symbol error even though the override object file actually
23+
# doesn't provide such symbol definition.
24+
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
25+
target_link_options(mbed-cellular
26+
INTERFACE
27+
LINKER:--undefined=LINK_SARA4_PPP_CPP
28+
)
29+
endif()

0 commit comments

Comments
 (0)