Skip to content

Commit 623fb0e

Browse files
carlescufimbolivar-ampere
authored andcommitted
build: relocation: Fix long command-line invocations
For applications relocating big parts of the code with many sections, builds were failing on Windows due to hitting the max command-line length on that platform. Fix this by using a file to store the dictionary passed to the python script. Fixes #60994. Signed-off-by: Carles Cufi <[email protected]>
1 parent 68ee177 commit 623fb0e

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

cmake/linker/ld/target_relocation.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ macro(toolchain_ld_relocation)
1010
"${PROJECT_BINARY_DIR}/include/generated/linker_sram_bss_relocate.ld")
1111
set(MEM_RELOCATION_CODE "${PROJECT_BINARY_DIR}/code_relocation.c")
1212
set(MEM_REGION_DEFAULT_RAM RAM)
13+
set(DICT_FILE "${PROJECT_BINARY_DIR}/relocation_dict.txt")
14+
15+
file(GENERATE
16+
OUTPUT
17+
${DICT_FILE}
18+
CONTENT
19+
$<TARGET_PROPERTY:code_data_relocation_target,COMPILE_DEFINITIONS>
20+
)
1321

1422
add_custom_command(
1523
OUTPUT ${MEM_RELOCATION_CODE} ${MEM_RELOCATION_LD}
@@ -18,7 +26,7 @@ macro(toolchain_ld_relocation)
1826
${ZEPHYR_BASE}/scripts/build/gen_relocate_app.py
1927
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
2028
-d ${APPLICATION_BINARY_DIR}
21-
-i \"$<TARGET_PROPERTY:code_data_relocation_target,COMPILE_DEFINITIONS>\"
29+
-i ${DICT_FILE}
2230
-o ${MEM_RELOCATION_LD}
2331
-s ${MEM_RELOCATION_SRAM_DATA_LD}
2432
-b ${MEM_RELOCATION_SRAM_BSS_LD}

scripts/build/gen_relocate_app.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,8 @@ def parse_args():
456456
formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)
457457
parser.add_argument("-d", "--directory", required=True,
458458
help="obj file's directory")
459-
parser.add_argument("-i", "--input_rel_dict", required=True,
460-
help="input src:memory type(sram2 or ccm or aon etc) string")
459+
parser.add_argument("-i", "--input_rel_dict", required=True, type=argparse.FileType('r'),
460+
help="input file with dict src:memory type(sram2 or ccm or aon etc)")
461461
parser.add_argument("-o", "--output", required=False, help="Output ld file")
462462
parser.add_argument("-s", "--output_sram_data", required=False,
463463
help="Output sram data ld file")
@@ -490,7 +490,7 @@ def get_obj_filename(searchpath, filename):
490490
# Returns a 4-tuple with them: (mem_region, program_header, flag, file_name)
491491
# If no `program_header` is defined, returns an empty string
492492
def parse_input_string(line):
493-
line = line.replace('\\ :', ':')
493+
line = line.replace(' :', ':')
494494

495495
flag_sep = ':NOCOPY:' if ':NOCOPY' in line else ':COPY:'
496496
mem_region_phdr, copy_flag, file_name = line.partition(flag_sep)
@@ -508,9 +508,10 @@ def create_dict_wrt_mem():
508508
rel_dict = dict()
509509
phdrs = dict()
510510

511-
if args.input_rel_dict == '':
511+
input_rel_dict = args.input_rel_dict.read()
512+
if input_rel_dict == '':
512513
sys.exit("Disable CONFIG_CODE_DATA_RELOCATION if no file needs relocation")
513-
for line in args.input_rel_dict.split('|'):
514+
for line in input_rel_dict.split('|'):
514515
if ':' not in line:
515516
continue
516517

0 commit comments

Comments
 (0)