cmake: Ninja: ld: Use the correct depfile in the second pass
When building for Ninja we were accidentally using the wrong depfile in the second pass. This commit moves the LINKER_SCRIPT_DEP logic into the custom command function so that it can be linker-pass-aware and set the depfile appropriately. This should fix an issue where Ninja reported: ninja: error: expected depfile 'zephyr/linker.cmd.dep' to mention 'zephyr/linker_pass2.cmd', got 'zephyr/linker.cmd' But this has not been reproduced. It has however been confirmed that a dependency issue with linker_pass2.cmd has been fixed because ninja no longer regenerates linker_pass2.cmd on every build like this: $ ninja [1/79] Generating always_rebuild Building for board qemu_x86 [2/3] Generating linker_pass2.cmd [3/3] Linking C executable zephyr/zephyr.elf Now: $ ninja [1/78] Generating always_rebuild Building for board qemu_x86 Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
This commit is contained in:
parent
b85dd3c238
commit
a0b9129e85
|
@ -404,25 +404,6 @@ endforeach()
|
|||
|
||||
get_property(OUTPUT_FORMAT GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT)
|
||||
|
||||
# Run the pre-processor on the linker script
|
||||
#
|
||||
# Deal with the un-preprocessed linker scripts differently with
|
||||
# different generators.
|
||||
if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
|
||||
# Note that the IMPLICIT_DEPENDS option is currently supported only
|
||||
# for Makefile generators and will be ignored by other generators.
|
||||
set(LINKER_SCRIPT_DEP IMPLICIT_DEPENDS C ${LINKER_SCRIPT})
|
||||
elseif(CMAKE_GENERATOR STREQUAL "Ninja")
|
||||
# Using DEPFILE with other generators than Ninja is an error.
|
||||
set(LINKER_SCRIPT_DEP DEPFILE ${PROJECT_BINARY_DIR}/linker.cmd.dep)
|
||||
else()
|
||||
# TODO: How would the linker script dependencies work for non-linker
|
||||
# script generators.
|
||||
message(STATUS "Warning; this generator is not well supported. The
|
||||
Linker script may not be regenerated when it should.")
|
||||
set(LINKER_SCRIPT_DEP "")
|
||||
endif()
|
||||
|
||||
get_property(LINKER_SCRIPT_DEFINES GLOBAL PROPERTY PROPERTY_LINKER_SCRIPT_DEFINES)
|
||||
|
||||
if(CONFIG_APPLICATION_MEMORY)
|
||||
|
@ -529,6 +510,22 @@ function(construct_add_custom_command_for_linker_pass linker_pass_number output_
|
|||
set(LINKER_PASS_DEFINE -DLINKER_PASS${linker_pass_number})
|
||||
endif()
|
||||
|
||||
# Different generators deal with depfiles differently.
|
||||
if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
|
||||
# Note that the IMPLICIT_DEPENDS option is currently supported only
|
||||
# for Makefile generators and will be ignored by other generators.
|
||||
set(LINKER_SCRIPT_DEP IMPLICIT_DEPENDS C ${LINKER_SCRIPT})
|
||||
elseif(CMAKE_GENERATOR STREQUAL "Ninja")
|
||||
# Using DEPFILE with other generators than Ninja is an error.
|
||||
set(LINKER_SCRIPT_DEP DEPFILE ${PROJECT_BINARY_DIR}/${linker_cmd_file_name}.dep)
|
||||
else()
|
||||
# TODO: How would the linker script dependencies work for non-linker
|
||||
# script generators.
|
||||
message(STATUS "Warning; this generator is not well supported. The
|
||||
Linker script may not be regenerated when it should.")
|
||||
set(LINKER_SCRIPT_DEP "")
|
||||
endif()
|
||||
|
||||
set(${output_variable}
|
||||
OUTPUT ${linker_cmd_file_name}
|
||||
DEPENDS ${LINKER_SCRIPT}
|
||||
|
|
Loading…
Reference in a new issue