]> granicus.if.org Git - esp-idf/commitdiff
esp32: Rename esp32.common.ld to esp32.project.ld to avoid build errors when downgrading
authorAngus Gratton <angus@espressif.com>
Wed, 13 Mar 2019 22:59:31 +0000 (09:59 +1100)
committerAngus Gratton <gus@projectgus.com>
Tue, 9 Apr 2019 00:20:33 +0000 (10:20 +1000)
Linker script generator produces build/esp32/esp32.common.ld from
components/esp32/ld/esp32.common.ld.in

This works fine until IDF is downgraded to V3.1 which uses components/esp32/ld/esp32.common.ld and
doesn't track build/esp32/esp32.common.ld at all.

At this point, the linker runs in the build/esp32 directory and "-T esp32.common.ld" picks up the
linker script generated .ld file, which causes mis-builds.

As reported on forums: https://esp32.com/viewtopic.php?f=13&t=9684&p=40105

components/esp32/CMakeLists.txt
components/esp32/Makefile.projbuild
components/esp32/component.mk
components/esp32/ld/esp32.ld
components/esp32/ld/esp32.project.ld.in [moved from components/esp32/ld/esp32.common.ld.in with 100% similarity]
docs/en/api-guides/linker-script-generation.rst
docs/zh_CN/api-guides/linker-script-generation.rst
tools/ci/test_build_system.sh
tools/ci/test_build_system_cmake.sh

index 4e9740a405dba6eb522ea8f22f67b2d0cf08297d..dbacc35a7d8e4a6681b19934569db27af29582e9 100644 (file)
@@ -72,21 +72,21 @@ else()
     target_linker_script(${COMPONENT_TARGET} "${CMAKE_CURRENT_BINARY_DIR}/esp32_out.ld")
 
     if(CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY)
-        # This has to be linked before esp32.common.ld
+        # This has to be linked before esp32.project.ld
         target_linker_script(${COMPONENT_TARGET} "ld/esp32.extram.bss.ld")
     endif()
 
     if(IDF_PROJECT_EXECUTABLE)
         # Process the template file through the linker script generation mechanism, and use the output for linking the
         # final binary
-        set(esp32_common_script "${CMAKE_CURRENT_BINARY_DIR}/esp32.common.ld")
-        set(esp32_common_template "${CMAKE_CURRENT_LIST_DIR}/ld/esp32.common.ld.in")
+        set(esp32_project_script "${CMAKE_CURRENT_BINARY_DIR}/esp32.project.ld")
+        set(esp32_project_template "${CMAKE_CURRENT_LIST_DIR}/ld/esp32.project.ld.in")
 
-        ldgen_process_template(${esp32_common_template} ${esp32_common_script})
+        ldgen_process_template(${esp32_project_template} ${esp32_project_script})
 
-        target_link_libraries(${COMPONENT_TARGET} "-T ${esp32_common_script}")
-        
-        set_property(TARGET ${IDF_PROJECT_EXECUTABLE} APPEND PROPERTY LINK_DEPENDS ${esp32_common_script})
+        target_link_libraries(${COMPONENT_TARGET} "-T ${esp32_project_script}")
+
+        set_property(TARGET ${IDF_PROJECT_EXECUTABLE} APPEND PROPERTY LINK_DEPENDS ${esp32_project_script})
     endif()
 
     target_linker_script(${COMPONENT_TARGET}
index 5f819ae8adf4cbd3829c87910aaba3e6a557e774..b99415538e9876bbcd9535f85bb7f0d453ad5153 100644 (file)
@@ -42,9 +42,9 @@ endif
 ifneq ("$(filter esp32,$(TEST_COMPONENTS_LIST))","")
 CPPFLAGS += -DESP_TIMER_DYNAMIC_OVERFLOW_VAL
 endif
-ESP32_LINKER_SCRIPT_TEMPLATE := $(COMPONENT_PATH)/ld/esp32.common.ld.in
+ESP32_LINKER_SCRIPT_TEMPLATE := $(COMPONENT_PATH)/ld/esp32.project.ld.in
 ESP32_LINKER_SCRIPT_OUTPUT_DIR := $(abspath $(BUILD_DIR_BASE)/esp32)
 
 # Target to generate linker script generator from fragments presented by each of
 # the components
-$(eval $(call ldgen_process_template, $(ESP32_LINKER_SCRIPT_TEMPLATE), $(ESP32_LINKER_SCRIPT_OUTPUT_DIR)/esp32.common.ld))
+$(eval $(call ldgen_process_template, $(ESP32_LINKER_SCRIPT_TEMPLATE), $(ESP32_LINKER_SCRIPT_OUTPUT_DIR)/esp32.project.ld))
index 54d4a2a5c537ed38da786e64c9b2939efc0fc7a5..21d8ce6bc307e35b3cc5bd43da9b0dcdbcaadec2 100644 (file)
@@ -9,14 +9,14 @@ LIBS += core rtc net80211 pp wpa smartconfig coexist wps wpa2 espnow phy mesh
 endif
 
 ifdef CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY  
-   # This linker script must come before esp32.common.ld
+   # This linker script must come before esp32.project.ld
    LINKER_SCRIPTS += esp32.extram.bss.ld
 endif
 
 #Linker scripts used to link the final application.
 #Warning: These linker scripts are only used when the normal app is compiled; the bootloader
 #specifies its own scripts.
-LINKER_SCRIPTS += $(COMPONENT_BUILD_DIR)/esp32.common.ld esp32.rom.ld esp32.peripherals.ld
+LINKER_SCRIPTS += $(COMPONENT_BUILD_DIR)/esp32.project.ld esp32.rom.ld esp32.peripherals.ld
 
 #Force pure functions from libgcc.a to be linked from ROM
 LINKER_SCRIPTS += esp32.rom.libgcc.ld
@@ -55,8 +55,8 @@ COMPONENT_SUBMODULES += lib
 # final linking of project ELF depends on all binary libraries, and
 # all linker scripts (except esp32_out.ld, as this is code generated here.)
 COMPONENT_ADD_LINKER_DEPS := $(ALL_LIB_FILES) \
-                            $(addprefix ld/, $(filter-out $(COMPONENT_BUILD_DIR)/esp32.common.ld, $(LINKER_SCRIPTS))) \
-                            $(COMPONENT_BUILD_DIR)/esp32.common.ld
+                            $(addprefix ld/, $(filter-out $(COMPONENT_BUILD_DIR)/esp32.project.ld, $(LINKER_SCRIPTS))) \
+                            $(COMPONENT_BUILD_DIR)/esp32.project.ld
 
 # Preprocess esp32.ld linker script into esp32_out.ld
 #
@@ -67,7 +67,7 @@ $(COMPONENT_LIBRARY): esp32_out.ld
 esp32_out.ld: $(COMPONENT_PATH)/ld/esp32.ld ../include/sdkconfig.h
        $(CC) -I ../include -C -P -x c -E $< -o $@
 
-COMPONENT_EXTRA_CLEAN := esp32_out.ld $(COMPONENT_BUILD_DIR)/esp32.common.ld
+COMPONENT_EXTRA_CLEAN := esp32_out.ld $(COMPONENT_BUILD_DIR)/esp32.project.ld
 
 # disable stack protection in files which are involved in initialization of that feature
 stack_check.o: CFLAGS := $(filter-out -fstack-protector%, $(CFLAGS))
index fd02e0d21082a569393af61b1bf08fc8cd51f3ec..11873b9d357f4a18ae35450d745eb1b17cc65aa6 100644 (file)
@@ -3,7 +3,7 @@
    This file describes the memory layout (memory blocks) as virtual
    memory addresses.
 
-   esp32.common.ld contains output sections to link compiler output
+   esp32.project.ld contains output sections to link compiler output
    into these memory blocks.
 
    ***
index aa2407791046961dbc0aa77c8061319be4fe6fb9..4c034703684b7d61ca90d0a3eb6c2964f4662e3e 100644 (file)
@@ -539,7 +539,7 @@ lives under ``$(IDF_PATH)/tools/ldgen``.
 
 Linker Script Template
 ^^^^^^^^^^^^^^^^^^^^^^
-Currently, the linker script template used is :component:`esp32/ld/esp32.common.ld.in`, and is used only for the app build. The generated output script is 
+Currently, the linker script template used is :component:`esp32/ld/esp32.project.ld.in`, and is used only for the app build. The generated output script is 
 put under the build directory of the same component. Modifying this linker script template triggers a re-link of the app binary. 
 
 Linker Fragment File
index 33a3527d5c26c5e0b46e270a8125924f13743e47..9e47f70445b45af7d8157d10a0ab65e8d157998d 100644 (file)
@@ -491,7 +491,7 @@ mapping 片段的映射条目共有三种类型,分别为:
 
 链接脚本模板
 ^^^^^^^^^^^^
-目前使用的链接脚本模板是 :component:`esp32/ld/esp32.common.ld.in`,仅用于应用程序的构建,生成的链接脚本文件将放在同一组件的构建目录下。值得注意的是,修改此链接描述文件模板会触发应用程序的二进制文件的重新链接。
+目前使用的链接脚本模板是 :component:`esp32/ld/esp32.project.ld.in`,仅用于应用程序的构建,生成的链接脚本文件将放在同一组件的构建目录下。值得注意的是,修改此链接描述文件模板会触发应用程序的二进制文件的重新链接。
 
 链接片段文件
 ^^^^^^^^^^^^
index 0915f2376852a8a89f2047bf8cc1151b48307ef4..ee8e70bd58e50f7ae43a5f1e3d4dcbd4f6c7805f 100755 (executable)
@@ -159,7 +159,7 @@ function run_tests()
 
     print_status "Touching app-only template ld file should only re-link app"
     take_build_snapshot
-    touch ${IDF_PATH}/components/esp32/ld/esp32.common.ld.in
+    touch ${IDF_PATH}/components/esp32/ld/esp32.project.ld.in
     make
     assert_rebuilt ${APP_BINS}
     assert_not_rebuilt ${BOOTLOADER_BINS}
index ae6bbd5baa66df8893207d689c87765b6235468e..75fb523c4a1080a61b375fb8910bbf275242d736 100755 (executable)
@@ -178,13 +178,13 @@ function run_tests()
 
     print_status "Updating app-only ld file should only re-link app"
     take_build_snapshot
-    cp ${IDF_PATH}/components/esp32/ld/esp32.common.ld.in .
+    cp ${IDF_PATH}/components/esp32/ld/esp32.project.ld.in .
     sleep 1  # ninja may ignore if the timestamp delta is too low
-    echo "/* (Build test comment) */" >> ${IDF_PATH}/components/esp32/ld/esp32.common.ld.in
+    echo "/* (Build test comment) */" >> ${IDF_PATH}/components/esp32/ld/esp32.project.ld.in
     idf.py build || failure "Failed to rebuild with modified linker script"
     assert_rebuilt ${APP_BINS}
     assert_not_rebuilt ${BOOTLOADER_BINS}
-    mv esp32.common.ld.in ${IDF_PATH}/components/esp32/ld/
+    mv esp32.project.ld.in ${IDF_PATH}/components/esp32/ld/
 
     print_status "Updating fragment file should only re-link app" # only app linker script is generated by tool for now
     take_build_snapshot