Fangrui Song | b6772b8 | 2018-06-26 22:20:04 | [diff] [blame] | 1 | // REQUIRES: x86 |
Igor Kudrin | 1309fc0 | 2015-09-28 15:01:59 | [diff] [blame] | 2 | // RUN: mkdir -p %t/lib |
| 3 | // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t/m.o |
| 4 | // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \ |
| 5 | // RUN: %p/Inputs/libsearch-st.s -o %t/st.o |
| 6 | // RUN: rm -f %t/lib/libls.a |
| 7 | // RUN: llvm-ar rcs %t/lib/libls.a %t/st.o |
Igor Kudrin | 1309fc0 | 2015-09-28 15:01:59 | [diff] [blame] | 8 | |
| 9 | // Should not link because of undefined symbol _bar |
Rafael Espindola | 9c8904f | 2015-11-18 06:11:01 | [diff] [blame] | 10 | // RUN: not ld.lld -o %t/r %t/m.o 2>&1 \ |
Igor Kudrin | 1309fc0 | 2015-09-28 15:01:59 | [diff] [blame] | 11 | // RUN: | FileCheck --check-prefix=UNDEFINED %s |
Rui Ueyama | b876020 | 2017-03-30 19:13:47 | [diff] [blame] | 12 | // UNDEFINED: error: undefined symbol: _bar |
| 13 | // UNDEFINED: >>> referenced by {{.*}}:(.text+0x1) |
Igor Kudrin | 1309fc0 | 2015-09-28 15:01:59 | [diff] [blame] | 14 | |
| 15 | // We need to be sure that there is no suitable library in the /lib directory |
Rafael Espindola | 9c8904f | 2015-11-18 06:11:01 | [diff] [blame] | 16 | // RUN: not ld.lld -o %t/r %t/m.o -L/lib -l:libls.a 2>&1 \ |
Igor Kudrin | 1309fc0 | 2015-09-28 15:01:59 | [diff] [blame] | 17 | // RUN: | FileCheck --check-prefix=NOLIB %s |
George Rimar | 777f963 | 2016-03-12 08:31:34 | [diff] [blame] | 18 | // NOLIB: unable to find library -l:libls.a |
Igor Kudrin | 1309fc0 | 2015-09-28 15:01:59 | [diff] [blame] | 19 | |
| 20 | // Should just remove the '=' symbol if --sysroot is not specified. |
| 21 | // Case 1: relative path |
Rafael Espindola | 9c8904f | 2015-11-18 06:11:01 | [diff] [blame] | 22 | // RUN: cd %t && ld.lld -o %t/r %t/m.o -L=lib -l:libls.a |
Igor Kudrin | 1309fc0 | 2015-09-28 15:01:59 | [diff] [blame] | 23 | // Case 2: absolute path |
Rafael Espindola | 9c8904f | 2015-11-18 06:11:01 | [diff] [blame] | 24 | // RUN: cd %p && ld.lld -o %t/r %t/m.o -L=%t/lib -l:libls.a |
Igor Kudrin | 1309fc0 | 2015-09-28 15:01:59 | [diff] [blame] | 25 | |
| 26 | // RUN: cd %p |
| 27 | |
| 28 | // Should substitute SysRoot if specified |
Rafael Espindola | 9c8904f | 2015-11-18 06:11:01 | [diff] [blame] | 29 | // RUN: ld.lld -o %t/r %t/m.o --sysroot=%t -L=lib -l:libls.a |
| 30 | // RUN: ld.lld -o %t/r %t/m.o --sysroot=%t -L=/lib -l:libls.a |
George Rimar | 4f37d57 | 2017-07-21 16:27:26 | [diff] [blame] | 31 | // Check alias. |
| 32 | // RUN: ld.lld -o %t/r %t/m.o --sysroot %t -L=lib -l:libls.a |
Igor Kudrin | 1309fc0 | 2015-09-28 15:01:59 | [diff] [blame] | 33 | |
| 34 | // Should not substitute SysRoot if the directory name does not start with '=' |
Rafael Espindola | 9c8904f | 2015-11-18 06:11:01 | [diff] [blame] | 35 | // RUN: not ld.lld -o %t/r %r/m.o --sysroot=%t -Llib -l:libls.a |
| 36 | // RUN: not ld.lld -o %t/r %r/m.o --sysroot=%t -L/lib -l:libls.a |
Igor Kudrin | 1309fc0 | 2015-09-28 15:01:59 | [diff] [blame] | 37 | |
Rui Ueyama | 144debc | 2016-04-27 02:58:27 | [diff] [blame] | 38 | .globl _start,_bar |
Igor Kudrin | 1309fc0 | 2015-09-28 15:01:59 | [diff] [blame] | 39 | _start: |
Eugene Leviant | 8983759 | 2016-10-06 09:45:04 | [diff] [blame] | 40 | call _bar |