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
|
|
|
|
// RUN: ld.lld2 -shared %tdyn.o -o %t.dir/libls.so
|
|
|
|
// 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
|
|
|
|
// RUN: not ld.lld2 -l 2>&1 \
|
|
|
|
// RUN: | FileCheck --check-prefix=NOLIBRARY %s
|
2015-10-20 19:07:03 +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-10-09 04:57:29 +08:00
|
|
|
// RUN: not ld.lld2 -o %t3 %t.o 2>&1 \
|
2015-10-02 00:42:03 +08:00
|
|
|
// RUN: | FileCheck --check-prefix=UNDEFINED %s
|
2015-09-28 20:52:21 +08:00
|
|
|
// UNDEFINED: undefined symbol: _bar
|
|
|
|
|
|
|
|
// Should fail if cannot find specified library (without -L switch)
|
2015-10-09 04:57:29 +08:00
|
|
|
// RUN: not ld.lld2 -o %t3 %t.o -lls 2>&1 \
|
2015-10-02 00:42:03 +08:00
|
|
|
// RUN: | FileCheck --check-prefix=NOLIB %s
|
2015-09-28 20:52:21 +08:00
|
|
|
// NOLIB: Unable to find library -lls
|
|
|
|
|
|
|
|
// Should use explicitly specified static library
|
2015-10-27 23:10:53 +08:00
|
|
|
// Also ensure that we accept -L <arg>
|
|
|
|
// RUN: ld.lld2 -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-10-12 23:58:38 +08:00
|
|
|
// RUN: ld.lld2 -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-10-12 23:58:38 +08:00
|
|
|
// RUN: ld.lld2 -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-10-12 23:58:38 +08:00
|
|
|
// RUN: ld.lld2 -o %t3 %t.o -lls -L%t.dir
|
2015-09-28 20:52:21 +08:00
|
|
|
|
|
|
|
// Check long forms as well
|
2015-10-12 23:58:38 +08:00
|
|
|
// RUN: ld.lld2 -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-10-12 23:58:38 +08:00
|
|
|
// RUN: ld.lld2 -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-10-12 23:58:38 +08:00
|
|
|
// RUN: not ld.lld2 -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
|
|
|
|
// NOLIB2: Unable to find library -lls2
|
|
|
|
|
|
|
|
// -Bdynamic should restore default behaviour
|
2015-10-12 23:58:38 +08:00
|
|
|
// RUN: ld.lld2 -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-10-12 23:58:38 +08:00
|
|
|
// RUN: ld.lld2 -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-10-12 23:58:38 +08:00
|
|
|
// RUN: ld.lld2 -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-10-12 23:58:38 +08:00
|
|
|
// RUN: ld.lld2 -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-10-12 23:58:38 +08:00
|
|
|
// RUN: ld.lld2 -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-10-12 23:58:38 +08:00
|
|
|
// RUN: ld.lld2 -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-10-12 23:58:38 +08:00
|
|
|
// RUN: ld.lld2 -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-10-12 23:58:38 +08:00
|
|
|
// RUN: ld.lld2 -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
|
|
|
|
|
2015-09-28 20:52:21 +08:00
|
|
|
.globl _start,_bar;
|
|
|
|
_start:
|