Skip to content

llvm-ar: Invalid archive when creating thin archives from other archives #27428

@hmartinez82

Description

@hmartinez82

Description / Steps to reproduce the issue

Using llvm-ar to create a thin archive from other archives result in invalid files where nm returns empty content and trying to link using the thin archive fails with ld.lld: error: unknown file type

Steps to repro:
dep.c:

int forty_two() {
    return 42;
}

Then running:

cc -c dep.c && \
nm -g dep.o &&  \
ar cr dep.a dep.o &&  \
nm -g dep.a  && \
ar crT archive.a dep.a && \
nm -g archive.a && \
file archive.a

GNU binutils doesn't have this error.

Expected behavior

forty_two
forty_two
forty_two
archive.a: thin archive with 1 symbol entry

Actual behavior

forty_two
forty_two
<nothing is shown here, the output of nm is empty>
archive.a: thin archive with 1684369454 symbol entries

Verification

Windows Version

MINGW64_NT-10.0-26200

MINGW environments affected

  • MINGW64
  • MINGW32
  • UCRT64
  • CLANG64
  • CLANGARM64

Are you willing to submit a PR?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions