[PATCH] D93138: Add initial support for multilibs in Baremetal toolchain.

2022-07-29 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added inline comments.



Comment at: clang/lib/Driver/ToolChains/BareMetal.cpp:177
   if (!getDriver().SysRoot.empty())
-return getDriver().SysRoot;
+return getDriver().SysRoot + SelectedMultilib.osSuffix();
 

zixuan-wu wrote:
> I think the multilib osSuffix added here will make every multilib contain 
> include dir, and those include dirs are the same. For lib, there should be 
> different multilib dir. 
> 
> So it's better to add osSuffix at construction function like following I 
> think instead of be part of sysroot.
> 
> ```
> if (!SysRoot.empty()) {
> llvm::sys::path::append(SysRoot, "lib", SelectedMultilib.osSuffix());
> getFilePaths().push_back(std::string(SysRoot));
>   }
> ```
> 
> @abidh 
The multilib include directories are not necessarily the same.  In my opinion, 
having a separate include and lib directory for every multilib is much cleaner 
then having all multilib share an include directory and then you put multilib 
specific directories inside that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93138/new/

https://reviews.llvm.org/D93138

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131225: Driver: Refactor and support per target dirs in baremetal

2022-08-08 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

I think this patch is moving the things in the right direction. But please wait 
for some other reviewers to chime in.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131225/new/

https://reviews.llvm.org/D131225

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131225: Driver: Refactor and support per target dirs in baremetal

2022-08-08 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

In D131225#3706239 , @barannikov88 
wrote:

> In D131225#3706207 , @abidh wrote:
>
>> I think this patch is moving the things in the right direction. But please 
>> wait for some other reviewers to chime in.
>
> It seems quite opposite to me.

To be clear, my comment was aimed at using target specific directory instead of 
using lib/baremetal.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131225/new/

https://reviews.llvm.org/D131225

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119837: [RISCV] Fix the include search path order between sysroot and resource folder

2022-02-16 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

In D119837#3326179 , @asb wrote:

> Thanks Kito. This LGTM, but I'd appreciate someone else reviewing and 
> approving as well.

Looks ok to me too.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119837/new/

https://reviews.llvm.org/D119837

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93023: Replace deprecated %T in 2 tests.

2020-12-10 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh created this revision.
abidh added a reviewer: MaskRay.
abidh added a project: clang.
Herald added subscribers: frasercrmck, luismarques, apazos, sameer.abuasal, 
pzheng, s.egerton, lenary, Jim, jocewei, PkmX, the_o, brucehoult, 
MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, 
simoncook, johnrusso, rbar, asb.
abidh requested review of this revision.
Herald added a subscriber: cfe-commits.

In D91442 , @MaskRay commented about a failure 
that he is seeing. As per his suggestion, I have replaced %T with %t. Patterns 
needs a little adjustment to match this change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93023

Files:
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain-extra.c


Index: clang/test/Driver/riscv64-toolchain-extra.c
===
--- clang/test/Driver/riscv64-toolchain-extra.c
+++ clang/test/Driver/riscv64-toolchain-extra.c
@@ -11,25 +11,25 @@
 // The test below checks that the driver correctly finds the linker and
 // runtime if and only if they exist.
 //
-// RUN: rm -rf %T/testroot-riscv64-baremetal-nogcc
-// RUN: mkdir -p %T/testroot-riscv64-baremetal-nogcc/bin
-// RUN: ln -s %clang %T/testroot-riscv64-baremetal-nogcc/bin/clang
-// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld 
%T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld
-// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf 
%T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf
-// RUN: %T/testroot-riscv64-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
-// RUN:--gcc-toolchain=%T/testroot-riscv64-baremetal-nogcc/invalid \
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/testroot-riscv64-baremetal-nogcc/bin
+// RUN: ln -s %clang %t/testroot-riscv64-baremetal-nogcc/bin/clang
+// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld 
%t/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld
+// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf 
%t/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf
+// RUN: %t/testroot-riscv64-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
+// RUN:--gcc-toolchain=%t/testroot-riscv64-baremetal-nogcc/invalid \
 // RUN:-target riscv64-unknown-elf --rtlib=platform -fuse-ld= 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 
-// RUN: %T/testroot-riscv64-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
+// RUN: %t/testroot-riscv64-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
 // RUN:-target riscv64-unknown-elf --rtlib=platform -fuse-ld= 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 
-// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/include"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib/crt0.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/clang_rt.crtbegin-riscv64.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib"
+// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" 
"{{.*}}/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/include"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib/crt0.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/clang_rt.crtbegin-riscv64.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib"
 // C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/libclang_rt.builtins-riscv64.a"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/clang_rt.crtend-riscv64.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/libclang_rt.builtins-riscv64.a"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/clang_rt.crtend-riscv64.o"
Index: clang/test/Driver/riscv32-toolchain-extra.c
===
--- clang/test/Driver/riscv32-toolchain-extra.c
+++ clang/test/Driver/riscv32-toolchain-extra.c
@@ -11,25 +11,25 @@
 // The test below checks that the driver correctly finds the linker and
 // runtime if and only if they exist.
 //
-// RUN: rm -rf %T/testroot-riscv32-baremetal-nogcc
-// RUN: mkdir -p %T/testroot-riscv32-baremetal-nogcc/bin
-/

[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-12-10 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

In D91442#2444399 , @MaskRay wrote:

> This change has been failing on my machine for the past two weeks.
>
> `riscv32-toolchain-extra.c` and `riscv64-toolchain-extra.c` are not hermit. I 
> have installed `/usr/lib/gcc-cross/riscv64-linux-gnu/10` 
> (gcc-10-riscv64-linux-gnu and its dependencies) on my machine and the test 
> will find some directories relative to 
> `/usr/lib/gcc-cross/riscv64-linux-gnu/10`. I think `--sysroot` is required 
> for such tests.
>
> `%T` is a deprecated lit feature. Please do something like `rm -rf %t; mkdir 
> %t` instead.

Hi MaskRay,
Thanks for reporting this issue. I don't fully understand how test is finding 
directories relative to some other location. But I have opened 
https://reviews.llvm.org/D93023 to replace %T with %t as you suggested. Please 
have a look and see if this fixes your issue.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91442/new/

https://reviews.llvm.org/D91442

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93023: Replace deprecated %T in 2 tests.

2020-12-10 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

In D93023#2446757 , @MaskRay wrote:

> If you do this, `testroot-riscv64-baremetal-nogcc/` is probably also not 
> useful (or you can replace it with a shorter string`.
>
> Can you fix the tests when gcc-riscv64-linux-gnu is installed?

Can you send me the error messages that failing testcase is printing?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93023/new/

https://reviews.llvm.org/D93023

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93023: Replace deprecated %T in 2 tests.

2020-12-14 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

It seems that testcase I added has brought to surface a hidden issue. If you
look at the end of Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes,
it adds sysroot/usr to the Prefixes. If the sysroot is empty, this will end up
using the toolchain that you installed in /usr.

This code path is only taken if --gcc-toolchain is empty (or not given). The
mips-reduced-toolchain.cpp is a good example as testcase is dependent on this
behavior. If user provides a non-empty gcc-toolchain path, even if that path is
non-existent, this code path is not taken. This is why riscv32-toolchain-extra.c
did not fail before because it used an invalid path and not empty path for
--gcc-toolchain.

As a result of this behavior, if the user of RISCVToolChain does not provide a
--gcc-toolchain, what happens is dependent of whether user had a riscv
toolchain in /usr directory.

1. If a toolchain was present then clang will pick it
2. Otherwise clang will try clang_dir/../ (see RISCVToolChain::computeSysRoot())

For cross toolchains, this seems fragile to me. In this case, clang is picking
runtime bits from a riscv64-linux-gnu for riscv32/64-unknown-elf target. This
may cause difficult to debug problem.

I would wait for users of RISCVToolChain to comment if this is expected 
behavior.
If yes then I can probably update the test on the pattern of 
mips-reduced-toolchain.cpp.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93023/new/

https://reviews.llvm.org/D93023

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93138: Add initial support for multilibs in Baremetal toolchain.

2020-12-14 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
abidh marked 3 inline comments as done.
Closed by commit rG670686ad8ecc: Add initial support for multilibs in Baremetal 
toolchain. (authored by abidh).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93138/new/

https://reviews.llvm.org/D93138

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/BareMetal.h
  clang/test/Driver/baremetal.cpp

Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -233,3 +233,113 @@
 // CHECK-RV64-NDL-SAME: "-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-RV64-NDL-SAME: "-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}basic_riscv64_tree{{[/\\]+}}riscv64-unknown-elf{{[/\\]+}}lib"
 // CHECK-RV64-NDL-SAME: "-o" "{{.*}}.o"
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target riscv64-unknown-elf \
+// RUN: -march=rv64imafdc -mabi=lp64d \
+// RUN: --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf \
+// RUN:   | FileCheck --check-prefix=CHECK-RV64FD %s
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target riscv64-unknown-elf \
+// RUN: -march=rv64gc -mabi=lp64d \
+// RUN: --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf \
+// RUN:   | FileCheck --check-prefix=CHECK-RV64FD %s
+
+// CHECK-RV64FD: "[[PREFIX_DIR:.*]]{{[/\\]+}}{{[^/^\\]+}}{{[/\\]+}}clang{{.*}}" "-cc1" "-triple" "riscv64-unknown-unknown-elf"
+// CHECK-RV64FD-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-RV64FD-SAME: "-isysroot" "[[SYSROOT:[^"]*]]"
+// CHECK-RV64FD-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}rv64imafdc{{[/\\]+}}lp64d{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
+// CHECk-RV64FD-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}rv64imafdc{{[/\\]+}}lp64d{{[/\\]+}}include"
+// CHECK-RV64FD-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
+// CHECK-RV64FD-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-RV64FD-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal{{[/\\]+}}rv64imafdc{{[/\\]+}}lp64d"
+// CHECK-RV64FD-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}rv64imafdc{{[/\\]+}}lp64d{{[/\\]+}}lib"
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target riscv32-unknown-elf \
+// RUN: -march=rv32i -mabi=ilp32 \
+// RUN: --sysroot=%S/Inputs/basic_riscv32_tree/riscv32-unknown-elf \
+// RUN:   | FileCheck --check-prefix=CHECK-RV32I %s
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target riscv32-unknown-elf \
+// RUN: -march=rv32ic -mabi=ilp32 \
+// RUN: --sysroot=%S/Inputs/basic_riscv32_tree/riscv32-unknown-elf \
+// RUN:   | FileCheck --check-prefix=CHECK-RV32I %s
+
+// CHECK-RV32I: "[[PREFIX_DIR:.*]]{{[/\\]+}}{{[^/^\\]+}}{{[/\\]+}}clang{{.*}}" "-cc1" "-triple" "riscv32-unknown-unknown-elf"
+// CHECK-RV32I-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-RV32I-SAME: "-isysroot" "[[SYSROOT:[^"]*]]"
+// CHECK-RV32I-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}rv32i{{[/\\]+}}ilp32{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
+// CHECK-RV32I-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}rv32i{{[/\\]+}}ilp32{{[/\\]+}}include"
+// CHECK-RV32I-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
+// CHECK-RV32I-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-RV32I-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal{{[/\\]+}}rv32i{{[/\\]+}}ilp32"
+// CHECK-RV32I-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}rv32i{{[/\\]+}}ilp32{{[/\\]+}}lib"
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target riscv32-unknown-elf \
+// RUN: -march=rv32im -mabi=ilp32 \
+// RUN: --sysroot=%S/Inputs/basic_riscv32_tree/riscv32-unknown-elf \
+// RUN:   | FileCheck --check-prefix=CHECK-RV32IM %s
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target riscv32-unknown-elf \
+// RUN: -march=rv32imc -mabi=ilp32 \
+// RUN: --sysroot=%S/Inputs/basic_riscv32_tree/riscv32-unknown-elf \
+// RUN:   | FileCheck --check-prefix=CHECK-RV32IM %s
+
+// CHECK-RV32IM: "[[PREFIX_DIR:.*]]{{[/\\]+}}{{[^/^\\]+}}{{[/\\]+}}clang{{.*}}" "-cc1" "-triple" "riscv32-unknown-unknown-elf"
+// CHECK-RV32IM-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-RV32IM-SAME: "-isysroot" "[[SYSROOT:[^"]*]]"
+// CHECK-RV32IM-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}rv32im{{[/\\]+}}ilp32{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
+// CHECK-RV32IM-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}rv32im{{[/\\]+}}ilp32{{[/\\]+}}include"
+// CHECK-RV32IM-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
+// CHECK-RV32IM-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}

[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-13 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh created this revision.
abidh added reviewers: asb, jroelofs, manojgupta, clang.
Herald added subscribers: cfe-commits, frasercrmck, luismarques, apazos, 
sameer.abuasal, pzheng, s.egerton, lenary, Jim, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, 
sabuasal, simoncook, johnrusso, rbar, kristof.beyls.
Herald added a project: clang.
abidh requested review of this revision.

I am working on a baremetal riscv toolchain using LLVM runtime and
LLD linker. Baremetal.cpp provides most of the things needed for such
toolchain. So I have modified it to also handle riscv64/32-unknown-elf
 targets alongside arm-none-eabi.

Currently, targets like riscv64-unknown-elf are handled by RISCVToolChain
which mostly expects a gcc toolchain to be present. If you dont
want the dependency on gcc-toolchain/libgloss or want to use LLD, then
RISCVToolChain is not a good fit.

So in the toolchain selection code, I have made this dependency of
RISCVToolChain on gcc toolchain explicit. It is created if gcc-toolchain
option is present. Otherwise Baremetal toolchain is created. I will be
happy to hear if there is a better way to choose between these two
toolchains.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91442

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal.cpp
  clang/test/Driver/riscv-gnutools.c
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain.c

Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -1,11 +1,13 @@
 // A basic clang -cc1 command-line, and simple environment check.
 // REQUIRES: platform-linker
 
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck -check-prefix=CC1 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv64 \
+// RUN: --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv64"
 
 // Test interaction with -fuse-ld=lld, if lld is available.
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld 2>&1 | FileCheck -check-prefix=LLD %s
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld \
+// RUN: --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 | FileCheck -check-prefix=LLD %s
 // LLD: {{(error: invalid linker name in argument '-fuse-ld=lld')|(ld.lld)}}
 
 // In the below tests, --rtlib=platform is used so that the driver ignores
@@ -133,6 +135,7 @@
 
 // Check that --rtlib can be used to override the used runtime library
 // RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk \
 // RUN:   -target riscv64-unknown-elf --rtlib=libgcc 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-RTLIB-LIBGCC-LP64 %s
 // C-RV64-RTLIB-LIBGCC-LP64: "{{.*}}crt0.o"
@@ -141,6 +144,7 @@
 // C-RV64-RTLIB-LIBGCC-LP64: "{{.*}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk \
 // RUN:   -target riscv64-unknown-elf --rtlib=compiler-rt 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-RTLIB-COMPILERRT-LP64 %s
 // C-RV64-RTLIB-COMPILERRT-LP64: "{{.*}}crt0.o"
Index: clang/test/Driver/riscv32-toolchain.c
===
--- clang/test/Driver/riscv32-toolchain.c
+++ clang/test/Driver/riscv32-toolchain.c
@@ -1,11 +1,13 @@
 // A basic clang -cc1 command-line, and simple environment check.
 // REQUIRES: platform-linker
 
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 2>&1 | FileCheck -check-prefix=CC1 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 \
+// RUN: --gcc-toolchain=%S/Inputs/basic_riscv32_tree 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv32"
 
 // Test interaction with -fuse-ld=lld, if lld is available.
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld 2>&1 | FileCheck -check-prefix=LLD %s
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 \
+// RUN: --gcc-toolchain=%S/Inputs/basic_riscv32_tree -fuse-ld=lld 2>&1 | FileCheck -check-prefix=LLD %s
 // LLD: {{(error: invalid linker name in argument '-fuse-ld=lld')|(ld.lld)}}
 
 // In the below tests, --rtlib=platform is used so that the driver ignores
@@ -177,6 +179,7 @@
 
 // Check that --rtlib can be used to override the used runtime library
 // RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk \
 // RUN:   -target riscv32-unknown-elf --rtlib=libgcc 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV32-RTLIB-LIBGCC-ILP32 %s
 // C-RV32-RTLIB-LIBGCC-ILP32: "{{.*}}crt0.o"
@@ -185,6 +188,7 @@
 // C-RV32-RTLIB-LIBGCC-ILP32: "{{.*}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes \

[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-13 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

In D91442#2394513 , @jrtc27 wrote:

> We use pure LLVM toolchains so improving support for that out of the box is 
> good in my books. However, I do worry this is going to cause friction for a 
> lot of people using LLVM for RISC-V; my understanding is that most use LLVM 
> with a GNU sysroot and binutils, and so this looks like it will break their 
> setups. Is there anything that can be done to automatically detect such 
> cases? What does Arm do here?

That was one of my concern too. Unlike riscv, Arm does not have an explicit 
check so it falls in the default where it picks Baremetal.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91442/new/

https://reviews.llvm.org/D91442

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91559: Add sysroot/lib to library search path of baremetal toolchain.

2020-11-16 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh created this revision.
abidh added reviewers: jroelofs, clang.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
abidh requested review of this revision.

Baremetal toolchain is not adding sysroot/lib to the library
search path. This is forcing the user to do it manually. This commit
fixes this shortcoming by adding the sysroot/lib to library search path
if sysroot is not empty.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91559

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal.cpp


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -12,6 +12,7 @@
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-C-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" 
"-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
 // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
@@ -34,6 +35,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-DEFAULTCXX %s
 // CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-DEFAULTCXX-SAME: "-o" "{{.*}}.o"
@@ -47,6 +49,7 @@
 // CHECK-V6M-LIBCXX: "-internal-isystem" 
"{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECK-V6M-LIBCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
 // CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"
@@ -60,6 +63,7 @@
 // CHECK-V6M-LIBSTDCXX: "-internal-isystem" 
"{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}6.0.0"
 // CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBSTDCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBSTDCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind"
 // CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBSTDCXX-SAME: "-o" "{{.*}}.o"
@@ -70,7 +74,8 @@
 // RUN: -nodefaultlibs \
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-NDL %s
 // CHECK-V6M-NDL: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" 
"-Bstatic"
-// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 "-o" "{{.*}}.o"
+// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib" "-o" 
"{{.*}}.o"
 
 // RUN: %clangxx -target arm-none-eabi -v 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-THREAD-MODEL
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -33,6 +33,11 @@
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getProgramPaths().push_back(getDriver().Dir);
+  SmallString<128> SysRoot(getDriver().SysRoot);
+  if (!SysRoot.empty()) {
+llvm::sys::path::append(SysRoot, "lib");
+getFilePaths().push_back(std::string(SysRoot.str()));
+  }
 }
 
 /// Is the triple {arm,thumb}-none-none-{eabi,eabihf} ?
@@ -189,6 +194,7 @@
 
   CmdArgs.push_back(Args.MakeArgString("-L" + TC.getRuntimesDir()));
 
+  TC.AddFilePathLibArgs(Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_e, options::OPT_s, options::OPT_t,
 options::OPT_Z_Flag, options::OPT_r});


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -12,6 +12,7 @@
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}bareme

[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-16 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh updated this revision to Diff 305573.
abidh added a comment.

Made the condition consistent in both places where Baremetal toolchain is 
instantiated as suggested in review.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91442/new/

https://reviews.llvm.org/D91442

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal.cpp
  clang/test/Driver/riscv-gnutools.c
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain.c

Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -1,11 +1,13 @@
 // A basic clang -cc1 command-line, and simple environment check.
 // REQUIRES: platform-linker
 
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck -check-prefix=CC1 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv64 \
+// RUN: --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv64"
 
 // Test interaction with -fuse-ld=lld, if lld is available.
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld 2>&1 | FileCheck -check-prefix=LLD %s
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld \
+// RUN: --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 | FileCheck -check-prefix=LLD %s
 // LLD: {{(error: invalid linker name in argument '-fuse-ld=lld')|(ld.lld)}}
 
 // In the below tests, --rtlib=platform is used so that the driver ignores
@@ -133,6 +135,7 @@
 
 // Check that --rtlib can be used to override the used runtime library
 // RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk \
 // RUN:   -target riscv64-unknown-elf --rtlib=libgcc 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-RTLIB-LIBGCC-LP64 %s
 // C-RV64-RTLIB-LIBGCC-LP64: "{{.*}}crt0.o"
@@ -141,6 +144,7 @@
 // C-RV64-RTLIB-LIBGCC-LP64: "{{.*}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk \
 // RUN:   -target riscv64-unknown-elf --rtlib=compiler-rt 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-RTLIB-COMPILERRT-LP64 %s
 // C-RV64-RTLIB-COMPILERRT-LP64: "{{.*}}crt0.o"
Index: clang/test/Driver/riscv32-toolchain.c
===
--- clang/test/Driver/riscv32-toolchain.c
+++ clang/test/Driver/riscv32-toolchain.c
@@ -1,11 +1,13 @@
 // A basic clang -cc1 command-line, and simple environment check.
 // REQUIRES: platform-linker
 
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 2>&1 | FileCheck -check-prefix=CC1 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 \
+// RUN: --gcc-toolchain=%S/Inputs/basic_riscv32_tree 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv32"
 
 // Test interaction with -fuse-ld=lld, if lld is available.
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld 2>&1 | FileCheck -check-prefix=LLD %s
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 \
+// RUN: --gcc-toolchain=%S/Inputs/basic_riscv32_tree -fuse-ld=lld 2>&1 | FileCheck -check-prefix=LLD %s
 // LLD: {{(error: invalid linker name in argument '-fuse-ld=lld')|(ld.lld)}}
 
 // In the below tests, --rtlib=platform is used so that the driver ignores
@@ -177,6 +179,7 @@
 
 // Check that --rtlib can be used to override the used runtime library
 // RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk \
 // RUN:   -target riscv32-unknown-elf --rtlib=libgcc 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV32-RTLIB-LIBGCC-ILP32 %s
 // C-RV32-RTLIB-LIBGCC-ILP32: "{{.*}}crt0.o"
@@ -185,6 +188,7 @@
 // C-RV32-RTLIB-LIBGCC-ILP32: "{{.*}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk \
 // RUN:   -target riscv32-unknown-elf --rtlib=compiler-rt 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV32-RTLIB-COMPILERRT-ILP32 %s
 // C-RV32-RTLIB-COMPILERRT-ILP32: "{{.*}}crt0.o"
Index: clang/test/Driver/riscv-gnutools.c
===
--- clang/test/Driver/riscv-gnutools.c
+++ clang/test/Driver/riscv-gnutools.c
@@ -5,15 +5,15 @@
 // 32-bit checks
 
 // Check default on riscv32-unknown-elf
-// RUN: %clang -target riscv32-unknown-elf -fno-integrated-as %s -### -c \
+// RUN: %clang -target riscv32-unknown-elf --gcc-toolchain=%S/Inputs/basic_riscv32_tree -fno-integrated-as %s -### -c \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32IMAC-ILP32 %s
 
 // Check default on riscv32-unknown-linux-gnu
-// RUN: %clang -target riscv32-unknown-linux-gnu -fno-integrated-as %s -### -c \
+// RUN: %clang -target riscv32-unknown-linux-gnu --gcc-toolchain=%S/Inputs/basic_riscv32_tree 

[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-16 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh marked an inline comment as done.
abidh added a comment.

In D91442#2394501 , @jroelofs wrote:

> Seems reasonable.
>
> I could see someone wanting to use `--gcc-toolchain` to point at the 
> baremetal toolchain for their target, but that's unlikely to work out of the 
> box anyway. I'd love to know where the Generic_GCC toolchain is used in 
> practice, since that's always seemed quite fragile to me.

Thanks for the review. I have handled the comment in updated diff. I will give 
it a few more days in case anyone else wants to comment before landing.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91442/new/

https://reviews.llvm.org/D91442

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-17 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

In D91442#2399200 , @lenary wrote:

> I'm worried about this change - I *think* it doesn't cover the existing 
> behaviour of a baremetal GCC toolchain being installed into the same prefix 
> as clang, and clang automatically picking up that baremetal gcc toolchain. 
> What should we expect to do here? This is especially an issue if you're 
> trying to make a relocatable toolchain tarball, where specifying 
> `--gcc-toolchain` automatically is difficult.

Would it be possible to use a relative path with --gcc-toolchain then this can 
be checked in either RISCVToolChain.cpp or GNU.cpp and adjusted accordingly?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91442/new/

https://reviews.llvm.org/D91442

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-17 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

In D91442#2399402 , @lenary wrote:

> In D91442#2399341 , @abidh wrote:
>
>> In D91442#2399200 , @lenary wrote:
>>
>>> I'm worried about this change - I *think* it doesn't cover the existing 
>>> behaviour of a baremetal GCC toolchain being installed into the same prefix 
>>> as clang, and clang automatically picking up that baremetal gcc toolchain. 
>>> What should we expect to do here? This is especially an issue if you're 
>>> trying to make a relocatable toolchain tarball, where specifying 
>>> `--gcc-toolchain` automatically is difficult.
>>
>> Would it be possible to use a relative path with --gcc-toolchain then this 
>> can be checked in either RISCVToolChain.cpp or GNU.cpp and adjusted 
>> accordingly?
>
> The GCC toolchain, when given a relative path, already interprets it relative 
> to the working directory the compiler was invoked from, not the directory the 
> compiler is located in, iirc.

I dont think path is made absolute relative using working directory. What is 
happening is that if (!VFS.exists(Prefix)) call in the following line will 
succeed if the path existed relative to working directory. This seems 
accidental to me.

https://github.com/llvm/llvm-project/blob/5a9f3867046c4e1c97760e22a505f4d1d788417e/clang/lib/Driver/ToolChains/Gnu.cpp#L1947

I tried a small change to turn a relative --gcc-toolchain into absolute using 
the compiler installed path and it works ok.  If this is something that works 
for you then I can post a patch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91442/new/

https://reviews.llvm.org/D91442

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-17 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

In D91442#2399753 , @jrtc27 wrote:

> In D91442#2399750 , @abidh wrote:
>
>> In D91442#2399402 , @lenary wrote:
>>
>>> In D91442#2399341 , @abidh wrote:
>>>
 In D91442#2399200 , @lenary wrote:

> I'm worried about this change - I *think* it doesn't cover the existing 
> behaviour of a baremetal GCC toolchain being installed into the same 
> prefix as clang, and clang automatically picking up that baremetal gcc 
> toolchain. What should we expect to do here? This is especially an issue 
> if you're trying to make a relocatable toolchain tarball, where 
> specifying `--gcc-toolchain` automatically is difficult.

 Would it be possible to use a relative path with --gcc-toolchain then this 
 can be checked in either RISCVToolChain.cpp or GNU.cpp and adjusted 
 accordingly?
>>>
>>> The GCC toolchain, when given a relative path, already interprets it 
>>> relative to the working directory the compiler was invoked from, not the 
>>> directory the compiler is located in, iirc.
>>
>> I dont think path is made absolute relative using working directory. What is 
>> happening is that if (!VFS.exists(Prefix)) call in the following line will 
>> succeed if the path existed relative to working directory. This seems 
>> accidental to me.
>>
>> https://github.com/llvm/llvm-project/blob/5a9f3867046c4e1c97760e22a505f4d1d788417e/clang/lib/Driver/ToolChains/Gnu.cpp#L1947
>>
>> I tried a small change to turn a relative --gcc-toolchain into absolute 
>> using the compiler installed path and it works ok.  If this is something 
>> that works for you then I can post a patch.
>
> Relative paths should be relative to the current working directory. That is 
> what everyone expects and is what every other argument does (and see `=` and 
> `$SYSROOT` for how GCC and compatible drivers get around that in cases like 
> -I).

The constructor of Driver class in clang resolves the default sysroot relative 
to install directory.  That gave me the idea that perhaps similar thing could 
be done with gcc-toolchain too. I dont have a strong opinion on it either way. 
I am just trying to find a way where current RISCVToolChain based toolchain 
continue working while I can instantiate Baremetal toolchain.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91442/new/

https://reviews.llvm.org/D91442

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-17 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

In D91442#2399772 , @lenary wrote:

> I recall that there is also https://reviews.llvm.org/D68407 which iirc hoped 
> to address using `RISCVToolchain` with Compiler-rt and libunwind - presumably 
> it is not a complete solution, but it might be we want to use some checking 
> of the GCCInstallation (like `RISCVToolChain::GetDefaultRuntimeLibType` does) 
> to choose which toolchain to instantiate? I'm not sure if we can satisfy that 
> ordering though.

But that function is not static and you need to instantiate the RISCVToolChain 
to use things like GCCInstallation.isValid().


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91442/new/

https://reviews.llvm.org/D91442

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91559: Add sysroot/lib to library search path of baremetal toolchain.

2020-11-18 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh updated this revision to Diff 306036.
abidh added a comment.

Handle review comment.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91559/new/

https://reviews.llvm.org/D91559

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal.cpp


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -12,6 +12,7 @@
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-C-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" 
"-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
 // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
@@ -34,6 +35,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-DEFAULTCXX %s
 // CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-DEFAULTCXX-SAME: "-o" "{{.*}}.o"
@@ -47,6 +49,7 @@
 // CHECK-V6M-LIBCXX: "-internal-isystem" 
"{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECK-V6M-LIBCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
 // CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"
@@ -60,6 +63,7 @@
 // CHECK-V6M-LIBSTDCXX: "-internal-isystem" 
"{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}6.0.0"
 // CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBSTDCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBSTDCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind"
 // CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBSTDCXX-SAME: "-o" "{{.*}}.o"
@@ -70,7 +74,8 @@
 // RUN: -nodefaultlibs \
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-NDL %s
 // CHECK-V6M-NDL: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" 
"-Bstatic"
-// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 "-o" "{{.*}}.o"
+// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib" "-o" 
"{{.*}}.o"
 
 // RUN: %clangxx -target arm-none-eabi -v 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-THREAD-MODEL
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -33,6 +33,11 @@
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getProgramPaths().push_back(getDriver().Dir);
+  SmallString<128> SysRoot(getDriver().SysRoot);
+  if (!SysRoot.empty()) {
+llvm::sys::path::append(SysRoot, "lib");
+getFilePaths().push_back(std::string(SysRoot));
+  }
 }
 
 /// Is the triple {arm,thumb}-none-none-{eabi,eabihf} ?
@@ -189,6 +194,7 @@
 
   CmdArgs.push_back(Args.MakeArgString("-L" + TC.getRuntimesDir()));
 
+  TC.AddFilePathLibArgs(Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_e, options::OPT_s, options::OPT_t,
 options::OPT_Z_Flag, options::OPT_r});


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -12,6 +12,7 @@
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
 // CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-C-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" "-Lsome{{[/\\

[PATCH] D91559: Add sysroot/lib to library search path of baremetal toolchain.

2020-11-18 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh marked an inline comment as done.
abidh added inline comments.



Comment at: clang/lib/Driver/ToolChains/BareMetal.cpp:39
+llvm::sys::path::append(SysRoot, "lib");
+getFilePaths().push_back(std::string(SysRoot.str()));
+  }

jroelofs wrote:
> Is the explicit `std::string` ctor call necessary here? Since `SmallString` 
> has an `operator std::string() const`, I think this can just be:
> 
> ```
> getFilePaths().push_back(SysRoot);
> ```
That operator is explicit. Although I noticed that I did not need the str() 
call.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91559/new/

https://reviews.llvm.org/D91559

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91559: Add sysroot/lib to library search path of baremetal toolchain.

2020-11-18 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
abidh marked an inline comment as done.
Closed by commit rG8cdc53887387: Add sysroot/lib to library search path of 
baremetal toolchain. (authored by abidh).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91559/new/

https://reviews.llvm.org/D91559

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal.cpp


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -12,6 +12,7 @@
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-C-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" 
"-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
 // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
@@ -34,6 +35,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-DEFAULTCXX %s
 // CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-DEFAULTCXX-SAME: "-o" "{{.*}}.o"
@@ -47,6 +49,7 @@
 // CHECK-V6M-LIBCXX: "-internal-isystem" 
"{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECK-V6M-LIBCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
 // CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"
@@ -60,6 +63,7 @@
 // CHECK-V6M-LIBSTDCXX: "-internal-isystem" 
"{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}6.0.0"
 // CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBSTDCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBSTDCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind"
 // CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBSTDCXX-SAME: "-o" "{{.*}}.o"
@@ -70,7 +74,8 @@
 // RUN: -nodefaultlibs \
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-NDL %s
 // CHECK-V6M-NDL: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" 
"-Bstatic"
-// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 "-o" "{{.*}}.o"
+// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib" "-o" 
"{{.*}}.o"
 
 // RUN: %clangxx -target arm-none-eabi -v 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-THREAD-MODEL
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -33,6 +33,11 @@
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getProgramPaths().push_back(getDriver().Dir);
+  SmallString<128> SysRoot(getDriver().SysRoot);
+  if (!SysRoot.empty()) {
+llvm::sys::path::append(SysRoot, "lib");
+getFilePaths().push_back(std::string(SysRoot));
+  }
 }
 
 /// Is the triple {arm,thumb}-none-none-{eabi,eabihf} ?
@@ -189,6 +194,7 @@
 
   CmdArgs.push_back(Args.MakeArgString("-L" + TC.getRuntimesDir()));
 
+  TC.AddFilePathLibArgs(Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_e, options::OPT_s, options::OPT_t,
 options::OPT_Z_Flag, options::OPT_r});


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -12,6 +12,7 @@
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
 // CHECK-V6M-C-

[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-18 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh updated this revision to Diff 306180.
abidh added a comment.
Herald added a subscriber: MaskRay.

This update contains following changes.

1. Address issue raised by lenary. I have introduced a static function that 
checks for the presence of gcc toolchain first by --gcc-toolchain argument or 
in the same prefix where clang is installed. If found, RISCVToolChain is 
instantiated. I have added tests in riscv64-toolchain-extra.c and 
riscv32-toolchain-extra.c to check this case.

2. Fixed some formatting things pointed out by jrtc27.

3. In the initial revision, jroelofs commented that other place where Baremetal 
is intantiated should have the similar check. I put that in 2nd version of the 
patch. But I think it does quite make sense in the current patch so I have 
removed it.

4. Rebased baremetal.cpp tests after recent changes and fixed some typos.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91442/new/

https://reviews.llvm.org/D91442

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.h
  clang/test/Driver/baremetal.cpp
  clang/test/Driver/riscv-gnutools.c
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain.c

Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -1,11 +1,15 @@
 // A basic clang -cc1 command-line, and simple environment check.
 // REQUIRES: platform-linker
 
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck -check-prefix=CC1 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv64 \
+// RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
+// RUN:   | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv64"
 
 // Test interaction with -fuse-ld=lld, if lld is available.
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld 2>&1 | FileCheck -check-prefix=LLD %s
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld \
+// RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
+// RUN:   | FileCheck -check-prefix=LLD %s
 // LLD: {{(error: invalid linker name in argument '-fuse-ld=lld')|(ld.lld)}}
 
 // In the below tests, --rtlib=platform is used so that the driver ignores
@@ -133,6 +137,7 @@
 
 // Check that --rtlib can be used to override the used runtime library
 // RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk \
 // RUN:   -target riscv64-unknown-elf --rtlib=libgcc 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-RTLIB-LIBGCC-LP64 %s
 // C-RV64-RTLIB-LIBGCC-LP64: "{{.*}}crt0.o"
@@ -141,6 +146,7 @@
 // C-RV64-RTLIB-LIBGCC-LP64: "{{.*}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk \
 // RUN:   -target riscv64-unknown-elf --rtlib=compiler-rt 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-RTLIB-COMPILERRT-LP64 %s
 // C-RV64-RTLIB-COMPILERRT-LP64: "{{.*}}crt0.o"
Index: clang/test/Driver/riscv64-toolchain-extra.c
===
--- clang/test/Driver/riscv64-toolchain-extra.c
+++ clang/test/Driver/riscv64-toolchain-extra.c
@@ -22,6 +22,10 @@
 // RUN:-target riscv64-unknown-elf --rtlib=platform 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 
+// RUN: %T/testroot-riscv64-baremetal-nogcc/bin/clang %s -### -no-canonical-prefixes \
+// RUN:-target riscv64-unknown-elf --rtlib=platform 2>&1 \
+// RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
+
 // C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/include"
 // C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld"
 // C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib/crt0.o"
Index: clang/test/Driver/riscv32-toolchain.c
===
--- clang/test/Driver/riscv32-toolchain.c
+++ clang/test/Driver/riscv32-toolchain.c
@@ -1,11 +1,15 @@
 // A basic clang -cc1 command-line, and simple environment check.
 // REQUIRES: platform-linker
 
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 2>&1 | FileCheck -check-prefix=CC1 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 \
+// RUN:   --gcc-toolchain=%S/Inputs/basic_riscv32_tree 2>&1 \
+// RUN:   | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv32"
 
 // Test interaction with -fuse-ld=lld, if lld is available.
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv32

[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-24 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

Hi @lenary,
Do you any more comments on the patch?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91442/new/

https://reviews.llvm.org/D91442

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-26 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG45ba2392d7e0: [clang][Driver] Handle risvc in Baremetal.cpp. 
(authored by abidh).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91442/new/

https://reviews.llvm.org/D91442

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.h
  clang/test/Driver/baremetal.cpp
  clang/test/Driver/riscv-gnutools.c
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain.c

Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -1,11 +1,15 @@
 // A basic clang -cc1 command-line, and simple environment check.
 // REQUIRES: platform-linker
 
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck -check-prefix=CC1 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv64 \
+// RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
+// RUN:   | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv64"
 
 // Test interaction with -fuse-ld=lld, if lld is available.
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld 2>&1 | FileCheck -check-prefix=LLD %s
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld \
+// RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
+// RUN:   | FileCheck -check-prefix=LLD %s
 // LLD: {{(error: invalid linker name in argument '-fuse-ld=lld')|(ld.lld)}}
 
 // In the below tests, --rtlib=platform is used so that the driver ignores
@@ -133,6 +137,7 @@
 
 // Check that --rtlib can be used to override the used runtime library
 // RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk \
 // RUN:   -target riscv64-unknown-elf --rtlib=libgcc 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-RTLIB-LIBGCC-LP64 %s
 // C-RV64-RTLIB-LIBGCC-LP64: "{{.*}}crt0.o"
@@ -141,6 +146,7 @@
 // C-RV64-RTLIB-LIBGCC-LP64: "{{.*}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk \
 // RUN:   -target riscv64-unknown-elf --rtlib=compiler-rt 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-RTLIB-COMPILERRT-LP64 %s
 // C-RV64-RTLIB-COMPILERRT-LP64: "{{.*}}crt0.o"
Index: clang/test/Driver/riscv64-toolchain-extra.c
===
--- clang/test/Driver/riscv64-toolchain-extra.c
+++ clang/test/Driver/riscv64-toolchain-extra.c
@@ -22,6 +22,10 @@
 // RUN:-target riscv64-unknown-elf --rtlib=platform 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 
+// RUN: %T/testroot-riscv64-baremetal-nogcc/bin/clang %s -### -no-canonical-prefixes \
+// RUN:-target riscv64-unknown-elf --rtlib=platform 2>&1 \
+// RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
+
 // C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/include"
 // C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld"
 // C-RV64-BAREMETAL-LP64-NOGCC: "{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib/crt0.o"
Index: clang/test/Driver/riscv32-toolchain.c
===
--- clang/test/Driver/riscv32-toolchain.c
+++ clang/test/Driver/riscv32-toolchain.c
@@ -1,11 +1,15 @@
 // A basic clang -cc1 command-line, and simple environment check.
 // REQUIRES: platform-linker
 
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 2>&1 | FileCheck -check-prefix=CC1 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 \
+// RUN:   --gcc-toolchain=%S/Inputs/basic_riscv32_tree 2>&1 \
+// RUN:   | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "riscv32"
 
 // Test interaction with -fuse-ld=lld, if lld is available.
-// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld 2>&1 | FileCheck -check-prefix=LLD %s
+// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 \
+// RUN:   --gcc-toolchain=%S/Inputs/basic_riscv32_tree -fuse-ld=lld 2>&1 \
+// RUN:   | FileCheck -check-prefix=LLD %s
 // LLD: {{(error: invalid linker name in argument '-fuse-ld=lld')|(ld.lld)}}
 
 // In the below tests, --rtlib=platform is used so that the driver ignores
@@ -177,6 +181,7 @@
 
 // Check that --rtlib can be used to override the used runtime library
 // RUN: %clang %s -### -no-canonical-prefixes \
+// RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_elf_sdk \
 // RUN:   -target riscv32-unknown-elf --rtlib=libgcc 2>&

[PATCH] D92176: Don't use sysroot/include when sysroot is empty.

2020-11-26 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh created this revision.
abidh added reviewers: jroelofs, manojgupta, cjdb.
abidh added a project: clang.
Herald added a subscriber: cfe-commits.
abidh requested review of this revision.

Baremetal toolchain add Driver.SysRoot/include to the system include
paths without checking if Driver.SysRoot is empty. This resulted in
"-internal-isystem" "include" in the command. This patch adds check for
empty sysroot.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92176

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal.cpp


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -93,6 +93,10 @@
 // RUN:   | FileCheck %s --check-prefix=CHECK-RTLIB-GCC
 // CHECK-RTLIB-GCC: -lgcc
 
+// RUN: %clang -### -target arm-none-eabi -v %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-SYSROOT-INC
+// CHECK-SYSROOT-INC-NOT: "-internal-isystem" "include"
+
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target riscv64-unknown-elf \
 // RUN: -L some/directory/user/asked/for \
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -107,8 +107,10 @@
 
   if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
 SmallString<128> Dir(getDriver().SysRoot);
-llvm::sys::path::append(Dir, "include");
-addSystemInclude(DriverArgs, CC1Args, Dir.str());
+if (!Dir.empty()) {
+  llvm::sys::path::append(Dir, "include");
+  addSystemInclude(DriverArgs, CC1Args, Dir.str());
+}
   }
 }
 


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -93,6 +93,10 @@
 // RUN:   | FileCheck %s --check-prefix=CHECK-RTLIB-GCC
 // CHECK-RTLIB-GCC: -lgcc
 
+// RUN: %clang -### -target arm-none-eabi -v %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-SYSROOT-INC
+// CHECK-SYSROOT-INC-NOT: "-internal-isystem" "include"
+
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target riscv64-unknown-elf \
 // RUN: -L some/directory/user/asked/for \
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -107,8 +107,10 @@
 
   if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
 SmallString<128> Dir(getDriver().SysRoot);
-llvm::sys::path::append(Dir, "include");
-addSystemInclude(DriverArgs, CC1Args, Dir.str());
+if (!Dir.empty()) {
+  llvm::sys::path::append(Dir, "include");
+  addSystemInclude(DriverArgs, CC1Args, Dir.str());
+}
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92176: Don't use sysroot/include when sysroot is empty.

2020-12-04 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

@jroelofs Do you have any comments on this patch?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92176/new/

https://reviews.llvm.org/D92176

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92176: Don't use sysroot/include when sysroot is empty.

2020-12-04 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGca2888310b24: Don't use sysroot/include when sysroot is 
empty. (authored by abidh).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92176/new/

https://reviews.llvm.org/D92176

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal.cpp


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -93,6 +93,10 @@
 // RUN:   | FileCheck %s --check-prefix=CHECK-RTLIB-GCC
 // CHECK-RTLIB-GCC: -lgcc
 
+// RUN: %clang -### -target arm-none-eabi -v %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-SYSROOT-INC
+// CHECK-SYSROOT-INC-NOT: "-internal-isystem" "include"
+
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target riscv64-unknown-elf \
 // RUN: -L some/directory/user/asked/for \
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -107,8 +107,10 @@
 
   if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
 SmallString<128> Dir(getDriver().SysRoot);
-llvm::sys::path::append(Dir, "include");
-addSystemInclude(DriverArgs, CC1Args, Dir.str());
+if (!Dir.empty()) {
+  llvm::sys::path::append(Dir, "include");
+  addSystemInclude(DriverArgs, CC1Args, Dir.str());
+}
   }
 }
 


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -93,6 +93,10 @@
 // RUN:   | FileCheck %s --check-prefix=CHECK-RTLIB-GCC
 // CHECK-RTLIB-GCC: -lgcc
 
+// RUN: %clang -### -target arm-none-eabi -v %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-SYSROOT-INC
+// CHECK-SYSROOT-INC-NOT: "-internal-isystem" "include"
+
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target riscv64-unknown-elf \
 // RUN: -L some/directory/user/asked/for \
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -107,8 +107,10 @@
 
   if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
 SmallString<128> Dir(getDriver().SysRoot);
-llvm::sys::path::append(Dir, "include");
-addSystemInclude(DriverArgs, CC1Args, Dir.str());
+if (!Dir.empty()) {
+  llvm::sys::path::append(Dir, "include");
+  addSystemInclude(DriverArgs, CC1Args, Dir.str());
+}
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92677: Provide default location of sysroot for Baremetal toolchain.

2020-12-04 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh created this revision.
abidh added reviewers: mcarrasco, jroelofs.
abidh added a project: clang.
Herald added subscribers: s.egerton, PkmX, simoncook, kristof.beyls.
abidh requested review of this revision.
Herald added a subscriber: cfe-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92677

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/BareMetal.h
  clang/test/Driver/baremetal-sysroot.cpp


Index: clang/test/Driver/baremetal-sysroot.cpp
===
--- /dev/null
+++ clang/test/Driver/baremetal-sysroot.cpp
@@ -0,0 +1,22 @@
+// 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"
Index: clang/lib/Driver/ToolChains/BareMetal.h
===
--- clang/lib/Driver/ToolChains/BareMetal.h
+++ clang/lib/Driver/ToolChains/BareMetal.h
@@ -67,6 +67,7 @@
llvm::opt::ArgStringList &CmdArgs) const override;
   void AddLinkRuntimeLib(const llvm::opt::ArgList &Args,
  llvm::opt::ArgStringList &CmdArgs) const;
+  std::string computeSysRoot() const override;
 };
 
 } // namespace toolchains
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -33,7 +33,7 @@
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getProgramPaths().push_back(getDriver().Dir);
-  SmallString<128> SysRoot(getDriver().SysRoot);
+  SmallString<128> SysRoot(computeSysRoot());
   if (!SysRoot.empty()) {
 llvm::sys::path::append(SysRoot, "lib");
 getFilePaths().push_back(std::string(SysRoot));
@@ -94,6 +94,20 @@
   return std::string(Dir.str());
 }
 
+std::string BareMetal::computeSysRoot() const {
+  if (!getDriver().SysRoot.empty())
+return getDriver().SysRoot;
+
+  SmallString<128> SysRootDir;
+  llvm::sys::path::append(SysRootDir, getDriver().Dir, "../lib/clang-runtimes",
+  getDriver().getTargetTriple());
+
+  if (!llvm::sys::fs::exists(SysRootDir))
+return std::string();
+
+  return std::string(SysRootDir.str());
+}
+
 void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
   ArgStringList &CC1Args) const {
   if (DriverArgs.hasArg(options::OPT_nostdinc))
@@ -106,7 +120,7 @@
   }
 
   if (!

[PATCH] D92677: Provide default location of sysroot for Baremetal toolchain.

2020-12-04 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh updated this revision to Diff 309637.
abidh added a comment.

Handled review comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92677/new/

https://reviews.llvm.org/D92677

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/BareMetal.h
  clang/test/Driver/baremetal-sysroot.cpp


Index: clang/test/Driver/baremetal-sysroot.cpp
===
--- /dev/null
+++ clang/test/Driver/baremetal-sysroot.cpp
@@ -0,0 +1,22 @@
+// 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"
Index: clang/lib/Driver/ToolChains/BareMetal.h
===
--- clang/lib/Driver/ToolChains/BareMetal.h
+++ clang/lib/Driver/ToolChains/BareMetal.h
@@ -67,6 +67,7 @@
llvm::opt::ArgStringList &CmdArgs) const override;
   void AddLinkRuntimeLib(const llvm::opt::ArgList &Args,
  llvm::opt::ArgStringList &CmdArgs) const;
+  std::string computeSysRoot() const override;
 };
 
 } // namespace toolchains
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -33,7 +33,7 @@
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getProgramPaths().push_back(getDriver().Dir);
-  SmallString<128> SysRoot(getDriver().SysRoot);
+  SmallString<128> SysRoot(computeSysRoot());
   if (!SysRoot.empty()) {
 llvm::sys::path::append(SysRoot, "lib");
 getFilePaths().push_back(std::string(SysRoot));
@@ -94,6 +94,17 @@
   return std::string(Dir.str());
 }
 
+std::string BareMetal::computeSysRoot() const {
+  if (!getDriver().SysRoot.empty())
+return getDriver().SysRoot;
+
+  SmallString<128> SysRootDir;
+  llvm::sys::path::append(SysRootDir, getDriver().Dir, "../lib/clang-runtimes",
+  getDriver().getTargetTriple());
+
+  return std::string(SysRootDir);
+}
+
 void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
   ArgStringList &CC1Args) const {
   if (DriverArgs.hasArg(options::OPT_nostdinc))
@@ -106,7 +117,7 @@
   }
 
   if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
-SmallString<128> Dir(getDriver().SysRoot);
+SmallString<128> Dir(computeSysRoot());
 if (!Dir.empty()) {
   llvm::sys::path::append(Dir, "include");
   addSystemInclude(DriverArgs, CC1Args, Dir.str());
@@ -127,7 +138,7 @@
   DriverArgs.hasArg(options::OPT_nostdincxx))
 return;
 
-  StringRef SysRoot = getDriver().SysRoot;
+  std::string SysRoot(computeSysRoot());
   if (SysRoot.empty())
 return;
 


Index: clang/test/Driver/baremetal-sysroot.cpp
===
--- /dev/null
+++ clang/test/Driver/baremetal-sysroot.cpp
@@ -0,0 +1,22 @@
+// 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

[PATCH] D92677: Provide default location of sysroot for Baremetal toolchain.

2020-12-04 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh marked an inline comment as done.
abidh added inline comments.



Comment at: clang/lib/Driver/ToolChains/BareMetal.cpp:108
+
+  return std::string(SysRootDir.str());
+}

jroelofs wrote:
> Small string has an implicit conversion to std::string, so you can just 
> `return SysRootDir;` here.
I was getting a compile error on that. Looking in SmallString.h, it seems that 
conversion to std::string is explicit.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92677/new/

https://reviews.llvm.org/D92677

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92677: Provide default location of sysroot for Baremetal toolchain.

2020-12-07 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG275592e71413: Provide default location of sysroot for 
Baremetal  toolchain. (authored by abidh).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92677/new/

https://reviews.llvm.org/D92677

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/BareMetal.h
  clang/test/Driver/baremetal-sysroot.cpp


Index: clang/test/Driver/baremetal-sysroot.cpp
===
--- /dev/null
+++ clang/test/Driver/baremetal-sysroot.cpp
@@ -0,0 +1,22 @@
+// 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"
Index: clang/lib/Driver/ToolChains/BareMetal.h
===
--- clang/lib/Driver/ToolChains/BareMetal.h
+++ clang/lib/Driver/ToolChains/BareMetal.h
@@ -67,6 +67,7 @@
llvm::opt::ArgStringList &CmdArgs) const override;
   void AddLinkRuntimeLib(const llvm::opt::ArgList &Args,
  llvm::opt::ArgStringList &CmdArgs) const;
+  std::string computeSysRoot() const override;
 };
 
 } // namespace toolchains
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -33,7 +33,7 @@
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getProgramPaths().push_back(getDriver().Dir);
-  SmallString<128> SysRoot(getDriver().SysRoot);
+  SmallString<128> SysRoot(computeSysRoot());
   if (!SysRoot.empty()) {
 llvm::sys::path::append(SysRoot, "lib");
 getFilePaths().push_back(std::string(SysRoot));
@@ -94,6 +94,17 @@
   return std::string(Dir.str());
 }
 
+std::string BareMetal::computeSysRoot() const {
+  if (!getDriver().SysRoot.empty())
+return getDriver().SysRoot;
+
+  SmallString<128> SysRootDir;
+  llvm::sys::path::append(SysRootDir, getDriver().Dir, "../lib/clang-runtimes",
+  getDriver().getTargetTriple());
+
+  return std::string(SysRootDir);
+}
+
 void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
   ArgStringList &CC1Args) const {
   if (DriverArgs.hasArg(options::OPT_nostdinc))
@@ -106,7 +117,7 @@
   }
 
   if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
-SmallString<128> Dir(getDriver().SysRoot);
+SmallString<128> Dir(computeSysRoot());
 if (!Dir.empty()) {
   llvm::sys::path::append(Dir, "include");
   addSystemInclude(DriverArgs, CC1Args, Dir.str());
@@ -127,7 +138,7 @@
   DriverArgs.hasArg(options::OPT_nostdincxx))
 return;
 
-  StringRef SysRoot = getDriver().SysRoot;
+  std::string SysRoot(computeSysRoot());
   if (SysRoot.empty())
 return;
 


Index: clang/test/Driver/baremetal-sysroot.cpp
===
--- /dev/null
+++ clang/test/Driver/baremetal-sysroot.cpp
@@ -0,0 +1,22 @@
+// 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/baremeta

[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2021-06-03 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:5216-5220
+if (toolchains::RISCVToolChain::hasGCCToolchain(*this, Args))
+  TC =
+  std::make_unique(*this, Target, 
Args);
+else
+  TC = std::make_unique(*this, Target, Args);

jrtc27 wrote:
> This has broken our use downstream. We construct a normal bare-metal 
> non-multilib baremetal sysroot, no GCC involved, passed explicitly with 
> --sysroot. However, BareMetal's findRISCVMultilibs unconditionally appends 
> multilib paths for anything other than IMAC (always ILP32/LP64) (well, it 
> still appends the path, just the multilib path is curiously empty), without 
> filtering out ones that don't exist like Gnu.cpp. I assume the empty string 
> for IMAC is a hack to allow most normal uses of bare-metal toolchains to 
> work, but it breaks if you want hard float support (or fewer extensions).
> 
> I suspect this is best fixed by filtering out non-existent directories from 
> findRISCVMultilibs (and at the same time, fixing IMAC to have a non-empty 
> path, since RISCVToolChain has one for it, and we no longer need the hacky, 
> insufficient workaround)?
IIRC the empty path was probably there to keep the non-multilib toolchain 
working. I don't mind if we remove the empty path for IMAC and all multilibs 
have non-empty paths.

I am not sure on filtering out non-existing folder though. It is a bit 
different from GNU.cpp in that we may not be using a pre-built sysroot and use 
the just-built compiler for building the runtime too. Also I am wondering what 
should happen if user wants a multilib whose runtime bits are not present in 
the toolchain. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91442/new/

https://reviews.llvm.org/D91442

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93023: Replace deprecated %T in 2 tests.

2021-02-11 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh updated this revision to Diff 322970.
abidh added a comment.

Changes in this version.

1. Added an explicit --sysroot argument.
2. Shortened "testroot-riscv{len}-baremetal-nogcc" string

As pointed out by @MaskRay  that some tests were failing when 
gcc-10-riscv64-linux-gnu was installed. This was happening because the test was 
checking a case when --gcc-toolchain is not provided. In this case, code does 
check the path alongside clang installation. But it also checks for a system 
wide installation in /usr. It prefers a higher version number too. So to make 
the test more robust, I have provided an explicit --sysroot argument. Its value 
has been chosen to match the existing pattern.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93023/new/

https://reviews.llvm.org/D93023

Files:
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain-extra.c


Index: clang/test/Driver/riscv64-toolchain-extra.c
===
--- clang/test/Driver/riscv64-toolchain-extra.c
+++ clang/test/Driver/riscv64-toolchain-extra.c
@@ -11,25 +11,26 @@
 // The test below checks that the driver correctly finds the linker and
 // runtime if and only if they exist.
 //
-// RUN: rm -rf %T/testroot-riscv64-baremetal-nogcc
-// RUN: mkdir -p %T/testroot-riscv64-baremetal-nogcc/bin
-// RUN: ln -s %clang %T/testroot-riscv64-baremetal-nogcc/bin/clang
-// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld 
%T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld
-// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf 
%T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf
-// RUN: %T/testroot-riscv64-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
-// RUN:--gcc-toolchain=%T/testroot-riscv64-baremetal-nogcc/invalid \
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/riscv64-nogcc/bin
+// RUN: ln -s %clang %t/riscv64-nogcc/bin/clang
+// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld 
%t/riscv64-nogcc/bin/riscv64-unknown-elf-ld
+// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf 
%t/riscv64-nogcc/riscv64-unknown-elf
+// RUN: %t/riscv64-nogcc/bin/clang %s -### -no-canonical-prefixes \
+// RUN:--gcc-toolchain=%t/riscv64-nogcc/invalid \
 // RUN:-target riscv64-unknown-elf --rtlib=platform -fuse-ld= 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 
-// RUN: %T/testroot-riscv64-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
+// RUN: %t/riscv64-nogcc/bin/clang %s -### -no-canonical-prefixes \
+// RUN:--sysroot=%t/riscv64-nogcc/bin/../riscv64-unknown-elf \
 // RUN:-target riscv64-unknown-elf --rtlib=platform -fuse-ld= 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 
-// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/include"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib/crt0.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/clang_rt.crtbegin-riscv64.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib"
+// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" 
"{{.*}}/riscv64-nogcc/bin/../riscv64-unknown-elf/include"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/riscv64-nogcc/bin/riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/riscv64-nogcc/bin/../riscv64-unknown-elf/lib/crt0.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/riscv64-nogcc/{{.*}}/lib/clang_rt.crtbegin-riscv64.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/riscv64-nogcc/bin/../riscv64-unknown-elf/lib"
 // C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/libclang_rt.builtins-riscv64.a"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/clang_rt.crtend-riscv64.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/riscv64-nogcc/{{.*}}/lib/libclang_rt.builtins-riscv64.a"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/riscv64-nogcc/{{.*}}/lib/clang_rt.crtend-riscv64.o"
Index: clang/test/Driver/riscv32-toolchain-extra.c
===
--- clang/test/Driver/riscv32-toolchain-extra.c
+++ clang/test/Driver/riscv32-toolchain-extra.c
@@ -11,25 +11,26 @@
 // The test below checks that the driver correctly finds the linker and
 // runtime if and only if they exist.
 //
-// RUN: rm -rf %T/testroot-riscv32-baremetal-nogcc
-// RUN: mkdir -p %T/testroot-riscv32-baremetal-nogcc/bin
-// RUN: ln -s %clang %T/testroot-riscv32-baremetal-nogcc/bin/clang
-// RUN: ln -s %S/Inputs/basic_riscv32_

[PATCH] D93023: Replace deprecated %T in 2 tests.

2021-02-11 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG60bed4ab57d5: Replace deprecated %T in 2 tests. (authored by 
abidh).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93023/new/

https://reviews.llvm.org/D93023

Files:
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain-extra.c


Index: clang/test/Driver/riscv64-toolchain-extra.c
===
--- clang/test/Driver/riscv64-toolchain-extra.c
+++ clang/test/Driver/riscv64-toolchain-extra.c
@@ -11,25 +11,26 @@
 // The test below checks that the driver correctly finds the linker and
 // runtime if and only if they exist.
 //
-// RUN: rm -rf %T/testroot-riscv64-baremetal-nogcc
-// RUN: mkdir -p %T/testroot-riscv64-baremetal-nogcc/bin
-// RUN: ln -s %clang %T/testroot-riscv64-baremetal-nogcc/bin/clang
-// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld 
%T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld
-// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf 
%T/testroot-riscv64-baremetal-nogcc/riscv64-unknown-elf
-// RUN: %T/testroot-riscv64-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
-// RUN:--gcc-toolchain=%T/testroot-riscv64-baremetal-nogcc/invalid \
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/riscv64-nogcc/bin
+// RUN: ln -s %clang %t/riscv64-nogcc/bin/clang
+// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/bin/riscv64-unknown-elf-ld 
%t/riscv64-nogcc/bin/riscv64-unknown-elf-ld
+// RUN: ln -s %S/Inputs/basic_riscv64_nogcc_tree/riscv64-unknown-elf 
%t/riscv64-nogcc/riscv64-unknown-elf
+// RUN: %t/riscv64-nogcc/bin/clang %s -### -no-canonical-prefixes \
+// RUN:--gcc-toolchain=%t/riscv64-nogcc/invalid \
 // RUN:-target riscv64-unknown-elf --rtlib=platform -fuse-ld= 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 
-// RUN: %T/testroot-riscv64-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
+// RUN: %t/riscv64-nogcc/bin/clang %s -### -no-canonical-prefixes \
+// RUN:--sysroot=%t/riscv64-nogcc/bin/../riscv64-unknown-elf \
 // RUN:-target riscv64-unknown-elf --rtlib=platform -fuse-ld= 2>&1 \
 // RUN:| FileCheck -check-prefix=C-RV64-BAREMETAL-LP64-NOGCC %s
 
-// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/include"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib/crt0.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/clang_rt.crtbegin-riscv64.o"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/bin/../riscv64-unknown-elf/lib"
+// C-RV64-BAREMETAL-LP64-NOGCC: "-internal-isystem" 
"{{.*}}/riscv64-nogcc/bin/../riscv64-unknown-elf/include"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/riscv64-nogcc/bin/riscv64-unknown-elf-ld"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/riscv64-nogcc/bin/../riscv64-unknown-elf/lib/crt0.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/riscv64-nogcc/{{.*}}/lib/clang_rt.crtbegin-riscv64.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/riscv64-nogcc/bin/../riscv64-unknown-elf/lib"
 // C-RV64-BAREMETAL-LP64-NOGCC: "--start-group" "-lc" "-lgloss" "--end-group"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/libclang_rt.builtins-riscv64.a"
-// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}Output/testroot-riscv64-baremetal-nogcc/{{.*}}/lib/clang_rt.crtend-riscv64.o"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/riscv64-nogcc/{{.*}}/lib/libclang_rt.builtins-riscv64.a"
+// C-RV64-BAREMETAL-LP64-NOGCC: 
"{{.*}}/riscv64-nogcc/{{.*}}/lib/clang_rt.crtend-riscv64.o"
Index: clang/test/Driver/riscv32-toolchain-extra.c
===
--- clang/test/Driver/riscv32-toolchain-extra.c
+++ clang/test/Driver/riscv32-toolchain-extra.c
@@ -11,25 +11,26 @@
 // The test below checks that the driver correctly finds the linker and
 // runtime if and only if they exist.
 //
-// RUN: rm -rf %T/testroot-riscv32-baremetal-nogcc
-// RUN: mkdir -p %T/testroot-riscv32-baremetal-nogcc/bin
-// RUN: ln -s %clang %T/testroot-riscv32-baremetal-nogcc/bin/clang
-// RUN: ln -s %S/Inputs/basic_riscv32_nogcc_tree/bin/riscv32-unknown-elf-ld 
%T/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
-// RUN: ln -s %S/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf 
%T/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
-// RUN: %T/testroot-riscv32-baremetal-nogcc/bin/clang %s -### 
-no-canonical-prefixes \
-// RUN:--gcc-toolchain=%T/testroot-riscv32-baremetal-nogcc/invalid \
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/riscv32-nogcc/bin
+// RUN: ln -s %clang %t/riscv32-nogcc/bin/clang
+/

[PATCH] D105414: Add x86 and x86_64 to the BareMetal toolchain

2021-07-05 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

You need to add some tests that check the functionality that you are adding.  
Look at clang/test/Driver/baremetal.cpp for an example.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105414/new/

https://reviews.llvm.org/D105414

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98113: [Driver] Also search FilePaths for compiler-rt before falling back

2021-03-08 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

In D98113#2609027 , @jrtc27 wrote:

> One thing that is currently rather ugly about BareMetal is that it ignores 
> the AddArch argument. Once you have a sysroot, the architecture suffix is 
> rather unnecessary, and given compiler-rt uses 
> LLVM_ENABLE_PER_TARGET_RUNTIME_DIR to decide both whether to add a suffix and 
> whether to add `lib/${OS}` to the install path, that means you can't nicely 
> point compiler-rt at the sysroot as the install directory (well, unless you 
> do something like make COMPILER_RT_OUTPUT_DIR point at the sysroot not the 
> libdir and set COMPILER_RT_OS_DIR to `.` (or maybe the empty string also 
> works)).

Agree that setting the compiler-rt installation directory is not ideal. I 
remember I ended up doing some post installation steps to make sure that 
libraries were in right folder.

Regarding this patch, currently Baremetal toolchain looks for compiler-rt in a 
multilib specific directory. Does that not solve the problem of finding 
compiler-rt for any given arch/abi combination automatically?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98113/new/

https://reviews.llvm.org/D98113

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136712: Define _GNU_SOURCE for arm baremetal in C++ mode.

2022-10-28 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

In D136712#3892986 , @manojgupta 
wrote:

> @tomhughes has more details on this but if we do not define it in clang 
> itself, we'll need to define it for every package manually at build time 
> since the usage goes deep inside newlib headers.

I remember facing a similar issue while I was trying to build a baremetal llvm 
toolchain for riscv. I think I defined it in libcxx config for newlib.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136712/new/

https://reviews.llvm.org/D136712

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68362: [libunwind][RISCV] Add 64-bit RISC-V support

2019-11-22 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added inline comments.



Comment at: libunwind/src/Registers.hpp:3765
+inline void Registers_riscv::setFloatRegister(int regNum, double value) {
+#ifdef __riscv_flen == 64
+  assert(validFloatRegister(regNum));

I am building these changes and get the following warning.
warning: extra tokens at end of #ifdef directive [-Wextra-tokens]

You probably meant #if here.



Comment at: libunwind/src/UnwindRegistersRestore.S:1042
+DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind15Registers_riscv6jumptoEv)
+#if __riscv_flen == 64
+  fldf0, (8 * 32 + 8 * 0)(a0)

This line generates the following warning when compiled without 'd' extension.

warning: '__riscv_flen' is not defined, evaluates to 0 [-Wundef]

Probably better to make it something like
#if defined(__riscv_flen) && __riscv_flen == 64



Comment at: libunwind/src/UnwindRegistersSave.S:1020
+
+#if __riscv_flen == 64
+  fsdf0, (8 * 32 + 8 * 0)(a0)

Similar problem here as described above.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68362/new/

https://reviews.llvm.org/D68362



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142986: Enable multilib.yaml in the BareMetal ToolChain

2023-03-13 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh accepted this revision.
abidh added a comment.

The BareMetal.cpp part looks ok to me.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142986/new/

https://reviews.llvm.org/D142986

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92677: Provide default location of sysroot for Baremetal toolchain.

2021-05-07 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

If gcc and clang based toolchains are installed in the same prefix then having 
sysroot at same location can cause one installation to overwrite parts of other.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92677/new/

https://reviews.llvm.org/D92677

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102049: [BareMetal] Ensure that sysroot always comes after library paths

2021-05-07 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh accepted this revision.
abidh added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102049/new/

https://reviews.llvm.org/D102049

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits