Files
clang-p2996/clang/test/Driver/arch-specific-libdir.c
Fangrui Song b876596a76 [Driver] Improve error when a compiler-rt library is not found (#81037)
BSD, Linux, and z/OS enable `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` by
default.
When a compiler-rt library is not found, we currently report an
incorrect filename `libclang_rt.XXX-$arch.a`
```
% /tmp/Debug/bin/clang++ a.cc -fsanitize=address -o a
ld.lld: error: cannot open /tmp/Debug/lib/clang/19/lib/linux/libclang_rt.asan-x86_64.a: No such file or directory
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
```

With this change, we will correctly report:
```
% /tmp/Debug/bin/clang++ a.cc -fsanitize=address -o a
ld.lld: error: cannot open /tmp/Debug/lib/clang/19/lib/x86_64-unknown-linux-gnu/libclang_rt.asan.a: No such file or directory
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
```

Link: https://discourse.llvm.org/t/runtime-directory-fallback/76860
2024-02-26 09:55:02 -08:00

53 lines
2.6 KiB
C

// Test that the driver adds an arch-specific subdirectory in
// {RESOURCE_DIR}/lib/linux to the search path.
//
// RUN: %clang %s -### --target=i386-unknown-linux \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir 2>&1 \
// RUN: | FileCheck --check-prefixes=FILEPATH,ARCHDIR-i386 %s
// RUN: %clang %s -### --target=i386-unknown-linux \
// RUN: -resource-dir=%S/Inputs/resource_dir 2>&1 \
// RUN: | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
// RUN: %clang %s -### --target=i686-unknown-linux \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir 2>&1 \
// RUN: | FileCheck --check-prefixes=FILEPATH,ARCHDIR-i386 %s
// RUN: %clang %s -### --target=i686-unknown-linux \
// RUN: -resource-dir=%S/Inputs/resource_dir 2>&1 \
// RUN: | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
// RUN: %clang %s -### --target=x86_64-unknown-linux \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir 2>&1 \
// RUN: | FileCheck --check-prefixes=FILEPATH,ARCHDIR-x86_64 %s
// RUN: %clang %s -### --target=x86_64-unknown-linux \
// RUN: -resource-dir=%S/Inputs/resource_dir 2>&1 \
// RUN: | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
// RUN: %clang %s -### --target=arm-unknown-linux \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir 2>&1 \
// RUN: | FileCheck --check-prefixes=FILEPATH,ARCHDIR-arm %s
// RUN: %clang %s -### --target=arm-unknown-linux \
// RUN: -resource-dir=%S/Inputs/resource_dir 2>&1 \
// RUN: | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
// RUN: %clang %s -### --target=aarch64-unknown-linux \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir 2>&1 \
// RUN: | FileCheck --check-prefixes=FILEPATH,ARCHDIR-aarch64 %s
// RUN: %clang %s -### --target=aarch64-unknown-linux \
// RUN: -resource-dir=%S/Inputs/resource_dir 2>&1 \
// RUN: | FileCheck --check-prefixes=FILEPATH,NO-ARCHDIR %s
// FILEPATH: "-x" "c" "[[FILE_PATH:.*]]{{(/|\\\\).*}}.c"
// ARCHDIR-i386: -L[[FILE_PATH]]{{(/|\\\\)Inputs(/|\\\\)resource_dir_with_arch_subdir(/|\\\\)lib(/|\\\\)linux(/|\\\\)i386}}
// ARCHDIR-x86_64: -L[[FILE_PATH]]{{(/|\\\\)Inputs(/|\\\\)resource_dir_with_arch_subdir(/|\\\\)lib(/|\\\\)linux(/|\\\\)x86_64}}
// ARCHDIR-arm: -L[[FILE_PATH]]{{(/|\\\\)Inputs(/|\\\\)resource_dir_with_arch_subdir(/|\\\\)lib(/|\\\\)linux(/|\\\\)arm}}
// ARCHDIR-aarch64: -L[[FILE_PATH]]{{(/|\\\\)Inputs(/|\\\\)resource_dir_with_arch_subdir(/|\\\\)lib(/|\\\\)linux(/|\\\\)aarch64}}
//
// Have a stricter check for no-archdir - that the driver doesn't add any
// subdirectory from the provided resource directory.
// NO-ARCHDIR-NOT: -L[[FILE_PATH]]/Inputs/resource_dir"