Skip to content

mbed target - Linking fails under Windows with large list of source files #839

Closed
@aureleq

Description

@aureleq

Bug Report

Current behavior

My project contains a library with a large number of source files (roughly 500 .cpp).
Under macOS the project compiles without any issue. However, under Windows 10 linking fails as the 500 object files put as argument make the command line exceeds 32k characters (Windows limit). The linking command line is roughly 64k characters long. The issue appears both with CLI or IDE.

Arduino output:
fork/exec C:\Users\aurel\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4/bin/arm-none-eabi-g++.exe: The filename or extension is too long.

Expected behavior

As a solution the list of object files should be put in a text file, linking command can read the list from it to avoid exceeding the 32k characters limit.

As a workaround, I created a platform.local.txt to bypass this issue, my linking command has become:

platform.local.txt

recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} "@{compiler.mbed.ldflags}" "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" --specs=nano.specs --specs=nosys.specs {compiler.ldflags} -o "{build.path}/{build.project_name}.elf" @{build.path}\obj_files.txt -Wl,--whole-archive "{build.path}/{archive_file}" {compiler.mbed} -Wl,--no-whole-archive -Wl,--start-group {compiler.mbed.extra_ldflags} {compiler.libraries.ldflags} -Wl,--end-group

This solution should work well for most of projects but this should be managed directly into the Arduino builder.

Environment

  • Arduino CLI version: 0.11
  • Arduino IDE version: 1.8.12
  • OS and platform: Windows 10

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    os: windowsSpecific to Windows operating system

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions