- 
                Notifications
    
You must be signed in to change notification settings  - Fork 15.1k
 
Labels
llvmUmbrella label for LLVM issuesUmbrella label for LLVM issuesmiscompilationregression:17Regression in 17 releaseRegression in 17 release
Description
Reduced repro (file names > 15 characters so that the string table is used):
% cat foo34567890123456789.cc 
void foo() {}
% cat bar34567890123456789.cc 
void bar() {}
Compile them and make a .lib, using SYM64_THRESHOLD to force switch to 64-bit mode without needing many large obj files:
% out/gn/bin/clang-cl /c foo34567890123456789.cc                                                                                 
% out/gn/bin/clang-cl /c bar34567890123456789.cc                                                             
% SYM64_THRESHOLD=800 out/gn/bin/lld-link /lib /out:foo.lib foo34567890123456789.obj bar34567890123456789.obj
Use it:
% cat main.cc   
void foo();
void bar();
int main() {
  foo();
  bar();
}
% out/gn/bin/clang-cl /c main.cc
% out/gn/bin/lld-link /winsysroot:$HOME/src/chrome/src/third_party/depot_tools/win_toolchain/vs_files/e4305f407e main.obj foo.lib
lld-link: error: could not get child name for archive foo.lib while loading symbol void __cdecl foo(void): truncated or malformed archive (string table at long name offset 25 not terminated)
The problem is that writeArchiveToStream in llvm/lib/Object/ArchiveWriter.cpp dynamically switches Kind to object::Archive::K_GNU64 if the output becomes large enough to require 64-bit offsets, but after https://reviews.llvm.org/D143540 / 4fcbf38, several places in ArchiveWriter.cpp check Kind and make binding decisions based on it before Kind may change.
Options:
- Short-term, revert the change to LibDriver.cpp to always use 
K_GNUto unbreak things - In ArchiveWriter, maybe do a first pass to figure out the final Kind, and then don't change 
Kindwhile writing in a second, actually-writing pass 
Metadata
Metadata
Assignees
Labels
llvmUmbrella label for LLVM issuesUmbrella label for LLVM issuesmiscompilationregression:17Regression in 17 releaseRegression in 17 release