Skip to content

Avoid command line length limits in gmake by adding objects to ar incrementally and using response file for linking #2638

@mercury233

Description

@mercury233

What problem will this solve?

When building with MinGW on Windows, a project with a large number of object files can hit the Windows command line length limit.

In the generated gmake files, static libraries are currently created by passing all object files to ar in a single command:

LINKCMD = $(AR) -rcs "$@" $(OBJECTS)

If $(OBJECTS) expands to many files, the command line can exceed the Windows limit (commonly cited as 8191 characters) and the build fails.

The final link step in the generated gmake files also does not use response files, which means large projects may encounter the same command length limitation during linking.

What might be a solution?
Submit object files to ar individually, and use a response file during the link step.

What other alternatives have you already considered?
This workaround seems don't work in beta8.

sed -i '/OBJECTS += $(OBJDIR)\/.*\.o/d' irrlicht.make
sed -i '/^# Rules/i\OBJECTS += $(OBJDIR)/*.o' irrlicht.make

Anything else we should know?
This issue tends to be less visible on typical Linux gmake environments because the supported command line length is significantly larger than on Windows.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions