Skip to content

[llvm-lib] Add /llvmlibindex:no to disable writing an index #120596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion lld/test/COFF/thin-archive.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,22 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-windows-msvc -o %t.lib.obj \
# RUN: %S/Inputs/mangled-symbol.s
# RUN: lld-link /lib /out:%t.lib %t.lib.obj
# RUN: lld-link /lib /llvmlibthin /out:%t_thin.lib %t.lib.obj
# RUN: lld-link /lib /llvmlibindex:no /out:%t_noindex.lib %t.lib.obj
# RUN: lld-link /lib /llvmlibthin /llvmlibindex /out:%t_thin.lib %t.lib.obj
# RUN: lld-link /lib /llvmlibthin /llvmlibindex:no \
# RUN: /out:%t_thin_noindex.lib %t.lib.obj

# RUN: llvm-nm --print-armap %t.lib \
# RUN: | FileCheck %s --check-prefix=SYMTAB
# RUN: llvm-nm --print-armap %t_noindex.lib \
# RUN: | FileCheck %s --check-prefix=NO-SYMTAB
# RUN: llvm-nm --print-armap %t_thin.lib \
# RUN: | FileCheck %s --check-prefix=SYMTAB
# RUN: llvm-nm --print-armap %t_thin_noindex.lib \
# RUN: | FileCheck %s --check-prefix=NO-SYMTAB

# SYMTAB: ?f@@YAHXZ in
# NO-SYMTAB-NOT: ?f@@YAHXZ in

# RUN: lld-link /entry:main %t.main.obj %t.lib /out:%t.exe 2>&1 | \
# RUN: FileCheck --allow-empty %s
Expand Down
8 changes: 7 additions & 1 deletion llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,14 @@ int llvm::libDriverMain(ArrayRef<const char *> ArgsArr) {
std::reverse(Members.begin(), Members.end());

bool Thin = Args.hasArg(OPT_llvmlibthin);

auto Symtab = Args.hasFlag(OPT_llvmlibindex, OPT_llvmlibindex_no,
/*default=*/true)
? SymtabWritingMode::NormalSymtab
: SymtabWritingMode::NoSymtab;

if (Error E = writeArchive(
OutputPath, Members, SymtabWritingMode::NormalSymtab,
OutputPath, Members, Symtab,
Thin ? object::Archive::K_GNU : object::Archive::K_COFF,
/*Deterministic=*/true, Thin, nullptr, COFF::isArm64EC(LibMachine))) {
handleAllErrors(std::move(E), [&](const ErrorInfoBase &EI) {
Expand Down
3 changes: 3 additions & 0 deletions llvm/lib/ToolDrivers/llvm-lib/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def nativedeffile : P<"defArm64Native", "def file to use to generate native ARM6
def llvmlibthin : F<"llvmlibthin">,
HelpText<"Make .lib point to .obj files instead of copying their contents">;

defm llvmlibindex : B<"llvmlibindex", "Write an index to the output (default)",
"Do not write an index to the output">;

def llvmlibempty : F<"llvmlibempty">,
HelpText<"When given no contents, produce an empty .lib file">;

Expand Down
Loading