mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 21:26:53 +00:00
[LLD][COFF] Update nodefaultlibs after updating search paths (#128813)
Fix #107346
This commit is contained in:
parent
d921bf233c
commit
90a08fb4b7
@ -786,6 +786,13 @@ void LinkerDriver::addWinSysRootLibSearchPaths() {
|
|||||||
path))
|
path))
|
||||||
searchPaths.push_back(saver().save(path));
|
searchPaths.push_back(saver().save(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Libraries specified by `/nodefaultlib:` may not be found in incomplete
|
||||||
|
// search paths before lld infers a machine type from input files.
|
||||||
|
std::set<std::string> noDefaultLibs;
|
||||||
|
for (const std::string &path : ctx.config.noDefaultLibs)
|
||||||
|
noDefaultLibs.insert(findLib(path).lower());
|
||||||
|
ctx.config.noDefaultLibs = noDefaultLibs;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parses LIB environment which contains a list of search paths.
|
// Parses LIB environment which contains a list of search paths.
|
||||||
|
24
lld/test/COFF/Inputs/defaultlib.yaml
Normal file
24
lld/test/COFF/Inputs/defaultlib.yaml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
--- !COFF
|
||||||
|
header:
|
||||||
|
Machine: IMAGE_FILE_MACHINE_AMD64
|
||||||
|
Characteristics: [ ]
|
||||||
|
sections:
|
||||||
|
- Name: .drectve
|
||||||
|
Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ]
|
||||||
|
Alignment: 1
|
||||||
|
SectionData: 202F44454641554C544C49423A64656661756C742E6C6962
|
||||||
|
SizeOfRawData: 24
|
||||||
|
symbols:
|
||||||
|
- Name: .drectve
|
||||||
|
Value: 0
|
||||||
|
SectionNumber: 1
|
||||||
|
SimpleType: IMAGE_SYM_TYPE_NULL
|
||||||
|
ComplexType: IMAGE_SYM_DTYPE_NULL
|
||||||
|
StorageClass: IMAGE_SYM_CLASS_STATIC
|
||||||
|
SectionDefinition:
|
||||||
|
Length: 24
|
||||||
|
NumberOfRelocations: 0
|
||||||
|
NumberOfLinenumbers: 0
|
||||||
|
CheckSum: 2526009418
|
||||||
|
Number: 1
|
||||||
|
...
|
@ -36,3 +36,12 @@ MSVC stamps uppercase references in OBJ directives, thus ensure that passing low
|
|||||||
|
|
||||||
UPPERCASE-NOT: OLDNAMES
|
UPPERCASE-NOT: OLDNAMES
|
||||||
UPPERCASE-NOT: LIBCMT
|
UPPERCASE-NOT: LIBCMT
|
||||||
|
|
||||||
|
# RUN: yaml2obj -o %T/defaultlib.obj %p/Inputs/defaultlib.yaml
|
||||||
|
# RUN: mkdir -p %t.dir/sysroot/VC/Tools/MSVC/1.1.1.1/lib/x64
|
||||||
|
# RUN: cp %p/Inputs/ret42.lib %t.dir/sysroot/VC/Tools/MSVC/1.1.1.1/lib/x64/default.lib
|
||||||
|
|
||||||
|
# RUN: lld-link /winsysroot:%t.dir/sysroot /out:%t.exe /entry:main /subsystem:console %T/defaultlib.obj
|
||||||
|
# RUN: not lld-link /winsysroot:%t.dir/sysroot /out:%t.exe /entry:main /subsystem:console /nodefaultlib:default.lib %T/defaultlib.obj 2>&1 | FileCheck -check-prefix=CHECK4 %s
|
||||||
|
|
||||||
|
CHECK4: error: <root>: undefined symbol: main
|
||||||
|
Loading…
x
Reference in New Issue
Block a user