xref: /minix3/external/bsd/llvm/dist/clang/test/Driver/sysroot-flags.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // Check for proper handling of --sysroot and -isysroot flags.
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // RUN: %clang -### -fsyntax-only -isysroot /foo/bar %s 2>&1 | \
4*f4a2713aSLionel Sambuc // RUN:   FileCheck %s -check-prefix=ISYSROOT
5*f4a2713aSLionel Sambuc // ISYSROOT: "-isysroot" "{{[^"]*}}/foo/bar"
6*f4a2713aSLionel Sambuc 
7*f4a2713aSLionel Sambuc // Check that we get both isysroot for headers, and pass --sysroot on to GCC to
8*f4a2713aSLionel Sambuc // produce the final binary.
9*f4a2713aSLionel Sambuc // RUN: %clang -### -target x86_64-unknown-linux-gnu \
10*f4a2713aSLionel Sambuc // RUN:   --sysroot=/foo/bar -o /dev/null %s 2>&1 | \
11*f4a2713aSLionel Sambuc // RUN:   FileCheck %s -check-prefix=SYSROOT_EQ
12*f4a2713aSLionel Sambuc // SYSROOT_EQ: "-isysroot" "{{[^"]*}}/foo/bar"
13*f4a2713aSLionel Sambuc // SYSROOT_EQ: "--sysroot{{" "|=}}{{[^"]*}}/foo/bar"
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc // Check for overriding the header sysroot by providing both --sysroot and
16*f4a2713aSLionel Sambuc // -isysroot.
17*f4a2713aSLionel Sambuc // RUN: %clang -### -target x86_64-unknown-linux-gnu -isysroot /baz \
18*f4a2713aSLionel Sambuc // RUN:   --sysroot=/foo/bar -o /dev/null %s 2>&1 | FileCheck %s \
19*f4a2713aSLionel Sambuc // RUN:   -check-prefix=ISYSROOT_AND_SYSROOT
20*f4a2713aSLionel Sambuc // ISYSROOT_AND_SYSROOT: "-isysroot" "{{[^"]*}}/baz"
21*f4a2713aSLionel Sambuc // ISYSROOT_AND_SYSROOT: "--sysroot{{" "|=}}{{[^"]*}}/foo/bar"
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc // Check that omitting the equals works as well.
24*f4a2713aSLionel Sambuc // RUN: %clang -### -target x86_64-unknown-linux-gnu \
25*f4a2713aSLionel Sambuc // RUN:   --sysroot /foo/bar -o /dev/null %s 2>&1 | \
26*f4a2713aSLionel Sambuc // RUN:   FileCheck %s -check-prefix=SYSROOT_SEPARATE
27*f4a2713aSLionel Sambuc // SYSROOT_SEPARATE: "-isysroot" "{{[^"]*}}/foo/bar"
28*f4a2713aSLionel Sambuc // SYSROOT_SEPARATE: "--sysroot{{" "|=}}{{[^"]*}}/foo/bar"
29