2015-09-28 20:52:21 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
|
2015-10-02 00:42:03 +08:00
|
|
|
// RUN: %p/Inputs/libsearch-dyn.s -o %tdyn.o
|
2015-09-28 20:52:21 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
|
2015-10-02 00:42:03 +08:00
|
|
|
// RUN: %p/Inputs/libsearch-st.s -o %tst.o
|
2015-10-12 23:58:38 +08:00
|
|
|
// RUN: mkdir -p %t.dir
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -shared %tdyn.o -o %t.dir/libls.so
|
2015-10-12 23:58:38 +08:00
|
|
|
// RUN: cp -f %t.dir/libls.so %t.dir/libls2.so
|
|
|
|
// RUN: rm -f %t.dir/libls.a
|
|
|
|
// RUN: llvm-ar rcs %t.dir/libls.a %tst.o
|
2015-09-28 20:52:21 +08:00
|
|
|
// REQUIRES: x86
|
|
|
|
|
2015-10-20 17:58:56 +08:00
|
|
|
// Should fail if no library specified
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: not ld.lld -l 2>&1 \
|
2015-10-20 17:58:56 +08:00
|
|
|
// RUN: | FileCheck --check-prefix=NOLIBRARY %s
|
2016-03-11 22:43:02 +08:00
|
|
|
// NOLIBRARY: missing arg value for "-l", expected 1 argument.
|
2015-10-20 17:58:56 +08:00
|
|
|
|
2015-09-28 20:52:21 +08:00
|
|
|
// Should not link because of undefined symbol _bar
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: not ld.lld -o %t3 %t.o 2>&1 \
|
2015-10-02 00:42:03 +08:00
|
|
|
// RUN: | FileCheck --check-prefix=UNDEFINED %s
|
2016-03-11 22:43:02 +08:00
|
|
|
// UNDEFINED: undefined symbol: _bar
|
2015-09-28 20:52:21 +08:00
|
|
|
|
|
|
|
// Should fail if cannot find specified library (without -L switch)
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: not ld.lld -o %t3 %t.o -lls 2>&1 \
|
2015-10-02 00:42:03 +08:00
|
|
|
// RUN: | FileCheck --check-prefix=NOLIB %s
|
2016-03-12 16:31:34 +08:00
|
|
|
// NOLIB: unable to find library -lls
|
2015-09-28 20:52:21 +08:00
|
|
|
|
|
|
|
// Should use explicitly specified static library
|
2015-10-27 23:10:53 +08:00
|
|
|
// Also ensure that we accept -L <arg>
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -o %t3 %t.o -L %t.dir -l:libls.a
|
2015-09-28 20:52:21 +08:00
|
|
|
// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=STATIC %s
|
|
|
|
// STATIC: Symbols [
|
|
|
|
// STATIC: Name: _static
|
|
|
|
// STATIC: ]
|
|
|
|
|
|
|
|
// Should use explicitly specified dynamic library
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -o %t3 %t.o -L%t.dir -l:libls.so
|
2015-09-28 20:52:21 +08:00
|
|
|
// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=DYNAMIC %s
|
|
|
|
// DYNAMIC: Symbols [
|
|
|
|
// DYNAMIC-NOT: Name: _static
|
|
|
|
// DYNAMIC: ]
|
|
|
|
|
|
|
|
// Should prefer dynamic to static
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -o %t3 %t.o -L%t.dir -lls
|
2015-09-28 20:52:21 +08:00
|
|
|
// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=DYNAMIC %s
|
|
|
|
|
|
|
|
// -L can be placed after -l
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -o %t3 %t.o -lls -L%t.dir
|
2015-09-28 20:52:21 +08:00
|
|
|
|
|
|
|
// Check long forms as well
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -o %t3 %t.o --library-path=%t.dir --library=ls
|
2015-09-28 20:52:21 +08:00
|
|
|
|
2015-10-02 00:42:03 +08:00
|
|
|
// Should not search for dynamic libraries if -Bstatic is specified
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -o %t3 %t.o -L%t.dir -Bstatic -lls
|
2015-10-02 00:42:03 +08:00
|
|
|
// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=STATIC %s
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: not ld.lld -o %t3 %t.o -L%t.dir -Bstatic -lls2 2>&1 \
|
2015-10-02 00:42:03 +08:00
|
|
|
// RUN: | FileCheck --check-prefix=NOLIB2 %s
|
2016-03-12 16:31:34 +08:00
|
|
|
// NOLIB2: unable to find library -lls2
|
2015-10-02 00:42:03 +08:00
|
|
|
|
|
|
|
// -Bdynamic should restore default behaviour
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -o %t3 %t.o -L%t.dir -Bstatic -Bdynamic -lls
|
2015-10-02 00:42:03 +08:00
|
|
|
// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=DYNAMIC %s
|
|
|
|
|
|
|
|
// -Bstatic and -Bdynamic should affect only libraries which follow them
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -o %t3 %t.o -L%t.dir -lls -Bstatic -Bdynamic
|
2015-10-02 00:42:03 +08:00
|
|
|
// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=DYNAMIC %s
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -o %t3 %t.o -L%t.dir -Bstatic -lls -Bdynamic
|
2015-10-02 00:42:03 +08:00
|
|
|
// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=STATIC %s
|
|
|
|
|
|
|
|
// Check aliases as well
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -o %t3 %t.o -L%t.dir -dn -lls
|
2015-10-02 00:42:03 +08:00
|
|
|
// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=STATIC %s
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -o %t3 %t.o -L%t.dir -non_shared -lls
|
2015-10-02 00:42:03 +08:00
|
|
|
// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=STATIC %s
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -o %t3 %t.o -L%t.dir -static -lls
|
2015-10-02 00:42:03 +08:00
|
|
|
// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=STATIC %s
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -o %t3 %t.o -L%t.dir -Bstatic -dy -lls
|
2015-10-02 00:42:03 +08:00
|
|
|
// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=DYNAMIC %s
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -o %t3 %t.o -L%t.dir -Bstatic -call_shared -lls
|
2015-10-02 00:42:03 +08:00
|
|
|
// RUN: llvm-readobj --symbols %t3 | FileCheck --check-prefix=DYNAMIC %s
|
|
|
|
|
2016-04-27 10:58:27 +08:00
|
|
|
.globl _start,_bar
|
2015-09-28 20:52:21 +08:00
|
|
|
_start:
|