Currently, Baremetal toolchain requires user to pass a sysroot location using a --sysroot flag. This is not very convenient for the user. It also creates problem for toolchain vendors who don't have a fixed location to put the sysroot bits. Clang does provide 'DEFAULT_SYSROOT' which can be used by the toolchain builder to provide the default location. But it does not work if toolchain is targeting multiple targets e.g. arm-none-eabi/riscv64-unknown-elf which clang is capable of doing. This patch tries to solve this problem by providing a default location of the toolchain if user does not explicitly provides --sysroot. The exact location and name can be different but it should fulfill these conditions: 1. The sysroot path should have a target triple element so that multi-target toolchain problem (as I described above) could be addressed. 2. The location should not be $TOP/$Triple as this is used by gcc generally and will be a problem for installing both gcc and clang based toolchain at the same location. Reviewed By: jroelofs Differential Revision: https://reviews.llvm.org/D92677
23 lines
1.4 KiB
C++
23 lines
1.4 KiB
C++
// REQUIRES: shell
|
|
// UNSUPPORTED: system-windows
|
|
|
|
// Test that when a --sysroot is not provided, driver picks the default
|
|
// location correctly if available.
|
|
|
|
// RUN: rm -rf %T/baremetal_default_sysroot
|
|
// RUN: mkdir -p %T/baremetal_default_sysroot/bin
|
|
// RUN: mkdir -p %T/baremetal_default_sysroot/lib/clang-runtimes/armv6m-none-eabi
|
|
// RUN: ln -s %clang %T/baremetal_default_sysroot/bin/clang
|
|
|
|
// RUN: %T/baremetal_default_sysroot/bin/clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
|
|
// RUN: -target armv6m-none-eabi \
|
|
// RUN: | FileCheck --check-prefix=CHECK-V6M-C %s
|
|
// CHECK-V6M-C: "{{.*}}clang{{.*}}" "-cc1" "-triple" "thumbv6m-none-unknown-eabi"
|
|
// CHECK-V6M-C-SAME: "-internal-isystem" "{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
|
|
// CHECk-V6M-C-SAME: "-internal-isystem" "{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}include"
|
|
// CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal-sysroot.cpp"
|
|
// CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
|
|
// CHECK-V6M-C-SAME: "-L{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}lib"
|
|
// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
|
|
// CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
|