1 // General tests that ld invocations on Linux targets sane. Note that we use 2 // sysroot to make these tests independent of the host system. 3 // 4 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ 5 // RUN: -ccc-host-triple i386-unknown-linux \ 6 // RUN: --sysroot=%S/Inputs/basic_linux_tree \ 7 // RUN: | FileCheck --check-prefix=CHECK-LD-32 %s 8 // CHECK-LD-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" 9 // CHECK-LD-32: "{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o" 10 // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0" 11 // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib" 12 // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.." 13 // CHECK-LD-32: "-L[[SYSROOT]]/lib" 14 // CHECK-LD-32: "-L[[SYSROOT]]/usr/lib" 15 // 16 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ 17 // RUN: -ccc-host-triple x86_64-unknown-linux \ 18 // RUN: --sysroot=%S/Inputs/basic_linux_tree \ 19 // RUN: | FileCheck --check-prefix=CHECK-LD-64 %s 20 // CHECK-LD-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" 21 // CHECK-LD-64: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o" 22 // CHECK-LD-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0" 23 // CHECK-LD-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib" 24 // CHECK-LD-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.." 25 // CHECK-LD-64: "-L[[SYSROOT]]/lib" 26 // CHECK-LD-64: "-L[[SYSROOT]]/usr/lib" 27 // 28 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ 29 // RUN: -ccc-host-triple i386-unknown-linux -m32 \ 30 // RUN: --sysroot=%S/Inputs/multilib_32bit_linux_tree \ 31 // RUN: | FileCheck --check-prefix=CHECK-32-TO-32 %s 32 // CHECK-32-TO-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" 33 // CHECK-32-TO-32: "{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o" 34 // CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0" 35 // CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib/../lib32" 36 // CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../lib32" 37 // CHECK-32-TO-32: "-L[[SYSROOT]]/lib/../lib32" 38 // CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/../lib32" 39 // CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib" 40 // CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.." 41 // CHECK-32-TO-32: "-L[[SYSROOT]]/lib" 42 // CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib" 43 // 44 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ 45 // RUN: -ccc-host-triple i386-unknown-linux -m64 \ 46 // RUN: --sysroot=%S/Inputs/multilib_32bit_linux_tree \ 47 // RUN: | FileCheck --check-prefix=CHECK-32-TO-64 %s 48 // CHECK-32-TO-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" 49 // CHECK-32-TO-64: "{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0/64/crtbegin.o" 50 // CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/64" 51 // CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib/../lib64" 52 // CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../lib64" 53 // CHECK-32-TO-64: "-L[[SYSROOT]]/lib/../lib64" 54 // CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/../lib64" 55 // CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0" 56 // CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib" 57 // CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.." 58 // CHECK-32-TO-64: "-L[[SYSROOT]]/lib" 59 // CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib" 60 // 61 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ 62 // RUN: -ccc-host-triple x86_64-unknown-linux -m64 \ 63 // RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree \ 64 // RUN: | FileCheck --check-prefix=CHECK-64-TO-64 %s 65 // CHECK-64-TO-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" 66 // CHECK-64-TO-64: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o" 67 // CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0" 68 // CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib/../lib64" 69 // CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../lib64" 70 // CHECK-64-TO-64: "-L[[SYSROOT]]/lib/../lib64" 71 // CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/../lib64" 72 // CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib" 73 // CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.." 74 // CHECK-64-TO-64: "-L[[SYSROOT]]/lib" 75 // CHECK-64-TO-64: "-L[[SYSROOT]]/usr/lib" 76 // 77 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ 78 // RUN: -ccc-host-triple x86_64-unknown-linux -m32 \ 79 // RUN: --sysroot=%S/Inputs/multilib_64bit_linux_tree \ 80 // RUN: | FileCheck --check-prefix=CHECK-64-TO-32 %s 81 // CHECK-64-TO-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" 82 // CHECK-64-TO-32: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32/crtbegin.o" 83 // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/32" 84 // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib/../lib32" 85 // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../lib32" 86 // CHECK-64-TO-32: "-L[[SYSROOT]]/lib/../lib32" 87 // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/../lib32" 88 // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0" 89 // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../../../x86_64-unknown-linux/lib" 90 // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.." 91 // CHECK-64-TO-32: "-L[[SYSROOT]]/lib" 92 // CHECK-64-TO-32: "-L[[SYSROOT]]/usr/lib" 93 // 94 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ 95 // RUN: -ccc-host-triple i386-unknown-linux -m32 \ 96 // RUN: -ccc-install-dir %S/Inputs/fake_install_tree/bin \ 97 // RUN: --sysroot=%S/Inputs/basic_linux_tree \ 98 // RUN: | FileCheck --check-prefix=CHECK-INSTALL-DIR-32 %s 99 // CHECK-INSTALL-DIR-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" 100 // CHECK-INSTALL-DIR-32: "{{.*}}/Inputs/fake_install_tree/bin/../lib/gcc/i386-unknown-linux/4.7.0/crtbegin.o" 101 // CHECK-INSTALL-DIR-32: "-L{{.*}}/Inputs/fake_install_tree/bin/../lib/gcc/i386-unknown-linux/4.7.0" 102 // 103 // Check that with 64-bit builds, we don't actually use the install directory 104 // as its version of GCC is lower than our sysrooted version. 105 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ 106 // RUN: -ccc-host-triple x86_64-unknown-linux -m64 \ 107 // RUN: -ccc-install-dir %S/Inputs/fake_install_tree/bin \ 108 // RUN: --sysroot=%S/Inputs/basic_linux_tree \ 109 // RUN: | FileCheck --check-prefix=CHECK-INSTALL-DIR-64 %s 110 // CHECK-INSTALL-DIR-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" 111 // CHECK-INSTALL-DIR-64: "{{.*}}/usr/lib/gcc/x86_64-unknown-linux/4.6.0/crtbegin.o" 112 // CHECK-INSTALL-DIR-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0" 113 // 114 // Check that we support unusual patch version formats, including missing that 115 // component. 116 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ 117 // RUN: -ccc-host-triple i386-unknown-linux -m32 \ 118 // RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing1/bin \ 119 // RUN: --sysroot=%S/Inputs/basic_linux_tree \ 120 // RUN: | FileCheck --check-prefix=CHECK-GCC-VERSION1 %s 121 // CHECK-GCC-VERSION1: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" 122 // CHECK-GCC-VERSION1: "{{.*}}/Inputs/gcc_version_parsing1/bin/../lib/gcc/i386-unknown-linux/4.7/crtbegin.o" 123 // CHECK-GCC-VERSION1: "-L{{.*}}/Inputs/gcc_version_parsing1/bin/../lib/gcc/i386-unknown-linux/4.7" 124 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ 125 // RUN: -ccc-host-triple i386-unknown-linux -m32 \ 126 // RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing2/bin \ 127 // RUN: --sysroot=%S/Inputs/basic_linux_tree \ 128 // RUN: | FileCheck --check-prefix=CHECK-GCC-VERSION2 %s 129 // CHECK-GCC-VERSION2: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" 130 // CHECK-GCC-VERSION2: "{{.*}}/Inputs/gcc_version_parsing2/bin/../lib/gcc/i386-unknown-linux/4.7.x/crtbegin.o" 131 // CHECK-GCC-VERSION2: "-L{{.*}}/Inputs/gcc_version_parsing2/bin/../lib/gcc/i386-unknown-linux/4.7.x" 132 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ 133 // RUN: -ccc-host-triple i386-unknown-linux -m32 \ 134 // RUN: -ccc-install-dir %S/Inputs/gcc_version_parsing3/bin \ 135 // RUN: --sysroot=%S/Inputs/basic_linux_tree \ 136 // RUN: | FileCheck --check-prefix=CHECK-GCC-VERSION3 %s 137 // CHECK-GCC-VERSION3: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" 138 // CHECK-GCC-VERSION3: "{{.*}}/Inputs/gcc_version_parsing3/bin/../lib/gcc/i386-unknown-linux/4.7.99-rc5/crtbegin.o" 139 // CHECK-GCC-VERSION3: "-L{{.*}}/Inputs/gcc_version_parsing3/bin/../lib/gcc/i386-unknown-linux/4.7.99-rc5" 140