-
Notifications
You must be signed in to change notification settings - Fork 3k
CMake: GCC ARM toolchain script specifies the wrong target variable for linker script and map file paths #13983
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
Comments
Thank you for raising this detailed GitHub issue. I am now notifying our internal issue triagers. |
I can confirm the issue. I tried changing Have you had any success? |
Thanks for the report, we will triage this.
What does this mean, using the argument does not work - the path is wrong, it fails or ? |
@0xc0170 with the following patch on diff --git a/tools/cmake/toolchains/GCC_ARM.cmake b/tools/cmake/toolchains/GCC_ARM.cmake
index 9b9fa2062f..63a5eef3e7 100644
--- a/tools/cmake/toolchains/GCC_ARM.cmake
+++ b/tools/cmake/toolchains/GCC_ARM.cmake
@@ -19,8 +19,8 @@ function(mbed_set_toolchain_options target)
"-lnosys"
"-Wl,--end-group"
"-specs=nosys.specs"
- "-T" "${CMAKE_BINARY_DIR}/${APP_TARGET}.link_script.ld"
- "-Wl,-Map=${CMAKE_BINARY_DIR}/${APP_TARGET}.map"
+ "-T" "${CMAKE_BINARY_DIR}/${target}.link_script.ld"
+ "-Wl,-Map=${CMAKE_BINARY_DIR}/${target}.map"
"-Wl,--cref"
) and the following on diff --git a/CMakeLists.txt b/CMakeLists.txt
index 917b959..f127905 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,31 +5,31 @@ cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)
set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/mbed-os CACHE INTERNAL "")
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.mbedbuild CACHE INTERNAL "")
-set(APP_TARGET mbed-os-example-blinky)
+# set(APP_TARGET mbed-os-example-blinky)
include(${MBED_PATH}/tools/cmake/app.cmake)
add_subdirectory(${MBED_PATH})
-add_executable(${APP_TARGET})
+add_executable(mbed-os-example-blinky)
-mbed_configure_app_target(${APP_TARGET})
+mbed_configure_app_target(mbed-os-example-blinky)
-mbed_set_mbed_target_linker_script(${APP_TARGET})
+mbed_set_mbed_target_linker_script(mbed-os-example-blinky)
-project(${APP_TARGET})
+project(mbed-os-example-blinky)
-target_sources(${APP_TARGET}
+target_sources(mbed-os-example-blinky
PRIVATE
main.cpp
)
-target_link_libraries(${APP_TARGET}
+target_link_libraries(mbed-os-example-blinky
PRIVATE
mbed-os
)
-mbed_set_post_build(${APP_TARGET})
+mbed_set_post_build(mbed-os-example-blinky) I get: [245/245] Linking CXX executable mbed-os-example-blinky
FAILED: mbed-os-example-blinky mbed-os-example-blinky.link_script.ld
cd /Users/ladislas/dev/tmp/mbed-os-example-blinky && arm-none-eabi-cpp @/Users/ladislas/dev/tmp/mbed-os-example-blinky/cmake_build/compile_time_defs.txt -x assembler-with-cpp -E -Wp,-P /Users/ladislas/dev/tmp/mbed-os-example-blinky/mbed-os/targets/TARGET_STM/TARGET_STM32F7/TARGET_STM32F769xI/TOOLCHAIN_GCC_ARM/STM32F769xI.ld -o /Users/ladislas/dev/tmp/mbed-os-example-blinky/cmake_build/mbed-os-example-blinky.link_script.ld && cd /Users/ladislas/dev/tmp/mbed-os-example-blinky/cmake_build && /usr/local/bin/arm-none-eabi-g++ -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=softfp -mcpu=cortex-m7 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -fmessage-length=0 -fno-exceptions -ffunction-sections -fdata-sections -funsigned-char -MMD -fomit-frame-pointer -g3 -Wl,--start-group -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys -Wl,--end-group -specs=nosys.specs -T /Users/ladislas/dev/tmp/mbed-os-example-blinky/cmake_build/mbed-core.link_script.ld -Wl,-Map=/Users/ladislas/dev/tmp/mbed-os-example-blinky/cmake_build/mbed-core.map -Wl,--cref -Wl,--gc-sections -Wl,--wrap,main -Wl,--wrap,_malloc_r -Wl,--wrap,_free_r -Wl,--wrap,_realloc_r -Wl,--wrap,_memalign_r -Wl,--wrap,_calloc_r -Wl,--wrap,exit -Wl,--wrap,atexit -Wl,-n -Wl,--wrap,printf -Wl,--wrap,sprintf -Wl,--wrap,snprintf -Wl,--wrap,vprintf -Wl,--wrap,vsprintf -Wl,--wrap,vsnprintf -Wl,--wrap,fprintf -Wl,--wrap,vfprintf @CMakeFiles/mbed-os-example-blinky.rsp -o mbed-os-example-blinky && cd /Users/ladislas/dev/tmp/mbed-os-example-blinky/cmake_build && arm-none-eabi-objcopy -O binary /Users/ladislas/dev/tmp/mbed-os-example-blinky/cmake_build/mbed-os-example-blinky /Users/ladislas/dev/tmp/mbed-os-example-blinky/cmake_build/mbed-os-example-blinky.bin && /usr/local/Cellar/cmake/3.19.1/bin/cmake -E echo "-- built: /Users/ladislas/dev/tmp/mbed-os-example-blinky/cmake_build/mbed-os-example-blinky.bin" && arm-none-eabi-objcopy -O ihex /Users/ladislas/dev/tmp/mbed-os-example-blinky/cmake_build/mbed-os-example-blinky /Users/ladislas/dev/tmp/mbed-os-example-blinky/cmake_build/mbed-os-example-blinky.hex && /usr/local/Cellar/cmake/3.19.1/bin/cmake -E echo "-- built: /Users/ladislas/dev/tmp/mbed-os-example-blinky/cmake_build/mbed-os-example-blinky.hex" && cd /Users/ladislas/dev/tmp/mbed-os-example-blinky/cmake_build && /usr/local/Frameworks/Python.framework/Versions/3.9/bin/python3.9 /Users/ladislas/dev/tmp/mbed-os-example-blinky/mbed-os/tools/memap.py -t GCC_ARM /Users/ladislas/dev/tmp/mbed-os-example-blinky/cmake_build/mbed-os-example-blinky.map
/usr/local/Cellar/arm-gcc-bin/9-2020-q2-update/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld: cannot open linker script file /Users/ladislas/dev/tmp/mbed-os-example-blinky/cmake_build/mbed-core.link_script.ld: No such file or directory
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
ERROR: CMake invocation failed! |
I could reproduce, thanks. We will fix. |
Fixes ARMmbed#13983 Move linker script to the function mbed_set_mbed_target_linker_script. I also moved memmap as it is needed for an app. The location might not be the best fit, we will address this in separate pull request.
Fix proposed #13985 |
Sorry, should have made that statement more clear! I attempted to make a project where Thanks for proposing a fix so quick! |
Description of defect
The CMake toolchain function
mbed_set_toolchain_options()
intools/cmake/toolchains/GCC_ARM.cmake
construct the linker script and map file paths using the variable${APP_TARGET}
instead of the function argument${target}
. This can cause improper files outputs ifAPP_TARGET
is not defined.https://github.com/ARMmbed/mbed-os/blob/master/tools/cmake/toolchains/GCC_ARM.cmake#L22
Target(s) affected by this defect ?
all
Toolchain(s) (name and version) displaying this defect ?
GCC ARM
What version of Mbed-os are you using (tag or sha) ?
33a7e66
What version(s) of tools are you using. List all that apply (E.g. mbed-cli)
mbed-tools, 4ed041a416e6b8a08eb22ffdfdd2bb111c2f2c84
How is this defect reproduced ?
NA
The text was updated successfully, but these errors were encountered: