Skip to content

Commit ce093f1

Browse files
author
Jamie Smith
authored
Don't use whole-archive linking (#71)
* First attempt at converting to OBJECT libraries. Not working due to more object library limitations * Only compile the main libraries as OBJECT, because that's all that CMake can be made to do right now. * Fix availability of target-specific flags * Missed some usages * Fix some STM32 ethernet stuff that was not linking correctly * More fixes for STM32 ethernet and weak symbols * Fix prebuilt object file linking for MUSCA_S1 * Fix STM32 eth init license headers
1 parent b90b13b commit ce093f1

File tree

29 files changed

+339
-171
lines changed

29 files changed

+339
-171
lines changed

CMakeLists.txt

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -264,23 +264,20 @@ add_subdirectory(cmsis/device/rtos EXCLUDE_FROM_ALL)
264264
# Create top-level targets ----------------------------------------------------------------------------------
265265

266266
if(NOT MBED_IS_NATIVE_BUILD)
267-
268-
# Create a distro for the microcontroller cmake target, ensuring its sources are only compiled once
269-
mbed_create_distro(${MBED_TARGET_CMAKE_NAME}-lib ${MBED_TARGET_CMAKE_NAME} mbed-core-flags)
270-
271-
# Set up the linker script and hook it up to the MCU cmake target
272-
mbed_setup_linker_script(${MBED_TARGET_CMAKE_NAME}-lib)
273-
274-
# Now make the Mbed OS code depend on the target, ensuring everything has access to the uC's flags and objects.
275-
target_link_libraries(mbed-core-flags INTERFACE ${MBED_TARGET_CMAKE_NAME}-lib)
276-
277267
# Core Mbed OS libraries
278268
# mbed-baremetal contains baremetal sources + target sources + target compile flags.
279269
# mbed-os will be a superset of mbed-baremetal, also containing the RTOS sources and RTOS flags.
280270
# Note that many different source files will compile differently depending on if the RTOS is in use.
281271
# So, it's needed to compile the core sources twice, once for RTOS and once for non-RTOS.
282-
mbed_create_distro(mbed-baremetal mbed-core-flags mbed-core-sources)
283-
mbed_create_distro(mbed-os mbed-core-flags mbed-core-sources mbed-rtos-flags mbed-rtos-sources)
272+
mbed_create_distro(mbed-baremetal ${MBED_TARGET_CMAKE_NAME} mbed-core-flags mbed-core-sources)
273+
mbed_create_distro(mbed-os ${MBED_TARGET_CMAKE_NAME} mbed-core-flags mbed-core-sources mbed-rtos-flags mbed-rtos-sources)
274+
275+
# Set up the linker script and hook it up to the top-level OS targets
276+
mbed_setup_linker_script(mbed-baremetal mbed-os)
277+
278+
# Make sure that things linking mbed-core-flags can also get the target-specific include dirs and flags.
279+
mbed_extract_flags(${MBED_TARGET_CMAKE_NAME}-flags ${MBED_TARGET_CMAKE_NAME})
280+
target_link_libraries(mbed-core-flags INTERFACE ${MBED_TARGET_CMAKE_NAME}-flags)
284281
endif()
285282

286283
# Ninja requires to be forced for response files

connectivity/drivers/emac/TARGET_STM/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ target_include_directories(mbed-emac
1919
target_sources(mbed-emac
2020
PRIVATE
2121
stm32xx_emac.cpp
22-
stm32xx_eth_irq_callback.cpp
2322
)

connectivity/drivers/emac/TARGET_STM/TARGET_STM32F2/TARGET_NUCLEO_F207ZG/stm32f2_eth_init.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* mbed Microcontroller Library
2-
* Copyright (c) 2018, STMicroelectronics
2+
* Copyright (c) 2022, STMicroelectronics
33
* All rights reserved.
44
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*
57
* Redistribution and use in source and binary forms, with or without
68
* modification, are permitted provided that the following conditions are met:
79
*
@@ -117,3 +119,7 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth)
117119
}
118120

119121
#endif /* USE_USER_DEFINED_HAL_ETH_MSPINIT */
122+
123+
// Blank, non-weak-override function to make sure the linker pulls in this file
124+
void stm32_eth_init_weak_symbol_helper()
125+
{}

connectivity/drivers/emac/TARGET_STM/TARGET_STM32F4/TARGET_ARCH_MAX/stm32f4_eth_init.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2022, STMicroelectronics
3+
* All rights reserved.
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice,
11+
* this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
* 3. Neither the name of STMicroelectronics nor the names of its contributors
16+
* may be used to endorse or promote products derived from this software
17+
* without specific prior written permission.
18+
*
19+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
131
#include "stm32f4xx_hal.h"
232

333
/**
@@ -79,3 +109,7 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth)
79109
NVIC_DisableIRQ(ETH_IRQn);
80110
}
81111
}
112+
113+
// Blank, non-weak-override function to make sure the linker pulls in this file
114+
void stm32_eth_init_weak_symbol_helper()
115+
{}

connectivity/drivers/emac/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F429ZI/stm32f4_eth_init.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* mbed Microcontroller Library
2-
* Copyright (c) 2018, STMicroelectronics
2+
* Copyright (c) 2022, STMicroelectronics
33
* All rights reserved.
44
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*
57
* Redistribution and use in source and binary forms, with or without
68
* modification, are permitted provided that the following conditions are met:
79
*
@@ -117,3 +119,7 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth)
117119
}
118120

119121
#endif /* USE_USER_DEFINED_HAL_ETH_MSPINIT */
122+
123+
// Blank, non-weak-override function to make sure the linker pulls in this file
124+
void stm32_eth_init_weak_symbol_helper()
125+
{}

connectivity/drivers/emac/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F439ZI/stm32f4_eth_init.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* mbed Microcontroller Library
2-
* Copyright (c) 2018, STMicroelectronics
2+
* Copyright (c) 2022, STMicroelectronics
33
* All rights reserved.
44
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*
57
* Redistribution and use in source and binary forms, with or without
68
* modification, are permitted provided that the following conditions are met:
79
*
@@ -117,3 +119,7 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth)
117119
}
118120

119121
#endif /* USE_USER_DEFINED_HAL_ETH_MSPINIT */
122+
123+
// Blank, non-weak-override function to make sure the linker pulls in this file
124+
void stm32_eth_init_weak_symbol_helper()
125+
{}

connectivity/drivers/emac/TARGET_STM/TARGET_STM32F7/TARGET_DISCO_F746NG/stm32f7_eth_init.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* mbed Microcontroller Library
2-
* Copyright (c) 2018, STMicroelectronics
2+
* Copyright (c) 2022, STMicroelectronics
33
* All rights reserved.
44
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*
57
* Redistribution and use in source and binary forms, with or without
68
* modification, are permitted provided that the following conditions are met:
79
*
@@ -116,3 +118,7 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth)
116118
}
117119

118120
#endif /* USE_USER_DEFINED_HAL_ETH_MSPINIT */
121+
122+
// Blank, non-weak-override function to make sure the linker pulls in this file
123+
void stm32_eth_init_weak_symbol_helper()
124+
{}

connectivity/drivers/emac/TARGET_STM/TARGET_STM32F7/TARGET_DISCO_F769NI/stm32f7_eth_init.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* mbed Microcontroller Library
2-
* Copyright (c) 2018, STMicroelectronics
2+
* Copyright (c) 2022, STMicroelectronics
33
* All rights reserved.
44
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*
57
* Redistribution and use in source and binary forms, with or without
68
* modification, are permitted provided that the following conditions are met:
79
*
@@ -122,3 +124,7 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth)
122124
}
123125

124126
#endif /* USE_USER_DEFINED_HAL_ETH_MSPINIT */
127+
128+
// Blank, non-weak-override function to make sure the linker pulls in this file
129+
void stm32_eth_init_weak_symbol_helper()
130+
{}

connectivity/drivers/emac/TARGET_STM/TARGET_STM32F7/TARGET_NUCLEO_F746ZG/stm32f7_eth_init.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* mbed Microcontroller Library
2-
* Copyright (c) 2018, STMicroelectronics
2+
* Copyright (c) 2022, STMicroelectronics
33
* All rights reserved.
44
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*
57
* Redistribution and use in source and binary forms, with or without
68
* modification, are permitted provided that the following conditions are met:
79
*
@@ -122,3 +124,7 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth)
122124
}
123125

124126
#endif /* USE_USER_DEFINED_HAL_ETH_MSPINIT */
127+
128+
// Blank, non-weak-override function to make sure the linker pulls in this file
129+
void stm32_eth_init_weak_symbol_helper()
130+
{}

connectivity/drivers/emac/TARGET_STM/TARGET_STM32F7/TARGET_NUCLEO_F756ZG/stm32f7_eth_init.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* mbed Microcontroller Library
2-
* Copyright (c) 2018, STMicroelectronics
2+
* Copyright (c) 2022, STMicroelectronics
33
* All rights reserved.
44
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*
57
* Redistribution and use in source and binary forms, with or without
68
* modification, are permitted provided that the following conditions are met:
79
*
@@ -122,3 +124,7 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth)
122124
}
123125

124126
#endif /* USE_USER_DEFINED_HAL_ETH_MSPINIT */
127+
128+
// Blank, non-weak-override function to make sure the linker pulls in this file
129+
void stm32_eth_init_weak_symbol_helper()
130+
{}

0 commit comments

Comments
 (0)