[PATCH] D150226: [Clang] Remove ability to downgrade warning on the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

2023-05-15 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

In D150226#4342516 , @aaron.ballman 
wrote:

> In D150226#4340166 , @manojgupta 
> wrote:
>
>> https://github.com/bminor/binutils-gdb/blob/master/include/diagnostics.h
>>
>> gdb only suppresses the warning. So this patch will likely break gdb.
>>
>> As per commit: 
>> https://github.com/bminor/binutils-gdb/commit/ae61525fcf456ab395d55c45492a106d1275873a
>>
>>   Since the current code does what we want, and I don't see any way of doing 
>> it
>>   differently, ignore -Wenum-constexpr-conversion around it.
>
> Hmmm, I'm not certain, but I *think* this does the right thing: 
> `std::is_signed_v() : 
> std::declval>())>;`
>
> https://godbolt.org/z/MWY4e1e9e

Can you please send a patch to gdb?


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

https://reviews.llvm.org/D150226

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


[PATCH] D150226: [Clang] Remove ability to downgrade warning on the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

2023-05-13 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

https://github.com/bminor/binutils-gdb/blob/master/include/diagnostics.h

gdb only suppresses the warning. So this patch will likely break gdb.

As per commit: 
https://github.com/bminor/binutils-gdb/commit/ae61525fcf456ab395d55c45492a106d1275873a

  Since the current code does what we want, and I don't see any way of doing it
  differently, ignore -Wenum-constexpr-conversion around it.


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

https://reviews.llvm.org/D150226

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


[PATCH] D150226: [Clang] Remove ability to downgrade warning on the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

2023-05-12 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

In D150226#4338738 , @manojgupta 
wrote:

>> I was under the impression from https://github.com/boostorg/mpl/issues/69 
>> that this was fixed but there are a number of issues off of the main one and 
>> maybe I am confused.
>
> Seems like boost 1.81 has the mentioned fix. I can try it and see if the 
> warning still fires.

Building boost 1.81 itself worked. But I still need to check the whole codebase.


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

https://reviews.llvm.org/D150226

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


[PATCH] D150226: [Clang] Remove ability to downgrade warning on the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

2023-05-12 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

> I was under the impression from https://github.com/boostorg/mpl/issues/69 
> that this was fixed but there are a number of issues off of the main one and 
> maybe I am confused.

Seems like boost 1.81 has the mentioned fix. I can try it and see if the 
warning still fires.


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

https://reviews.llvm.org/D150226

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


[PATCH] D150226: [Clang] Remove ability to downgrade warning on the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

2023-05-11 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

We also use Wno-enum-constexpr-conversion in ChromeOS. There are many packages 
that break with this warning. One of them is boost which is used in many other 
packages.

The errors in boost were:

  ./boost/mpl/aux_/integral_wrapper.hpp:73:31: error: integer value -1 is 
outside the valid range of values [0, 3] for this enumeration type 
[-Wenum-constexpr-conversion]
  ./boost/mpl/aux_/static_cast.hpp:24:47: note: expanded from macro 
'BOOST_MPL_AUX_STATIC_CAST'
  #   define BOOST_MPL_AUX_STATIC_CAST(T, expr) static_cast(expr)
^

I do not think boost upstream has updated these files, I see they were last 
updated 3 years back.
https://github.com/boostorg/mpl/blob/master/include/boost/mpl/aux_/static_cast.hpp
and 
https://github.com/boostorg/mpl/blob/master/include/boost/mpl/aux_/integral_wrapper.hpp


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

https://reviews.llvm.org/D150226

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


[PATCH] D144331: [libc++][format] Implements formatter thread::id.

2023-04-13 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Thanks, sent a patch to gdb at 
https://sourceware.org/pipermail/gdb-patches/2023-April/198870.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144331

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


[PATCH] D144331: [libc++][format] Implements formatter thread::id.

2023-04-13 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Hmm, looking deeper, gdb (actually binutils), is doing something weird.

https://github.com/bminor/binutils-gdb/blob/master/include/safe-ctype.h

  /* Prevent the users of safe-ctype.h from accidently using the routines
 from ctype.h.  Initially, the approach was to produce an error when
 detecting that ctype.h has been included.  But this was causing
 trouble as ctype.h might get indirectly included as a result of
 including another system header (for instance gnulib's stdint.h).
 So we include ctype.h here and then immediately redefine its macros.  */
  
  #include 
  #undef isalpha
  #define isalpha(c) do_not_use_isalpha_with_safe_ctype
  #undef isalnum
  #define isalnum(c) do_not_use_isalnum_with_safe_ctype
  

So any use of isupper/islower etc will cause an error.
Why this patch is triggering it:
It adds an include of #include <__format/formatter_integral.h> which ends up 
including  which has  internal definitions of isupper/islower causing 
clang to complain.
Any suggestions on what would be the right fix here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144331

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


[PATCH] D144331: [libc++][format] Implements formatter thread::id.

2023-04-12 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

I have opened a bug at issuetracker.google.com/issues/277967395


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144331

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


[PATCH] D144331: [libc++][format] Implements formatter thread::id.

2023-04-12 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Just a heads up, with this change, we are hitting issues in building gdb. 
Appreciate any ideas on what is wrong.

  aarch64-cros-linux-gnu-clang++ -x c++-I. -I. -I./config 
-DLOCALEDIR="\"/usr/share/locale\"" -DHAVE_CONFIG_H -I./../include/opcode   
-I../bfd -I./../bfd -I./../include -I../libdecnumber -I./../libdecnumber  
-I./../gnulib/import -I../gnulib/import -I./.. -I..  -DTUI=1-I./.. -pthread 
 -Wall -Wpointer-arith -Wno-unused -Wunused-value -Wunused-function -Wno-switch 
-Wno-char-subscripts -Wempty-body -Wunused-but-set-parameter 
-Wunused-but-set-variable -Wno-sign-compare -Wno-error=maybe-uninitialized 
-Wno-mismatched-tags -Wno-error=deprecated-register -Wsuggest-override 
-Wimplicit-fallthrough=3 -Wduplicated-cond -Wshadow=local -Wdeprecated-copy 
-Wdeprecated-copy-dtor -Wredundant-move -Wmissing-declarations 
-Wmissing-prototypes -Wstrict-null-sentinel -Wformat -Wformat-nonliteral  -Os 
-pipe -march=armv8-a+crc+crypto -ftree-vectorize -g -ffunction-sections 
-fdata-sections -c -o minsyms.o -MT minsyms.o -MMD -MP -MF 
./.deps/minsyms.Tpo minsyms.c
   In file included from minsyms.c:56:
   In file included from ./../gdbsupport/parallel-for.h:25:
   In file included from /usr/bin/../include/c++/v1/thread:100:
   In file included from 
/usr/bin/../include/c++/v1/__format/formatter_integral.h:32:
   In file included from /usr/bin/../include/c++/v1/locale:203:
   /usr/bin/../include/c++/v1/__locale:600:5: error: '__abi_tag__' attribute 
only applies to structs, variables, functions, and namespaces
   _LIBCPP_INLINE_VISIBILITY
   ^
   /usr/bin/../include/c++/v1/__config:668:37: note: expanded from macro 
'_LIBCPP_INLINE_VISIBILITY'
   #  define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
   ^
   /usr/bin/../include/c++/v1/__config:647:26: note: expanded from macro 
'_LIBCPP_HIDE_FROM_ABI'
 
__attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_VERSIONED_IDENTIFIER
^
   In file included from minsyms.c:56:
   In file included from ./../gdbsupport/parallel-for.h:25:
   In file included from /usr/bin/../include/c++/v1/thread:100:
   In file included from 
/usr/bin/../include/c++/v1/__format/formatter_integral.h:32:
   In file included from /usr/bin/../include/c++/v1/locale:203:
   /usr/bin/../include/c++/v1/__locale:601:37: error: expected ';' at end of 
declaration list
   char_type toupper(char_type __c) const
   ^
   /usr/bin/../include/c++/v1/__locale:607:48: error: too many arguments 
provided to function-like macro invocation
   const char_type* toupper(char_type* __low, const char_type* __high) const
  ^
   ./../include/safe-ctype.h:146:9: note: macro 'toupper' defined here
   #define toupper(c) do_not_use_toupper_with_safe_ctype
   ^
   In file included from minsyms.c:56:
   In file included from ./../gdbsupport/parallel-for.h:25:
   In file included from /usr/bin/../include/c++/v1/thread:100:
   In file included from 
/usr/bin/../include/c++/v1/__format/formatter_integral.h:32:
   In file included from /usr/bin/../include/c++/v1/locale:203:
   /usr/bin/../include/c++/v1/__locale:619:48: error: too many arguments 
provided to function-like macro invocation
   const char_type* tolower(char_type* __low, const char_type* __high) const
  ^
   ./../include/safe-ctype.h:148:9: note: macro 'tolower' defined here
   #define tolower(c) do_not_use_tolower_with_safe_ctype
   ^

Contents of __locale at line 600:

  _LIBCPP_INLINE_VISIBILITY
  char_type toupper(char_type __c) const
  {
  return do_toupper(__c);
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144331

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


[PATCH] D137379: [-Wunsafe-buffer-usage] Add warnings for unsafe buffer accesses by array subscript operations

2023-03-27 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

This is firing even in checked length codes, is that expected?

example:
https://godbolt.org/z/Todje76ao

  std::optional result;
  bool ReadDevice(uint8_t* data, size_t len) {
  if (!result)
return false;
memset(data, 0, len);
if (len > 0) data[0] = (result.value() >> 8) & 0xFF;
if (len > 1) data[1] = result.value() & 0xFF;
return true;
  }

  :7:26: warning: 'data' is an unsafe pointer used for buffer access 
[-Wunsafe-buffer-usage]
  bool ReadDevice(uint8_t* data, size_t len) {
  ~^~~~
  :13:20: note: used in buffer access here
if (len > 1) data[1] = result.value() & 0xFF;
 ^~~~


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137379

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


[PATCH] D140224: [Driver] Revert D139717 and add -Xparser instead

2022-12-16 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a subscriber: rpbeltran.
manojgupta added a comment.

> If ChromeOS needs time for migration, I think -Xcompiler can be temporarily 
> ignored.

If you can wait for a few weeks, that'd be great. We are already fighting with 
a large number of ToT issues. And this change makes our builds fail very early.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140224

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


[PATCH] D140224: [Driver] Revert D139717 and add -Xparser instead

2022-12-16 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Here are a few instances of Xcompiler usage for a non-exhaustive search (I 
can't look inside package tarballs if they are using it ):

https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/main/net-vpn/openvpn/openvpn-2.4.4.ebuild#74
https://chromium.googlesource.com/external/googleappengine/python/+/bedccc3dd4178880371cdf44064b222d82a5f30d/lib/distutils/distutils/extension.py#219

We already ignore Xcompiler for GCC in our compiler wrapper 
(https://chromium.googlesource.com/chromiumos/third_party/toolchain-utils/+/main/compiler_wrapper/gcc_flags.go),
 and we can do the same for clang as well.
So in theory, we'll be ok with the removal but it is annoying for sure to deal 
with.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140224

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


[PATCH] D140224: [Driver] Revert D139717 and add -Xparser instead

2022-12-16 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Without -Xcompiler, ChromeOS code will break. It may not be supported by GCC 
but it is supported in some other compilers like Cuda and a few others if you 
search. Also being supported by libtool makes it more important to keep it 
working.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140224

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


[PATCH] D139717: Revert "[Driver] Remove Joined -X"

2022-12-15 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Xlinker still works. Xcompiler is failing.

A google search will show that Xcompiler is a wide-spread option used by many 
packages. Whether or not GCC supports it is not relevant. Please do not remove 
options just because you do not use them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139717

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


[PATCH] D139717: Revert "[Driver] Remove Joined -X"

2022-12-12 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

We use -Xcompiler and -Xlinker which are passed in programs and they raise 
error now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139717

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


[PATCH] D139717: Revert "[Driver] Remove Joined -X"

2022-12-09 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

The removal is also breaking ChromeOS builds which use -Xpattern in some cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139717

___
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-11-03 Thread Manoj Gupta via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2497d5aa7716: Define _GNU_SOURCE for arm baremetal in C++ 
mode. (authored by manojgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136712

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Preprocessor/init-arm.c


Index: clang/test/Preprocessor/init-arm.c
===
--- clang/test/Preprocessor/init-arm.c
+++ clang/test/Preprocessor/init-arm.c
@@ -1450,3 +1450,8 @@
 
 // THUMB-MINGW:#define __ARM_DWARF_EH__ 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=thumbv6m-none-unknown-eabi < 
/dev/null | FileCheck -match-full-lines -check-prefix Thumbv6m-elf %s
+// Thumbv6m-elf: #define __ELF__ 1
+
+// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding 
-triple=thumbv6m-none-unknown-eabi < /dev/null | FileCheck -match-full-lines 
-check-prefix Thumbv6m-cxx %s
+// Thumbv6m-cxx: #define _GNU_SOURCE 1
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -705,8 +705,11 @@
   // For bare-metal none-eabi.
   if (getTriple().getOS() == llvm::Triple::UnknownOS &&
   (getTriple().getEnvironment() == llvm::Triple::EABI ||
-   getTriple().getEnvironment() == llvm::Triple::EABIHF))
+   getTriple().getEnvironment() == llvm::Triple::EABIHF)) {
 Builder.defineMacro("__ELF__");
+if (Opts.CPlusPlus)
+  Builder.defineMacro("_GNU_SOURCE");
+  }
 
   // Target properties.
   Builder.defineMacro("__REGISTER_PREFIX__", "");


Index: clang/test/Preprocessor/init-arm.c
===
--- clang/test/Preprocessor/init-arm.c
+++ clang/test/Preprocessor/init-arm.c
@@ -1450,3 +1450,8 @@
 
 // THUMB-MINGW:#define __ARM_DWARF_EH__ 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=thumbv6m-none-unknown-eabi < /dev/null | FileCheck -match-full-lines -check-prefix Thumbv6m-elf %s
+// Thumbv6m-elf: #define __ELF__ 1
+
+// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=thumbv6m-none-unknown-eabi < /dev/null | FileCheck -match-full-lines -check-prefix Thumbv6m-cxx %s
+// Thumbv6m-cxx: #define _GNU_SOURCE 1
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -705,8 +705,11 @@
   // For bare-metal none-eabi.
   if (getTriple().getOS() == llvm::Triple::UnknownOS &&
   (getTriple().getEnvironment() == llvm::Triple::EABI ||
-   getTriple().getEnvironment() == llvm::Triple::EABIHF))
+   getTriple().getEnvironment() == llvm::Triple::EABIHF)) {
 Builder.defineMacro("__ELF__");
+if (Opts.CPlusPlus)
+  Builder.defineMacro("_GNU_SOURCE");
+  }
 
   // Target properties.
   Builder.defineMacro("__REGISTER_PREFIX__", "");
___
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-11-03 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta updated this revision to Diff 473004.
manojgupta added a comment.

Updated test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136712

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Preprocessor/init-arm.c


Index: clang/test/Preprocessor/init-arm.c
===
--- clang/test/Preprocessor/init-arm.c
+++ clang/test/Preprocessor/init-arm.c
@@ -1450,3 +1450,8 @@
 
 // THUMB-MINGW:#define __ARM_DWARF_EH__ 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=thumbv6m-none-unknown-eabi < 
/dev/null | FileCheck -match-full-lines -check-prefix Thumbv6m-elf %s
+// Thumbv6m-elf: #define __ELF__ 1
+
+// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding 
-triple=thumbv6m-none-unknown-eabi < /dev/null | FileCheck -match-full-lines 
-check-prefix Thumbv6m-cxx %s
+// Thumbv6m-cxx: #define _GNU_SOURCE 1
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -705,8 +705,11 @@
   // For bare-metal none-eabi.
   if (getTriple().getOS() == llvm::Triple::UnknownOS &&
   (getTriple().getEnvironment() == llvm::Triple::EABI ||
-   getTriple().getEnvironment() == llvm::Triple::EABIHF))
+   getTriple().getEnvironment() == llvm::Triple::EABIHF)) {
 Builder.defineMacro("__ELF__");
+if (Opts.CPlusPlus)
+  Builder.defineMacro("_GNU_SOURCE");
+  }
 
   // Target properties.
   Builder.defineMacro("__REGISTER_PREFIX__", "");


Index: clang/test/Preprocessor/init-arm.c
===
--- clang/test/Preprocessor/init-arm.c
+++ clang/test/Preprocessor/init-arm.c
@@ -1450,3 +1450,8 @@
 
 // THUMB-MINGW:#define __ARM_DWARF_EH__ 1
 
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=thumbv6m-none-unknown-eabi < /dev/null | FileCheck -match-full-lines -check-prefix Thumbv6m-elf %s
+// Thumbv6m-elf: #define __ELF__ 1
+
+// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=thumbv6m-none-unknown-eabi < /dev/null | FileCheck -match-full-lines -check-prefix Thumbv6m-cxx %s
+// Thumbv6m-cxx: #define _GNU_SOURCE 1
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -705,8 +705,11 @@
   // For bare-metal none-eabi.
   if (getTriple().getOS() == llvm::Triple::UnknownOS &&
   (getTriple().getEnvironment() == llvm::Triple::EABI ||
-   getTriple().getEnvironment() == llvm::Triple::EABIHF))
+   getTriple().getEnvironment() == llvm::Triple::EABIHF)) {
 Builder.defineMacro("__ELF__");
+if (Opts.CPlusPlus)
+  Builder.defineMacro("_GNU_SOURCE");
+  }
 
   // Target properties.
   Builder.defineMacro("__REGISTER_PREFIX__", "");
___
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-11-03 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta updated this revision to Diff 472962.
manojgupta added a comment.

Restore back to C++ only.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136712

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Driver/arm-baremetal-defines.cpp


Index: clang/test/Driver/arm-baremetal-defines.cpp
===
--- /dev/null
+++ clang/test/Driver/arm-baremetal-defines.cpp
@@ -0,0 +1,11 @@
+// RUN: %clangxx --target=arm-none-eabi -march=armv7-m %s -emit-llvm -S -c -o 
- 2>&1 | FileCheck %s
+
+// CHECK: __ELF__defined
+#ifdef __ELF__
+void __ELF__defined() {}
+#endif
+
+// CHECK: _GNU_SOURCEdefined
+#ifdef _GNU_SOURCE
+void _GNU_SOURCEdefined() {}
+#endif
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -705,8 +705,11 @@
   // For bare-metal none-eabi.
   if (getTriple().getOS() == llvm::Triple::UnknownOS &&
   (getTriple().getEnvironment() == llvm::Triple::EABI ||
-   getTriple().getEnvironment() == llvm::Triple::EABIHF))
+   getTriple().getEnvironment() == llvm::Triple::EABIHF)) {
 Builder.defineMacro("__ELF__");
+if (Opts.CPlusPlus)
+  Builder.defineMacro("_GNU_SOURCE");
+  }
 
   // Target properties.
   Builder.defineMacro("__REGISTER_PREFIX__", "");


Index: clang/test/Driver/arm-baremetal-defines.cpp
===
--- /dev/null
+++ clang/test/Driver/arm-baremetal-defines.cpp
@@ -0,0 +1,11 @@
+// RUN: %clangxx --target=arm-none-eabi -march=armv7-m %s -emit-llvm -S -c -o - 2>&1 | FileCheck %s
+
+// CHECK: __ELF__defined
+#ifdef __ELF__
+void __ELF__defined() {}
+#endif
+
+// CHECK: _GNU_SOURCEdefined
+#ifdef _GNU_SOURCE
+void _GNU_SOURCEdefined() {}
+#endif
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -705,8 +705,11 @@
   // For bare-metal none-eabi.
   if (getTriple().getOS() == llvm::Triple::UnknownOS &&
   (getTriple().getEnvironment() == llvm::Triple::EABI ||
-   getTriple().getEnvironment() == llvm::Triple::EABIHF))
+   getTriple().getEnvironment() == llvm::Triple::EABIHF)) {
 Builder.defineMacro("__ELF__");
+if (Opts.CPlusPlus)
+  Builder.defineMacro("_GNU_SOURCE");
+  }
 
   // Target properties.
   Builder.defineMacro("__REGISTER_PREFIX__", "");
___
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-11-03 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta updated this revision to Diff 472961.
manojgupta added a comment.

restore back to C++ only


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136712

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Driver/arm-baremetal-defines.cpp


Index: clang/test/Driver/arm-baremetal-defines.cpp
===
--- /dev/null
+++ clang/test/Driver/arm-baremetal-defines.cpp
@@ -0,0 +1,11 @@
+// RUN: %clangxx --target=arm-none-eabi -march=armv7-m %s -emit-llvm -S -c -o 
- 2>&1 | FileCheck %s
+
+// CHECK: __ELF__defined
+#ifdef __ELF__
+void __ELF__defined() {}
+#endif
+
+// CHECK: _GNU_SOURCEdefined
+#ifdef _GNU_SOURCE
+void _GNU_SOURCEdefined() {}
+#endif
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -705,8 +705,11 @@
   // For bare-metal none-eabi.
   if (getTriple().getOS() == llvm::Triple::UnknownOS &&
   (getTriple().getEnvironment() == llvm::Triple::EABI ||
-   getTriple().getEnvironment() == llvm::Triple::EABIHF))
+   getTriple().getEnvironment() == llvm::Triple::EABIHF)) {
 Builder.defineMacro("__ELF__");
+if (Opts.CPlusPlus)
+  Builder.defineMacro("_GNU_SOURCE");
+  }
 
   // Target properties.
   Builder.defineMacro("__REGISTER_PREFIX__", "");


Index: clang/test/Driver/arm-baremetal-defines.cpp
===
--- /dev/null
+++ clang/test/Driver/arm-baremetal-defines.cpp
@@ -0,0 +1,11 @@
+// RUN: %clangxx --target=arm-none-eabi -march=armv7-m %s -emit-llvm -S -c -o - 2>&1 | FileCheck %s
+
+// CHECK: __ELF__defined
+#ifdef __ELF__
+void __ELF__defined() {}
+#endif
+
+// CHECK: _GNU_SOURCEdefined
+#ifdef _GNU_SOURCE
+void _GNU_SOURCEdefined() {}
+#endif
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -705,8 +705,11 @@
   // For bare-metal none-eabi.
   if (getTriple().getOS() == llvm::Triple::UnknownOS &&
   (getTriple().getEnvironment() == llvm::Triple::EABI ||
-   getTriple().getEnvironment() == llvm::Triple::EABIHF))
+   getTriple().getEnvironment() == llvm::Triple::EABIHF)) {
 Builder.defineMacro("__ELF__");
+if (Opts.CPlusPlus)
+  Builder.defineMacro("_GNU_SOURCE");
+  }
 
   // Target properties.
   Builder.defineMacro("__REGISTER_PREFIX__", "");
___
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 Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

@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.


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] D136712: Define _GNU_SOURCE for arm baremetal in C++ mode.

2022-10-28 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added reviewers: MaskRay, efriedma.
manojgupta added subscribers: MaskRay, efriedma.
manojgupta added a comment.
Herald added a subscriber: StephenFan.

I am not sure who is a good reviewer for this. Starting with @MaskRay and 
@efriedma


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] D136712: Define _GNU_SOURCE for arm baremetal in C++ mode.

2022-10-25 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta updated this revision to Diff 470611.
manojgupta added a comment.

Removed c++ limitation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136712

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Driver/arm-baremetal-defines.cpp


Index: clang/test/Driver/arm-baremetal-defines.cpp
===
--- /dev/null
+++ clang/test/Driver/arm-baremetal-defines.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang --target=arm-none-eabi -march=armv7-m %s -emit-llvm -S -c -o - 
2>&1 | FileCheck %s
+
+// CHECK: __ELF__defined
+#ifdef __ELF__
+void __ELF__defined() {}
+#endif
+
+// CHECK: _GNU_SOURCEdefined
+#ifdef _GNU_SOURCE
+void _GNU_SOURCEdefined() {}
+#endif
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -692,8 +692,10 @@
   // For bare-metal none-eabi.
   if (getTriple().getOS() == llvm::Triple::UnknownOS &&
   (getTriple().getEnvironment() == llvm::Triple::EABI ||
-   getTriple().getEnvironment() == llvm::Triple::EABIHF))
+   getTriple().getEnvironment() == llvm::Triple::EABIHF)) {
 Builder.defineMacro("__ELF__");
+Builder.defineMacro("_GNU_SOURCE");
+  }
 
   // Target properties.
   Builder.defineMacro("__REGISTER_PREFIX__", "");


Index: clang/test/Driver/arm-baremetal-defines.cpp
===
--- /dev/null
+++ clang/test/Driver/arm-baremetal-defines.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang --target=arm-none-eabi -march=armv7-m %s -emit-llvm -S -c -o - 2>&1 | FileCheck %s
+
+// CHECK: __ELF__defined
+#ifdef __ELF__
+void __ELF__defined() {}
+#endif
+
+// CHECK: _GNU_SOURCEdefined
+#ifdef _GNU_SOURCE
+void _GNU_SOURCEdefined() {}
+#endif
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -692,8 +692,10 @@
   // For bare-metal none-eabi.
   if (getTriple().getOS() == llvm::Triple::UnknownOS &&
   (getTriple().getEnvironment() == llvm::Triple::EABI ||
-   getTriple().getEnvironment() == llvm::Triple::EABIHF))
+   getTriple().getEnvironment() == llvm::Triple::EABIHF)) {
 Builder.defineMacro("__ELF__");
+Builder.defineMacro("_GNU_SOURCE");
+  }
 
   // Target properties.
   Builder.defineMacro("__REGISTER_PREFIX__", "");
___
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-25 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta created this revision.
manojgupta added reviewers: abidh, tomhughes.
Herald added subscribers: kristof.beyls, ki.stfu, dschuff.
Herald added a project: All.
manojgupta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This matches other C++ drivers e.g. Linux that define
_GNU_SOURCE. This lets clang compiler more code by default
without explicitly passing _GNU_SOURCE on command line.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136712

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Driver/arm-baremetal-defines.cpp


Index: clang/test/Driver/arm-baremetal-defines.cpp
===
--- /dev/null
+++ clang/test/Driver/arm-baremetal-defines.cpp
@@ -0,0 +1,13 @@
+// RUN: %clangxx --target=arm-none-eabi -march=armv7-m %s -emit-llvm -S -c -o 
- 2>&1 | FileCheck %s
+
+// ECHO: {{.*}} "-cc1" {{.*}}mipsel-nacl-defines.c
+
+// CHECK: __ELF__defined
+#ifdef __ELF__
+void __ELF__defined() {}
+#endif
+
+// CHECK: _GNU_SOURCEdefined
+#ifdef _GNU_SOURCE
+void _GNU_SOURCEdefined() {}
+#endif
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -692,8 +692,11 @@
   // For bare-metal none-eabi.
   if (getTriple().getOS() == llvm::Triple::UnknownOS &&
   (getTriple().getEnvironment() == llvm::Triple::EABI ||
-   getTriple().getEnvironment() == llvm::Triple::EABIHF))
+   getTriple().getEnvironment() == llvm::Triple::EABIHF)) {
 Builder.defineMacro("__ELF__");
+if (Opts.CPlusPlus)
+  Builder.defineMacro("_GNU_SOURCE");
+  }
 
   // Target properties.
   Builder.defineMacro("__REGISTER_PREFIX__", "");


Index: clang/test/Driver/arm-baremetal-defines.cpp
===
--- /dev/null
+++ clang/test/Driver/arm-baremetal-defines.cpp
@@ -0,0 +1,13 @@
+// RUN: %clangxx --target=arm-none-eabi -march=armv7-m %s -emit-llvm -S -c -o - 2>&1 | FileCheck %s
+
+// ECHO: {{.*}} "-cc1" {{.*}}mipsel-nacl-defines.c
+
+// CHECK: __ELF__defined
+#ifdef __ELF__
+void __ELF__defined() {}
+#endif
+
+// CHECK: _GNU_SOURCEdefined
+#ifdef _GNU_SOURCE
+void _GNU_SOURCEdefined() {}
+#endif
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -692,8 +692,11 @@
   // For bare-metal none-eabi.
   if (getTriple().getOS() == llvm::Triple::UnknownOS &&
   (getTriple().getEnvironment() == llvm::Triple::EABI ||
-   getTriple().getEnvironment() == llvm::Triple::EABIHF))
+   getTriple().getEnvironment() == llvm::Triple::EABIHF)) {
 Builder.defineMacro("__ELF__");
+if (Opts.CPlusPlus)
+  Builder.defineMacro("_GNU_SOURCE");
+  }
 
   // Target properties.
   Builder.defineMacro("__REGISTER_PREFIX__", "");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134478: BareMetal: detect usr/include/c++/v1 path in sysroot

2022-10-07 Thread Manoj Gupta via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5e5d21462d1e: BareMetal: detect usr/include/c++/v1 path in 
sysroot (authored by manojgupta).

Changed prior to commit:
  https://reviews.llvm.org/D134478?vs=465647=466250#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134478

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
@@ -77,6 +77,22 @@
 // CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-NDL-SAME: "-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 
+// RUN: rm -rf %T/baremetal_cxx_sysroot
+// RUN: mkdir -p %T/baremetal_cxx_sysroot/usr/include/c++/v1
+// RUN: %clangxx %s -### 2>&1 \
+// RUN: --target=armv6m-none-eabi \
+// RUN: --sysroot=%T/baremetal_cxx_sysroot \
+// RUN: -stdlib=libc++ \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBCXX-USR %s
+// CHECK-V6M-LIBCXX-USR: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-V6M-LIBCXX-USR-NOT: "-internal-isystem" 
"{{[^"]+}}baremetal_cxx_sysroot{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}{{[^v].*}}"
+// CHECK-V6M-LIBCXX-USR-SAME: "-internal-isystem" 
"{{[^"]+}}baremetal_cxx_sysroot{{[/\\]+}}usr{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
+// CHECK-V6M-LIBCXX-USR: "{{[^"]*}}-Bstatic"
+// CHECK-V6M-LIBCXX-USR-SAME: 
"-L{{[^"]*}}{{[/\\]+}}baremetal_cxx_sysroot{{[/\\]+}}lib"
+// CHECK-V6M-LIBCXX-USR-SAME: 
"-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBCXX-USR-SAME: "-lc++" "-lc++abi" "-lunwind"
+// CHECK-V6M-LIBCXX-USR-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
+
 // RUN: %clangxx --target=arm-none-eabi -v 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-THREAD-MODEL
 // CHECK-THREAD-MODEL: Thread model: posix
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -217,12 +217,21 @@
   DriverArgs.hasArg(options::OPT_nostdincxx))
 return;
 
+  const Driver  = getDriver();
   std::string SysRoot(computeSysRoot());
   if (SysRoot.empty())
 return;
 
   switch (GetCXXStdlibType(DriverArgs)) {
   case ToolChain::CST_Libcxx: {
+// First check sysroot/usr/include/c++/v1 if it exists.
+SmallString<128> TargetDir(SysRoot);
+llvm::sys::path::append(TargetDir, "usr", "include", "c++", "v1");
+if (D.getVFS().exists(TargetDir)) {
+  addSystemInclude(DriverArgs, CC1Args, TargetDir.str());
+  break;
+}
+// Add generic path if nothing else succeeded so far.
 SmallString<128> Dir(SysRoot);
 llvm::sys::path::append(Dir, "include", "c++", "v1");
 addSystemInclude(DriverArgs, CC1Args, Dir.str());
@@ -234,9 +243,8 @@
 std::error_code EC;
 Generic_GCC::GCCVersion Version = {"", -1, -1, -1, "", "", ""};
 // Walk the subdirs, and find the one with the newest gcc version:
-for (llvm::vfs::directory_iterator
- LI = getDriver().getVFS().dir_begin(Dir.str(), EC),
- LE;
+for (llvm::vfs::directory_iterator LI = D.getVFS().dir_begin(Dir.str(), 
EC),
+   LE;
  !EC && LI != LE; LI = LI.increment(EC)) {
   StringRef VersionText = llvm::sys::path::filename(LI->path());
   auto CandidateVersion = Generic_GCC::GCCVersion::Parse(VersionText);


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -77,6 +77,22 @@
 // CHECK-V6M-NDL-SAME: "-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-NDL-SAME: "-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 
+// RUN: rm -rf %T/baremetal_cxx_sysroot
+// RUN: mkdir -p %T/baremetal_cxx_sysroot/usr/include/c++/v1
+// RUN: %clangxx %s -### 2>&1 \
+// RUN: --target=armv6m-none-eabi \
+// RUN: --sysroot=%T/baremetal_cxx_sysroot \
+// RUN: -stdlib=libc++ \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBCXX-USR %s
+// CHECK-V6M-LIBCXX-USR: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-V6M-LIBCXX-USR-NOT: "-internal-isystem" "{{[^"]+}}baremetal_cxx_sysroot{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}{{[^v].*}}"
+// CHECK-V6M-LIBCXX-USR-SAME: "-internal-isystem" "{{[^"]+}}baremetal_cxx_sysroot{{[/\\]+}}usr{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
+// CHECK-V6M-LIBCXX-USR: "{{[^"]*}}-Bstatic"
+// CHECK-V6M-LIBCXX-USR-SAME: "-L{{[^"]*}}{{[/\\]+}}baremetal_cxx_sysroot{{[/\\]+}}lib"
+// CHECK-V6M-LIBCXX-USR-SAME: "-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBCXX-USR-SAME: "-lc++" "-lc++abi" "-lunwind"
+// 

[PATCH] D134478: BareMetal: detect usr/include/c++/v1 path in sysroot

2022-10-05 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta updated this revision to Diff 465647.
manojgupta added a comment.

address comments and check CI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134478

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
@@ -72,6 +72,22 @@
 // CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"
 
+// RUN: rm -rf %T/baremetal_cxx_sysroot
+// RUN: mkdir -p %T/baremetal_cxx_sysroot/usr/include/c++/v1
+// RUN: %clangxx %s -### 2>&1 \
+// RUN: --target=armv6m-none-eabi \
+// RUN: --sysroot=%T/baremetal_cxx_sysroot \
+// RUN: -stdlib=libc++ \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBCXX-USR %s
+// CHECK-V6M-LIBCXX-USR: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-V6M-LIBCXX-USR-NOT: "-internal-isystem" 
"{{[^"]+}}baremetal_cxx_sysroot{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}{{[^v].*}}"
+// CHECK-V6M-LIBCXX-USR-SAME: "-internal-isystem" 
"{{[^"]+}}baremetal_cxx_sysroot{{[/\\]+}}usr{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
+// CHECK-V6M-LIBCXX-USR: "{{[^"]*}}-Bstatic"
+// CHECK-V6M-LIBCXX-USR-SAME: 
"-L{{[^"]*}}{{[/\\]+}}baremetal_cxx_sysroot{{[/\\]+}}lib"
+// CHECK-V6M-LIBCXX-USR-SAME: 
"-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBCXX-USR-SAME: "-lc++" "-lc++abi" "-lunwind"
+// CHECK-V6M-LIBCXX-USR-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
+
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target armv6m-none-eabi \
 // RUN: --sysroot=%S/Inputs/baremetal_arm \
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -217,12 +217,21 @@
   DriverArgs.hasArg(options::OPT_nostdincxx))
 return;
 
+  const Driver  = getDriver();
   std::string SysRoot(computeSysRoot());
   if (SysRoot.empty())
 return;
 
   switch (GetCXXStdlibType(DriverArgs)) {
   case ToolChain::CST_Libcxx: {
+// First check sysroot/usr/include/c++/v1 if it exists.
+SmallString<128> TargetDir(SysRoot);
+llvm::sys::path::append(TargetDir, "usr", "include", "c++", "v1");
+if (D.getVFS().exists(TargetDir)) {
+  addSystemInclude(DriverArgs, CC1Args, TargetDir.str());
+  break;
+}
+// Add generic path if nothing else succeeded so far.
 SmallString<128> Dir(SysRoot);
 llvm::sys::path::append(Dir, "include", "c++", "v1");
 addSystemInclude(DriverArgs, CC1Args, Dir.str());
@@ -234,9 +243,8 @@
 std::error_code EC;
 Generic_GCC::GCCVersion Version = {"", -1, -1, -1, "", "", ""};
 // Walk the subdirs, and find the one with the newest gcc version:
-for (llvm::vfs::directory_iterator
- LI = getDriver().getVFS().dir_begin(Dir.str(), EC),
- LE;
+for (llvm::vfs::directory_iterator LI = D.getVFS().dir_begin(Dir.str(), 
EC),
+   LE;
  !EC && LI != LE; LI = LI.increment(EC)) {
   StringRef VersionText = llvm::sys::path::filename(LI->path());
   auto CandidateVersion = Generic_GCC::GCCVersion::Parse(VersionText);


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -72,6 +72,22 @@
 // CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"
 
+// RUN: rm -rf %T/baremetal_cxx_sysroot
+// RUN: mkdir -p %T/baremetal_cxx_sysroot/usr/include/c++/v1
+// RUN: %clangxx %s -### 2>&1 \
+// RUN: --target=armv6m-none-eabi \
+// RUN: --sysroot=%T/baremetal_cxx_sysroot \
+// RUN: -stdlib=libc++ \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBCXX-USR %s
+// CHECK-V6M-LIBCXX-USR: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-V6M-LIBCXX-USR-NOT: "-internal-isystem" "{{[^"]+}}baremetal_cxx_sysroot{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}{{[^v].*}}"
+// CHECK-V6M-LIBCXX-USR-SAME: "-internal-isystem" "{{[^"]+}}baremetal_cxx_sysroot{{[/\\]+}}usr{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
+// CHECK-V6M-LIBCXX-USR: "{{[^"]*}}-Bstatic"
+// CHECK-V6M-LIBCXX-USR-SAME: "-L{{[^"]*}}{{[/\\]+}}baremetal_cxx_sysroot{{[/\\]+}}lib"
+// CHECK-V6M-LIBCXX-USR-SAME: "-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBCXX-USR-SAME: "-lc++" "-lc++abi" "-lunwind"
+// CHECK-V6M-LIBCXX-USR-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
+
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target armv6m-none-eabi \
 // RUN: --sysroot=%S/Inputs/baremetal_arm \
Index: clang/lib/Driver/ToolChains/BareMetal.cpp

[PATCH] D134478: BareMetal: detect usr/include/c++/v1 path in sysroot

2022-10-03 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

friendly ping for review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134478

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


[PATCH] D134478: BareMetal: detect usr/include/c++/v1 path in sysroot

2022-09-22 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta created this revision.
manojgupta added reviewers: MaskRay, barannikov88, abidh.
Herald added subscribers: StephenFan, ki.stfu.
Herald added a project: All.
manojgupta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Currently baremetal driver adds /include/c++/v1
for libc++ headers. However on ChromeOS, all include files
are inside /usr/include. So add
/usr/include/c++/v1 if it exists in baremetal driver.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134478

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
@@ -72,6 +72,23 @@
 // CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"
 
+// RUN: rm -rf %T/baremetal_cxx_sysroot
+// RUN: mkdir -p %T/baremetal_cxx_sysroot/usr/include/c++/v1
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv6m-none-eabi \
+// RUN: --sysroot=%T/baremetal_cxx_sysroot \
+// RUN: -stdlib=libc++ \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBCXX-USR %s
+// CHECK-V6M-LIBCXX-USR: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-V6M-LIBCXX-USR-NOT: "-internal-isystem" 
"{{[^"]+}}baremetal_cxx_sysroot{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}{{[^v].*}}"
+// CHECK-V6M-LIBCXX-USR-SAME: "-internal-isystem" 
"{{[^"]+}}baremetal_cxx_sysroot{{[/\\]+}}usr{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
+// CHECK-V6M-LIBCXX-USR: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
+// CHECK-V6M-LIBCXX-USR-SAME: 
"-L{{[^"]*}}{{[/\\]+}}baremetal_cxx_sysroot{{[/\\]+}}lib"
+// CHECK-V6M-LIBCXX-USR-SAME: 
"-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBCXX-USR-SAME: "-lc++" "-lc++abi" "-lunwind"
+// CHECK-V6M-LIBCXX-USR-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
+// CHECK-V6M-LIBCXX-USR-SAME: "-o" "{{.*}}.o"
+
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target armv6m-none-eabi \
 // RUN: --sysroot=%S/Inputs/baremetal_arm \
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -217,12 +217,21 @@
   DriverArgs.hasArg(options::OPT_nostdincxx))
 return;
 
+  const Driver  = getDriver();
   std::string SysRoot(computeSysRoot());
   if (SysRoot.empty())
 return;
 
   switch (GetCXXStdlibType(DriverArgs)) {
   case ToolChain::CST_Libcxx: {
+// First check sysroot/usr/include/c++/v1 if it exists.
+SmallString<128> TargetDir(SysRoot);
+llvm::sys::path::append(TargetDir, "usr", "include", "c++", "v1");
+if (D.getVFS().exists(TargetDir)) {
+  addSystemInclude(DriverArgs, CC1Args, TargetDir.str());
+  break;
+}
+// Add generic path if nothing else succeeded so far.
 SmallString<128> Dir(SysRoot);
 llvm::sys::path::append(Dir, "include", "c++", "v1");
 addSystemInclude(DriverArgs, CC1Args, Dir.str());
@@ -234,9 +243,8 @@
 std::error_code EC;
 Generic_GCC::GCCVersion Version = {"", -1, -1, -1, "", "", ""};
 // Walk the subdirs, and find the one with the newest gcc version:
-for (llvm::vfs::directory_iterator
- LI = getDriver().getVFS().dir_begin(Dir.str(), EC),
- LE;
+for (llvm::vfs::directory_iterator LI = D.getVFS().dir_begin(Dir.str(), 
EC),
+   LE;
  !EC && LI != LE; LI = LI.increment(EC)) {
   StringRef VersionText = llvm::sys::path::filename(LI->path());
   auto CandidateVersion = Generic_GCC::GCCVersion::Parse(VersionText);


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -72,6 +72,23 @@
 // CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"
 
+// RUN: rm -rf %T/baremetal_cxx_sysroot
+// RUN: mkdir -p %T/baremetal_cxx_sysroot/usr/include/c++/v1
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv6m-none-eabi \
+// RUN: --sysroot=%T/baremetal_cxx_sysroot \
+// RUN: -stdlib=libc++ \
+// RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBCXX-USR %s
+// CHECK-V6M-LIBCXX-USR: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-V6M-LIBCXX-USR-NOT: "-internal-isystem" "{{[^"]+}}baremetal_cxx_sysroot{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}{{[^v].*}}"
+// CHECK-V6M-LIBCXX-USR-SAME: "-internal-isystem" "{{[^"]+}}baremetal_cxx_sysroot{{[/\\]+}}usr{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
+// CHECK-V6M-LIBCXX-USR: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
+// 

[PATCH] D134454: [Driver][Distro] Fix ArchLinux triplet and sysroot detection

2022-09-22 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Thanks for the patch. Can you please post a full diff (git diff -U).

Adding @MaskRay as a reviewer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134454

___
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-10 Thread Manoj Gupta via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG06fc5a771462: Driver: Refactor and support per target dirs 
in baremetal (authored by manojgupta).

Changed prior to commit:
  https://reviews.llvm.org/D131225?vs=451352=451517#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131225

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/BareMetal.h
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/armv7m-vendor-none-eabi/libclang_rt.builtins.a
  clang/test/Driver/baremetal.cpp
  clang/test/Driver/print-libgcc-file-name-clangrt.c

Index: clang/test/Driver/print-libgcc-file-name-clangrt.c
===
--- clang/test/Driver/print-libgcc-file-name-clangrt.c
+++ clang/test/Driver/print-libgcc-file-name-clangrt.c
@@ -48,3 +48,9 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL %s
 // CHECK-CLANGRT-ARM-BAREMETAL: libclang_rt.builtins-armv7m.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=armv7m-vendor-none-eabi \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET %s
+// CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET: libclang_rt.builtins.a
Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -31,6 +31,20 @@
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBINC %s
 // CHECK-V6M-LIBINC-NOT: "-internal-isystem"
 
+// RUN: %clang -no-canonical-prefixes -rtlib=compiler-rt %s -### -o %t.o 2>&1 \
+// RUN: -target armv7m-vendor-none-eabi \
+// RUN: --sysroot=%S/Inputs/baremetal_arm \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARMV7M-PER-TARGET %s
+// CHECK-ARMV7M-PER-TARGET: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-ARMV7M-PER-TARGET: "-isysroot" "[[SYSROOT:[^"]*]]"
+// CHECK-ARMV7M-PER-TARGET: "-x" "c++" "{{.*}}baremetal.cpp"
+// CHECK-ARMV7M-PER-TARGET: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-ARMV7M-PER-TARGET: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
+// CHECK-ARMV7M-PER-TARGET: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}armv7m-vendor-none-eabi
+// CHECK-ARMV7M-PER-TARGET: "-lc" "-lm" "-lclang_rt.builtins"
+// CHECK-ARMV7M-PER-TARGET: "-o" "{{.*}}.o"
+
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target armv6m-none-eabi \
 // RUN: --sysroot=%S/Inputs/baremetal_arm \
Index: clang/lib/Driver/ToolChains/BareMetal.h
===
--- clang/lib/Driver/ToolChains/BareMetal.h
+++ clang/lib/Driver/ToolChains/BareMetal.h
@@ -1,4 +1,4 @@
-//===--- BareMetal.h - Bare Metal Tool and ToolChain -*- C++ -*-===//
+//===--- BareMetal.h - Bare Metal Tool and ToolChain *- C++-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -33,13 +33,9 @@
 protected:
   Tool *buildLinker() const override;
 
-  std::string buildCompilerRTBasename(const llvm::opt::ArgList ,
-  StringRef Component,
-  FileType Type = ToolChain::FT_Static,
-  bool AddArch = true) const override;
-
 public:
   bool useIntegratedAs() const override { return true; }
+  bool isBareMetal() const override { return true; }
   bool isCrossCompiling() const override { return true; }
   bool isPICDefault() const override { return false; }
   bool isPIEDefault(const llvm::opt::ArgList ) const override {
@@ -50,8 +46,6 @@
 
   StringRef getOSLibName() const override { return "baremetal"; }
 
-  std::string getCompilerRTPath() const override;
-
   RuntimeLibType GetDefaultRuntimeLibType() const override {
 return ToolChain::RLT_CompilerRT;
   }
@@ -61,12 +55,13 @@
 
   const char *getDefaultLinker() const override { return "ld.lld"; }
 
-  std::string getRuntimesDir() const;
-  void AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
- llvm::opt::ArgStringList ) const override;
-  void addClangTargetOptions(const llvm::opt::ArgList ,
- llvm::opt::ArgStringList ,
- Action::OffloadKind DeviceOffloadKind) const override;
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const override;
+  void
+  addClangTargetOptions(const 

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

2022-08-09 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta updated this revision to Diff 451352.
manojgupta added a comment.

Going back to older handlesTarget() style in Baremetal.
Apparently RISCV can be both Baremetal or RISCVToolchain for the
same tuple. I do not know of the nuances so trying not to disturb that for
now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131225

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/BareMetal.h
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/armv7m-vendor-none-eabi/libclang_rt.builtins.a
  clang/test/Driver/baremetal.cpp
  clang/test/Driver/print-libgcc-file-name-clangrt.c

Index: clang/test/Driver/print-libgcc-file-name-clangrt.c
===
--- clang/test/Driver/print-libgcc-file-name-clangrt.c
+++ clang/test/Driver/print-libgcc-file-name-clangrt.c
@@ -48,3 +48,9 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL %s
 // CHECK-CLANGRT-ARM-BAREMETAL: libclang_rt.builtins-armv7m.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=armv7m-vendor-none-eabi \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET %s
+// CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET: libclang_rt.builtins.a
Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -31,6 +31,20 @@
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBINC %s
 // CHECK-V6M-LIBINC-NOT: "-internal-isystem"
 
+// RUN: %clang -no-canonical-prefixes -rtlib=compiler-rt %s -### -o %t.o 2>&1 \
+// RUN: -target armv7m-vendor-none-eabi \
+// RUN: --sysroot=%S/Inputs/baremetal_arm \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARMV7M-PER-TARGET %s
+// CHECK-ARMV7M-PER-TARGET: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-ARMV7M-PER-TARGET: "-isysroot" "[[SYSROOT:[^"]*]]"
+// CHECK-ARMV7M-PER-TARGET: "-x" "c++" "{{.*}}baremetal.cpp"
+// CHECK-ARMV7M-PER-TARGET: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-ARMV7M-PER-TARGET: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
+// CHECK-ARMV7M-PER-TARGET: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}armv7m-vendor-none-eabi
+// CHECK-ARMV7M-PER-TARGET: "-lc" "-lm" "-lclang_rt.builtins"
+// CHECK-ARMV7M-PER-TARGET: "-o" "{{.*}}.o"
+
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target armv6m-none-eabi \
 // RUN: --sysroot=%S/Inputs/baremetal_arm \
Index: clang/lib/Driver/ToolChains/BareMetal.h
===
--- clang/lib/Driver/ToolChains/BareMetal.h
+++ clang/lib/Driver/ToolChains/BareMetal.h
@@ -1,4 +1,5 @@
-//===--- BareMetal.h - Bare Metal Tool and ToolChain -*- C++ -*-===//
+//===--- BareMetal.h - Bare Metal Tool and ToolChain -*- C++
+//-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -33,13 +34,9 @@
 protected:
   Tool *buildLinker() const override;
 
-  std::string buildCompilerRTBasename(const llvm::opt::ArgList ,
-  StringRef Component,
-  FileType Type = ToolChain::FT_Static,
-  bool AddArch = true) const override;
-
 public:
   bool useIntegratedAs() const override { return true; }
+  bool isBareMetal() const override { return true; }
   bool isCrossCompiling() const override { return true; }
   bool isPICDefault() const override { return false; }
   bool isPIEDefault(const llvm::opt::ArgList ) const override {
@@ -50,8 +47,6 @@
 
   StringRef getOSLibName() const override { return "baremetal"; }
 
-  std::string getCompilerRTPath() const override;
-
   RuntimeLibType GetDefaultRuntimeLibType() const override {
 return ToolChain::RLT_CompilerRT;
   }
@@ -61,12 +56,13 @@
 
   const char *getDefaultLinker() const override { return "ld.lld"; }
 
-  std::string getRuntimesDir() const;
-  void AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
- llvm::opt::ArgStringList ) const override;
-  void addClangTargetOptions(const llvm::opt::ArgList ,
- llvm::opt::ArgStringList ,
- Action::OffloadKind DeviceOffloadKind) const override;
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const override;
+  void
+  

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

2022-08-09 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta updated this revision to Diff 451325.
manojgupta added a comment.

Fix clang-format complains.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131225

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/BareMetal.h
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/armv7m-vendor-none-eabi/libclang_rt.builtins.a
  clang/test/Driver/baremetal.cpp
  clang/test/Driver/print-libgcc-file-name-clangrt.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp

Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1932,6 +1932,45 @@
   }
 }
 
+bool Triple::isARMBareMetal() const {
+  if (getArch() != arm && getArch() != thumb)
+return false;
+  if (getVendor() != UnknownVendor)
+return false;
+  if (getOS() != UnknownOS)
+return false;
+  if (getEnvironment() != EABI && getEnvironment() != EABIHF)
+return false;
+
+  return true;
+}
+
+bool Triple::isAArch64BareMetal() const {
+  if (getArch() != aarch64)
+return false;
+  if (getVendor() != UnknownVendor)
+return false;
+  if (getOS() != UnknownOS)
+return false;
+
+  return getEnvironmentName() == "elf";
+}
+
+bool Triple::isRISCVBareMetal() const {
+  if (getArch() != riscv32 && getArch() != riscv64)
+return false;
+  if (getVendor() != UnknownVendor)
+return false;
+  if (getOS() != UnknownOS)
+return false;
+
+  return getEnvironmentName() == "elf";
+}
+
+bool Triple::isBareMetal() const {
+  return isARMBareMetal() || isAArch64BareMetal() || isRISCVBareMetal();
+}
+
 // HLSL triple environment orders are relied on in the front end
 static_assert(Triple::Vertex - Triple::Pixel == 1,
   "incorrect HLSL stage order");
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -912,6 +912,18 @@
 return Env == Triple::GNUX32 || Env == Triple::MuslX32;
   }
 
+  /// Tests if the target is {arm,thumb}-none-none-{eabi,eabihf}.
+  bool isARMBareMetal() const;
+
+  /// Tests if the target is aarch64-none-elf.
+  bool isAArch64BareMetal() const;
+
+  /// Tests if the target is riscv-none-none-elf.
+  bool isRISCVBareMetal() const;
+
+  /// Tests if this is a bare metal target.
+  bool isBareMetal() const;
+
   /// Tests whether the target supports comdat
   bool supportsCOMDAT() const {
 return !(isOSBinFormatMachO() || isOSBinFormatXCOFF());
Index: clang/test/Driver/print-libgcc-file-name-clangrt.c
===
--- clang/test/Driver/print-libgcc-file-name-clangrt.c
+++ clang/test/Driver/print-libgcc-file-name-clangrt.c
@@ -48,3 +48,9 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL %s
 // CHECK-CLANGRT-ARM-BAREMETAL: libclang_rt.builtins-armv7m.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=armv7m-vendor-none-eabi \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET %s
+// CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET: libclang_rt.builtins.a
Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -31,6 +31,20 @@
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBINC %s
 // CHECK-V6M-LIBINC-NOT: "-internal-isystem"
 
+// RUN: %clang -no-canonical-prefixes -rtlib=compiler-rt %s -### -o %t.o 2>&1 \
+// RUN: -target armv7m-vendor-none-eabi \
+// RUN: --sysroot=%S/Inputs/baremetal_arm \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARMV7M-PER-TARGET %s
+// CHECK-ARMV7M-PER-TARGET: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-ARMV7M-PER-TARGET: "-isysroot" "[[SYSROOT:[^"]*]]"
+// CHECK-ARMV7M-PER-TARGET: "-x" "c++" "{{.*}}baremetal.cpp"
+// CHECK-ARMV7M-PER-TARGET: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-ARMV7M-PER-TARGET: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
+// CHECK-ARMV7M-PER-TARGET: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}armv7m-vendor-none-eabi
+// CHECK-ARMV7M-PER-TARGET: "-lc" "-lm" "-lclang_rt.builtins"
+// CHECK-ARMV7M-PER-TARGET: "-o" "{{.*}}.o"
+
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target armv6m-none-eabi \
 // RUN: --sysroot=%S/Inputs/baremetal_arm \
Index: clang/lib/Driver/ToolChains/BareMetal.h
===
--- 

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

2022-08-09 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta updated this revision to Diff 451222.
manojgupta added a comment.

Address maskray comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131225

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/BareMetal.h
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/armv7m-vendor-none-eabi/libclang_rt.builtins.a
  clang/test/Driver/baremetal.cpp
  clang/test/Driver/print-libgcc-file-name-clangrt.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp

Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1932,6 +1932,45 @@
   }
 }
 
+bool Triple::isARMBareMetal() const {
+  if (getArch() != arm && getArch() != thumb)
+return false;
+  if (getVendor() != UnknownVendor)
+return false;
+  if (getOS() != UnknownOS)
+return false;
+  if (getEnvironment() != EABI && getEnvironment() != EABIHF)
+return false;
+
+  return true;
+}
+
+bool Triple::isAArch64BareMetal() const {
+  if (getArch() != aarch64)
+return false;
+  if (getVendor() != UnknownVendor)
+return false;
+  if (getOS() != UnknownOS)
+return false;
+
+  return getEnvironmentName() == "elf";
+}
+
+bool Triple::isRISCVBareMetal() const {
+  if (getArch() != riscv32 && getArch() != riscv64)
+return false;
+  if (getVendor() != UnknownVendor)
+return false;
+  if (getOS() != UnknownOS)
+return false;
+
+  return getEnvironmentName() == "elf";
+}
+
+bool Triple::isBareMetal() const {
+  return isARMBareMetal() || isAArch64BareMetal() || isRISCVBareMetal();
+}
+
 // HLSL triple environment orders are relied on in the front end
 static_assert(Triple::Vertex - Triple::Pixel == 1,
   "incorrect HLSL stage order");
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -912,6 +912,18 @@
 return Env == Triple::GNUX32 || Env == Triple::MuslX32;
   }
 
+  /// Tests if the target is {arm,thumb}-none-none-{eabi,eabihf}.
+  bool isARMBareMetal() const;
+
+  /// Tests if the target is aarch64-none-elf.
+  bool isAArch64BareMetal() const;
+
+  /// Tests if the target is riscv-none-none-elf.
+  bool isRISCVBareMetal() const;
+
+  /// Tests if this is a bare metal target.
+  bool isBareMetal() const;
+
   /// Tests whether the target supports comdat
   bool supportsCOMDAT() const {
 return !(isOSBinFormatMachO() || isOSBinFormatXCOFF());
Index: clang/test/Driver/print-libgcc-file-name-clangrt.c
===
--- clang/test/Driver/print-libgcc-file-name-clangrt.c
+++ clang/test/Driver/print-libgcc-file-name-clangrt.c
@@ -48,3 +48,9 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL %s
 // CHECK-CLANGRT-ARM-BAREMETAL: libclang_rt.builtins-armv7m.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=armv7m-vendor-none-eabi \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET %s
+// CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET: libclang_rt.builtins.a
Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -31,6 +31,20 @@
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBINC %s
 // CHECK-V6M-LIBINC-NOT: "-internal-isystem"
 
+// RUN: %clang -no-canonical-prefixes -rtlib=compiler-rt %s -### -o %t.o 2>&1 \
+// RUN: -target armv7m-vendor-none-eabi \
+// RUN: --sysroot=%S/Inputs/baremetal_arm \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARMV7M-PER-TARGET %s
+// CHECK-ARMV7M-PER-TARGET: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-ARMV7M-PER-TARGET: "-isysroot" "[[SYSROOT:[^"]*]]"
+// CHECK-ARMV7M-PER-TARGET: "-x" "c++" "{{.*}}baremetal.cpp"
+// CHECK-ARMV7M-PER-TARGET: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-ARMV7M-PER-TARGET: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
+// CHECK-ARMV7M-PER-TARGET: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}armv7m-vendor-none-eabi
+// CHECK-ARMV7M-PER-TARGET: "-lc" "-lm" "-lclang_rt.builtins"
+// CHECK-ARMV7M-PER-TARGET: "-o" "{{.*}}.o"
+
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target armv6m-none-eabi \
 // RUN: --sysroot=%S/Inputs/baremetal_arm \
Index: clang/lib/Driver/ToolChains/BareMetal.h
===
--- 

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

2022-08-08 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added inline comments.



Comment at: clang/lib/Driver/ToolChains/BareMetal.cpp:228-237
+  case ToolChain::RLT_CompilerRT: {
+const std::string fileName = getCompilerRT(Args, "builtins");
+std::string baseName = llvm::sys::path::filename(fileName).str();
+llvm::StringRef baseNameRef(baseName);
+baseNameRef.consume_front("lib");
+baseNameRef.consume_back(".a");
 CmdArgs.push_back(

barannikov88 wrote:
> There are a few style issues.
> * `return` is usually within the braces
> * Variable names should start with capital letter
> * Looks like std::string could be avoided completely in favor of `StringRef` 
> and `Twine`
> 
> Same applies to ConstructJob below, there are also redundant braces in `for` 
> statement.
Addressed most.
std::string is needed initially to avoid dangling storage issue:

warning: object backing the pointer will be destroyed at the end of the 
full-expression [-Wdangling-gsl]


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 Manoj Gupta via Phabricator via cfe-commits
manojgupta updated this revision to Diff 450910.
manojgupta added a comment.

Address more style lints.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131225

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/BareMetal.h
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/armv7m-vendor-none-eabi/libclang_rt.builtins.a
  clang/test/Driver/baremetal.cpp
  clang/test/Driver/print-libgcc-file-name-clangrt.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp

Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1932,6 +1932,51 @@
   }
 }
 
+bool Triple::isARMBareMetal() const {
+  if (getArch() != arm && getArch() != thumb)
+return false;
+
+  if (getVendor() != UnknownVendor)
+return false;
+
+  if (getOS() != UnknownOS)
+return false;
+
+  if (getEnvironment() != EABI && getEnvironment() != EABIHF)
+return false;
+
+  return true;
+}
+
+bool Triple::isAArch64BareMetal() const {
+  if (getArch() != aarch64)
+return false;
+
+  if (getVendor() != UnknownVendor)
+return false;
+
+  if (getOS() != UnknownOS)
+return false;
+
+  return getEnvironmentName() == "elf";
+}
+
+bool Triple::isRISCVBareMetal() const {
+  if (getArch() != riscv32 && getArch() != riscv64)
+return false;
+
+  if (getVendor() != UnknownVendor)
+return false;
+
+  if (getOS() != UnknownOS)
+return false;
+
+  return getEnvironmentName() == "elf";
+}
+
+bool Triple::isBareMetal() const {
+  return isARMBareMetal() || isAArch64BareMetal() || isRISCVBareMetal();
+}
 // HLSL triple environment orders are relied on in the front end
 static_assert(Triple::Vertex - Triple::Pixel == 1,
   "incorrect HLSL stage order");
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -912,6 +912,18 @@
 return Env == Triple::GNUX32 || Env == Triple::MuslX32;
   }
 
+  /// Tests if the target is {arm,thumb}-none-none-{eabi,eabihf}.
+  bool isARMBareMetal() const;
+
+  /// Tests if the target is aarch64-none-elf.
+  bool isAArch64BareMetal() const;
+
+  /// Tests if the target is riscv-none-none-elf.
+  bool isRISCVBareMetal() const;
+
+  /// Tests if this is a bare metal target.
+  bool isBareMetal() const;
+
   /// Tests whether the target supports comdat
   bool supportsCOMDAT() const {
 return !(isOSBinFormatMachO() || isOSBinFormatXCOFF());
Index: clang/test/Driver/print-libgcc-file-name-clangrt.c
===
--- clang/test/Driver/print-libgcc-file-name-clangrt.c
+++ clang/test/Driver/print-libgcc-file-name-clangrt.c
@@ -48,3 +48,9 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL %s
 // CHECK-CLANGRT-ARM-BAREMETAL: libclang_rt.builtins-armv7m.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=armv7m-vendor-none-eabi \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET %s
+// CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET: libclang_rt.builtins.a
Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -31,6 +31,20 @@
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBINC %s
 // CHECK-V6M-LIBINC-NOT: "-internal-isystem"
 
+// RUN: %clang -no-canonical-prefixes -rtlib=compiler-rt %s -### -o %t.o 2>&1 \
+// RUN: -target armv7m-vendor-none-eabi \
+// RUN: --sysroot=%S/Inputs/baremetal_arm \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARMV7M-PER-TARGET %s
+// CHECK-ARMV7M-PER-TARGET: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-ARMV7M-PER-TARGET: "-isysroot" "[[SYSROOT:[^"]*]]"
+// CHECK-ARMV7M-PER-TARGET: "-x" "c++" "{{.*}}baremetal.cpp"
+// CHECK-ARMV7M-PER-TARGET: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-ARMV7M-PER-TARGET: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
+// CHECK-ARMV7M-PER-TARGET: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}armv7m-vendor-none-eabi
+// CHECK-ARMV7M-PER-TARGET: "-lc" "-lm" "-lclang_rt.builtins"
+// CHECK-ARMV7M-PER-TARGET: "-o" "{{.*}}.o"
+
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target armv6m-none-eabi \
 // RUN: --sysroot=%S/Inputs/baremetal_arm \
Index: clang/lib/Driver/ToolChains/BareMetal.h
===
--- 

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

2022-08-08 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta updated this revision to Diff 450908.
manojgupta added a comment.

Address style nits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131225

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/BareMetal.h
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/armv7m-vendor-none-eabi/libclang_rt.builtins.a
  clang/test/Driver/baremetal.cpp
  clang/test/Driver/print-libgcc-file-name-clangrt.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp

Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1932,6 +1932,52 @@
   }
 }
 
+bool Triple::isARMBareMetal() const {
+  if (getArch() != llvm::Triple::arm && getArch() != Triple::thumb)
+return false;
+
+  if (getVendor() != llvm::Triple::UnknownVendor)
+return false;
+
+  if (getOS() != llvm::Triple::UnknownOS)
+return false;
+
+  if (getEnvironment() != llvm::Triple::EABI &&
+  getEnvironment() != llvm::Triple::EABIHF)
+return false;
+
+  return true;
+}
+
+bool Triple::isAArch64BareMetal() const {
+  if (getArch() != llvm::Triple::aarch64)
+return false;
+
+  if (getVendor() != llvm::Triple::UnknownVendor)
+return false;
+
+  if (getOS() != llvm::Triple::UnknownOS)
+return false;
+
+  return getEnvironmentName() == "elf";
+}
+
+bool Triple::isRISCVBareMetal() const {
+  if (getArch() != llvm::Triple::riscv32 && getArch() != llvm::Triple::riscv64)
+return false;
+
+  if (getVendor() != llvm::Triple::UnknownVendor)
+return false;
+
+  if (getOS() != llvm::Triple::UnknownOS)
+return false;
+
+  return getEnvironmentName() == "elf";
+}
+
+bool Triple::isBareMetal() const {
+  return isARMBareMetal() || isAArch64BareMetal() || isRISCVBareMetal();
+}
 // HLSL triple environment orders are relied on in the front end
 static_assert(Triple::Vertex - Triple::Pixel == 1,
   "incorrect HLSL stage order");
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -912,6 +912,18 @@
 return Env == Triple::GNUX32 || Env == Triple::MuslX32;
   }
 
+  /// Tests if the target is {arm,thumb}-none-none-{eabi,eabihf}.
+  bool isARMBareMetal() const;
+
+  /// Tests if the target is aarch64-none-elf.
+  bool isAArch64BareMetal() const;
+
+  /// Tests if the target is riscv-none-none-elf.
+  bool isRISCVBareMetal() const;
+
+  /// Tests if this is a bare metal target.
+  bool isBareMetal() const;
+
   /// Tests whether the target supports comdat
   bool supportsCOMDAT() const {
 return !(isOSBinFormatMachO() || isOSBinFormatXCOFF());
Index: clang/test/Driver/print-libgcc-file-name-clangrt.c
===
--- clang/test/Driver/print-libgcc-file-name-clangrt.c
+++ clang/test/Driver/print-libgcc-file-name-clangrt.c
@@ -48,3 +48,9 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL %s
 // CHECK-CLANGRT-ARM-BAREMETAL: libclang_rt.builtins-armv7m.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=armv7m-vendor-none-eabi \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET %s
+// CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET: libclang_rt.builtins.a
Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -31,6 +31,20 @@
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBINC %s
 // CHECK-V6M-LIBINC-NOT: "-internal-isystem"
 
+// RUN: %clang -no-canonical-prefixes -rtlib=compiler-rt %s -### -o %t.o 2>&1 \
+// RUN: -target armv7m-vendor-none-eabi \
+// RUN: --sysroot=%S/Inputs/baremetal_arm \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARMV7M-PER-TARGET %s
+// CHECK-ARMV7M-PER-TARGET: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-ARMV7M-PER-TARGET: "-isysroot" "[[SYSROOT:[^"]*]]"
+// CHECK-ARMV7M-PER-TARGET: "-x" "c++" "{{.*}}baremetal.cpp"
+// CHECK-ARMV7M-PER-TARGET: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-ARMV7M-PER-TARGET: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
+// CHECK-ARMV7M-PER-TARGET: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}armv7m-vendor-none-eabi
+// CHECK-ARMV7M-PER-TARGET: "-lc" "-lm" "-lclang_rt.builtins"
+// CHECK-ARMV7M-PER-TARGET: "-o" "{{.*}}.o"
+
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target armv6m-none-eabi 

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

2022-08-08 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta updated this revision to Diff 450898.
manojgupta added a comment.
Herald added a subscriber: hiraditya.

Moved defs to Triple.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131225

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/BareMetal.h
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/armv7m-vendor-none-eabi/libclang_rt.builtins.a
  clang/test/Driver/baremetal.cpp
  clang/test/Driver/print-libgcc-file-name-clangrt.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Support/Triple.cpp

Index: llvm/lib/Support/Triple.cpp
===
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1932,6 +1932,52 @@
   }
 }
 
+bool Triple::isARMBareMetal() const {
+  if (getArch() != llvm::Triple::arm && getArch() != Triple::thumb)
+return false;
+
+  if (getVendor() != llvm::Triple::UnknownVendor)
+return false;
+
+  if (getOS() != llvm::Triple::UnknownOS)
+return false;
+
+  if (getEnvironment() != llvm::Triple::EABI &&
+  getEnvironment() != llvm::Triple::EABIHF)
+return false;
+
+  return true;
+}
+
+bool Triple::isAArch64BareMetal() const {
+  if (getArch() != llvm::Triple::aarch64)
+return false;
+
+  if (getVendor() != llvm::Triple::UnknownVendor)
+return false;
+
+  if (getOS() != llvm::Triple::UnknownOS)
+return false;
+
+  return getEnvironmentName() == "elf";
+}
+
+bool Triple::isRISCVBareMetal() const {
+  if (getArch() != llvm::Triple::riscv32 && getArch() != llvm::Triple::riscv64)
+return false;
+
+  if (getVendor() != llvm::Triple::UnknownVendor)
+return false;
+
+  if (getOS() != llvm::Triple::UnknownOS)
+return false;
+
+  return getEnvironmentName() == "elf";
+}
+
+bool Triple::isBareMetal() const {
+  return isARMBareMetal() || isAArch64BareMetal() || isRISCVBareMetal();
+}
 // HLSL triple environment orders are relied on in the front end
 static_assert(Triple::Vertex - Triple::Pixel == 1,
   "incorrect HLSL stage order");
Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -912,6 +912,18 @@
 return Env == Triple::GNUX32 || Env == Triple::MuslX32;
   }
 
+  /// Tests if the target is {arm,thumb}-none-none-{eabi,eabihf}.
+  bool isARMBareMetal() const;
+
+  /// Tests if the target is aarch64-none-elf.
+  bool isAArch64BareMetal() const;
+
+  /// Tests if the target is riscv-none-none-elf.
+  bool isRISCVBareMetal() const;
+
+  /// Tests if this is a bare metal target.
+  bool isBareMetal() const;
+
   /// Tests whether the target supports comdat
   bool supportsCOMDAT() const {
 return !(isOSBinFormatMachO() || isOSBinFormatXCOFF());
Index: clang/test/Driver/print-libgcc-file-name-clangrt.c
===
--- clang/test/Driver/print-libgcc-file-name-clangrt.c
+++ clang/test/Driver/print-libgcc-file-name-clangrt.c
@@ -48,3 +48,9 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL %s
 // CHECK-CLANGRT-ARM-BAREMETAL: libclang_rt.builtins-armv7m.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=armv7m-vendor-none-eabi \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET %s
+// CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET: libclang_rt.builtins.a
Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -31,6 +31,20 @@
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBINC %s
 // CHECK-V6M-LIBINC-NOT: "-internal-isystem"
 
+// RUN: %clang -no-canonical-prefixes -rtlib=compiler-rt %s -### -o %t.o 2>&1 \
+// RUN: -target armv7m-vendor-none-eabi \
+// RUN: --sysroot=%S/Inputs/baremetal_arm \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARMV7M-PER-TARGET %s
+// CHECK-ARMV7M-PER-TARGET: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-ARMV7M-PER-TARGET: "-isysroot" "[[SYSROOT:[^"]*]]"
+// CHECK-ARMV7M-PER-TARGET: "-x" "c++" "{{.*}}baremetal.cpp"
+// CHECK-ARMV7M-PER-TARGET: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-ARMV7M-PER-TARGET: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
+// CHECK-ARMV7M-PER-TARGET: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}armv7m-vendor-none-eabi
+// CHECK-ARMV7M-PER-TARGET: "-lc" "-lm" "-lclang_rt.builtins"
+// CHECK-ARMV7M-PER-TARGET: "-o" "{{.*}}.o"
+
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 

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

2022-08-08 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added inline comments.



Comment at: clang/include/clang/Driver/ToolChain.h:388
+  /// IsRISCVBareMetal - Does this tool chain is a riscv baremetal target.
+  static bool IsRISCVBareMetal(const llvm::Triple &);
+

barannikov88 wrote:
> barannikov88 wrote:
> > manojgupta wrote:
> > > barannikov88 wrote:
> > > > The ToolChain class is an interface class. It is strange to see such 
> > > > kind of methods here. `IsBareMetal` should at least be virtual and 
> > > > overridden in concrete implementation of baremetal toolchains. 
> > > > `IsRISCVBareMetal` should not be here at all.
> > > > What was wrong with the previous implementation that made you move the 
> > > > methods here?
> > > There is a need to check for IsBareMetal and variants. They can't be made 
> > > virtual since the checks need to happen before instantiating ToolChain 
> > > class. I think moving them to Triple class (Triple.h) is a clearer option.
> > > I think moving them to Triple class (Triple.h) is a clearer option.
> > Is the triple is all that is necessary to decide whether the target is bare 
> > metal or not?
> > Sounds interesting, but one may argue that Triple should not know about 
> > toolchains (like it should not know about C data type bit widths, for 
> > example).
> > What if just add a few switch-cases to Driver::getToolChain as for every 
> > other toolchain? Retaining the former static method 
> > 'BareMetalToolChain::handlesTarget' is still better in my opinion.
> > They can't be made virtual since the checks need to happen before 
> > instantiating ToolChain class. 
> 
> This is kind of two different things. It can be made virtual. The name of the 
> method `IsBareMetal` of the `ToolChain` class suggests that it is checking 
> whether //this concrete instance// of the ToolChain is baremetal. This 
> (virtual) method could be used in getCompilerRTPath, for example.
> To //instantiate// BareMetalToolchain you need another function (like the 
> former BareMetalToolChain::handlesTarget, or the suggested approach with 
> Triple). For these instantiations `IsBareMetal` will return true, and false 
> for all other instantiations which are not bare metal.
> 
>Is the triple is all that is necessary to decide whether the target is bare 
>metal or not?

At least for baremetal, from what I see, triple seems to be the way how 
baremetal toolchain is decided in practice.

Examples: 
1. https://gitweb.gentoo.org/proj/crossdev.git/tree/crossdev#n331 ( 
# Bare metal targets*-newlib|*-elf|*-eabi|*-rtems*)
2. https://elinux.org/images/1/15/Anatomy_of_Cross-Compilation_Toolchains.pdf ( 
arm-foo-none-eabi, bare-metal toolchain targeting the ARM architecture, from
vendor foo )


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 Manoj Gupta via Phabricator via cfe-commits
manojgupta updated this revision to Diff 450894.
manojgupta added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Moved Baremetal triple related code to Triple.h.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131225

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/BareMetal.h
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/armv7m-vendor-none-eabi/libclang_rt.builtins.a
  clang/test/Driver/baremetal.cpp
  clang/test/Driver/print-libgcc-file-name-clangrt.c
  llvm/include/llvm/ADT/Triple.h

Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -912,6 +912,57 @@
 return Env == Triple::GNUX32 || Env == Triple::MuslX32;
   }
 
+  /// Tests if the target is {arm,thumb}-none-none-{eabi,eabihf}.
+  bool isARMBareMetal() const {
+if (getArch() != Triple::arm && getArch() != Triple::thumb)
+  return false;
+
+if (getVendor() != Triple::UnknownVendor)
+  return false;
+
+if (getOS() != Triple::UnknownOS)
+  return false;
+
+if (getEnvironment() != Triple::EABI &&
+getEnvironment() != Triple::EABIHF)
+  return false;
+
+return true;
+  }
+
+  /// Tests if the target is aarch64-none-elf.
+  bool isAArch64BareMetal() const {
+if (getArch() != Triple::aarch64)
+  return false;
+
+if (getVendor() != Triple::UnknownVendor)
+  return false;
+
+if (getOS() != Triple::UnknownOS)
+  return false;
+
+return getEnvironmentName() == "elf";
+  }
+
+  /// Tests if the target is riscv-none-none-elf.
+  bool isRISCVBareMetal() const {
+if (getArch() != Triple::riscv32 && getArch() != llvm::Triple::riscv64)
+  return false;
+
+if (getVendor() != Triple::UnknownVendor)
+  return false;
+
+if (getOS() != Triple::UnknownOS)
+  return false;
+
+return getEnvironmentName() == "elf";
+  }
+
+  /// Tests if this is a bare metal target.
+  bool isBareMetal() const {
+return isARMBareMetal() || isAArch64BareMetal() || isRISCVBareMetal();
+  }
+
   /// Tests whether the target supports comdat
   bool supportsCOMDAT() const {
 return !(isOSBinFormatMachO() || isOSBinFormatXCOFF());
Index: clang/test/Driver/print-libgcc-file-name-clangrt.c
===
--- clang/test/Driver/print-libgcc-file-name-clangrt.c
+++ clang/test/Driver/print-libgcc-file-name-clangrt.c
@@ -48,3 +48,9 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL %s
 // CHECK-CLANGRT-ARM-BAREMETAL: libclang_rt.builtins-armv7m.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=armv7m-vendor-none-eabi \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET %s
+// CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET: libclang_rt.builtins.a
Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -31,6 +31,20 @@
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBINC %s
 // CHECK-V6M-LIBINC-NOT: "-internal-isystem"
 
+// RUN: %clang -no-canonical-prefixes -rtlib=compiler-rt %s -### -o %t.o 2>&1 \
+// RUN: -target armv7m-vendor-none-eabi \
+// RUN: --sysroot=%S/Inputs/baremetal_arm \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARMV7M-PER-TARGET %s
+// CHECK-ARMV7M-PER-TARGET: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-ARMV7M-PER-TARGET: "-isysroot" "[[SYSROOT:[^"]*]]"
+// CHECK-ARMV7M-PER-TARGET: "-x" "c++" "{{.*}}baremetal.cpp"
+// CHECK-ARMV7M-PER-TARGET: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-ARMV7M-PER-TARGET: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
+// CHECK-ARMV7M-PER-TARGET: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}armv7m-vendor-none-eabi
+// CHECK-ARMV7M-PER-TARGET: "-lc" "-lm" "-lclang_rt.builtins"
+// CHECK-ARMV7M-PER-TARGET: "-o" "{{.*}}.o"
+
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target armv6m-none-eabi \
 // RUN: --sysroot=%S/Inputs/baremetal_arm \
Index: clang/lib/Driver/ToolChains/BareMetal.h
===
--- clang/lib/Driver/ToolChains/BareMetal.h
+++ clang/lib/Driver/ToolChains/BareMetal.h
@@ -25,19 +25,11 @@
 const llvm::opt::ArgList );
   ~BareMetal() override = default;
 
-  static bool handlesTarget(const llvm::Triple );
-
   void findMultilibs(const Driver , const llvm::Triple 

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

2022-08-08 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added inline comments.



Comment at: clang/include/clang/Driver/ToolChain.h:384
 
+  /// IsBareMetal - Does this tool chain is a baremetal target.
+  static bool IsBareMetal(const llvm::Triple &);

barannikov88 wrote:
> Is this a correct sentence? (My English is poor.)
> 
I'll fix it. Somehow I forgot to check them.



Comment at: clang/include/clang/Driver/ToolChain.h:388
+  /// IsRISCVBareMetal - Does this tool chain is a riscv baremetal target.
+  static bool IsRISCVBareMetal(const llvm::Triple &);
+

barannikov88 wrote:
> The ToolChain class is an interface class. It is strange to see such kind of 
> methods here. `IsBareMetal` should at least be virtual and overridden in 
> concrete implementation of baremetal toolchains. `IsRISCVBareMetal` should 
> not be here at all.
> What was wrong with the previous implementation that made you move the 
> methods here?
There is a need to check for IsBareMetal and variants. They can't be made 
virtual since the checks need to happen before instantiating ToolChain class. I 
think moving them to Triple class (Triple.h) is a clearer option.


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-04 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta created this revision.
manojgupta added reviewers: MaskRay, abidh, kristof.beyls.
Herald added subscribers: luke957, StephenFan, s.egerton, simoncook, ki.stfu.
Herald added a project: All.
manojgupta requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead.
Herald added a project: clang.

Refactor baremetal driver code to reduce the bespoke
additions and base class overrides.
This lets us use the per target runtimes like other clang
targets. E.g. clang -target armv7m-cros-none-eabi will now
be able to use the runtimes installed at
/lib/armv7m-cros-none-eabi instead of the hardcoded
path /lib/baremetal.
The older code paths should still continue to work as before if
/lib/ does not exist.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131225

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/BareMetal.h
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/armv7m-vendor-none-eabi/libclang_rt.builtins.a
  clang/test/Driver/baremetal.cpp
  clang/test/Driver/print-libgcc-file-name-clangrt.c

Index: clang/test/Driver/print-libgcc-file-name-clangrt.c
===
--- clang/test/Driver/print-libgcc-file-name-clangrt.c
+++ clang/test/Driver/print-libgcc-file-name-clangrt.c
@@ -48,3 +48,9 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL %s
 // CHECK-CLANGRT-ARM-BAREMETAL: libclang_rt.builtins-armv7m.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=armv7m-vendor-none-eabi \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET %s
+// CHECK-CLANGRT-ARM-BAREMETAL-PER-TARGET: libclang_rt.builtins.a
Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -31,6 +31,20 @@
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-LIBINC %s
 // CHECK-V6M-LIBINC-NOT: "-internal-isystem"
 
+// RUN: %clang -no-canonical-prefixes -rtlib=compiler-rt %s -### -o %t.o 2>&1 \
+// RUN: -target armv7m-vendor-none-eabi \
+// RUN: --sysroot=%S/Inputs/baremetal_arm \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-ARMV7M-PER-TARGET %s
+// CHECK-ARMV7M-PER-TARGET: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-ARMV7M-PER-TARGET: "-isysroot" "[[SYSROOT:[^"]*]]"
+// CHECK-ARMV7M-PER-TARGET: "-x" "c++" "{{.*}}baremetal.cpp"
+// CHECK-ARMV7M-PER-TARGET: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-ARMV7M-PER-TARGET: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
+// CHECK-ARMV7M-PER-TARGET: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}armv7m-vendor-none-eabi
+// CHECK-ARMV7M-PER-TARGET: "-lc" "-lm" "-lclang_rt.builtins"
+// CHECK-ARMV7M-PER-TARGET: "-o" "{{.*}}.o"
+
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target armv6m-none-eabi \
 // RUN: --sysroot=%S/Inputs/baremetal_arm \
Index: clang/lib/Driver/ToolChains/BareMetal.h
===
--- clang/lib/Driver/ToolChains/BareMetal.h
+++ clang/lib/Driver/ToolChains/BareMetal.h
@@ -25,19 +25,11 @@
 const llvm::opt::ArgList );
   ~BareMetal() override = default;
 
-  static bool handlesTarget(const llvm::Triple );
-
   void findMultilibs(const Driver , const llvm::Triple ,
  const llvm::opt::ArgList );
 
 protected:
   Tool *buildLinker() const override;
-
-  std::string buildCompilerRTBasename(const llvm::opt::ArgList ,
-  StringRef Component,
-  FileType Type = ToolChain::FT_Static,
-  bool AddArch = true) const override;
-
 public:
   bool useIntegratedAs() const override { return true; }
   bool isCrossCompiling() const override { return true; }
@@ -50,8 +42,6 @@
 
   StringRef getOSLibName() const override { return "baremetal"; }
 
-  std::string getCompilerRTPath() const override;
-
   RuntimeLibType GetDefaultRuntimeLibType() const override {
 return ToolChain::RLT_CompilerRT;
   }
@@ -61,7 +51,6 @@
 
   const char *getDefaultLinker() const override { return "ld.lld"; }
 
-  std::string getRuntimesDir() const;
   void AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
  llvm::opt::ArgStringList ) const override;
   void addClangTargetOptions(const llvm::opt::ArgList ,
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- 

[PATCH] D122983: [C11/C2x] Change the behavior of the implicit function declaration warning

2022-04-30 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Hmm, the commit message says that Wno-error should work but this is not really 
the case :(.

> (they can disable the warning or use -Wno-error to downgrade the
> error


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122983

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


[PATCH] D122895: [C89/C2x] Improve diagnostics around strict prototypes in C

2022-04-30 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Following behavior is also surprising:


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122895

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


[PATCH] D122895: [C89/C2x] Improve diagnostics around strict prototypes in C

2022-04-30 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Tried locally but I still see the warning with -fno-knr-functions. It also says 
that the argument is unused.

bin/clang --version
clang version 15.0.0 (https://github.com/llvm/llvm-project.git 
a9d68a5524dea113cace5983697786599cbdce9a 
)
Target: x86_64-unknown-linux-gnu

$ cat pr.c
void foo(void);

void foo() 
{
}
$ bin/clang -c pr.c -Wstrict-prototypes -fno-knr-functions
clang-14: warning: argument unused during compilation: '-fno-knr-functions' 
[-Wunused-command-line-argument]
pr.c:3:9: warning: a function declaration without a prototype is deprecated in 
all versions of C [-Wstrict-prototypes]
void foo()

  ^
   void

1 warning generated.

It works if -fno-knr-functions is passed with Xclang .  Is it intentional that 
-fno-knr-functions is only a cc1 option? That makes it very hard for us to 
enable it.

$ bin/clang -c pr.c -Wstrict-prototypes -Xclang -fno-knr-functions (no warnings)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122895

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


[PATCH] D122983: [C11/C2x] Change the behavior of the implicit function declaration warning

2022-04-30 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

We are finding a lot of failures in our ToT builds with this change. here is an 
example for a configure script:

$ cat tent.c
int  main ()
{
 tgetent(0,0);
 return 0;
}
$ bin/clang -c tent.c -Wno-error
tent.c:3:2: error: call to undeclared function 'tgetent'; ISO C99 and later do 
not support implicit function declarations [-Wimplicit-function-declaration]
 tgetent(0,0);
 ^
1 error generated.

It feels very surprising that Wno-error does not suppress this warning. Is that 
expected?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122983

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


[PATCH] D122895: [C89/C2x] Improve diagnostics around strict prototypes in C

2022-04-29 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Unless I  probably mis-interpreted something, -fno-knr-functions does not 
suppress the warning:  https://godbolt.org/z/rbEfbbb33


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122895

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


[PATCH] D122895: [C89/C2x] Improve diagnostics around strict prototypes in C

2022-04-29 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

  Basically, I'm wondering if you'd be able to enable -fno-knr-function?

Thanks. this looks promising. Any ideas when  -fno-knr-function support was 
added?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122895

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


[PATCH] D122895: [C89/C2x] Improve diagnostics around strict prototypes in C

2022-04-29 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

  Is disabling the pedantic warning an option for your users?

Disabling it wholesale is not an option since they actually want this warning  
(the older version). But we agreed to disable it specifically for the code 
where the warning was getting fired.
One instance is https://review.coreboot.org/c/coreboot/+/63936 .

I have been fixing our codebase to clean this and clean the instances. But it 
takes a lot of time and effort. Plus it takes a long time to clean one failure 
before I can find others  (public CLs) 
https://chromium-review.googlesource.com/q/Wstrict-prototypes+owner:manojgupta


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122895

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


[PATCH] D122895: [C89/C2x] Improve diagnostics around strict prototypes in C

2022-04-28 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Some of our users are not very happy with the churn probably caused by this 
change where the declaration has the "void" argument but the later definition 
does not have explicit "void".

  void foo(void);
  
  void foo() 
  {
  }

GCC  does not warn about this usage: https://godbolt.org/z/zPP8qjc98

Any opinions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122895

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


[PATCH] D123300: [Clang] Enable opaque pointers by default

2022-04-14 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

We noticed a new crash that still repros at head.

clang -target armv7a-linux-gnueabihf -march=armv8a -mthumb -c -O2 file.cc

llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10135: llvm::Value 
*llvm::VPTransformState::get(llvm::VPValue *, unsigned int): Assertion 
`(isa(Def->getDef()) || 
isa(Def->getDef())) && "unexpected recipe found to be 
invariant"' failed.

   C
  struct b;
  struct c {
using a = b *;
  };
  struct d {
d(c::a);
  };
  struct g;
  struct i {
typedef g *a;
  };
  struct g {
typedef i::a e;
e f;
  } * h;
  struct o {
typedef g ::e e;
  };
  struct p;
  struct H {
typedef g 
  };
  template  struct q;
  template  struct q {
static bq *bu(H::a r) {
  g  = r;
  h = 
  return h;
}
  };
  struct s : g {
e cf() { return q::bu(*this); }
  };
  struct t {
s ck;
  };
  template  struct K {
typedef cg bf;
typedef typename bf::ce ce;
struct cs {
  cs(bf) {}
  t cp;
} co;
K() : co(bf()) {
  typename ce::e k = co.cp.ck.cf();
  k->f = k;
}
  };
  struct L {
typedef K a;
  };
  struct p {
typedef o ce;
  };
  struct b : L::a {};
  struct M {
int l;
using m = b;
d n{new m[l]};
  };
  void u() { new M; }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123300

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


[PATCH] D121328: Disable -Wmissing-prototypes for internal linkage functions that aren't explicitly marked "static"""

2022-03-09 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

For the background, we had hit this in Chrome OS when building bluetooth code.

This is the one of structs hitting the issue where the warning got promoted to 
an error:

typedef struct {

private:

  static std::string AppendCapability(std::string& result, bool append,
  const std::string& name) {
   
  }

} btav_a2dp_codec_config_t;

Previously this was a warning that was suppressed in this code upstream using 
-Wno-non-c-typedef-for-linkage  but now it turns into a non-suppressible error.

The exact code actually comes from aosp, but this is the Chrome OS public 
accessible copy:
https://chromium.googlesource.com/aosp/platform/packages/modules/Bluetooth/+/main/system/include/hardware/bt_av.h


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121328

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


[PATCH] D114312: libfuzzer: Disable broken tests for arm

2021-11-22 Thread Manoj Gupta via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2e67276d984d: libfuzzer: Disable broken tests for arm 
(authored by manojgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114312

Files:
  compiler-rt/test/fuzzer/acquire-crash-state.test
  compiler-rt/test/fuzzer/compressed.test
  compiler-rt/test/fuzzer/msan-custom-mutator.test
  compiler-rt/test/fuzzer/msan-param-unpoison.test
  compiler-rt/test/fuzzer/msan.test
  compiler-rt/test/fuzzer/sigint.test
  compiler-rt/test/fuzzer/value-profile-div.test


Index: compiler-rt/test/fuzzer/value-profile-div.test
===
--- compiler-rt/test/fuzzer/value-profile-div.test
+++ compiler-rt/test/fuzzer/value-profile-div.test
@@ -1,5 +1,5 @@
 UNSUPPORTED: ios
-UNSUPPORTED: aarch64
+UNSUPPORTED: arm, aarch64
 CHECK: AddressSanitizer: {{FPE|int-divide-by-zero}}
 RUN: %cpp_compiler %S/DivTest.cpp -fsanitize-coverage=trace-div -o %t-DivTest
 RUN: not %run %t-DivTest -seed=1 -use_value_profile=1 -runs=1000 2>&1 | 
FileCheck %s
Index: compiler-rt/test/fuzzer/sigint.test
===
--- compiler-rt/test/fuzzer/sigint.test
+++ compiler-rt/test/fuzzer/sigint.test
@@ -1,4 +1,5 @@
 REQUIRES: msan
+UNSUPPORTED: arm
 
 # Check that libFuzzer exits gracefully under SIGINT with MSan.
 RUN: rm -rf %t
Index: compiler-rt/test/fuzzer/msan.test
===
--- compiler-rt/test/fuzzer/msan.test
+++ compiler-rt/test/fuzzer/msan.test
@@ -1,4 +1,5 @@
 REQUIRES: msan
+UNSUPPORTED: arm
 RUN: %msan_compiler %S/SimpleTestStdio.cpp -o %t
 RUN: not %run %t -seed=1 -runs=1000 2>&1 | FileCheck %s 
--check-prefix=NO-REPORT
 
Index: compiler-rt/test/fuzzer/msan-param-unpoison.test
===
--- compiler-rt/test/fuzzer/msan-param-unpoison.test
+++ compiler-rt/test/fuzzer/msan-param-unpoison.test
@@ -1,4 +1,5 @@
 REQUIRES: msan
+UNSUPPORTED: arm
 RUN: %msan_compiler %S/MsanParamUnpoison.cpp -o %t
 RUN: %run %t -seed=1 -runs=1000 2>&1 | FileCheck %s
 
Index: compiler-rt/test/fuzzer/msan-custom-mutator.test
===
--- compiler-rt/test/fuzzer/msan-custom-mutator.test
+++ compiler-rt/test/fuzzer/msan-custom-mutator.test
@@ -1,4 +1,5 @@
 REQUIRES: msan
+UNSUPPORTED: arm
 RUN: %msan_compiler %S/MsanCustomMutator.cpp -o %t
 RUN: %run %t -seed=1 -runs=1000 2>&1 | FileCheck %s
 
Index: compiler-rt/test/fuzzer/compressed.test
===
--- compiler-rt/test/fuzzer/compressed.test
+++ compiler-rt/test/fuzzer/compressed.test
@@ -2,7 +2,7 @@
 REQUIRES: zlib
 # zlib is "supported" on i386 even when only for x86_64, explicitly make i386
 # unsupported by this test.
-UNSUPPORTED: i386
+UNSUPPORTED: i386, arm
 # Custom mutator should find this bug, w/o custom -- no chance.
 RUN: %cpp_compiler %S/CompressedTest.cpp -o %t-CompressedTestCustom 
-DCUSTOM_MUTATOR -lz
 RUN: %cpp_compiler %S/CompressedTest.cpp -o %t-CompressedTestPlain -lz
Index: compiler-rt/test/fuzzer/acquire-crash-state.test
===
--- compiler-rt/test/fuzzer/acquire-crash-state.test
+++ compiler-rt/test/fuzzer/acquire-crash-state.test
@@ -1,3 +1,4 @@
+UNSUPPORTED: arm
 RUN: %cpp_compiler %S/AcquireCrashStateTest.cpp -o %t
 RUN: %run %t 2>&1 | FileCheck %s
 CHECK-NOT: fuzz target exited


Index: compiler-rt/test/fuzzer/value-profile-div.test
===
--- compiler-rt/test/fuzzer/value-profile-div.test
+++ compiler-rt/test/fuzzer/value-profile-div.test
@@ -1,5 +1,5 @@
 UNSUPPORTED: ios
-UNSUPPORTED: aarch64
+UNSUPPORTED: arm, aarch64
 CHECK: AddressSanitizer: {{FPE|int-divide-by-zero}}
 RUN: %cpp_compiler %S/DivTest.cpp -fsanitize-coverage=trace-div -o %t-DivTest
 RUN: not %run %t-DivTest -seed=1 -use_value_profile=1 -runs=1000 2>&1 | FileCheck %s
Index: compiler-rt/test/fuzzer/sigint.test
===
--- compiler-rt/test/fuzzer/sigint.test
+++ compiler-rt/test/fuzzer/sigint.test
@@ -1,4 +1,5 @@
 REQUIRES: msan
+UNSUPPORTED: arm
 
 # Check that libFuzzer exits gracefully under SIGINT with MSan.
 RUN: rm -rf %t
Index: compiler-rt/test/fuzzer/msan.test
===
--- compiler-rt/test/fuzzer/msan.test
+++ compiler-rt/test/fuzzer/msan.test
@@ -1,4 +1,5 @@
 REQUIRES: msan
+UNSUPPORTED: arm
 RUN: %msan_compiler %S/SimpleTestStdio.cpp -o %t
 RUN: not %run %t -seed=1 -runs=1000 2>&1 | FileCheck %s --check-prefix=NO-REPORT
 
Index: compiler-rt/test/fuzzer/msan-param-unpoison.test
===
--- 

[PATCH] D114312: libfuzzer: Disable broken tests for arm

2021-11-19 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta created this revision.
manojgupta added reviewers: morehouse, metzman.
Herald added a subscriber: kristof.beyls.
manojgupta requested review of this revision.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

libfuzzer was recently enabled for Arm32 in D112091 
.
A few tests apparently do not work with arm32 so disable them.
The list of tests was obtained from
https://lab.llvm.org/buildbot/#/builders/190/builds/513


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114312

Files:
  compiler-rt/test/fuzzer/acquire-crash-state.test
  compiler-rt/test/fuzzer/compressed.test
  compiler-rt/test/fuzzer/msan-custom-mutator.test
  compiler-rt/test/fuzzer/msan-param-unpoison.test
  compiler-rt/test/fuzzer/msan.test
  compiler-rt/test/fuzzer/sigint.test
  compiler-rt/test/fuzzer/value-profile-div.test


Index: compiler-rt/test/fuzzer/value-profile-div.test
===
--- compiler-rt/test/fuzzer/value-profile-div.test
+++ compiler-rt/test/fuzzer/value-profile-div.test
@@ -1,5 +1,5 @@
 UNSUPPORTED: ios
-UNSUPPORTED: aarch64
+UNSUPPORTED: arm, aarch64
 CHECK: AddressSanitizer: {{FPE|int-divide-by-zero}}
 RUN: %cpp_compiler %S/DivTest.cpp -fsanitize-coverage=trace-div -o %t-DivTest
 RUN: not %run %t-DivTest -seed=1 -use_value_profile=1 -runs=1000 2>&1 | 
FileCheck %s
Index: compiler-rt/test/fuzzer/sigint.test
===
--- compiler-rt/test/fuzzer/sigint.test
+++ compiler-rt/test/fuzzer/sigint.test
@@ -1,4 +1,5 @@
 REQUIRES: msan
+UNSUPPORTED: arm
 
 # Check that libFuzzer exits gracefully under SIGINT with MSan.
 RUN: rm -rf %t
Index: compiler-rt/test/fuzzer/msan.test
===
--- compiler-rt/test/fuzzer/msan.test
+++ compiler-rt/test/fuzzer/msan.test
@@ -1,4 +1,5 @@
 REQUIRES: msan
+UNSUPPORTED: arm
 RUN: %msan_compiler %S/SimpleTestStdio.cpp -o %t
 RUN: not %run %t -seed=1 -runs=1000 2>&1 | FileCheck %s 
--check-prefix=NO-REPORT
 
Index: compiler-rt/test/fuzzer/msan-param-unpoison.test
===
--- compiler-rt/test/fuzzer/msan-param-unpoison.test
+++ compiler-rt/test/fuzzer/msan-param-unpoison.test
@@ -1,4 +1,5 @@
 REQUIRES: msan
+UNSUPPORTED: arm
 RUN: %msan_compiler %S/MsanParamUnpoison.cpp -o %t
 RUN: %run %t -seed=1 -runs=1000 2>&1 | FileCheck %s
 
Index: compiler-rt/test/fuzzer/msan-custom-mutator.test
===
--- compiler-rt/test/fuzzer/msan-custom-mutator.test
+++ compiler-rt/test/fuzzer/msan-custom-mutator.test
@@ -1,4 +1,5 @@
 REQUIRES: msan
+UNSUPPORTED: arm
 RUN: %msan_compiler %S/MsanCustomMutator.cpp -o %t
 RUN: %run %t -seed=1 -runs=1000 2>&1 | FileCheck %s
 
Index: compiler-rt/test/fuzzer/compressed.test
===
--- compiler-rt/test/fuzzer/compressed.test
+++ compiler-rt/test/fuzzer/compressed.test
@@ -2,7 +2,7 @@
 REQUIRES: zlib
 # zlib is "supported" on i386 even when only for x86_64, explicitly make i386
 # unsupported by this test.
-UNSUPPORTED: i386
+UNSUPPORTED: i386, arm
 # Custom mutator should find this bug, w/o custom -- no chance.
 RUN: %cpp_compiler %S/CompressedTest.cpp -o %t-CompressedTestCustom 
-DCUSTOM_MUTATOR -lz
 RUN: %cpp_compiler %S/CompressedTest.cpp -o %t-CompressedTestPlain -lz
Index: compiler-rt/test/fuzzer/acquire-crash-state.test
===
--- compiler-rt/test/fuzzer/acquire-crash-state.test
+++ compiler-rt/test/fuzzer/acquire-crash-state.test
@@ -1,3 +1,4 @@
+UNSUPPORTED: arm
 RUN: %cpp_compiler %S/AcquireCrashStateTest.cpp -o %t
 RUN: %run %t 2>&1 | FileCheck %s
 CHECK-NOT: fuzz target exited


Index: compiler-rt/test/fuzzer/value-profile-div.test
===
--- compiler-rt/test/fuzzer/value-profile-div.test
+++ compiler-rt/test/fuzzer/value-profile-div.test
@@ -1,5 +1,5 @@
 UNSUPPORTED: ios
-UNSUPPORTED: aarch64
+UNSUPPORTED: arm, aarch64
 CHECK: AddressSanitizer: {{FPE|int-divide-by-zero}}
 RUN: %cpp_compiler %S/DivTest.cpp -fsanitize-coverage=trace-div -o %t-DivTest
 RUN: not %run %t-DivTest -seed=1 -use_value_profile=1 -runs=1000 2>&1 | FileCheck %s
Index: compiler-rt/test/fuzzer/sigint.test
===
--- compiler-rt/test/fuzzer/sigint.test
+++ compiler-rt/test/fuzzer/sigint.test
@@ -1,4 +1,5 @@
 REQUIRES: msan
+UNSUPPORTED: arm
 
 # Check that libFuzzer exits gracefully under SIGINT with MSan.
 RUN: rm -rf %t
Index: compiler-rt/test/fuzzer/msan.test
===
--- compiler-rt/test/fuzzer/msan.test
+++ compiler-rt/test/fuzzer/msan.test
@@ -1,4 +1,5 @@
 REQUIRES: msan
+UNSUPPORTED: arm
 RUN: 

[PATCH] D113779: [Clang] Add mfp16, mfp16fml and mdotprod flags for ARM target features.

2021-11-18 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

> More subjective: for most users this whole -march business is abstracted away 
> in build systems, so they won't have to deal with this, that's why this isn't 
> so much of an improvement.



> If we want a better user experience set options, there are probably other 
> things that are more important, like checking legal/illegal architecture 
> combinations.



> So, in summary, we prefer not to go ahead with this. And the precedent that 
> was mentioned, -mcrc, should probably be deprecated.

I'd argue the contrary that the current way of -march=isa+feature is broken. I 
am yet to see a build system that understands or processes the values inside 
march arguments. And this blocks users from choosing custom hw features without 
resorting to terrible hacks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113779

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


[PATCH] D112091: libfuzzer: All building libfuzzer for ARM32

2021-11-18 Thread Manoj Gupta via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2782cb8da0b3: libfuzzer: All building libfuzzer for ARM32 
(authored by manojgupta).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112091

Files:
  compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake


Index: compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
===
--- compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -38,7 +38,7 @@
 endif()
 
 if(OS_NAME MATCHES "Linux")
-  set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM64} ${S390X})
+  set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${S390X})
 elseif (OS_NAME MATCHES "Windows")
   set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${X86_64})
 elseif(OS_NAME MATCHES "Android")


Index: compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
===
--- compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -38,7 +38,7 @@
 endif()
 
 if(OS_NAME MATCHES "Linux")
-  set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM64} ${S390X})
+  set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${S390X})
 elseif (OS_NAME MATCHES "Windows")
   set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${X86_64})
 elseif(OS_NAME MATCHES "Android")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112091: libfuzzer: All building libfuzzer for ARM32

2021-11-17 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a reviewer: morehouse.
manojgupta added a comment.

Matt, do you think you can review this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112091

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


[PATCH] D113779: [Clang] Add mfp16, mfp16fml and mdotprod flags for ARM target features.

2021-11-15 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Yes, the current approach of "-march=+feature" is terrible and does not 
work with developers who want flexibility of features. This being pitched as a 
feature imo is akin to promoting a design bug as a feature. 
Any additive or subtractive alternative is welcome.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113779

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


[PATCH] D112091: libfuzzer: All building libfuzzer for ARM32

2021-10-28 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

@kcc do you have any concerns?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112091

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


[PATCH] D112091: libfuzzer: All building libfuzzer for ARM32

2021-10-19 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta created this revision.
manojgupta added a reviewer: metzman.
Herald added subscribers: kristof.beyls, mgorny.
manojgupta requested review of this revision.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

We need libfuzzer libraries on Arm32 so that we can fuzz
Arm32 binaries on Linux (Chrome OS). Android already
allows Arm32 for libfuzzer.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112091

Files:
  compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake


Index: compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
===
--- compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -38,7 +38,7 @@
 endif()
 
 if(OS_NAME MATCHES "Linux")
-  set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM64} ${S390X})
+  set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${S390X})
 elseif (OS_NAME MATCHES "Windows")
   set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${X86_64})
 elseif(OS_NAME MATCHES "Android")


Index: compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
===
--- compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -38,7 +38,7 @@
 endif()
 
 if(OS_NAME MATCHES "Linux")
-  set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM64} ${S390X})
+  set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${S390X})
 elseif (OS_NAME MATCHES "Windows")
   set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${X86_64})
 elseif(OS_NAME MATCHES "Android")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112059: Fix inline builtin handling in case of redefinition

2021-10-19 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

thanks, I can verify that it fixes the crash we were seeing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112059

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


[PATCH] D111009: Update inline builtin handling to honor gnu inline attribute

2021-10-16 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

I am noticing a clang crash with ToT after this change.

- testcase --

  long a;
  char b, d;
  extern inline __attribute__((always_inline))
  __attribute__((gnu_inline)) unsigned long
  strlen() {
return a;
  }
  c(void) {
strlen();
return 0;
  }
  unsigned long strlen() { return d; }

  bin/clang -x c foo.c -Wno-error
  foo.c:8:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
  c(void) {
  ^
  Global is external, but doesn't have external or weak linkage!
  i64 (i8*)* @strlen.inline
  fatal error: error in backend: Broken module found, compilation aborted!
  clang version 14.0.0 (https://github.com/llvm/llvm-project.git 
3129aa5caf1f9b5c48ab708f43cb3fc5173dd021)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111009

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


[PATCH] D99517: Implemented [[clang::musttail]] attribute for guaranteed tail calls.

2021-08-09 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Please also see https://bugs.llvm.org/show_bug.cgi?id=51416


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99517

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


[PATCH] D52524: Add -Wpoison-system-directories warning

2021-05-20 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

An earlier version did check for library directories [1]. I am not exactly sure 
why was it removed, maybe it didn't work. So if anyone is willing to test that, 
please apply the diff and try.

[1] Diff https://reviews.llvm.org/D52524?id=215958


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

https://reviews.llvm.org/D52524

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


[PATCH] D97894: [Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection

2021-03-11 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta accepted this revision.
manojgupta added a comment.

@MaskRay I have verified that Chrome OS builds are not affected by this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97894

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


[PATCH] D97993: [Driver] Suppress GCC detection under -B for non-Android

2021-03-05 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a subscriber: tstellar.
manojgupta added a comment.

Thanks for the clarification. I do not have any objections but I feel that am 
not the right person to approve this change.
@tstellar can you please review it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97993

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


[PATCH] D97993: [Driver] Suppress GCC detection under -B for non-Android

2021-03-05 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Another concern is people generally want clang to work out of box without any 
special arguments.  As a user, after installing clang's distro package or 
building from source, I expect that basic compilation should work out-of-box 
which includes gcc detection.
i.e. "clang foo.cpp -o foo" should just work in most cases.

If a user now needs to pass "-gcc-toolchain" to find gcc libraries when it just 
used to work, that is most likely not desirable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97993

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


[PATCH] D97993: [Driver] Suppress GCC detection under -B for non-Android

2021-03-04 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Thanks for explaining that it only affects "-B". While I believe that this 
change won't affect us in Chrome OS, I think it should be reviewed and approved 
by a few Linux distro contributors since there is already known reliance e.g. 
Android on the current behavior.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97993

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


[PATCH] D97902: [Driver] Clarify --gcc-toolchain

2021-03-04 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

thanks, this is much needed documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97902

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


[PATCH] D97993: [Driver] Suppress GCC detection under -B for non-Android

2021-03-04 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

I am not sure of the rationale or upside of this change and why do we want to 
drop gcc detection? GCC does not need to do the GCC detection because it has 
the needed information at configure time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97993

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


[PATCH] D97894: [Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection

2021-03-04 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

> With the special rule, it is: if --gcc-toolchain is $sysroot/usr, suppress 
> sysroot GCC detection as well.
>
> Clang -B and --gcc-toolchain have some weird behaviors. Hope you can share 
> your opinions on 
> https://lists.llvm.org/pipermail/cfe-dev/2021-March/067827.html

Sure, I have replied on the thread with chrome os usage explanation. I also 
noticed that we also use "--gcc-toolchain" as well so the whole lot.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97894

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


[PATCH] D97894: [Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection

2021-03-04 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

In Chrome OS, we currently both "-B" and "--prefix". "-B" points to binutils 
bin directory and the "--prefix" has the binutils directory + target suffix. 
Should we drop "-B" and still get the same behavior?

Sample invocation: '/usr/bin/clang++' '--sysroot=/usr/x86_64-cros-linux-gnu 
'-fcrash-diagnostics-dir=/tmp/clang_crash_diagnostics' '-fcommon' 
'-fstack-protector-strong' '-fPIE' '-pie' '-D_FORTIFY_SOURCE=2' 
'-fno-omit-frame-pointer' 
'--prefix=../../../../../../usr/libexec/gcc/x86_64-cros-linux-gnu/x86_64-cros-linux-gnu-'
 'foo.o' '-o' 'main' 
'-B../../../../../../usr/libexec/gcc/x86_64-cros-linux-gnu' '-target' 
'x86_64-cros-linux-gnu'

I am not yet able to test this change in Chrome OS thoroughly yet because of 
some CQ issues. But manually checking the command lines for a few common cases 
does not show any difference so far.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97894

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


[PATCH] D97894: [Driver] Drop $sysroot/usr special case from Gentoo gcc-config detection

2021-03-03 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Thanks @MaskRay for this clean up. I can't speak for all of Gentoo but please 
give me a couple of days to at least test this on Chrome OS.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97894

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


[PATCH] D92892: [clang] Change builtin object size to be compatible with GCC when sub-object is invalid

2021-01-20 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

This CL has caused two issues in Chrome OS :
Compilation fail with FORTIFY: 
https://bugs.chromium.org/p/chromium/issues/detail?id=1168199
Runtime failures: https://bugs.chromium.org/p/chromium/issues/detail?id=1167504

I have requested George to take a look but will it be ok to revert this 
meanwhile?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92892

___
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-11-26 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

lgtm but not an expert in this area.


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] D89327: fixes compiler-rt bug when printing libgcc for baremetal

2020-10-14 Thread Manoj Gupta via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG18432bea7648: [Driver]: fix compiler-rt path when printing 
libgcc for baremetal (authored by cjdb, committed by manojgupta).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D89327?vs=297924=298180#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89327

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/BareMetal.h
  clang/test/Driver/print-libgcc-file-name-clangrt.c


Index: clang/test/Driver/print-libgcc-file-name-clangrt.c
===
--- clang/test/Driver/print-libgcc-file-name-clangrt.c
+++ clang/test/Driver/print-libgcc-file-name-clangrt.c
@@ -42,3 +42,9 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-ABI %s
 // CHECK-CLANGRT-ARM-ABI: libclang_rt.builtins-armhf.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=armv7m-none-eabi \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL %s
+// CHECK-CLANGRT-ARM-BAREMETAL: libclang_rt.builtins-armv7m.a
Index: clang/lib/Driver/ToolChains/BareMetal.h
===
--- clang/lib/Driver/ToolChains/BareMetal.h
+++ clang/lib/Driver/ToolChains/BareMetal.h
@@ -23,7 +23,7 @@
 public:
   BareMetal(const Driver , const llvm::Triple ,
 const llvm::opt::ArgList );
-  ~BareMetal() override;
+  ~BareMetal() override = default;
 
   static bool handlesTarget(const llvm::Triple );
 protected:
@@ -37,6 +37,14 @@
   bool isPICDefaultForced() const override { return false; }
   bool SupportsProfiling() const override { return false; }
 
+  StringRef getOSLibName() const override { return "baremetal"; }
+
+  std::string getCompilerRTPath() const override;
+  std::string getCompilerRTBasename(const llvm::opt::ArgList ,
+StringRef Component,
+FileType Type = ToolChain::FT_Static,
+bool AddArch = true) const override;
+
   RuntimeLibType GetDefaultRuntimeLibType() const override {
 return ToolChain::RLT_CompilerRT;
   }
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -35,8 +35,6 @@
 getProgramPaths().push_back(getDriver().Dir);
 }
 
-BareMetal::~BareMetal() {}
-
 /// Is the triple {arm,thumb}-none-none-{eabi,eabihf} ?
 static bool isARMBareMetal(const llvm::Triple ) {
   if (Triple.getArch() != llvm::Triple::arm &&
@@ -64,6 +62,13 @@
   return new tools::baremetal::Linker(*this);
 }
 
+std::string BareMetal::getCompilerRTPath() const { return getRuntimesDir(); }
+
+std::string BareMetal::getCompilerRTBasename(const llvm::opt::ArgList &,
+ StringRef, FileType, bool) const {
+  return ("libclang_rt.builtins-" + getTriple().getArchName() + ".a").str();
+}
+
 std::string BareMetal::getRuntimesDir() const {
   SmallString<128> Dir(getDriver().ResourceDir);
   llvm::sys::path::append(Dir, "lib", "baremetal");
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -419,10 +419,10 @@
   getCompilerRTArgString(const llvm::opt::ArgList , StringRef Component,
  FileType Type = ToolChain::FT_Static) const;
 
-  std::string getCompilerRTBasename(const llvm::opt::ArgList ,
-StringRef Component,
-FileType Type = ToolChain::FT_Static,
-bool AddArch = true) const;
+  virtual std::string
+  getCompilerRTBasename(const llvm::opt::ArgList , StringRef Component,
+FileType Type = ToolChain::FT_Static,
+bool AddArch = true) const;
 
   // Returns target specific runtime path if it exists.
   virtual Optional getRuntimePath() const;
@@ -435,7 +435,7 @@
   std::string getArchSpecificLibPath() const;
 
   // Returns  part of above.
-  StringRef getOSLibName() const;
+  virtual StringRef getOSLibName() const;
 
   /// needsProfileRT - returns true if instrumentation profile is on.
   static bool needsProfileRT(const llvm::opt::ArgList );


Index: clang/test/Driver/print-libgcc-file-name-clangrt.c
===
--- clang/test/Driver/print-libgcc-file-name-clangrt.c
+++ 

[PATCH] D87901: [Driver] Filter out /gcc and /gcc-cross if they do not exists

2020-09-26 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added inline comments.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:1949
+  // Maybe filter out /gcc and /gcc-cross.
+  GCCDirExists = D.getVFS().exists(LibDir + "/gcc");
+  GCCCrossDirExists = D.getVFS().exists(LibDir + "/gcc-cross");

Since these are class fields, please initialize these to false in beginning of 
the function. Otherwise, it might be tempting to use them elsewhere where they 
may not be initialized.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87901

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


[PATCH] D87143: Check whether Gentoo-specific configuration directory exists

2020-09-04 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta accepted this revision.
manojgupta added a comment.
This revision is now accepted and ready to land.

Looks ok to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87143

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


[PATCH] D87143: Check whether Gentoo-specific configuration directory exists

2020-09-04 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a reviewer: mgorny.
manojgupta added inline comments.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:2537-2538
 const SmallVectorImpl ) {
+  if (!D.getVFS().exists(GentooConfigDir))
+return false;
+

I think it should be D.SysRoot + GentooConfigDir. Otherwise, there is no way to 
test a Gentoo configuration tests on a non-Gentoo machine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87143

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


[PATCH] D78862: [IR] Convert null-pointer-is-valid into an enum attribute

2020-04-28 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

@nikic Thanks for the work.

In D78862#2003684 , @arsenm wrote:

> FWIW I think this attribute should be replaced with a data layout property, 
> so this would eventually be removed


@arsenm  Is there any work planned on moving to data layout? Moving to data 
layout may affect cross TU inlining e.g. LTO where 1 TU is compiled with 
`-fno-delete-null-pointer-checks` and other TU is not. There might be other 
potential impact that we might not know yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78862



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


[PATCH] D71082: Allow system header to provide their own implementation of some builtin

2020-04-07 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

I opened https://github.com/ClangBuiltLinux/linux/issues/979 to see if we can 
fix this in Linux kernel.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71082



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


[PATCH] D71082: Allow system header to provide their own implementation of some builtin

2020-04-02 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Yes, it'd be nice if all of the FORTIFY handling can be improved. For a simple 
call like memcpy of 8 bytes in the example, there is no reason to emit all 
these stack/range checks since they'd degrade memcpy performance.

I still think this change should be reverted if it can't handle Linux kernel's 
FORTIFY implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71082



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


[PATCH] D71082: Allow system header to provide their own implementation of some builtin

2020-03-31 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Unfortunately, cherry-picking the kernel patches didn't work including latest 
memcpy for x86 
(https://github.com/torvalds/linux/commit/170d13ca3a2fdaaa0283399247631b76b441cca2
 and 
https://github.com/torvalds/linux/commit/c228d294f2040c3a5f5965ff04d4947d0bf6e7da
 ).
Also tried ToT Linux kernel but still the same problem.

So far, it is not clear to me whether clang is at fault or Linux kernel has 
incorrect assumptions about memcpy. Also note that memcpy_fromio has the 
argument type as volatile void* which I believe is to inhibit some compiler 
optimizations.

@efriedma do you have any suggestions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71082



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


[PATCH] D71082: Allow system header to provide their own implementation of some builtin

2020-03-31 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added subscribers: nickdesaulniers, llozano, srhines.
manojgupta added a comment.

I was able to reduce to following:

  typedef unsigned int u32;
  typedef unsigned long long u64;
  typedef unsigned long size_t;
  
  void fortify_panic(const char *name) __attribute__((noreturn)) ;
  void __read_overflow(void) ;
  void __read_overflow2(void) ;
  void __write_overflow(void) ;
  
  extern void *memcpy(void *to, const void *from, size_t len);
  extern void *__memcpy(void *to, const void *from, size_t len);
  
  extern inline __attribute__((unused)) __attribute__((no_instrument_function)) 
__attribute__((always_inline)) __attribute__((gnu_inline)) void *memcpy(void 
*p, const void *q, size_t size)
  {
   size_t p_size = __builtin_object_size(p, 0);
   size_t q_size = __builtin_object_size(q, 0);
   if (__builtin_constant_p(size)) {
if (p_size < size)
 __write_overflow();
if (q_size < size)
 __read_overflow2();
   }
   if (p_size < size || q_size < size)
fortify_panic(__func__);
   return __builtin_memcpy(p, q, size);
  }
  
  static inline __attribute__((unused)) __attribute__((no_instrument_function)) 
void
  memcpy_fromio(void *dst, const volatile void *src, size_t count)
  {
   memcpy(dst, (const void *)src, count);
  }
  
  u64 sst_shim32_read64(void *addr, u32 offset)
  {
   u64 val;
   memcpy_fromio(, addr + offset, sizeof(val));
   return val;
  }

Compiling with

  clang -Qunused-arguments -D_FORTIFY_SOURCE=2 -fno-omit-frame-pointer 
-fno-stack-protector  -nostdinc  -fno-strict-aliasing -fno-common  -std=gnu89 
-fno-PIE -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -mno-80387 
-mstack-alignment=8 -mtune=generic -mno-red-zone -mcmodel=kernel 
-funit-at-a-time  -pipe  -mretpoline-external-thunk 
-fno-delete-null-pointer-checks  -Os -fstack-protector-strong -mno-global-merge 
-no-integrated-as  -fno-omit-frame-pointer -fno-optimize-sibling-calls 
-ftrivial-auto-var-init=pattern  -pg -mfentry  -fno-strict-overflow 
-fno-merge-all-constants -fno-stack-check  -c -o test.o test.c -target 
x86_64-cros-linux-gnu

and objdump -drW test.o
before:
No memcpy is emitted as clang is able to optimize it.

   :
 0: e8 00 00 00 00  callq  5 
1: R_X86_64_PLT32   __fentry__-0x4
 5: 55  push   %rbp
 6: 48 89 e5mov%rsp,%rbp
 9: 89 f0   mov%esi,%eax
 b: 48 8b 04 07 mov(%rdi,%rax,1),%rax
 f: 5d  pop%rbp
10: c3  retq 

After:

A call to memcpy is emitted.

   :
 0: e8 00 00 00 00  callq  5 
1: R_X86_64_PLT32   __fentry__-0x4
 5: 55  push   %rbp
 6: 48 89 e5mov%rsp,%rbp
 9: 53  push   %rbx
 a: 48 83 ec 10 sub$0x10,%rsp
 e: 65 48 8b 04 25 28 00mov%gs:0x28,%rax
15: 00 00 
17: 48 89 45 f0 mov%rax,-0x10(%rbp)
1b: 48 b8 aa aa aa aa aamovabs $0x,%rax
22: aa aa aa 
25: 48 8d 5d e8 lea-0x18(%rbp),%rbx
29: 48 89 03mov%rax,(%rbx)
2c: 89 f6   mov%esi,%esi
2e: 48 01 feadd%rdi,%rsi
31: ba 08 00 00 00  mov$0x8,%edx
36: 48 89 dfmov%rbx,%rdi
39: e8 00 00 00 00  callq  3e 
3a: R_X86_64_PLT32  memcpy-0x4
3e: 48 8b 03mov(%rbx),%rax
41: 65 48 8b 0c 25 28 00mov%gs:0x28,%rcx
48: 00 00 
4a: 48 3b 4d f0 cmp-0x10(%rbp),%rcx
4e: 75 07   jne57 
50: 48 83 c4 10 add$0x10,%rsp
54: 5b  pop%rbx
55: 5d  pop%rbp
56: c3  retq   
57: e8 00 00 00 00  callq  5c 
58: R_X86_64_PLT32  __stack_chk_fail-0x4

At this point, it is not clear to me if clang is doing anything wrong here is 
or this a bug in kernel 4.4 that it is using a regular memcpy for IO which 
cannot use regular memcpy.
And so I suspect we need to backport 
https://github.com/torvalds/linux/commit/c2327da06b33d8e1093ce2c28f395bc500d1b0d3
 to older kernel versions.

@nickdesaulniers wdyt?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71082



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


[PATCH] D71082: Allow system header to provide their own implementation of some builtin

2020-03-31 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Sure, I am trying to root cause the issue. Will report back hopefully soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71082



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


[PATCH] D71082: Allow system header to provide their own implementation of some builtin

2020-03-31 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

We believe this change (relanded as 
https://reviews.llvm.org/rGd437fba8ef626b6d8b7928540f630163a9b04021) is causing 
a mis-compile in Linux kernel 4.4 builds resulting in local test failures.
Chrome OS bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1066638

I will try to see if I can reduce it further but will it be ok to revert this 
change meanwhile?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71082



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


[PATCH] D62627: [NFC] Do not run CGProfilePass when -fno-integrated-as is on

2020-03-23 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Thanks,

Noticed a few typos. Rest lgtm but deferring to other reviewers for now for 
approval.




Comment at: clang/lib/CodeGen/BackendUtil.cpp:1110
   PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+  PTO.CallGrpahProfile = CodeGenOpts.CallGraphProfile;
   PTO.Coroutines = LangOpts.Coroutines;

Typo: PTO.CallGrpahProfile -> PTO.CallGraphProfile



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1518
   Conf.PTO.SLPVectorization = CGOpts.VectorizeSLP;
+  Conf.PTO.CallGrpahProfile = CGOpts.CallGraphProfile;
 

Same typo.



Comment at: llvm/include/llvm/Passes/PassBuilder.h:111
+  /// true.
+  bool CallGrpahProfile;
 };

CallGrpahProfile -> CallGraphProfile


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62627



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


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-03-20 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Thanks for the quick fix, verified that the crash is fixed on trunk.


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

https://reviews.llvm.org/D73534



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


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-03-20 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Still causing a crash using a previously supplied test 
https://bugs.chromium.org/p/chromium/issues/detail?id=1061533#c7. Any reason 
this was not tested with a previous repro?


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

https://reviews.llvm.org/D73534



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


[PATCH] D48680: Add missing visibility annotation for __base

2020-03-18 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Thanks a lot!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D48680



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


[PATCH] D48680: Add missing visibility annotation for __base

2020-03-18 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Friendly ping  @pcc and @ldionne . We have been carrying this patch I think for 
too long now.
Also, we have not discovered any LTO issues elsewhere so can't tell from our 
side if there are other places in libc++ that need visibility annotations.


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D48680



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


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-03-12 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Hi,

I see another crash with this change when building gdb.

Reduced test case:
struct type *a(type *, type *, long, long);
enum b {};
static int empty_array(type *, int c) { type *d = a(__null, d, c, c - 1); }
long e;
b f() { empty_array(0, e); }

Repros with:
clang -cc1 -triple x86_64-linux-gnu -emit-obj -disable-free -mrelocation-model 
pic -pic-level 2 -pic-is-pie -mthread-model posix -mframe-pointer=all  
-mconstructor-aliases -munwind-tables  -dwarf-column-info  
-debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb  -O2  -x c++

Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1060788


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

https://reviews.llvm.org/D73534



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


[PATCH] D75758: [Sema] Add -Wpointer-to-enum-cast and -Wvoid-pointer-to-enum-cast

2020-03-06 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Thanks, Verified that this fixes the kernel warnings in my local builds with 
https://gist.github.com/nathanchance/767cccf4d093c1342e1994083518815e!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75758



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


[PATCH] D52524: Add -Wpoison-system-directories warning

2019-09-12 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta closed this revision.
manojgupta added a comment.

Submitted as https://reviews.llvm.org/rL371785.
Thanks for the patch!


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

https://reviews.llvm.org/D52524



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


[PATCH] D52524: Add -Wno-poison-system-directories flag

2019-08-19 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added reviewers: rtrieu, aaron.ballman.
manojgupta added a comment.

Thanks,

Adding a few more reviewers since I am not very familiar with this part of 
clang.
Please also update the patch description as suggested by @thakis


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

https://reviews.llvm.org/D52524



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


[PATCH] D52524: Add -Wno-poison-system-directories flag

2019-08-19 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added inline comments.



Comment at: clang/test/Frontend/warning-poison-system-directories.c:12
+// Missing target but included sysroot still causes the warning.
+// RUN: %clang -Wpoison-system-directories -I/usr/include --sysroot 
%S/Inputs/sysroot_x86_64_cross_linux_tree -c -o - %s 2> %t.2.stderr
+// RUN: FileCheck -check-prefix=WARN < %t.2.stderr %s

Thanks, Can you also add a test for  -Werror=poison-system-directories .


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

https://reviews.llvm.org/D52524



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


[PATCH] D52524: Add -Wno-poison-system-directories flag

2019-08-14 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticGroups.td:1071
+// cross-compiling.
+def PoisonSystemDirectories : DiagGroup<"poison-system-directories">;
+

Please verify that the warning is not enabled by default.


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

https://reviews.llvm.org/D52524



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


[PATCH] D52524: Add -Wno-poison-system-directories flag

2019-08-14 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

In D52524#1630767 , @thakis wrote:

> Wouldn't those projects just move to also disabling the warning by passing 
> -Wno-poison-system-directories? If there are projects that are actively 
> adding -I/usr/include, that means they're consciously fighting the build 
> system and you've kind of already lost, no? Can't you tell them to not use 
> -I/usr/include?


Most of the time, those packages are not exactly fighting cross-compilation 
(e.g. samba), just they just have a broken build system that adds I/usr/include 
when building them. This warning will help catch bad includes whenever someone 
imports a new package or upgrade to a newer version from upstream.
Note: in Chrome OS, packages are built using their native build system e.g. 
LLVM is built with cmake, tensorflow is built with bazel etc.


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

https://reviews.llvm.org/D52524



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


[PATCH] D52524: Add -Wno-poison-system-directories flag

2019-08-14 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

In D52524#1621468 , @thakis wrote:

> Couldn't cross build users just pass -nostdsysteminc to tell clang to not 
> look in system header locations?


My understanding is "-nostdsysteminc " does not block users from passing 
include paths from host that are outside sysroot. i.e. clang --sysroot=/foo 
-nostdsysteminc  -I/usr/include still works.
This warning is to catch this behavior.
This is an actual problem in Chrome OS where building some third party packages 
do not respect cross-compilation.


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

https://reviews.llvm.org/D52524



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


[PATCH] D48680: Add missing visibility annotation for __base

2019-07-16 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

@pcc can you please submit this patch if there are no objections?


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D48680



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


[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-07-15 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

@dankm are you still working on this patch?


Repository:
  rC Clang

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

https://reviews.llvm.org/D49466



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


  1   2   >