aboutsummaryrefslogtreecommitdiff
path: root/lld/test/COFF/nodefaultlib.test
blob: fbf6b43a11dfeb7df9ead0958e09f95cfed6bcec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# RUN: mkdir -p %t.dir
# RUN: cp %p/Inputs/hello64.obj %t.dir
# RUN: cp %p/Inputs/std64.lib %t.dir

# RUN: not lld-link /out:%t.exe /entry:main /subsystem:console \
# RUN:   hello64.obj /defaultlib:std64.lib >& %t.log
# RUN: FileCheck -DMSG=%errc_ENOENT -check-prefix=CHECK1 %s < %t.log

# RUN: not lld-link /out:%t.exe /entry:main /subsystem:console \
# RUN:   hello64 /defaultlib:std64.lib >& %t.log
# RUN: FileCheck -DMSG=%errc_ENOENT -check-prefix=CHECK2 %s < %t.log

# RUN: lld-link /libpath:%t.dir /out:%t.exe /entry:main \
# RUN:   /subsystem:console hello64.obj /defaultlib:std64.lib \
# RUN:   /nodefaultlib:std64.lib >& %t.log || true
# RUN: FileCheck -check-prefix=CHECK3 %s < %t.log

# RUN: lld-link /libpath:%t.dir /out:%t.exe /entry:main \
# RUN:   /subsystem:console hello64.obj /defaultlib:std64 \
# RUN:   /nodefaultlib:std64.lib >& %t.log || true
# RUN: FileCheck -check-prefix=CHECK3 %s < %t.log

CHECK1: error: could not open 'hello64.obj': [[MSG]]
CHECK2: error: could not open 'hello64': [[MSG]]
CHECK3: error: undefined symbol: MessageBoxA
CHECK3-NEXT: >>> referenced by {{.*}}hello64.obj:(main)

# RUN: lld-link /libpath:%t.dir /out:%t.exe /entry:main \
# RUN:   /subsystem:console hello64.obj /defaultlib:std64.lib

# RUN: env LIB=%t.dir lld-link /out:%t.exe /entry:main \
# RUN:   /subsystem:console hello64.obj /defaultlib:std64.lib

MSVC stamps uppercase references in OBJ directives, thus ensure that passing lowercase 'libcmt' and 'oldnames' to /nodefaultlib works.
# RUN: lld-link %S/Inputs/precomp.obj %S/Inputs/precomp-a.obj %S/Inputs/precomp-b.obj /nodefaultlib:libcmt /nodefaultlib:oldnames /entry:main /debug /pdb:%t.pdb /out:%t.exe /opt:ref /opt:icf
# RUN: llvm-pdbutil dump -modules %t.pdb | FileCheck %s -check-prefix UPPERCASE

UPPERCASE-NOT: OLDNAMES
UPPERCASE-NOT: LIBCMT

# RUN: yaml2obj -o %t.dir/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.dir/defaultlib.obj
# RUN: not lld-link /winsysroot:%t.dir/sysroot /out:%t.exe /entry:main /subsystem:console /nodefaultlib:default.lib %t.dir/defaultlib.obj 2>&1 | FileCheck -check-prefix=CHECK4 %s

CHECK4: error: <root>: undefined symbol: main