[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-05 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.

This doesn't only happen for incorrectly built apps, it also happens
for libraries loaded with dlopen.


Repository:
  rL LLVM

https://reviews.llvm.org/D38599

Files:
  src/private_typeinfo.cpp


Index: src/private_typeinfo.cpp
===
--- src/private_typeinfo.cpp
+++ src/private_typeinfo.cpp
@@ -10,39 +10,19 @@
 #include "private_typeinfo.h"
 
 // The flag _LIBCXX_DYNAMIC_FALLBACK is used to make dynamic_cast more
-// forgiving when type_info's mistakenly have hidden visibility and thus
-// multiple type_infos can exist for a single type.
-// 
+// forgiving when multiple type_infos exist for a single type. This happens if
+// the libraries are mistakenly built with the type_infos having hidden
+// visibility, but also occurs when the libraries are loaded with dlopen.
+//
 // When _LIBCXX_DYNAMIC_FALLBACK is defined, and only in the case where
 // there is a detected inconsistency in the type_info hierarchy during a
 // dynamic_cast, then the equality operation will fall back to using strcmp
 // on type_info names to determine type_info equality.
-// 
-// This change happens *only* under dynamic_cast, and only when
-// dynamic_cast is faced with the choice:  abort, or possibly give back the
-// wrong answer.  If when the dynamic_cast is done with this fallback
-// algorithm and an inconsistency is still detected, dynamic_cast will call
-// abort with an appropriate message.
-// 
-// The current implementation of _LIBCXX_DYNAMIC_FALLBACK requires a
-// printf-like function called syslog:
-// 
-// void syslog(int facility_priority, const char* format, ...);
-// 
-// If you want this functionality but your platform doesn't have syslog,
-// just implement it in terms of fprintf(stderr, ...).
-// 
+//
 // _LIBCXX_DYNAMIC_FALLBACK is currently off by default.
 
-
 #include 
 
-
-#ifdef _LIBCXX_DYNAMIC_FALLBACK
-#include "abort_message.h"
-#include 
-#endif
-
 // On Windows, typeids are different between DLLs and EXEs, so comparing
 // type_info* will work for typeids from the same compiled file but fail
 // for typeids from a DLL and an executable. Among other things, exceptions
@@ -647,11 +627,11 @@
 //   find (static_ptr, static_type), either on a public or private path
 if (info.path_dst_ptr_to_static_ptr == unknown)
 {
-// We get here only if there is some kind of visibility problem
-//   in client code.
-syslog(LOG_ERR, "dynamic_cast error 1: Both of the following 
type_info's "
-"should have public visibility.  At least one of them is 
hidden. %s" 
-", %s.\n", static_type->name(), dynamic_type->name());
+// We get here only if there is some kind of visibility problem in
+// client code. Possibly because the binaries were built
+// incorrectly, but possibly because the library was loaded with
+// dlopen.
+//
 // Redo the search comparing type_info's using strcmp
 info = {dst_type, static_ptr, static_type, src2dst_offset, 0};
 info.number_of_dst_type = 1;
@@ -672,10 +652,6 @@
 if (info.path_dst_ptr_to_static_ptr == unknown &&
 info.path_dynamic_ptr_to_static_ptr == unknown)
 {
-syslog(LOG_ERR, "dynamic_cast error 2: One or more of the 
following type_info's "
-" has hidden visibility.  They should all have 
public visibility.  "
-" %s, %s, %s.\n", static_type->name(), 
dynamic_type->name(),
-dst_type->name());
 // Redo the search comparing type_info's using strcmp
 info = {dst_type, static_ptr, static_type, src2dst_offset, 0};
 dynamic_type->search_below_dst(&info, dynamic_ptr, public_path, 
true);


Index: src/private_typeinfo.cpp
===
--- src/private_typeinfo.cpp
+++ src/private_typeinfo.cpp
@@ -10,39 +10,19 @@
 #include "private_typeinfo.h"
 
 // The flag _LIBCXX_DYNAMIC_FALLBACK is used to make dynamic_cast more
-// forgiving when type_info's mistakenly have hidden visibility and thus
-// multiple type_infos can exist for a single type.
-// 
+// forgiving when multiple type_infos exist for a single type. This happens if
+// the libraries are mistakenly built with the type_infos having hidden
+// visibility, but also occurs when the libraries are loaded with dlopen.
+//
 // When _LIBCXX_DYNAMIC_FALLBACK is defined, and only in the case where
 // there is a detected inconsistency in the type_info hierarchy during a
 // dynamic_cast, then the equality operation will fall back to using strcmp
 // on type_info names to determine type_info equality.
-// 
-// This change happens *only* under dynamic_cast, and only when
-// dynamic_cast is faced with the choice:  abort, or possibly give back the
-// wrong answer

[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-09 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

In https://reviews.llvm.org/D38599#889842, @smeenai wrote:

> Does dlopen cause issues even with `RTLD_GLOBAL`?


From my testing, yes. Regardless, `RTLD_LOCAL` is how JNI libraries get loaded 
when `System.loadLibrary` is used, so the `strcmp` fallback is a requirement 
for that use case.


Repository:
  rL LLVM

https://reviews.llvm.org/D38599



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


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-09 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

> Are you 100% sure that you're not just a person with broken code?

Absolutely, since it isn't my code ;) I maintain the toolchain and this is a 
behavioral change when switching from libstdc++ to libc++.

> In other words, what did this guy from 2013 get wrong? -- or, if "he got 
> nothing wrong", then why can't you just follow his advice to eliminate the 
> duplicate typeinfos from your code? 
> http://www.russellmcc.com/posts/2013-08-03-rtti.html

That post is all about binaries that were built with hidden visibility and says 
nothing about the case of `dlopen`. There's nothing wrong with the code as 
built. All the symbols have public visibility, all the `type_infos` are weak, 
everything works correctly if you explicitly link the libraries to the final 
executable or `dlopen` only one library (not always an option).

If anyone is still skeptical, libsupc++ went through this at one point too and 
eventually decided to use `strcmp` by default because otherwise RTTI doesn't 
work in plugin architectures (which is essentially what JNI is). 
https://gcc.gnu.org/ml/gcc-patches/2009-07/msg01239.html


Repository:
  rL LLVM

https://reviews.llvm.org/D38599



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


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-10 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

In https://reviews.llvm.org/D38599#893903, @jroelofs wrote:

> That reminds me... this does need a testcase or two.


Didn't realize I could do multi binary test cases with this test runner. It'll 
be a little messy, but I'll try adding one.


Repository:
  rL LLVM

https://reviews.llvm.org/D38599



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


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-10 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

In https://reviews.llvm.org/D38599#893903, @jroelofs wrote:

> That reminds me... this does need a testcase or two.


Oh, also, any test I add is going to fail, since the case I'm trying to account 
for here is not the default behavior.

I could make the more invasive change and actually make libc++abi use the 
fallback by default like libsupc++ does, but I was willing to settle for just 
not spamming the user with warnings that they can't do anything about.


Repository:
  rL LLVM

https://reviews.llvm.org/D38599



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


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-10 Thread Dan Albert via Phabricator via cfe-commits
danalbert updated this revision to Diff 118502.
danalbert edited the summary of this revision.
danalbert added a comment.

Added a (failing) test case. The test case will fail unless the default value 
of `_LIBCXX_DYNAMIC_FALLBACK` is changed.


https://reviews.llvm.org/D38599

Files:
  src/private_typeinfo.cpp
  test/dlopen_dynamic_cast.sh.cpp

Index: test/dlopen_dynamic_cast.sh.cpp
===
--- /dev/null
+++ test/dlopen_dynamic_cast.sh.cpp
@@ -0,0 +1,87 @@
+//=== dlopen_dynamic_cast.sh.cpp --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// type_infos are not coalesced across dlopen boundaries when RTLD_LOCAL is
+// used, as is common in plugin interfaces and JNI libraries. For dynamic_cast
+// to work across a dlopen boundary, we must use a string comparison of the type
+// names instead of a pointer comparison of the type_infos.
+// https://reviews.llvm.org/D38599
+
+// RUN: %cxx %flags %compile_flags -DBUILD_BASE -fPIC -c %s -o %T/base.o
+// RUN: %cxx %flags %link_flags -shared %T/base.o -o %T/libbase.so
+// RUN: %cxx %flags %compile_flags -DBUILD_TEST -fPIC -c %s -o %T/test.o
+// RUN: %cxx %flags %link_flags -shared %T/test.o -o %T/libtest.so -L%T -lbase
+// RUN: %cxx %flags %compile_flags -DBUILD_EXE -c %s -o %t.o
+// RUN: %cxx %flags %link_flags %t.o -o %t.exe -ldl
+// RUN: LD_LIBRARY_PATH=%T %t.exe
+
+class Base {
+public:
+  virtual ~Base(){};
+};
+
+class BaseImpl : public Base {
+public:
+  BaseImpl();
+};
+
+#ifdef BUILD_BASE
+BaseImpl::BaseImpl() {}
+#endif
+
+#ifdef BUILD_TEST
+extern "C" bool do_test() {
+  BaseImpl base_impl;
+  Base* base = &base_impl;
+  return dynamic_cast(base) != nullptr;
+}
+#endif
+
+#ifdef BUILD_EXE
+#include 
+#include 
+#include 
+
+typedef bool (*test_func)();
+
+void* load_library(const char* name) {
+  void* lib = dlopen(name, RTLD_NOW | RTLD_LOCAL);
+  if (lib == nullptr) {
+fprintf(stderr, "dlopen %s failed: %s\n", name, dlerror());
+abort();
+  }
+  return lib;
+}
+
+test_func load_func(void* lib, const char* name) {
+  test_func sym = reinterpret_cast(dlsym(lib, name));
+  if (sym == nullptr) {
+fprintf(stderr, "dlsym %s failed: %s\n", name, dlerror());
+abort();
+  }
+  return sym;
+}
+
+int main(int argc, char**) {
+  // Explicitly loading libbase.so before libtest.so causes the test to fail
+  // because the type_infos do not get coalesced.
+  load_library("libbase.so");
+
+  void* libtest = load_library("libtest.so");
+  test_func do_test = load_func(libtest, "do_test");
+
+  if (!do_test()) {
+fprintf(stderr, "do_test() failed!\n");
+return EXIT_FAILURE;
+  } else {
+fprintf(stderr, "do_test() passed!\n");
+return EXIT_SUCCESS;
+  }
+}
+#endif
Index: src/private_typeinfo.cpp
===
--- src/private_typeinfo.cpp
+++ src/private_typeinfo.cpp
@@ -10,39 +10,19 @@
 #include "private_typeinfo.h"
 
 // The flag _LIBCXX_DYNAMIC_FALLBACK is used to make dynamic_cast more
-// forgiving when type_info's mistakenly have hidden visibility and thus
-// multiple type_infos can exist for a single type.
-// 
+// forgiving when multiple type_infos exist for a single type. This happens if
+// the libraries are mistakenly built with the type_infos having hidden
+// visibility, but also occurs when the libraries are loaded with dlopen.
+//
 // When _LIBCXX_DYNAMIC_FALLBACK is defined, and only in the case where
 // there is a detected inconsistency in the type_info hierarchy during a
 // dynamic_cast, then the equality operation will fall back to using strcmp
 // on type_info names to determine type_info equality.
-// 
-// This change happens *only* under dynamic_cast, and only when
-// dynamic_cast is faced with the choice:  abort, or possibly give back the
-// wrong answer.  If when the dynamic_cast is done with this fallback
-// algorithm and an inconsistency is still detected, dynamic_cast will call
-// abort with an appropriate message.
-// 
-// The current implementation of _LIBCXX_DYNAMIC_FALLBACK requires a
-// printf-like function called syslog:
-// 
-// void syslog(int facility_priority, const char* format, ...);
-// 
-// If you want this functionality but your platform doesn't have syslog,
-// just implement it in terms of fprintf(stderr, ...).
-// 
+//
 // _LIBCXX_DYNAMIC_FALLBACK is currently off by default.
 
-
 #include 
 
-
-#ifdef _LIBCXX_DYNAMIC_FALLBACK
-#include "abort_message.h"
-#include 
-#endif
-
 // On Windows, typeids are different between DLLs and EXEs, so comparing
 // type_info* will work for typeids from the same compiled file but fail
 // for typeids from a DLL and an executable. Among other things, exceptions

[PATCH] D38827: Add a cmake option for using strcmp for type_infos.

2017-10-11 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
Herald added a subscriber: mgorny.

libc++ doesn't yet have the code for this, but libc++abi does. Adding
the switch to libc++ since the flag in libc++abi is
`_LIBCXX_DYNAMIC_FALLBACK`, not `_LIBCXXABI_DYNAMIC_FALLBACK`, and it
will be needed here as well.


Repository:
  rL LLVM

https://reviews.llvm.org/D38827

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -103,6 +103,7 @@
 option(LIBCXX_ABI_FORCE_MICROSOFT "Ignore auto-detection and force use of the 
Microsoft ABI.")
 set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI 
macros to define in the site config header.")
 option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
+option(LIBCXX_DYNAMIC_FALLBACK  "Use strcmp fallback for comparing 
type_infos." OFF)
 
 if (NOT LIBCXX_ENABLE_SHARED AND NOT LIBCXX_ENABLE_STATIC)
   message(FATAL_ERROR "libc++ must be built as either a shared or static 
library.")


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -103,6 +103,7 @@
 option(LIBCXX_ABI_FORCE_MICROSOFT "Ignore auto-detection and force use of the Microsoft ABI.")
 set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon separated list of ABI macros to define in the site config header.")
 option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
+option(LIBCXX_DYNAMIC_FALLBACK  "Use strcmp fallback for comparing type_infos." OFF)
 
 if (NOT LIBCXX_ENABLE_SHARED AND NOT LIBCXX_ENABLE_STATIC)
   message(FATAL_ERROR "libc++ must be built as either a shared or static library.")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-11 Thread Dan Albert via Phabricator via cfe-commits
danalbert updated this revision to Diff 118711.
danalbert added a comment.
Herald added a subscriber: mgorny.

Update the test with an XFAIL when _LIBCXX_DYNAMIC_FALLBACK is not set.

https://reviews.llvm.org/D38827 adds this cmake option to libc++.


https://reviews.llvm.org/D38599

Files:
  CMakeLists.txt
  src/private_typeinfo.cpp
  test/CMakeLists.txt
  test/dlopen_dynamic_cast.sh.cpp
  test/libcxxabi/test/config.py
  test/lit.site.cfg.in

Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -16,6 +16,7 @@
 config.executor = "@LIBCXXABI_EXECUTOR@"
 config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@"
 config.enable_shared= "@LIBCXX_ENABLE_SHARED@"
+config.dynamic_fallback = "@LIBCXX_DYNAMIC_FALLBACK@"
 config.enable_exceptions= "@LIBCXXABI_ENABLE_EXCEPTIONS@"
 config.host_triple  = "@LLVM_HOST_TRIPLE@"
 config.target_triple= "@TARGET_TRIPLE@"
Index: test/libcxxabi/test/config.py
===
--- test/libcxxabi/test/config.py
+++ test/libcxxabi/test/config.py
@@ -48,6 +48,11 @@
 if not self.get_lit_bool('llvm_unwinder', False):
 self.config.available_features.add('libcxxabi-has-system-unwinder')
 
+if self.get_lit_bool('dynamic_fallback', False):
+self.config.available_features.add('libcxx-dynamic-fallback')
+else:
+self.config.available_features.add('libcxx-no-dynamic-fallback')
+
 def configure_compile_flags(self):
 self.cxx.compile_flags += ['-DLIBCXXABI_NO_TIMER']
 if self.get_lit_bool('enable_exceptions', True):
Index: test/dlopen_dynamic_cast.sh.cpp
===
--- /dev/null
+++ test/dlopen_dynamic_cast.sh.cpp
@@ -0,0 +1,89 @@
+//=== dlopen_dynamic_cast.sh.cpp --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// type_infos are not coalesced across dlopen boundaries when RTLD_LOCAL is
+// used, as is common in plugin interfaces and JNI libraries. For dynamic_cast
+// to work across a dlopen boundary, we must use a string comparison of the type
+// names instead of a pointer comparison of the type_infos.
+// https://reviews.llvm.org/D38599
+
+// XFAIL: libcxx-no-dynamic-fallback
+
+// RUN: %cxx %flags %compile_flags -DBUILD_BASE -fPIC -c %s -o %T/base.o
+// RUN: %cxx %flags %link_flags -shared %T/base.o -o %T/libbase.so
+// RUN: %cxx %flags %compile_flags -DBUILD_TEST -fPIC -c %s -o %T/test.o
+// RUN: %cxx %flags %link_flags -shared %T/test.o -o %T/libtest.so -L%T -lbase
+// RUN: %cxx %flags %compile_flags -DBUILD_EXE -c %s -o %t.o
+// RUN: %cxx %flags %link_flags %t.o -o %t.exe -ldl
+// RUN: LD_LIBRARY_PATH=%T %t.exe
+
+class Base {
+public:
+  virtual ~Base(){};
+};
+
+class BaseImpl : public Base {
+public:
+  BaseImpl();
+};
+
+#ifdef BUILD_BASE
+BaseImpl::BaseImpl() {}
+#endif
+
+#ifdef BUILD_TEST
+extern "C" bool do_test() {
+  BaseImpl base_impl;
+  Base* base = &base_impl;
+  return dynamic_cast(base) != nullptr;
+}
+#endif
+
+#ifdef BUILD_EXE
+#include 
+#include 
+#include 
+
+typedef bool (*test_func)();
+
+void* load_library(const char* name) {
+  void* lib = dlopen(name, RTLD_NOW | RTLD_LOCAL);
+  if (lib == nullptr) {
+fprintf(stderr, "dlopen %s failed: %s\n", name, dlerror());
+abort();
+  }
+  return lib;
+}
+
+test_func load_func(void* lib, const char* name) {
+  test_func sym = reinterpret_cast(dlsym(lib, name));
+  if (sym == nullptr) {
+fprintf(stderr, "dlsym %s failed: %s\n", name, dlerror());
+abort();
+  }
+  return sym;
+}
+
+int main(int argc, char**) {
+  // Explicitly loading libbase.so before libtest.so causes the test to fail
+  // because the type_infos do not get coalesced.
+  load_library("libbase.so");
+
+  void* libtest = load_library("libtest.so");
+  test_func do_test = load_func(libtest, "do_test");
+
+  if (!do_test()) {
+fprintf(stderr, "do_test() failed!\n");
+return EXIT_FAILURE;
+  } else {
+fprintf(stderr, "do_test() passed!\n");
+return EXIT_SUCCESS;
+  }
+}
+#endif
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -18,6 +18,7 @@
 pythonize_bool(LIBCXXABI_ENABLE_EXCEPTIONS)
 pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
 pythonize_bool(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
+pythonize_bool(LIBCXX_DYNAMIC_FALLBACK)
 set(LIBCXXABI_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
 "TargetInfo to use when setting up test environment.")
 set(LIBCXXABI_EXECUTOR "None" CACHE STRING
Index: 

[PATCH] D38827: Add a cmake option for using strcmp for type_infos.

2017-10-11 Thread Dan Albert via Phabricator via cfe-commits
danalbert planned changes to this revision.
danalbert added a comment.

Actually, I was wrong. This is implemented. Will update to set the flag the 
configures this and add a test.


Repository:
  rL LLVM

https://reviews.llvm.org/D38827



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


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-11 Thread Dan Albert via Phabricator via cfe-commits
danalbert planned changes to this revision.
danalbert added a comment.

In https://reviews.llvm.org/D38599#894041, @jroelofs wrote:

> (possibly renamed to _LIBCXXABI_DYNAMIC_FALLBACK)


I opted for adding this switch to libc++ instead. Like @rprichard points out, 
we'll need to do this in `std::type_info::operator==` as well. I thought that 
code wasn't in libc++ yet, but it seems it is. I'm going to rename this option 
in libc++abi to match the one in libc++.


https://reviews.llvm.org/D38599



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


[PATCH] D38827: Add a cmake option for using strcmp for type_infos.

2017-10-11 Thread Dan Albert via Phabricator via cfe-commits
danalbert abandoned this revision.
danalbert added a comment.

zygoloid and nbjoerg got me pointed in the right direction on this. Looks like 
the user didn't have a key function defined for one of their classes, which was 
actually the root of the problem.


Repository:
  rL LLVM

https://reviews.llvm.org/D38827



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


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-11 Thread Dan Albert via Phabricator via cfe-commits
danalbert abandoned this revision.
danalbert added a comment.

nbjoerg and zygoloid got me pointed in the right direction. Both `Base` and 
`BaseImpl` are missing their key functions, and that's the problem here. Patch 
should be unnecessary.


https://reviews.llvm.org/D38599



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


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-16 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

In https://reviews.llvm.org/D38599#899196, @howard.hinnant wrote:

> Fwiw, I wrote this code.  All of that "fallback" stuff was written to make 
> customer code that was incorrect, but working on OS X 
> -version-that-used-libsupc++ continue to work.  I.e. to be a crutch for 
> incorrect code.  It should all be removed if you no longer want to provide 
> such a crutch.


Android may end up wanting to use it for the same reason. I've backed it out 
for now, but it may end up being something we need since a fair number of NDK 
users (majority, probably) use libsupc++ and that might be a point of pain in 
migrating to libc++abi. Other Linux distros may want it as well, so probably 
worth leaving the code around.


https://reviews.llvm.org/D38599



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


[PATCH] D43203: [Driver] Generate .eh_frame_hdr for static executables too.

2018-02-12 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added a reviewer: srhines.

libgcc won't unwind without an .eh_frame_hdr section.


Repository:
  rC Clang

https://reviews.llvm.org/D43203

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/linux-ld.c


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -156,7 +156,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-LD-64-STATIC %s
 // CHECK-LD-64-STATIC-NOT: warning:
 // CHECK-LD-64-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
-// CHECK-LD-64-STATIC-NOT: "--eh-frame-hdr"
+// CHECK-LD-64-STATIC: "--eh-frame-hdr"
 // CHECK-LD-64-STATIC: "-m" "elf_x86_64"
 // CHECK-LD-64-STATIC-NOT: "-dynamic-linker"
 // CHECK-LD-64-STATIC: "-static"
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -378,9 +378,7 @@
   for (const auto &Opt : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 
-  if (!Args.hasArg(options::OPT_static)) {
-CmdArgs.push_back("--eh-frame-hdr");
-  }
+  CmdArgs.push_back("--eh-frame-hdr");
 
   if (const char *LDMOption = getLDMOption(ToolChain.getTriple(), Args)) {
 CmdArgs.push_back("-m");


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -156,7 +156,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-LD-64-STATIC %s
 // CHECK-LD-64-STATIC-NOT: warning:
 // CHECK-LD-64-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
-// CHECK-LD-64-STATIC-NOT: "--eh-frame-hdr"
+// CHECK-LD-64-STATIC: "--eh-frame-hdr"
 // CHECK-LD-64-STATIC: "-m" "elf_x86_64"
 // CHECK-LD-64-STATIC-NOT: "-dynamic-linker"
 // CHECK-LD-64-STATIC: "-static"
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -378,9 +378,7 @@
   for (const auto &Opt : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 
-  if (!Args.hasArg(options::OPT_static)) {
-CmdArgs.push_back("--eh-frame-hdr");
-  }
+  CmdArgs.push_back("--eh-frame-hdr");
 
   if (const char *LDMOption = getLDMOption(ToolChain.getTriple(), Args)) {
 CmdArgs.push_back("-m");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43203: [Driver] Generate .eh_frame_hdr for static executables too.

2018-02-21 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC325733: [Driver] Generate .eh_frame_hdr for static 
executables too. (authored by danalbert, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43203?vs=133907&id=135336#toc

Repository:
  rC Clang

https://reviews.llvm.org/D43203

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/linux-ld.c


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -378,9 +378,7 @@
   for (const auto &Opt : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 
-  if (!Args.hasArg(options::OPT_static)) {
-CmdArgs.push_back("--eh-frame-hdr");
-  }
+  CmdArgs.push_back("--eh-frame-hdr");
 
   if (const char *LDMOption = getLDMOption(ToolChain.getTriple(), Args)) {
 CmdArgs.push_back("-m");
Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -156,7 +156,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-LD-64-STATIC %s
 // CHECK-LD-64-STATIC-NOT: warning:
 // CHECK-LD-64-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
-// CHECK-LD-64-STATIC-NOT: "--eh-frame-hdr"
+// CHECK-LD-64-STATIC: "--eh-frame-hdr"
 // CHECK-LD-64-STATIC: "-m" "elf_x86_64"
 // CHECK-LD-64-STATIC-NOT: "-dynamic-linker"
 // CHECK-LD-64-STATIC: "-static"


Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -378,9 +378,7 @@
   for (const auto &Opt : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 
-  if (!Args.hasArg(options::OPT_static)) {
-CmdArgs.push_back("--eh-frame-hdr");
-  }
+  CmdArgs.push_back("--eh-frame-hdr");
 
   if (const char *LDMOption = getLDMOption(ToolChain.getTriple(), Args)) {
 CmdArgs.push_back("-m");
Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -156,7 +156,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-LD-64-STATIC %s
 // CHECK-LD-64-STATIC-NOT: warning:
 // CHECK-LD-64-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
-// CHECK-LD-64-STATIC-NOT: "--eh-frame-hdr"
+// CHECK-LD-64-STATIC: "--eh-frame-hdr"
 // CHECK-LD-64-STATIC: "-m" "elf_x86_64"
 // CHECK-LD-64-STATIC-NOT: "-dynamic-linker"
 // CHECK-LD-64-STATIC: "-static"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40743: Make rehash(0) work with ubsan's unsigned-integer-overflow.

2018-01-08 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX322031: Make rehash(0) work with ubsan's 
unsigned-integer-overflow. (authored by danalbert, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D40743?vs=125193&id=128979#toc

Repository:
  rCXX libc++

https://reviews.llvm.org/D40743

Files:
  include/__hash_table


Index: include/__hash_table
===
--- include/__hash_table
+++ include/__hash_table
@@ -2136,7 +2136,7 @@
 void
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n)
 {
-if (__n == 1)
+if (__n < 2)
 __n = 2;
 else if (__n & (__n - 1))
 __n = __next_prime(__n);


Index: include/__hash_table
===
--- include/__hash_table
+++ include/__hash_table
@@ -2136,7 +2136,7 @@
 void
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n)
 {
-if (__n == 1)
+if (__n < 2)
 __n = 2;
 else if (__n & (__n - 1))
 __n = __next_prime(__n);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40743: Make rehash(0) work with ubsan's unsigned-integer-overflow.

2018-01-08 Thread Dan Albert via Phabricator via cfe-commits
danalbert added inline comments.



Comment at: include/__hash_table:2141
 __n = 2;
 else if (__n & (__n - 1))
 __n = __next_prime(__n);

mclow.lists wrote:
> danalbert wrote:
> > With `rehash(0)` this is `0 & (0 - 1)`, which triggers 
> > unsigned-integer-overflow.
> Grumble, grumble. That's not UB, that's just UBSan whining.
> On the other hand, this doesn't appear to change any behavior, and shuts 
> UBSan up.
FWIW, this check isn't enabled in ubsan by default. Android uses it for testing 
and mititgation in a handful of projects because it does catch errors 
(stagefright was an unsigned overflow issue). It's good to keep the libc++ 
headers clean of these issues so we're not dictating the compile flags of 
libc++ users.


Repository:
  rCXX libc++

https://reviews.llvm.org/D40743



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


[PATCH] D53109: [Driver] Default Android toolchains to libc++.

2018-10-10 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added reviewers: srhines, pirama.
Herald added a reviewer: EricWF.

Repository:
  rC Clang

https://reviews.llvm.org/D53109

Files:
  lib/Driver/ToolChains/Linux.cpp
  lib/Driver/ToolChains/Linux.h
  test/Driver/android-ndk-standalone.cpp

Index: test/Driver/android-ndk-standalone.cpp
===
--- test/Driver/android-ndk-standalone.cpp
+++ test/Driver/android-ndk-standalone.cpp
@@ -2,21 +2,13 @@
 // toolchain.
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target arm-linux-androideabi21 -stdlib=libstdc++ \
+// RUN: -target arm-linux-androideabi21 \
 // RUN: -B%S/Inputs/basic_android_ndk_tree \
 // RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \
 // RUN:   | FileCheck  %s
 // CHECK: {{.*}}clang{{.*}}" "-cc1"
 // CHECK: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
-// CHECK: "-internal-isystem" "{{.*}}/include/c++/4.9"
-// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a/thumb"
-// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a"
-// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb"
-// CHECK: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi"
-// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a/thumb"
-// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a"
-// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb"
-// CHECK: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
+// CHECK: "-internal-isystem" "{{.*}}/include/c++/v1"
 // CHECK: "-internal-isystem" "{{.*}}/sysroot/usr/local/include"
 // CHECK: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
 // CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include/arm-linux-androideabi"
@@ -49,21 +41,47 @@
 // CHECK-14: "-L{{.*}}/sysroot/usr/lib/arm-linux-androideabi"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target armv7a-none-linux-androideabi21 -stdlib=libstdc++ \
+// RUN: -target arm-linux-androideabi21 -stdlib=libstdc++ \
+// RUN: -B%S/Inputs/basic_android_ndk_tree \
+// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \
+// RUN:   | FileCheck --check-prefix=CHECK-STDCXX %s
+// CHECK-STDCXX: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-STDCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-STDCXX: "-internal-isystem" "{{.*}}/include/c++/4.9"
+// CHECK-STDCXX-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a/thumb"
+// CHECK-STDCXX-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a"
+// CHECK-STDCXX-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb"
+// CHECK-STDCXX: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi"
+// CHECK-STDCXX-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a/thumb"
+// CHECK-STDCXX-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a"
+// CHECK-STDCXX-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb"
+// CHECK-STDCXX: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
+// CHECK-STDCXX: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a/thumb"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/thumb"
+// CHECK-STDCXX: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a/thumb"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/thumb"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7-a/thumb"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7-a"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/thumb"
+// CHECK-STDCXX: "-L{{.*}}/sysroot/usr/lib/arm-linux-androideabi/21"
+// CHECK-STDCXX: "-L{{.*}}/sysroot/usr/lib/arm-linux-androideabi"
+// CHECK-STDCXX: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/arm-linux-androideabi/lib"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7-a/thumb"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7-a"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/thumb"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv7a-none-linux-androideabi21 \
 // RUN: -B%S/Inputs/basic_android_ndk_tree \
 // RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \
 // RUN:   | FileCheck  --check-prefix=CHECK-ARMV

[PATCH] D53109: [Driver] Default Android toolchains to libc++.

2018-10-10 Thread Dan Albert via Phabricator via cfe-commits
danalbert planned changes to this revision.
danalbert added a comment.

Oops, ignore this for a moment. Accidentally ran `check-cxx` instead of 
`check-clang`.


Repository:
  rC Clang

https://reviews.llvm.org/D53109



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


[PATCH] D53109: [Driver] Default Android toolchains to libc++.

2018-10-10 Thread Dan Albert via Phabricator via cfe-commits
danalbert updated this revision to Diff 169097.
danalbert added a comment.

Fixed bad merge conflict resolution.


Repository:
  rC Clang

https://reviews.llvm.org/D53109

Files:
  lib/Driver/ToolChains/Linux.cpp
  lib/Driver/ToolChains/Linux.h
  test/Driver/android-ndk-standalone.cpp

Index: test/Driver/android-ndk-standalone.cpp
===
--- test/Driver/android-ndk-standalone.cpp
+++ test/Driver/android-ndk-standalone.cpp
@@ -2,21 +2,13 @@
 // toolchain.
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target arm-linux-androideabi21 -stdlib=libstdc++ \
+// RUN: -target arm-linux-androideabi21 \
 // RUN: -B%S/Inputs/basic_android_ndk_tree \
 // RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \
 // RUN:   | FileCheck  %s
 // CHECK: {{.*}}clang{{.*}}" "-cc1"
 // CHECK: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
-// CHECK: "-internal-isystem" "{{.*}}/include/c++/4.9"
-// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a/thumb"
-// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a"
-// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb"
-// CHECK: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi"
-// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a/thumb"
-// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a"
-// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb"
-// CHECK: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
+// CHECK: "-internal-isystem" "{{.*}}/include/c++/v1"
 // CHECK: "-internal-isystem" "{{.*}}/sysroot/usr/local/include"
 // CHECK: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
 // CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include/arm-linux-androideabi"
@@ -49,21 +41,47 @@
 // CHECK-14: "-L{{.*}}/sysroot/usr/lib/arm-linux-androideabi"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target armv7a-none-linux-androideabi21 -stdlib=libstdc++ \
+// RUN: -target arm-linux-androideabi21 -stdlib=libstdc++ \
+// RUN: -B%S/Inputs/basic_android_ndk_tree \
+// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \
+// RUN:   | FileCheck --check-prefix=CHECK-STDCXX %s
+// CHECK-STDCXX: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-STDCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-STDCXX: "-internal-isystem" "{{.*}}/include/c++/4.9"
+// CHECK-STDCXX-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a/thumb"
+// CHECK-STDCXX-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a"
+// CHECK-STDCXX-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb"
+// CHECK-STDCXX: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi"
+// CHECK-STDCXX-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a/thumb"
+// CHECK-STDCXX-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a"
+// CHECK-STDCXX-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb"
+// CHECK-STDCXX: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
+// CHECK-STDCXX: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a/thumb"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/thumb"
+// CHECK-STDCXX: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a/thumb"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/thumb"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7-a/thumb"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7-a"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/thumb"
+// CHECK-STDCXX: "-L{{.*}}/sysroot/usr/lib/arm-linux-androideabi/21"
+// CHECK-STDCXX: "-L{{.*}}/sysroot/usr/lib/arm-linux-androideabi"
+// CHECK-STDCXX: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/arm-linux-androideabi/lib"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7-a/thumb"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7-a"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/thumb"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv7a-none-linux-androideabi21 \
 // RUN: -B%S/Inputs/basic_android_ndk_tree \
 // RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \
 // RUN:   | FileCheck  --check-prefix=CHECK-

[PATCH] D53117: [Driver] Default to `-z now` and `-z relro` on Android.

2018-10-10 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added reviewers: srhines, pirama.

RTLD_LAZY is not supported on Android (though failing to use `-z now`
will work since it is assumed by the loader).

  

RelRO is required.


Repository:
  rC Clang

https://reviews.llvm.org/D53117

Files:
  lib/Driver/ToolChains/Linux.cpp
  test/Driver/linux-ld.c


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -1241,6 +1241,8 @@
 // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID %s
 // CHECK-ANDROID: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-ANDROID: "-z" "now"
+// CHECK-ANDROID: "-z" "relro"
 // CHECK-ANDROID: "--enable-new-dtags"
 // CHECK-ANDROID: "{{.*}}{{/|}}crtbegin_dynamic.o"
 // CHECK-ANDROID: "-L[[SYSROOT]]/usr/lib"
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -229,12 +229,13 @@
 
   Distro Distro(D.getVFS());
 
-  if (Distro.IsAlpineLinux()) {
+  if (Distro.IsAlpineLinux() || Triple.isAndroid()) {
 ExtraOpts.push_back("-z");
 ExtraOpts.push_back("now");
   }
 
-  if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux()) {
+  if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux() ||
+  Triple.isAndroid()) {
 ExtraOpts.push_back("-z");
 ExtraOpts.push_back("relro");
   }


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -1241,6 +1241,8 @@
 // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID %s
 // CHECK-ANDROID: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-ANDROID: "-z" "now"
+// CHECK-ANDROID: "-z" "relro"
 // CHECK-ANDROID: "--enable-new-dtags"
 // CHECK-ANDROID: "{{.*}}{{/|}}crtbegin_dynamic.o"
 // CHECK-ANDROID: "-L[[SYSROOT]]/usr/lib"
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -229,12 +229,13 @@
 
   Distro Distro(D.getVFS());
 
-  if (Distro.IsAlpineLinux()) {
+  if (Distro.IsAlpineLinux() || Triple.isAndroid()) {
 ExtraOpts.push_back("-z");
 ExtraOpts.push_back("now");
   }
 
-  if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux()) {
+  if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux() ||
+  Triple.isAndroid()) {
 ExtraOpts.push_back("-z");
 ExtraOpts.push_back("relro");
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53118: [Driver] Fix --hash-style choice for Android.

2018-10-10 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added reviewers: srhines, pirama.

Android supports GNU style hashes as of Marshmallow, so we should be
generating both styles for pre-M targets and GNU hashes for newer
targets.


Repository:
  rC Clang

https://reviews.llvm.org/D53118

Files:
  lib/Driver/ToolChains/Linux.cpp
  test/Driver/linux-ld.c


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -975,6 +975,20 @@
 // CHECK-MIPS64EL-REDHAT: "-dynamic-linker" "{{.*}}/lib{{(64)?}}/ld.so.1"
 // CHECK-MIPS64EL-REDHAT-NOT: "-dynamic-linker" 
"{{.*}}/lib{{(64)?}}/ld-musl-mipsel.so.1"
 // CHECK-MIPS64EL-REDHAT-NOT: "--hash-style={{gnu|both}}"
+
+// Check that we pass --hash-style=both for pre-M Android versions and
+// --hash-style=gnu for newer Android versions.
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android21 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-HASH-STYLE-L %s
+// CHECK-ANDROID-HASH-STYLE-L: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-HASH-STYLE-L: "--hash-style=both"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android23 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-HASH-STYLE-M %s
+// CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu"
 //
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN: --target=sparc-unknown-linux-gnu \
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -264,15 +264,18 @@
   // and the MIPS ABI require .dynsym to be sorted in different ways.
   // .gnu.hash needs symbols to be grouped by hash code whereas the MIPS
   // ABI requires a mapping between the GOT and the symbol table.
-  // Android loader does not support .gnu.hash.
+  // Android loader does not support .gnu.hash until API 23.
   // Hexagon linker/loader does not support .gnu.hash
-  if (!IsMips && !IsAndroid && !IsHexagon) {
+  if (!IsMips && !IsHexagon) {
 if (Distro.IsRedhat() || Distro.IsOpenSUSE() || Distro.IsAlpineLinux() ||
-(Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick))
+(Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick) ||
+(IsAndroid && !Triple.isAndroidVersionLT(23)))
   ExtraOpts.push_back("--hash-style=gnu");
 
-if (Distro.IsDebian() || Distro.IsOpenSUSE() || Distro == 
Distro::UbuntuLucid ||
-Distro == Distro::UbuntuJaunty || Distro == Distro::UbuntuKarmic)
+if (Distro.IsDebian() || Distro.IsOpenSUSE() ||
+Distro == Distro::UbuntuLucid || Distro == Distro::UbuntuJaunty ||
+Distro == Distro::UbuntuKarmic ||
+(IsAndroid && Triple.isAndroidVersionLT(23)))
   ExtraOpts.push_back("--hash-style=both");
   }
 


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -975,6 +975,20 @@
 // CHECK-MIPS64EL-REDHAT: "-dynamic-linker" "{{.*}}/lib{{(64)?}}/ld.so.1"
 // CHECK-MIPS64EL-REDHAT-NOT: "-dynamic-linker" "{{.*}}/lib{{(64)?}}/ld-musl-mipsel.so.1"
 // CHECK-MIPS64EL-REDHAT-NOT: "--hash-style={{gnu|both}}"
+
+// Check that we pass --hash-style=both for pre-M Android versions and
+// --hash-style=gnu for newer Android versions.
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android21 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-HASH-STYLE-L %s
+// CHECK-ANDROID-HASH-STYLE-L: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-HASH-STYLE-L: "--hash-style=both"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android23 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-HASH-STYLE-M %s
+// CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu"
 //
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN: --target=sparc-unknown-linux-gnu \
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -264,15 +264,18 @@
   // and the MIPS ABI require .dynsym to be sorted in different ways.
   // .gnu.hash needs symbols to be grouped by hash code whereas the MIPS
   // ABI requires a mapping between the GOT and the symbol table.
-  // Android loader does not support .gnu.hash.
+  // Android loader does not support .gnu.hash until API 23.
   // Hexagon linker/loader does not support .gnu.hash
-  if (!IsMips && !IsAndroid && !IsHexagon) {
+  if (!IsMips && !IsHexagon) {
 if (Distro.IsRedhat() || Distro.IsOpenSUSE() || Distro.IsAlpineLinux() ||
-(Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick))
+(Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick) ||
+(IsAndroid && !Triple.isAndroidVersionLT(23)))
   ExtraOpts.push_back("--hash

[PATCH] D53121: [Driver] Add defaults for Android ARM FPUs.

2018-10-10 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added reviewers: srhines, pirama.
Herald added a reviewer: javed.absar.
Herald added subscribers: chrib, kristof.beyls.

Android mandates that devices have at least vfpv3-d16 until
Marshmallow and NEON after that. Still honor the user's decision, but
raise the defaults for Android targets.


Repository:
  rC Clang

https://reviews.llvm.org/D53121

Files:
  lib/Driver/ToolChains/Arch/ARM.cpp
  test/Driver/arm-mfpu.c


Index: test/Driver/arm-mfpu.c
===
--- test/Driver/arm-mfpu.c
+++ test/Driver/arm-mfpu.c
@@ -364,3 +364,56 @@
 // CHECK-SOFT-ABI-FP: "-target-feature" "-fp-armv8"
 // CHECK-SOFT-ABI-FP: "-target-feature" "-neon"
 // CHECK-SOFT-ABI-FP: "-target-feature" "-crypto"
+
+// RUN: %clang -target arm-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM5-ANDROID-FP-DEFAULT %s
+// CHECK-ARM5-ANDROID-FP-DEFAULT: "-target-feature" "+soft-float"
+// CHECK-ARM5-ANDROID-FP-DEFAULT: "-target-feature" "+soft-float-abi"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+d16"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+vfp3"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+neon"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-DEFAULT %s
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+soft-float-abi"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+d16"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+vfp3"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+neon"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi21 -mfpu=neon %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-NEON %s
+// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+soft-float-abi"
+// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+vfp3"
+// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+neon"
+// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi23 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-DEFAULT %s
+// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+soft-float-abi"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+vfp3"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+neon"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi23 %s -mfpu=vfp3-d16 -### -c 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-D16 %s
+// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+soft-float-abi"
+// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+d16"
+// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+vfp3"
+// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+neon"
+// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+crypto"
Index: lib/Driver/ToolChains/Arch/ARM.cpp
===
--- lib/Driver/ToolChains/Arch/ARM.cpp
+++ lib/Driver/ToolChains/Arch/ARM.cpp
@@ -357,6 +357,12 @@
 checkARMCPUName(D, CPUArg, Args, CPUName, ArchName, Features, Triple);
   }
 
+  unsigned ArchVersion;
+  if (ArchName.empty())
+  ArchVersion = getARMSubArchVersionNumber(Triple);
+  else
+  ArchVersion = llvm::ARM::parseArchVersion(ArchName);
+
   // Add CPU features for generic CPUs
   if (CPUName == "native") {
 llvm::StringMap HostFeatures;
@@ -378,6 +384,13 @@
   Features);
   } else if (FPUArg) {
 getARMFPUFeatures(D, FPUArg, Args, FPUArg->getValue(), Features);
+  } else if (Triple.isAndroid() && ArchVersion >= 7) {
+// Android mandates minimum FPU requirements based on OS version.
+const char *AndroidFPU =
+Triple.isAndroidVersionLT(23) ? "vfpv3-d16" : "neon";
+if (!llvm::ARM::getFPUFeatures(llvm

[PATCH] D53121: [Driver] Add defaults for Android ARM FPUs.

2018-10-10 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

Related to this but something I was less sure we should do: Android no longer 
supports ARMv5. Should we make `arm-linux-androideabi` targets auto pull up to 
armv7 if there's no `-march` flag?


Repository:
  rC Clang

https://reviews.llvm.org/D53121



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


[PATCH] D53121: [Driver] Add defaults for Android ARM FPUs.

2018-10-11 Thread Dan Albert via Phabricator via cfe-commits
danalbert added inline comments.



Comment at: lib/Driver/ToolChains/Arch/ARM.cpp:360
 
+  unsigned ArchVersion;
+  if (ArchName.empty())

peter.smith wrote:
> Do you need to parse the arch version here? I would expect the -march=armv7 
> to be reflected in getARMSubArchVersionNumber(Triple)
> 
> If reduce this to ArchVersion = getARMSubArchVersionNumber(Triple) and add a 
> test with -target arm-linux-androideabi21 -march=armv7 then everything still 
> passes.
> 
> If I'm right you should be able to simplify this and perhaps roll it into the 
> if (Triple.isAndroid() && ArchVersion >= 7) below. If I'm wrong can we add a 
> test case that fails without the ArchVersion = 
> llvm::ARM::parseArchVersion(ArchName) ?
> 
> It will also be worth adding tests for a generic target with -march 
I had assumed that that wouldn't handle a case like `-target 
arm-linux-androideabi21 -march=armv7-a` where the `-target` argument specifies 
ARMv5 but `-march` rasies that to ARMv7, but you're right, the triple is 
updated to account for `-march` (which makes sense now that I think about it; 
that would lead to a lot of messy code all over if it didn't). Cleaned this up.

(I think I've also added the test you're asking for, but lmk if I misunderstood 
what you meant by "generic target")



Comment at: test/Driver/arm-mfpu.c:410
+
+// RUN: %clang -target armv7-linux-androideabi23 %s -mfpu=vfp3-d16 -### -c 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-D16 %s

>>! In D53121#1261602, @kristof.beyls wrote:
> Seems fine to me too. I'd maybe just add an additional test case to verify 
> that things still work as expected when users explicitly specify that they 
> want to target a different FPU (e.g. "-mfpu=none").

Is this test (and it's counterpart in `CHECK-ARM-ANDROID-L-FP-NEON`) not 
sufficient? It shows that `-mfpu` is honored regardless of the default. Is 
there something special about `-mfpu=none` that this doesn't exercise?


Repository:
  rC Clang

https://reviews.llvm.org/D53121



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


[PATCH] D53121: [Driver] Add defaults for Android ARM FPUs.

2018-10-11 Thread Dan Albert via Phabricator via cfe-commits
danalbert updated this revision to Diff 169291.
danalbert added a comment.

Addressed review comments.


Repository:
  rC Clang

https://reviews.llvm.org/D53121

Files:
  lib/Driver/ToolChains/Arch/ARM.cpp
  test/Driver/arm-mfpu.c


Index: test/Driver/arm-mfpu.c
===
--- test/Driver/arm-mfpu.c
+++ test/Driver/arm-mfpu.c
@@ -364,3 +364,67 @@
 // CHECK-SOFT-ABI-FP: "-target-feature" "-fp-armv8"
 // CHECK-SOFT-ABI-FP: "-target-feature" "-neon"
 // CHECK-SOFT-ABI-FP: "-target-feature" "-crypto"
+
+// RUN: %clang -target arm-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM5-ANDROID-FP-DEFAULT %s
+// CHECK-ARM5-ANDROID-FP-DEFAULT: "-target-feature" "+soft-float"
+// CHECK-ARM5-ANDROID-FP-DEFAULT: "-target-feature" "+soft-float-abi"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+d16"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+vfp3"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+neon"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target arm-linux-androideabi21 -march=armv7-a %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MARCH-ARM7-ANDROID-FP %s
+// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+soft-float"
+// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+soft-float-abi"
+// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+d16"
+// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+vfp3"
+// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+vfp4"
+// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+fp-armv8"
+// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+neon"
+// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-DEFAULT %s
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+soft-float-abi"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+d16"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+vfp3"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+neon"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi21 -mfpu=neon %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-NEON %s
+// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+soft-float-abi"
+// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+vfp3"
+// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+neon"
+// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi23 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-DEFAULT %s
+// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+soft-float-abi"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+vfp3"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+neon"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi23 %s -mfpu=vfp3-d16 -### -c 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-D16 %s
+// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+soft-float-abi"
+// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+d16"
+// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+vfp3"
+// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+neon"
+// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+crypto"
Index: lib/Driver/ToolChains/Arch/ARM.cpp
===
--- lib/Driver/ToolChains/Arch/ARM.cpp
+++ lib/Driver/ToolChains/Arch/ARM.cpp
@@ -378,6 +378,13 @@
   Features);
   } else if (FPUArg) {
 getARMFPUFeatures(D, FPUArg, Args, FPUArg->getValue(), Features);
+  } else if (Triple.isAndroid() && getARMSubArchVersionNumber(Triple) >= 7) {
+// Android mandates minimum FPU requirements based on OS version.
+const char *AndroidFPU =
+Triple.isAndroidVersion

[PATCH] D53118: [Driver] Fix --hash-style choice for Android.

2018-10-11 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344293: [Driver] Fix --hash-style choice for Android. 
(authored by danalbert, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D53118

Files:
  cfe/trunk/lib/Driver/ToolChains/Linux.cpp
  cfe/trunk/test/Driver/linux-ld.c


Index: cfe/trunk/test/Driver/linux-ld.c
===
--- cfe/trunk/test/Driver/linux-ld.c
+++ cfe/trunk/test/Driver/linux-ld.c
@@ -975,6 +975,20 @@
 // CHECK-MIPS64EL-REDHAT: "-dynamic-linker" "{{.*}}/lib{{(64)?}}/ld.so.1"
 // CHECK-MIPS64EL-REDHAT-NOT: "-dynamic-linker" 
"{{.*}}/lib{{(64)?}}/ld-musl-mipsel.so.1"
 // CHECK-MIPS64EL-REDHAT-NOT: "--hash-style={{gnu|both}}"
+
+// Check that we pass --hash-style=both for pre-M Android versions and
+// --hash-style=gnu for newer Android versions.
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android21 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-HASH-STYLE-L %s
+// CHECK-ANDROID-HASH-STYLE-L: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-HASH-STYLE-L: "--hash-style=both"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android23 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-HASH-STYLE-M %s
+// CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu"
 //
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN: --target=sparc-unknown-linux-gnu \
Index: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp
@@ -264,15 +264,18 @@
   // and the MIPS ABI require .dynsym to be sorted in different ways.
   // .gnu.hash needs symbols to be grouped by hash code whereas the MIPS
   // ABI requires a mapping between the GOT and the symbol table.
-  // Android loader does not support .gnu.hash.
+  // Android loader does not support .gnu.hash until API 23.
   // Hexagon linker/loader does not support .gnu.hash
-  if (!IsMips && !IsAndroid && !IsHexagon) {
+  if (!IsMips && !IsHexagon) {
 if (Distro.IsRedhat() || Distro.IsOpenSUSE() || Distro.IsAlpineLinux() ||
-(Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick))
+(Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick) ||
+(IsAndroid && !Triple.isAndroidVersionLT(23)))
   ExtraOpts.push_back("--hash-style=gnu");
 
-if (Distro.IsDebian() || Distro.IsOpenSUSE() || Distro == 
Distro::UbuntuLucid ||
-Distro == Distro::UbuntuJaunty || Distro == Distro::UbuntuKarmic)
+if (Distro.IsDebian() || Distro.IsOpenSUSE() ||
+Distro == Distro::UbuntuLucid || Distro == Distro::UbuntuJaunty ||
+Distro == Distro::UbuntuKarmic ||
+(IsAndroid && Triple.isAndroidVersionLT(23)))
   ExtraOpts.push_back("--hash-style=both");
   }
 


Index: cfe/trunk/test/Driver/linux-ld.c
===
--- cfe/trunk/test/Driver/linux-ld.c
+++ cfe/trunk/test/Driver/linux-ld.c
@@ -975,6 +975,20 @@
 // CHECK-MIPS64EL-REDHAT: "-dynamic-linker" "{{.*}}/lib{{(64)?}}/ld.so.1"
 // CHECK-MIPS64EL-REDHAT-NOT: "-dynamic-linker" "{{.*}}/lib{{(64)?}}/ld-musl-mipsel.so.1"
 // CHECK-MIPS64EL-REDHAT-NOT: "--hash-style={{gnu|both}}"
+
+// Check that we pass --hash-style=both for pre-M Android versions and
+// --hash-style=gnu for newer Android versions.
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android21 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-HASH-STYLE-L %s
+// CHECK-ANDROID-HASH-STYLE-L: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-HASH-STYLE-L: "--hash-style=both"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android23 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-HASH-STYLE-M %s
+// CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu"
 //
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN: --target=sparc-unknown-linux-gnu \
Index: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp
@@ -264,15 +264,18 @@
   // and the MIPS ABI require .dynsym to be sorted in different ways.
   // .gnu.hash needs symbols to be grouped by hash code whereas the MIPS
   // ABI requires a mapping between the GOT and the symbol table.
-  // Android loader does not support .gnu.hash.
+  // Android loader does not support .gnu.hash until API 23.
   // Hexagon linker/loader does not support .gnu.hash
-  if (!IsMips && !IsAndroid && !IsHexagon) {
+  if (!IsMips && !IsHexagon) {
 if (Distro.IsRedhat() || Distro.IsOpenSUSE() || Distro.IsAlpineLinux() ||
-(Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick))
+(Dis

[PATCH] D53117: [Driver] Default to `-z now` and `-z relro` on Android.

2018-10-11 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC344295: [Driver] Default to `-z now` and `-z relro` on 
Android. (authored by danalbert, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53117?vs=169133&id=169300#toc

Repository:
  rC Clang

https://reviews.llvm.org/D53117

Files:
  lib/Driver/ToolChains/Linux.cpp
  test/Driver/linux-ld.c


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -1255,6 +1255,8 @@
 // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID %s
 // CHECK-ANDROID: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-ANDROID: "-z" "now"
+// CHECK-ANDROID: "-z" "relro"
 // CHECK-ANDROID: "--enable-new-dtags"
 // CHECK-ANDROID: "{{.*}}{{/|}}crtbegin_dynamic.o"
 // CHECK-ANDROID: "-L[[SYSROOT]]/usr/lib"
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -229,12 +229,13 @@
 
   Distro Distro(D.getVFS());
 
-  if (Distro.IsAlpineLinux()) {
+  if (Distro.IsAlpineLinux() || Triple.isAndroid()) {
 ExtraOpts.push_back("-z");
 ExtraOpts.push_back("now");
   }
 
-  if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux()) {
+  if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux() ||
+  Triple.isAndroid()) {
 ExtraOpts.push_back("-z");
 ExtraOpts.push_back("relro");
   }


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -1255,6 +1255,8 @@
 // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID %s
 // CHECK-ANDROID: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-ANDROID: "-z" "now"
+// CHECK-ANDROID: "-z" "relro"
 // CHECK-ANDROID: "--enable-new-dtags"
 // CHECK-ANDROID: "{{.*}}{{/|}}crtbegin_dynamic.o"
 // CHECK-ANDROID: "-L[[SYSROOT]]/usr/lib"
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -229,12 +229,13 @@
 
   Distro Distro(D.getVFS());
 
-  if (Distro.IsAlpineLinux()) {
+  if (Distro.IsAlpineLinux() || Triple.isAndroid()) {
 ExtraOpts.push_back("-z");
 ExtraOpts.push_back("now");
   }
 
-  if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux()) {
+  if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux() ||
+  Triple.isAndroid()) {
 ExtraOpts.push_back("-z");
 ExtraOpts.push_back("relro");
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53109: [Driver] Default Android toolchains to libc++.

2018-10-11 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344296: [Driver] Default Android toolchains to libc++. 
(authored by danalbert, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D53109

Files:
  cfe/trunk/lib/Driver/ToolChains/Linux.cpp
  cfe/trunk/lib/Driver/ToolChains/Linux.h
  cfe/trunk/test/Driver/android-ndk-standalone.cpp

Index: cfe/trunk/test/Driver/android-ndk-standalone.cpp
===
--- cfe/trunk/test/Driver/android-ndk-standalone.cpp
+++ cfe/trunk/test/Driver/android-ndk-standalone.cpp
@@ -2,21 +2,13 @@
 // toolchain.
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target arm-linux-androideabi21 -stdlib=libstdc++ \
+// RUN: -target arm-linux-androideabi21 \
 // RUN: -B%S/Inputs/basic_android_ndk_tree \
 // RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \
 // RUN:   | FileCheck  %s
 // CHECK: {{.*}}clang{{.*}}" "-cc1"
 // CHECK: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
-// CHECK: "-internal-isystem" "{{.*}}/include/c++/4.9"
-// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a/thumb"
-// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a"
-// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb"
-// CHECK: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi"
-// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a/thumb"
-// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a"
-// CHECK-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb"
-// CHECK: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
+// CHECK: "-internal-isystem" "{{.*}}/include/c++/v1"
 // CHECK: "-internal-isystem" "{{.*}}/sysroot/usr/local/include"
 // CHECK: "-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
 // CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include/arm-linux-androideabi"
@@ -49,21 +41,47 @@
 // CHECK-14: "-L{{.*}}/sysroot/usr/lib/arm-linux-androideabi"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: -target armv7a-none-linux-androideabi21 -stdlib=libstdc++ \
+// RUN: -target arm-linux-androideabi21 -stdlib=libstdc++ \
+// RUN: -B%S/Inputs/basic_android_ndk_tree \
+// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree/sysroot \
+// RUN:   | FileCheck --check-prefix=CHECK-STDCXX %s
+// CHECK-STDCXX: {{.*}}clang{{.*}}" "-cc1"
+// CHECK-STDCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-STDCXX: "-internal-isystem" "{{.*}}/include/c++/4.9"
+// CHECK-STDCXX-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a/thumb"
+// CHECK-STDCXX-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a"
+// CHECK-STDCXX-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb"
+// CHECK-STDCXX: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi"
+// CHECK-STDCXX-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a/thumb"
+// CHECK-STDCXX-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/armv7-a"
+// CHECK-STDCXX-NOT: "-internal-isystem" "{{.*}}/include/c++/4.9/arm-linux-androideabi/thumb"
+// CHECK-STDCXX: "-internal-isystem" "{{.*}}/include/c++/4.9/backward"
+// CHECK-STDCXX: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a/thumb"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/thumb"
+// CHECK-STDCXX: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a/thumb"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/armv7-a"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/thumb"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7-a/thumb"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7-a"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/thumb"
+// CHECK-STDCXX: "-L{{.*}}/sysroot/usr/lib/arm-linux-androideabi/21"
+// CHECK-STDCXX: "-L{{.*}}/sysroot/usr/lib/arm-linux-androideabi"
+// CHECK-STDCXX: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/arm-linux-androideabi/lib"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7-a/thumb"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/armv7-a"
+// CHECK-STDCXX-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ ]*}}/lib/thumb"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target armv7a-none-linux-an

[PATCH] D53121: [Driver] Add defaults for Android ARM FPUs.

2018-10-12 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC344367: [Driver] Add defaults for Android ARM FPUs. 
(authored by danalbert, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53121?vs=169291&id=169450#toc

Repository:
  rC Clang

https://reviews.llvm.org/D53121

Files:
  lib/Driver/ToolChains/Arch/ARM.cpp
  test/Driver/arm-mfpu.c


Index: lib/Driver/ToolChains/Arch/ARM.cpp
===
--- lib/Driver/ToolChains/Arch/ARM.cpp
+++ lib/Driver/ToolChains/Arch/ARM.cpp
@@ -378,6 +378,13 @@
   Features);
   } else if (FPUArg) {
 getARMFPUFeatures(D, FPUArg, Args, FPUArg->getValue(), Features);
+  } else if (Triple.isAndroid() && getARMSubArchVersionNumber(Triple) >= 7) {
+// Android mandates minimum FPU requirements based on OS version.
+const char *AndroidFPU =
+Triple.isAndroidVersionLT(23) ? "vfpv3-d16" : "neon";
+if (!llvm::ARM::getFPUFeatures(llvm::ARM::parseFPU(AndroidFPU), Features))
+  D.Diag(clang::diag::err_drv_clang_unsupported)
+  << std::string("-mfpu=") + AndroidFPU;
   }
 
   // Honor -mhwdiv=. ClangAs gives preference to -Wa,-mhwdiv=.
Index: test/Driver/arm-mfpu.c
===
--- test/Driver/arm-mfpu.c
+++ test/Driver/arm-mfpu.c
@@ -364,3 +364,67 @@
 // CHECK-SOFT-ABI-FP: "-target-feature" "-fp-armv8"
 // CHECK-SOFT-ABI-FP: "-target-feature" "-neon"
 // CHECK-SOFT-ABI-FP: "-target-feature" "-crypto"
+
+// RUN: %clang -target arm-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM5-ANDROID-FP-DEFAULT %s
+// CHECK-ARM5-ANDROID-FP-DEFAULT: "-target-feature" "+soft-float"
+// CHECK-ARM5-ANDROID-FP-DEFAULT: "-target-feature" "+soft-float-abi"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+d16"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+vfp3"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+neon"
+// CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target arm-linux-androideabi21 -march=armv7-a %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MARCH-ARM7-ANDROID-FP %s
+// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+soft-float"
+// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+soft-float-abi"
+// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+d16"
+// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+vfp3"
+// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+vfp4"
+// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+fp-armv8"
+// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+neon"
+// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-DEFAULT %s
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+soft-float-abi"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+d16"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+vfp3"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+neon"
+// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi21 -mfpu=neon %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-NEON %s
+// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+soft-float-abi"
+// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+vfp3"
+// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+neon"
+// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi23 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-DEFAULT %s
+// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+soft-float-abi"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+vfp3"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+neon"
+// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi23 %s -mfpu=vfp3-d16 -### -c 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-D16 %s
+// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature"

[PATCH] D53343: [Driver] Default Android toolchains to noexecstack.

2018-10-16 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added a reviewer: srhines.

Android does not support executable stacks.


Repository:
  rC Clang

https://reviews.llvm.org/D53343

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  lib/Driver/ToolChains/Linux.h
  test/Driver/integrated-as.c
  test/Driver/linux-as.c
  test/Driver/linux-ld.c

Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -989,6 +989,15 @@
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-HASH-STYLE-M %s
 // CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu"
+
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android21 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-NOEXECSTACK %s
+// CHECK-ANDROID-NOEXECSTACK: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-NOEXECSTACK: "-z" "noexecstack"
+// CHECK-ANDROID-NOEXECSTACK-NOT: "-z" "execstack"
+// CHECK-ANDROID-NOEXECSTACK-NOT: "-z,execstack"
+// CHECK-ANDROID-NOEXECSTACK-NOT: "-zexecstack"
 //
 // RUN: %clang %s -### -o %t.o 2>&1 --target=mips64-linux-gnuabin32 \
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL-GNUABIN32 %s
Index: test/Driver/linux-as.c
===
--- test/Driver/linux-as.c
+++ test/Driver/linux-as.c
@@ -108,12 +108,12 @@
 // RUN: %clang -target arm-linux-androideabi -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-ANDROID %s
-// CHECK-ARM-ANDROID: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft"
+// CHECK-ARM-ANDROID: as{{(.exe)?}}" "--noexecstack" "-EL" "-mfloat-abi=soft"
 //
 // RUN: %clang -target arm-linux-androideabi -march=armv7-a -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-ANDROID-SOFTFP %s
-// CHECK-ARM-ANDROID-SOFTFP: as{{(.exe)?}}" "-EL" "-mfloat-abi=softfp" "-march=armv7-a"
+// CHECK-ARM-ANDROID-SOFTFP: as{{(.exe)?}}" "--noexecstack" "-EL" "-mfloat-abi=softfp" "-march=armv7-a"
 //
 // RUN: %clang -target arm-linux-eabi -mhard-float -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
Index: test/Driver/integrated-as.c
===
--- test/Driver/integrated-as.c
+++ test/Driver/integrated-as.c
@@ -13,3 +13,8 @@
 // NOFIAS-NOT: cc1as
 // NOFIAS: -cc1
 // NOFIAS: -no-integrated-as
+
+// RUN: %clang -target arm-linux-androideabi -### \
+// RUN:   -integrated-as -c %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ARM-ANDROID %s
+// CHECK-ARM-ANDROID: "-mnoexecstack"
Index: lib/Driver/ToolChains/Linux.h
===
--- lib/Driver/ToolChains/Linux.h
+++ lib/Driver/ToolChains/Linux.h
@@ -38,6 +38,7 @@
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
   bool isPIEDefault() const override;
+  bool isNoExecStackDefault() const override;
   bool IsMathErrnoDefault() const override;
   SanitizerMask getSupportedSanitizers() const override;
   void addProfileRTLibs(const llvm::opt::ArgList &Args,
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -955,6 +955,10 @@
   getTriple().isMusl() || getSanitizerArgs().requiresPIE();
 }
 
+bool Linux::isNoExecStackDefault() const {
+return getTriple().isAndroid();
+}
+
 bool Linux::IsMathErrnoDefault() const {
   if (getTriple().isAndroid())
 return false;
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -353,6 +353,11 @@
   if (IsPIE)
 CmdArgs.push_back("-pie");
 
+  if (ToolChain.isNoExecStackDefault()) {
+CmdArgs.push_back("-z");
+CmdArgs.push_back("noexecstack");
+  }
+
   if (Args.hasArg(options::OPT_rdynamic))
 CmdArgs.push_back("-export-dynamic");
 
@@ -599,6 +604,10 @@
 }
   }
 
+  if (getToolChain().isNoExecStackDefault()) {
+  CmdArgs.push_back("--noexecstack");
+  }
+
   switch (getToolChain().getArch()) {
   default:
 break;
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1933,6 +1933,7 @@
   bool TakeNextArg = false;
 
   bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations();
+  bool UseNoExecStack = C.getDefaultToolChain().isNoExecStackDefault();
   const char *MipsTargetFeature = nullptr;
   for (const Arg *A :
Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {
@@ -2014,7 +2015,7 @@
   } else if (Value == "--fa

[PATCH] D53344: [Driver] Use --warn-shared-textrel for Android.

2018-10-16 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added a reviewer: srhines.

Android does not allow shared text relocations. Enable the linker
warning to detect them by default.


Repository:
  rC Clang

https://reviews.llvm.org/D53344

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/linux-ld.c


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -989,7 +989,13 @@
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-HASH-STYLE-M %s
 // CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu"
-//
+
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android21 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-WARN-SHARED-TEXTREL %s
+// CHECK-ANDROID-WARN-SHARED-TEXTREL: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-WARN-SHARED-TEXTREL: "--warn-shared-textrel"
+
 // RUN: %clang %s -### -o %t.o 2>&1 --target=mips64-linux-gnuabin32 \
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL-GNUABIN32 %s
 // CHECK-MIPS64EL-GNUABIN32: "{{.*}}ld{{(.exe)?}}"
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -375,6 +375,11 @@
   CmdArgs.push_back("--fix-cortex-a53-843419");
   }
 
+  // Android does not allow shared text relocations. Emit a warning if the
+  // user's code contains any.
+  if (isAndroid)
+  CmdArgs.push_back("--warn-shared-textrel");
+
   for (const auto &Opt : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -989,7 +989,13 @@
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-HASH-STYLE-M %s
 // CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu"
-//
+
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android21 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-WARN-SHARED-TEXTREL %s
+// CHECK-ANDROID-WARN-SHARED-TEXTREL: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-WARN-SHARED-TEXTREL: "--warn-shared-textrel"
+
 // RUN: %clang %s -### -o %t.o 2>&1 --target=mips64-linux-gnuabin32 \
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL-GNUABIN32 %s
 // CHECK-MIPS64EL-GNUABIN32: "{{.*}}ld{{(.exe)?}}"
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -375,6 +375,11 @@
   CmdArgs.push_back("--fix-cortex-a53-843419");
   }
 
+  // Android does not allow shared text relocations. Emit a warning if the
+  // user's code contains any.
+  if (isAndroid)
+  CmdArgs.push_back("--warn-shared-textrel");
+
   for (const auto &Opt : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53463: [Driver] allow Android triples to alias for non Android targets

2018-10-22 Thread Dan Albert via Phabricator via cfe-commits
danalbert accepted this revision.
danalbert added a comment.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D53463



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


[PATCH] D38430: Enable -pie and --enable-new-dtags by default on Android.

2019-01-15 Thread Dan Albert via Phabricator via cfe-commits
danalbert added inline comments.



Comment at: cfe/trunk/lib/Driver/ToolChains/Linux.cpp:814
+bool Linux::isPIEDefault() const {
+  return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) ||
+ getSanitizerArgs().requiresPIE();

pcc wrote:
> eugenis wrote:
> > pcc wrote:
> > > Why only on API level >= 16? If I create an executable targeting an older 
> > > API level, it should still work on higher API levels.
> > Because it needs to work on lower API levels, too. I think at some point 
> > PIE was actually not supported, so there is no good default that works for 
> > everyone.
> I see. Looking at the tags in which 
> https://github.com/aosp-mirror/platform_bionic/commit/d9ad62343c2db6b66a5fa597c9b20a6faabd7a9a
>  was present, support was indeed added in Jelly Bean, which was API level 16. 
> So this is correct.
Correct. Supported as of 16, required as of 21.

The NDK itself doesn't actually support pre-16 any more, but probably best for 
Clang to do the right thing anyway in case some user is trying to maintain 
their own sysroot for ICS that uses a modern Clang.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D38430



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


[PATCH] D53956: Fix test assumption that Linux implies glibc.

2018-10-31 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added a reviewer: EricWF.
Herald added subscribers: libcxx-commits, ldionne, christof.

This fixes an regression when using bionic introduced in r345173.

I need to follow up and figure out what exactly is implied by
TEST_HAS_C11_FEATURES and see what the correct configuration is for
bionic (new versions should have everything the tests care about,
versions that predate C11 certainly don't), but this gets the tests
back to the old behavior.


Repository:
  rCXX libc++

https://reviews.llvm.org/D53956

Files:
  test/support/test_macros.h


Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -91,9 +91,11 @@
 #if (defined(__has_include) && __has_include()) || \
 defined(__linux__)
 #include 
+#if defined(__GLIBC_PREREQ)
 #define TEST_HAS_GLIBC
 #define TEST_GLIBC_PREREQ(major, minor) __GLIBC_PREREQ(major, minor)
 #endif
+#endif
 
 #if TEST_STD_VER >= 11
 #define TEST_ALIGNOF(...) alignof(__VA_ARGS__)
@@ -135,12 +137,16 @@
 #define TEST_HAS_C11_FEATURES
 #define TEST_HAS_TIMESPEC_GET
 #  elif defined(__linux__)
-#if !defined(_LIBCPP_HAS_MUSL_LIBC)
-#  if defined(TEST_GLIBC_PREREQ) && TEST_GLIBC_PREREQ(2, 17)
+// This block preserves the old behavior used by include/__config:
+// _LIBCPP_GLIBC_PREREQ would be defined to 0 if __GLIBC_PREREQ was not
+// available. The configuration here may be too vague though, as Bionic, 
uClibc,
+// newlib, etc may all support these features but need to be configured.
+#if defined(TEST_GLIBC_PREREQ)
+#  if TEST_GLIBC_PREREQ(2, 17)
 #define TEST_HAS_TIMESPEC_GET
 #define TEST_HAS_C11_FEATURES
 #  endif
-#else // defined(_LIBCPP_HAS_MUSL_LIBC)
+#elif defined(_LIBCPP_HAS_MUSL_LIBC)
 #  define TEST_HAS_C11_FEATURES
 #  define TEST_HAS_TIMESPEC_GET
 #endif


Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -91,9 +91,11 @@
 #if (defined(__has_include) && __has_include()) || \
 defined(__linux__)
 #include 
+#if defined(__GLIBC_PREREQ)
 #define TEST_HAS_GLIBC
 #define TEST_GLIBC_PREREQ(major, minor) __GLIBC_PREREQ(major, minor)
 #endif
+#endif
 
 #if TEST_STD_VER >= 11
 #define TEST_ALIGNOF(...) alignof(__VA_ARGS__)
@@ -135,12 +137,16 @@
 #define TEST_HAS_C11_FEATURES
 #define TEST_HAS_TIMESPEC_GET
 #  elif defined(__linux__)
-#if !defined(_LIBCPP_HAS_MUSL_LIBC)
-#  if defined(TEST_GLIBC_PREREQ) && TEST_GLIBC_PREREQ(2, 17)
+// This block preserves the old behavior used by include/__config:
+// _LIBCPP_GLIBC_PREREQ would be defined to 0 if __GLIBC_PREREQ was not
+// available. The configuration here may be too vague though, as Bionic, uClibc,
+// newlib, etc may all support these features but need to be configured.
+#if defined(TEST_GLIBC_PREREQ)
+#  if TEST_GLIBC_PREREQ(2, 17)
 #define TEST_HAS_TIMESPEC_GET
 #define TEST_HAS_C11_FEATURES
 #  endif
-#else // defined(_LIBCPP_HAS_MUSL_LIBC)
+#elif defined(_LIBCPP_HAS_MUSL_LIBC)
 #  define TEST_HAS_C11_FEATURES
 #  define TEST_HAS_TIMESPEC_GET
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53956: Fix test assumption that Linux implies glibc.

2018-11-01 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX345900: Fix test assumption that Linux implies glibc. 
(authored by danalbert, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53956?vs=172038&id=172255#toc

Repository:
  rCXX libc++

https://reviews.llvm.org/D53956

Files:
  test/support/test_macros.h


Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -91,9 +91,11 @@
 #if (defined(__has_include) && __has_include()) || \
 defined(__linux__)
 #include 
+#if defined(__GLIBC_PREREQ)
 #define TEST_HAS_GLIBC
 #define TEST_GLIBC_PREREQ(major, minor) __GLIBC_PREREQ(major, minor)
 #endif
+#endif
 
 #if TEST_STD_VER >= 11
 #define TEST_ALIGNOF(...) alignof(__VA_ARGS__)
@@ -135,12 +137,16 @@
 #define TEST_HAS_C11_FEATURES
 #define TEST_HAS_TIMESPEC_GET
 #  elif defined(__linux__)
-#if !defined(_LIBCPP_HAS_MUSL_LIBC)
-#  if defined(TEST_GLIBC_PREREQ) && TEST_GLIBC_PREREQ(2, 17)
+// This block preserves the old behavior used by include/__config:
+// _LIBCPP_GLIBC_PREREQ would be defined to 0 if __GLIBC_PREREQ was not
+// available. The configuration here may be too vague though, as Bionic, 
uClibc,
+// newlib, etc may all support these features but need to be configured.
+#if defined(TEST_GLIBC_PREREQ)
+#  if TEST_GLIBC_PREREQ(2, 17)
 #define TEST_HAS_TIMESPEC_GET
 #define TEST_HAS_C11_FEATURES
 #  endif
-#else // defined(_LIBCPP_HAS_MUSL_LIBC)
+#elif defined(_LIBCPP_HAS_MUSL_LIBC)
 #  define TEST_HAS_C11_FEATURES
 #  define TEST_HAS_TIMESPEC_GET
 #endif


Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -91,9 +91,11 @@
 #if (defined(__has_include) && __has_include()) || \
 defined(__linux__)
 #include 
+#if defined(__GLIBC_PREREQ)
 #define TEST_HAS_GLIBC
 #define TEST_GLIBC_PREREQ(major, minor) __GLIBC_PREREQ(major, minor)
 #endif
+#endif
 
 #if TEST_STD_VER >= 11
 #define TEST_ALIGNOF(...) alignof(__VA_ARGS__)
@@ -135,12 +137,16 @@
 #define TEST_HAS_C11_FEATURES
 #define TEST_HAS_TIMESPEC_GET
 #  elif defined(__linux__)
-#if !defined(_LIBCPP_HAS_MUSL_LIBC)
-#  if defined(TEST_GLIBC_PREREQ) && TEST_GLIBC_PREREQ(2, 17)
+// This block preserves the old behavior used by include/__config:
+// _LIBCPP_GLIBC_PREREQ would be defined to 0 if __GLIBC_PREREQ was not
+// available. The configuration here may be too vague though, as Bionic, uClibc,
+// newlib, etc may all support these features but need to be configured.
+#if defined(TEST_GLIBC_PREREQ)
+#  if TEST_GLIBC_PREREQ(2, 17)
 #define TEST_HAS_TIMESPEC_GET
 #define TEST_HAS_C11_FEATURES
 #  endif
-#else // defined(_LIBCPP_HAS_MUSL_LIBC)
+#elif defined(_LIBCPP_HAS_MUSL_LIBC)
 #  define TEST_HAS_C11_FEATURES
 #  define TEST_HAS_TIMESPEC_GET
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53343: [Driver] Default Android toolchains to noexecstack.

2019-03-28 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC357197: [Driver] Default Android toolchains to noexecstack. 
(authored by danalbert, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53343?vs=169901&id=192686#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D53343

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Linux.cpp
  lib/Driver/ToolChains/Linux.h
  test/Driver/integrated-as.c
  test/Driver/linux-as.c
  test/Driver/linux-ld.c

Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -360,6 +360,11 @@
 CmdArgs.push_back("--no-dynamic-linker");
   }
 
+  if (ToolChain.isNoExecStackDefault()) {
+CmdArgs.push_back("-z");
+CmdArgs.push_back("noexecstack");
+  }
+
   if (Args.hasArg(options::OPT_rdynamic))
 CmdArgs.push_back("-export-dynamic");
 
@@ -609,6 +614,10 @@
 }
   }
 
+  if (getToolChain().isNoExecStackDefault()) {
+  CmdArgs.push_back("--noexecstack");
+  }
+
   switch (getToolChain().getArch()) {
   default:
 break;
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2053,6 +2053,7 @@
   bool TakeNextArg = false;
 
   bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations();
+  bool UseNoExecStack = C.getDefaultToolChain().isNoExecStackDefault();
   const char *MipsTargetFeature = nullptr;
   for (const Arg *A :
Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {
@@ -2134,7 +2135,7 @@
   } else if (Value == "--fatal-warnings") {
 CmdArgs.push_back("-massembler-fatal-warnings");
   } else if (Value == "--noexecstack") {
-CmdArgs.push_back("-mnoexecstack");
+UseNoExecStack = true;
   } else if (Value.startswith("-compress-debug-sections") ||
  Value.startswith("--compress-debug-sections") ||
  Value == "-nocompress-debug-sections" ||
@@ -2197,6 +2198,8 @@
   }
   if (UseRelaxRelocations)
 CmdArgs.push_back("--mrelax-relocations");
+  if (UseNoExecStack)
+CmdArgs.push_back("-mnoexecstack");
   if (MipsTargetFeature != nullptr) {
 CmdArgs.push_back("-target-feature");
 CmdArgs.push_back(MipsTargetFeature);
Index: lib/Driver/ToolChains/Linux.h
===
--- lib/Driver/ToolChains/Linux.h
+++ lib/Driver/ToolChains/Linux.h
@@ -38,6 +38,7 @@
llvm::opt::ArgStringList &CC1Args) const override;
   CXXStdlibType GetDefaultCXXStdlibType() const override;
   bool isPIEDefault() const override;
+  bool isNoExecStackDefault() const override;
   bool IsMathErrnoDefault() const override;
   SanitizerMask getSupportedSanitizers() const override;
   void addProfileRTLibs(const llvm::opt::ArgList &Args,
Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -971,6 +971,10 @@
   getTriple().isMusl() || getSanitizerArgs().requiresPIE();
 }
 
+bool Linux::isNoExecStackDefault() const {
+return getTriple().isAndroid();
+}
+
 bool Linux::IsMathErrnoDefault() const {
   if (getTriple().isAndroid())
 return false;
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -112,6 +112,10 @@
   return ENABLE_X86_RELAX_RELOCATIONS;
 }
 
+bool ToolChain::isNoExecStackDefault() const {
+return false;
+}
+
 const SanitizerArgs& ToolChain::getSanitizerArgs() const {
   if (!SanitizerArguments.get())
 SanitizerArguments.reset(new SanitizerArgs(*this, Args));
Index: include/clang/Driver/ToolChain.h
===
--- include/clang/Driver/ToolChain.h
+++ include/clang/Driver/ToolChain.h
@@ -412,6 +412,9 @@
   /// Test whether this toolchain defaults to PIE.
   virtual bool isPIEDefault() const = 0;
 
+  /// Test whether this toolchaind defaults to non-executable stacks.
+  virtual bool isNoExecStackDefault() const;
+
   /// Tests whether this toolchain forces its default for PIC, PIE or
   /// non-PIC.  If this returns true, any PIC related flags should be ignored
   /// and instead the results of \c isPICDefault() and \c isPIEDefault() are
Index: test/Driver/linux-as.c
===
--- test/Driver/linux-as.c
+++ test/Driver/linux-as.c
@@ -108,12 +108,12 @@
 // RUN: %clang -target arm-linux-androideabi -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   

[PATCH] D53344: [Driver] Use --warn-shared-textrel for Android.

2019-03-29 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC357296: [Driver] Use --warn-shared-textrel for Android. 
(authored by danalbert, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53344?vs=169903&id=192874#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D53344

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/linux-ld.c


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -1006,7 +1006,13 @@
 // CHECK-ANDROID-NOEXECSTACK-NOT: "-z" "execstack"
 // CHECK-ANDROID-NOEXECSTACK-NOT: "-z,execstack"
 // CHECK-ANDROID-NOEXECSTACK-NOT: "-zexecstack"
-//
+
++// RUN: %clang %s -### -o %t.o 2>&1 \
++// RUN: --target=armv7-linux-android21 \
++// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-WARN-SHARED-TEXTREL %s
++// CHECK-ANDROID-WARN-SHARED-TEXTREL: "{{.*}}ld{{(.exe)?}}"
++// CHECK-ANDROID-WARN-SHARED-TEXTREL: "--warn-shared-textrel"
+
 // RUN: %clang %s -### -o %t.o 2>&1 --target=mips64-linux-gnuabin32 \
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL-GNUABIN32 %s
 // CHECK-MIPS64EL-GNUABIN32: "{{.*}}ld{{(.exe)?}}"
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -387,6 +387,11 @@
   CmdArgs.push_back("--fix-cortex-a53-843419");
   }
 
+  // Android does not allow shared text relocations. Emit a warning if the
+  // user's code contains any.
+  if (isAndroid)
+  CmdArgs.push_back("--warn-shared-textrel");
+
   for (const auto &Opt : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -1006,7 +1006,13 @@
 // CHECK-ANDROID-NOEXECSTACK-NOT: "-z" "execstack"
 // CHECK-ANDROID-NOEXECSTACK-NOT: "-z,execstack"
 // CHECK-ANDROID-NOEXECSTACK-NOT: "-zexecstack"
-//
+
++// RUN: %clang %s -### -o %t.o 2>&1 \
++// RUN: --target=armv7-linux-android21 \
++// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-WARN-SHARED-TEXTREL %s
++// CHECK-ANDROID-WARN-SHARED-TEXTREL: "{{.*}}ld{{(.exe)?}}"
++// CHECK-ANDROID-WARN-SHARED-TEXTREL: "--warn-shared-textrel"
+
 // RUN: %clang %s -### -o %t.o 2>&1 --target=mips64-linux-gnuabin32 \
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL-GNUABIN32 %s
 // CHECK-MIPS64EL-GNUABIN32: "{{.*}}ld{{(.exe)?}}"
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -387,6 +387,11 @@
   CmdArgs.push_back("--fix-cortex-a53-843419");
   }
 
+  // Android does not allow shared text relocations. Emit a warning if the
+  // user's code contains any.
+  if (isAndroid)
+  CmdArgs.push_back("--warn-shared-textrel");
+
   for (const auto &Opt : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58153: [Driver] Default all Android ARM targets to NEON.

2019-02-12 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added reviewers: srhines, pirama, kristof.beyls.
danalbert added a project: clang.
Herald added a subscriber: javed.absar.

There are an insignificant number of ARM Android devices that don't
support NEON. Default to using NEON since that will improve
performance on the majority of devices. Users that need to target
non-NEON devices can still explicitly disable NEON.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58153

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-mfpu.c


Index: clang/test/Driver/arm-mfpu.c
===
--- clang/test/Driver/arm-mfpu.c
+++ clang/test/Driver/arm-mfpu.c
@@ -376,55 +376,23 @@
 // CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+neon"
 // CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+crypto"
 
-// RUN: %clang -target arm-linux-androideabi21 -march=armv7-a %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MARCH-ARM7-ANDROID-FP %s
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+soft-float"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+soft-float-abi"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+d16"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+vfp3"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+vfp4"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+fp-armv8"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+neon"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+crypto"
-
 // RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-DEFAULT %s
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+d16"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+crypto"
-
-// RUN: %clang -target armv7-linux-androideabi21 -mfpu=neon %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-NEON %s
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+crypto"
-
-// RUN: %clang -target armv7-linux-androideabi23 %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-DEFAULT %s
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+crypto"
-
-// RUN: %clang -target armv7-linux-androideabi23 %s -mfpu=vfp3-d16 -### -c 
2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-D16 %s
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+d16"
-// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+crypto"
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID-FP-DEFAULT %s
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID-FP-DEFAULT: "-target-feature" "+soft-float-abi"
+// CHECK-ARM7-ANDROID-FP-DEFAULT: "-target-feature" "+vfp3"
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM7-ANDROID-FP-DEFAULT: "-target-feature" "+neon"
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi21 %s -mfpu=vfp3-d16 -### -c 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID-FP-D16 %s
+// CHECK-ARM7-ANDROID-FP-D16-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID-FP-D16: "-target-feature" "+soft-float-abi"
+// CHECK-ARM7-ANDROID-FP-D16: "-target-feature" "+d16"
+// CHEC

[PATCH] D58153: [Driver] Default all Android ARM targets to NEON.

2019-02-13 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

In D58153#1395601 , @efriedma wrote:

> The official documentation still says "Your app must perform runtime 
> detection to confirm that NEON-capable machine code can be run on the target 
> device" 
> (https://developer.android.com/ndk/guides/cpu-arm-neon#runtime_detection).  
> Is that wrong?


I'll update those docs when this change lands in the NDK (thanks for spotting 
that). Since there are so few devices affected by this we're instead advising 
developers to blacklist these CPUs or explicitly set their `-mfpu` to 
`vfp3-d16` if they want to continue supporting those devices.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58153



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


[PATCH] D58153: [Driver] Default all Android ARM targets to NEON.

2019-02-15 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354166: [Driver] Default all Android ARM targets to NEON. 
(authored by danalbert, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58153?vs=186553&id=187066#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58153

Files:
  cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
  cfe/trunk/test/Driver/arm-mfpu.c


Index: cfe/trunk/test/Driver/arm-mfpu.c
===
--- cfe/trunk/test/Driver/arm-mfpu.c
+++ cfe/trunk/test/Driver/arm-mfpu.c
@@ -376,55 +376,23 @@
 // CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+neon"
 // CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+crypto"
 
-// RUN: %clang -target arm-linux-androideabi21 -march=armv7-a %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MARCH-ARM7-ANDROID-FP %s
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+soft-float"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+soft-float-abi"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+d16"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+vfp3"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+vfp4"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+fp-armv8"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+neon"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+crypto"
-
 // RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-DEFAULT %s
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+d16"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+crypto"
-
-// RUN: %clang -target armv7-linux-androideabi21 -mfpu=neon %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-NEON %s
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+crypto"
-
-// RUN: %clang -target armv7-linux-androideabi23 %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-DEFAULT %s
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+crypto"
-
-// RUN: %clang -target armv7-linux-androideabi23 %s -mfpu=vfp3-d16 -### -c 
2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-D16 %s
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+d16"
-// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+crypto"
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID-FP-DEFAULT %s
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID-FP-DEFAULT: "-target-feature" "+soft-float-abi"
+// CHECK-ARM7-ANDROID-FP-DEFAULT: "-target-feature" "+vfp3"
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM7-ANDROID-FP-DEFAULT: "-target-feature" "+neon"
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi21 %s -mfpu=vfp3-d16 -### -c 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID-FP-D16 %s
+// CHECK-ARM7-ANDROID-FP-D16-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID-FP-D16: "-target-feature" "+soft-float-abi"
+// CHECK-ARM7-ANDROID-FP-D16: "-target-feature" "+d16"
+// C

[PATCH] D58314: [Driver] Sync ARM behavior between clang-as and gas.

2019-02-15 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added reviewers: peter.smith, kristof.beyls, srhines, pirama.
Herald added a subscriber: javed.absar.
Herald added a project: clang.

The ARM gas driver previously enabled NEON for ARMv7 and up, and a
handful of other extensions for ARMv8 and up (although only if the
architecture version was a part of the triple; the -march flag was
not honored). Neither of these are actually guaranteed, and the
behavior does not match the integrated assembler.

Note that I've elected to always pass an explicit -march flag to gas
if the user has not specified one. I'm not certain if Clang's default
ARM version matches GNU's, so being explicit allows us to keep the
same behavior if that isn't the case. This also makes it clear that
the correct architecture is passed to gas based on -mcpu.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58314

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/linux-as.c

Index: clang/test/Driver/linux-as.c
===
--- clang/test/Driver/linux-as.c
+++ clang/test/Driver/linux-as.c
@@ -3,17 +3,17 @@
 // RUN: %clang -target arm-linux -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM %s
-// CHECK-ARM: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft"
+// CHECK-ARM: as{{(.exe)?}}" "-EL" "-march=armv4t" "-mfloat-abi=soft"
 //
 // RUN: %clang -target arm-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MCPU %s
-// CHECK-ARM-MCPU: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-ARM-MCPU: as{{(.exe)?}}" "-EL" "-march=armv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target arm-linux -mfpu=neon -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MFPU %s
-// CHECK-ARM-MFPU: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-mfpu=neon"
+// CHECK-ARM-MFPU: as{{(.exe)?}}" "-EL" "-march=armv4t" "-mfloat-abi=soft" "-mfpu=neon"
 //
 // RUN: %clang -target arm-linux -march=armv7-a -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
@@ -63,62 +63,72 @@
 // RUN: %clang -target armv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-TARGET %s
-// CHECK-ARM-TARGET: as{{(.exe)?}}" "-EL" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-ARM-TARGET: as{{(.exe)?}}" "-EL" "-march=armv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target armebv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARMEB-TARGET %s
-// CHECK-ARMEB-TARGET: as{{(.exe)?}}" "-EB" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-ARMEB-TARGET: as{{(.exe)?}}" "-EB" "-march=armebv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target thumbv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-THUMB-TARGET %s
-// CHECK-THUMB-TARGET: as{{(.exe)?}}" "-EL" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-THUMB-TARGET: as{{(.exe)?}}" "-EL" "-march=armv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target thumbebv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-THUMBEB-TARGET %s
-// CHECK-THUMBEB-TARGET: as{{(.exe)?}}" "-EB" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-THUMBEB-TARGET: as{{(.exe)?}}" "-EB" "-march=armebv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target armv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-TARGET-V8 %s
-// CHECK-ARM-TARGET-V8: as{{(.exe)?}}" "-EL" "-mfpu=crypto-neon-fp-armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
+// CHECK-ARM-TARGET-V8: as{{(.exe)?}}" "-EL" "-march=armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
 //
 // RUN: %clang -target armebv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARMEB-TARGET-V8 %s
-// CHECK-ARMEB-TARGET-V8: as{{(.exe)?}}" "-EB" "-mfpu=crypto-neon-fp-armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
+// CHECK-ARMEB-TARGET-V8: as{{(.exe)?}}" "-EB" "-march=armebv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
 //
 // RUN: %clang -target thumbv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-THUMB-TARGET-V8 %s
-// CHECK-THUMB-TARGET-V8: as{{(.exe)?}}" "-EL" "-mfpu=crypto-neon-fp-armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
+// CHECK-THUMB-TARGET-V8: as{{(.exe)?}}" "-EL" "-march=armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
 //
 // RUN: %clang -target thumbebv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-pr

[PATCH] D58314: [Driver] Sync ARM behavior between clang-as and gas.

2019-02-20 Thread Dan Albert via Phabricator via cfe-commits
danalbert updated this revision to Diff 187670.
danalbert marked 6 inline comments as done.
danalbert added a comment.

Updated to address some review comments:

- Additional tests for gnueabi/gnueabihf
- Fixed behavior for `-mfpu=neon -mfloat-abi=soft`, added test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58314

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/linux-as.c

Index: clang/test/Driver/linux-as.c
===
--- clang/test/Driver/linux-as.c
+++ clang/test/Driver/linux-as.c
@@ -3,17 +3,17 @@
 // RUN: %clang -target arm-linux -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM %s
-// CHECK-ARM: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft"
+// CHECK-ARM: as{{(.exe)?}}" "-EL" "-march=armv4t" "-mfloat-abi=soft"
 //
 // RUN: %clang -target arm-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MCPU %s
-// CHECK-ARM-MCPU: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-ARM-MCPU: as{{(.exe)?}}" "-EL" "-march=armv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target arm-linux -mfpu=neon -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MFPU %s
-// CHECK-ARM-MFPU: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-mfpu=neon"
+// CHECK-ARM-MFPU: as{{(.exe)?}}" "-EL" "-march=armv4t" "-mfloat-abi=soft" "-mfpu=neon"
 //
 // RUN: %clang -target arm-linux -march=armv7-a -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
@@ -63,62 +63,97 @@
 // RUN: %clang -target armv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-TARGET %s
-// CHECK-ARM-TARGET: as{{(.exe)?}}" "-EL" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-ARM-TARGET: as{{(.exe)?}}" "-EL" "-march=armv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target armebv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARMEB-TARGET %s
-// CHECK-ARMEB-TARGET: as{{(.exe)?}}" "-EB" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-ARMEB-TARGET: as{{(.exe)?}}" "-EB" "-march=armebv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target thumbv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-THUMB-TARGET %s
-// CHECK-THUMB-TARGET: as{{(.exe)?}}" "-EL" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-THUMB-TARGET: as{{(.exe)?}}" "-EL" "-march=armv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target thumbebv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-THUMBEB-TARGET %s
-// CHECK-THUMBEB-TARGET: as{{(.exe)?}}" "-EB" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-THUMBEB-TARGET: as{{(.exe)?}}" "-EB" "-march=armebv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target armv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-TARGET-V8 %s
-// CHECK-ARM-TARGET-V8: as{{(.exe)?}}" "-EL" "-mfpu=crypto-neon-fp-armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
+// CHECK-ARM-TARGET-V8: as{{(.exe)?}}" "-EL" "-march=armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
 //
 // RUN: %clang -target armebv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARMEB-TARGET-V8 %s
-// CHECK-ARMEB-TARGET-V8: as{{(.exe)?}}" "-EB" "-mfpu=crypto-neon-fp-armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
+// CHECK-ARMEB-TARGET-V8: as{{(.exe)?}}" "-EB" "-march=armebv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
 //
 // RUN: %clang -target thumbv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-THUMB-TARGET-V8 %s
-// CHECK-THUMB-TARGET-V8: as{{(.exe)?}}" "-EL" "-mfpu=crypto-neon-fp-armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
+// CHECK-THUMB-TARGET-V8: as{{(.exe)?}}" "-EL" "-march=armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
 //
 // RUN: %clang -target thumbebv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-THUMBEB-TARGET-V8 %s
-// CHECK-THUMBEB-TARGET-V8: as{{(.exe)?}}" "-EB" "-mfpu=crypto-neon-fp-armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
+// CHECK-THUMBEB-TARGET-V8: as{{(.exe)?}}" "-EB" "-march=armebv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
 //
 // RUN: %clang -target arm-linux -mfloat-abi=hard -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MFLOAT-ABI %s
-// CHECK-ARM-MFLOAT-ABI: as{{(.exe)?}}" "-EL" "-mfloat-abi=hard"
+// CHE

[PATCH] D58314: [Driver] Sync ARM behavior between clang-as and gas.

2019-02-20 Thread Dan Albert via Phabricator via cfe-commits
danalbert added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:277
+  }
+  return "";
+}

peter.smith wrote:
> I'm a bit worried that we've changed the default behaviour for gnueabi[hf] 
> targets here. 
> For example with:
> ```
> .text
> vmov.32 d13[1], r6 ; Needs VFPv2
> vadd.i32 d0, d0, d0 ; Needs Neon
> ```
> I get with --target=armv7a-linux (no environment, -mfloat-abi will disable 
> floating point, and neon)
> ```
> clang: warning: unknown platform, assuming -mfloat-abi=soft
> neon.s:2:9: error: instruction requires: VFP2
> vmov.32 d13[1],r6
> ^
> neon.s:3:9: error: instruction requires: NEON
> vadd.i32 d0, d0, d0
> ^
> ```
> With the target=armv7a-linux-gnueabi armv7a-linux-gnueabihf or explicitly 
> adding -mfloat-abi=softfp the integrated assembler will happily assemble it.
> GNU needs -mfpu=neon to assemble the file:
> 
> ```
> arm-linux-gnueabihf-as -march=armv7-a neon.s 
> neon.s: Assembler messages:
> neon.s:2: Error: selected processor does not support ARM mode `vmov.32 
> d13[1],r6'
> neon.s:3: Error: selected processor does not support ARM mode `vadd.i32 
> d0,d0,d0'
> ```
> It is a similar story for armv8 and crypto.
> 
> I think we should have something like:
> ```
> if (Triple.isLinux() && getARMSubArchVersionNumber(Triple) >= 8)
>return "crypto-neon-fp-armv8";
> if (Triple.isAndroid() || Triple.isLinux() && 
> getARMSubArchVersionNumber(Triple) >= 7)
> return "neon";
> return "";
> ```
I suppose it depends on which direction you want the behavior change to go. I 
assumed those samples _shouldn't_ assemble since they're not enabling NEON. The 
fact that the direct `arm-linux-gnueabihf-as` doesn't enable NEON by default 
makes me assume that NEON is not an assumed feature of the gnueabihf 
environment.

It's not up to me whether NEON is available by default for ARMv7 for 
non-Android, but I do think that the behavior should be consistent regardless 
of the assembler being used. Right now we have no FPU by default with the 
integrated assembler and NEON by default with GAS. This change makes GAS have 
the same behavior as the integrated assembler, since I assume that is the 
better traveled path and afaict is the one that has had more effort put in to 
it.

If that's not right, I can change this so that the integrated assembler _also_ 
gets FPU features that are not necessarily available for the given 
architecture, but I wanted to clarify that that is what you're asking for first.



Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:389
+std::string DefaultFPU = getDefaultFPUName(Triple);
+if (DefaultFPU != "") {
+  if (!llvm::ARM::getFPUFeatures(llvm::ARM::parseFPU(DefaultFPU), 
Features))

peter.smith wrote:
> I'm wondering whether you need this bit of code anymore? In D53121 there 
> needed to be a switch between vfpv3-d16 and neon based on Android version. 
> With --target=armv7a-linux-android or --target=arm-linux-android 
> -march=armv7a or any v7a -mcpu applicable to Android then you'll get feature 
> Neon by default and won't need to do this? We could then move 
> getDefaultFPUName out of ARM.cpp
I don't understand. This bit of code is the piece that provides the NEON 
default. If I remove this then Android ARMv7 targets revert to no FPU features.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:692
+}
+if (!hasMOrWaMArg(Args, options::OPT_mfpu_EQ, "-mfpu=")) {
+std::string DefaultFPU = arm::getDefaultFPUName(Triple);

peter.smith wrote:
> I think we'd not want to do this for -mfloat-abi=soft as this disables the 
> FPU in the integrated assembler. It seems like -mfloat-abi has no effect at 
> all on the gnu assembler, it will happily assemble neon instructions with 
> -mfloat-abi=soft -mfpu=neon.
>  
Added a check for soft float ABI and added a test to match.



Comment at: clang/test/Driver/linux-as.c:3
 //
 // RUN: %clang -target arm-linux -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \

peter.smith wrote:
> the target arm-linux (effectively arm-linux-unknown) defaults to 
> -mfloat-abi=soft which disables the FPU for the integrated assembler. While 
> these test cases are not wrong, the number of v7a + linux targets without an 
> FPU using entirely software floating point is likely to be very small. We 
> should have some more that have arm-linux-gnueabi and arm-linux-gnueabihf.
Added a handful. Not really sure what needs to be tested here, but I covered 
the basic cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58314



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


[PATCH] D58477: [Driver] Fix float ABI default for Android ARMv8.

2019-02-20 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added reviewers: srhines, pirama.
Herald added subscribers: kristof.beyls, javed.absar.
Herald added a project: clang.

Android doesn't regress back to soft float after ARMv7 :)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58477

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-float-abi.c


Index: clang/test/Driver/arm-float-abi.c
===
--- clang/test/Driver/arm-float-abi.c
+++ clang/test/Driver/arm-float-abi.c
@@ -4,3 +4,13 @@
 
 // ARMV7-ERROR: unsupported option '-mfloat-abi=hard' for target 'thumbv7'
 // NOERROR-NOT: unsupported option
+
+// RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID %s
+// CHECK-ARM7-ANDROID-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID: "-target-feature" "+soft-float-abi"
+
+// RUN: %clang -target armv8-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM8-ANDROID %s
+// CHECK-ARM8-ANDROID-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM8-ANDROID: "-target-feature" "+soft-float-abi"
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -248,7 +248,7 @@
 ABI = FloatABI::SoftFP;
 break;
   case llvm::Triple::Android:
-ABI = (SubArch == 7) ? FloatABI::SoftFP : FloatABI::Soft;
+ABI = (SubArch >= 7) ? FloatABI::SoftFP : FloatABI::Soft;
 break;
   default:
 // Assume "soft", but warn the user we are guessing.


Index: clang/test/Driver/arm-float-abi.c
===
--- clang/test/Driver/arm-float-abi.c
+++ clang/test/Driver/arm-float-abi.c
@@ -4,3 +4,13 @@
 
 // ARMV7-ERROR: unsupported option '-mfloat-abi=hard' for target 'thumbv7'
 // NOERROR-NOT: unsupported option
+
+// RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID %s
+// CHECK-ARM7-ANDROID-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID: "-target-feature" "+soft-float-abi"
+
+// RUN: %clang -target armv8-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM8-ANDROID %s
+// CHECK-ARM8-ANDROID-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM8-ANDROID: "-target-feature" "+soft-float-abi"
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -248,7 +248,7 @@
 ABI = FloatABI::SoftFP;
 break;
   case llvm::Triple::Android:
-ABI = (SubArch == 7) ? FloatABI::SoftFP : FloatABI::Soft;
+ABI = (SubArch >= 7) ? FloatABI::SoftFP : FloatABI::Soft;
 break;
   default:
 // Assume "soft", but warn the user we are guessing.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58314: [Driver] Sync ARM behavior between clang-as and gas.

2019-02-21 Thread Dan Albert via Phabricator via cfe-commits
danalbert marked 3 inline comments as done.
danalbert added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:389
+std::string DefaultFPU = getDefaultFPUName(Triple);
+if (DefaultFPU != "") {
+  if (!llvm::ARM::getFPUFeatures(llvm::ARM::parseFPU(DefaultFPU), 
Features))

peter.smith wrote:
> danalbert wrote:
> > peter.smith wrote:
> > > I'm wondering whether you need this bit of code anymore? In D53121 there 
> > > needed to be a switch between vfpv3-d16 and neon based on Android 
> > > version. With --target=armv7a-linux-android or --target=arm-linux-android 
> > > -march=armv7a or any v7a -mcpu applicable to Android then you'll get 
> > > feature Neon by default and won't need to do this? We could then move 
> > > getDefaultFPUName out of ARM.cpp
> > I don't understand. This bit of code is the piece that provides the NEON 
> > default. If I remove this then Android ARMv7 targets revert to no FPU 
> > features.
> My understanding is that adding the equivalent of -fpu=neon here has the 
> effect of adding extra feature flags to the call to clang -cc1. I can observe 
> the difference with -###. However when compiling these are then added back in 
> by TargetInfo::CreateTargetInfo() by calls like initFeatureMap that take the 
> default features from the target. When invoking -cc1as the 
> createMCSubtargetInfo via a long chain of function calls will add the 
> FeatureNEON bit for armv7-a unless the -neon feature has been cleared.  
> 
> If I have it right I think the lack of floating point features in the clang 
> -cc1 command line is not a problem as the defaults for armv7-a will put them 
> in anyway unless they've been explicitly turned off via something like 
> -mfloat-abi=soft. My information is based on reverse engineering the code so 
> I could easily be missing something important though?
Oh, I thought that the cc1 args were the full story. I'll need to do some more 
digging then to make sure that the behavior actually does match.



Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:251
   case llvm::Triple::Android:
 ABI = (SubArch == 7) ? FloatABI::SoftFP : FloatABI::Soft;
 break;

peter.smith wrote:
> Not strictly related to this patch, but you'll probably want to make that 
> (SubArch >= 7), I tried --target=armv8a-linux-android as an experiment and 
> got my floating point support removed.
I actually uploaded a fix for that yesterday: https://reviews.llvm.org/D58477

Didn't submit because I wanted to wait until I knew I'd be around to babysit 
build bots just in case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58314



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


[PATCH] D58477: [Driver] Fix float ABI default for Android ARMv8.

2019-02-21 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354622: [Driver] Fix float ABI default for Android ARMv8. 
(authored by danalbert, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58477?vs=187673&id=187851#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58477

Files:
  cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
  cfe/trunk/test/Driver/arm-float-abi.c


Index: cfe/trunk/test/Driver/arm-float-abi.c
===
--- cfe/trunk/test/Driver/arm-float-abi.c
+++ cfe/trunk/test/Driver/arm-float-abi.c
@@ -4,3 +4,13 @@
 
 // ARMV7-ERROR: unsupported option '-mfloat-abi=hard' for target 'thumbv7'
 // NOERROR-NOT: unsupported option
+
+// RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID %s
+// CHECK-ARM7-ANDROID-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID: "-target-feature" "+soft-float-abi"
+
+// RUN: %clang -target armv8-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM8-ANDROID %s
+// CHECK-ARM8-ANDROID-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM8-ANDROID: "-target-feature" "+soft-float-abi"
Index: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -248,7 +248,7 @@
 ABI = FloatABI::SoftFP;
 break;
   case llvm::Triple::Android:
-ABI = (SubArch == 7) ? FloatABI::SoftFP : FloatABI::Soft;
+ABI = (SubArch >= 7) ? FloatABI::SoftFP : FloatABI::Soft;
 break;
   default:
 // Assume "soft", but warn the user we are guessing.


Index: cfe/trunk/test/Driver/arm-float-abi.c
===
--- cfe/trunk/test/Driver/arm-float-abi.c
+++ cfe/trunk/test/Driver/arm-float-abi.c
@@ -4,3 +4,13 @@
 
 // ARMV7-ERROR: unsupported option '-mfloat-abi=hard' for target 'thumbv7'
 // NOERROR-NOT: unsupported option
+
+// RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID %s
+// CHECK-ARM7-ANDROID-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID: "-target-feature" "+soft-float-abi"
+
+// RUN: %clang -target armv8-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM8-ANDROID %s
+// CHECK-ARM8-ANDROID-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM8-ANDROID: "-target-feature" "+soft-float-abi"
Index: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -248,7 +248,7 @@
 ABI = FloatABI::SoftFP;
 break;
   case llvm::Triple::Android:
-ABI = (SubArch == 7) ? FloatABI::SoftFP : FloatABI::Soft;
+ABI = (SubArch >= 7) ? FloatABI::SoftFP : FloatABI::Soft;
 break;
   default:
 // Assume "soft", but warn the user we are guessing.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64089: [Driver] Introduce -stdlib++-isystem

2019-07-02 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

> For example, when we're building against the Android NDK, we might want to 
> use the NDK's C++ headers (which have a custom inline namespace) even if we 
> have C++ headers installed next to the driver.

Since NDK r19 the NDK libc++ headers are already installed alongside the 
driver, so this doesn't benefit that use case. The others sound useful, just 
FYI in case the NDK was the main motivating factor here :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64089



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


[PATCH] D55856: [Driver] Also obey -nostdlib++ when rewriting -lstdc++.

2018-12-18 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added a reviewer: pirama.

Repository:
  rC Clang

https://reviews.llvm.org/D55856

Files:
  lib/Driver/Driver.cpp
  test/Driver/nostdlibxx.cpp


Index: test/Driver/nostdlibxx.cpp
===
--- test/Driver/nostdlibxx.cpp
+++ test/Driver/nostdlibxx.cpp
@@ -6,3 +6,12 @@
 // CHECK-NOT: -lstdc++
 // CHECK-NOT: -lc++
 // CHECK: -lm
+
+// Make sure -lstdc++ isn't rewritten to the default stdlib when -nostdlib++ is
+// used.
+//
+// RUN: %clangxx -target i686-pc-linux-gnu -### \
+// RUN: -nostdlib++ -stdlib=libc++ -lstdc++%s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-RESERVED-LIB-REWRITE < %t %s
+// CHECK-RESERVED-LIB-REWRITE: -lstdc++
+// CHECK-RESERVED-LIB-REWRITE-NOT: -lc++
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -303,6 +303,7 @@
   DerivedArgList *DAL = new DerivedArgList(Args);
 
   bool HasNostdlib = Args.hasArg(options::OPT_nostdlib);
+  bool HasNostdlibxx = Args.hasArg(options::OPT_nostdlibxx);
   bool HasNodefaultlib = Args.hasArg(options::OPT_nodefaultlibs);
   for (Arg *A : Args) {
 // Unfortunately, we have to parse some forwarding options (-Xassembler,
@@ -347,7 +348,8 @@
   StringRef Value = A->getValue();
 
   // Rewrite unless -nostdlib is present.
-  if (!HasNostdlib && !HasNodefaultlib && Value == "stdc++") {
+  if (!HasNostdlib && !HasNodefaultlib && !HasNostdlibxx &&
+  Value == "stdc++") {
 DAL->AddFlagArg(A, 
Opts->getOption(options::OPT_Z_reserved_lib_stdcxx));
 continue;
   }


Index: test/Driver/nostdlibxx.cpp
===
--- test/Driver/nostdlibxx.cpp
+++ test/Driver/nostdlibxx.cpp
@@ -6,3 +6,12 @@
 // CHECK-NOT: -lstdc++
 // CHECK-NOT: -lc++
 // CHECK: -lm
+
+// Make sure -lstdc++ isn't rewritten to the default stdlib when -nostdlib++ is
+// used.
+//
+// RUN: %clangxx -target i686-pc-linux-gnu -### \
+// RUN: -nostdlib++ -stdlib=libc++ -lstdc++%s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-RESERVED-LIB-REWRITE < %t %s
+// CHECK-RESERVED-LIB-REWRITE: -lstdc++
+// CHECK-RESERVED-LIB-REWRITE-NOT: -lc++
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -303,6 +303,7 @@
   DerivedArgList *DAL = new DerivedArgList(Args);
 
   bool HasNostdlib = Args.hasArg(options::OPT_nostdlib);
+  bool HasNostdlibxx = Args.hasArg(options::OPT_nostdlibxx);
   bool HasNodefaultlib = Args.hasArg(options::OPT_nodefaultlibs);
   for (Arg *A : Args) {
 // Unfortunately, we have to parse some forwarding options (-Xassembler,
@@ -347,7 +348,8 @@
   StringRef Value = A->getValue();
 
   // Rewrite unless -nostdlib is present.
-  if (!HasNostdlib && !HasNodefaultlib && Value == "stdc++") {
+  if (!HasNostdlib && !HasNodefaultlib && !HasNostdlibxx &&
+  Value == "stdc++") {
 DAL->AddFlagArg(A, Opts->getOption(options::OPT_Z_reserved_lib_stdcxx));
 continue;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55856: [Driver] Also obey -nostdlib++ when rewriting -lstdc++.

2018-12-18 Thread Dan Albert via Phabricator via cfe-commits
danalbert updated this revision to Diff 178805.

Repository:
  rC Clang

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

https://reviews.llvm.org/D55856

Files:
  lib/Driver/Driver.cpp
  test/Driver/nostdlibxx.cpp


Index: test/Driver/nostdlibxx.cpp
===
--- test/Driver/nostdlibxx.cpp
+++ test/Driver/nostdlibxx.cpp
@@ -6,3 +6,12 @@
 // CHECK-NOT: -lstdc++
 // CHECK-NOT: -lc++
 // CHECK: -lm
+
+// Make sure -lstdc++ isn't rewritten to the default stdlib when -nostdlib++ is
+// used.
+//
+// RUN: %clangxx -target i686-pc-linux-gnu -### \
+// RUN: -nostdlib++ -stdlib=libc++ -lstdc++ %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-RESERVED-LIB-REWRITE < %t %s
+// CHECK-RESERVED-LIB-REWRITE: -lstdc++
+// CHECK-RESERVED-LIB-REWRITE-NOT: -lc++
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -303,6 +303,7 @@
   DerivedArgList *DAL = new DerivedArgList(Args);
 
   bool HasNostdlib = Args.hasArg(options::OPT_nostdlib);
+  bool HasNostdlibxx = Args.hasArg(options::OPT_nostdlibxx);
   bool HasNodefaultlib = Args.hasArg(options::OPT_nodefaultlibs);
   for (Arg *A : Args) {
 // Unfortunately, we have to parse some forwarding options (-Xassembler,
@@ -347,7 +348,8 @@
   StringRef Value = A->getValue();
 
   // Rewrite unless -nostdlib is present.
-  if (!HasNostdlib && !HasNodefaultlib && Value == "stdc++") {
+  if (!HasNostdlib && !HasNodefaultlib && !HasNostdlibxx &&
+  Value == "stdc++") {
 DAL->AddFlagArg(A, 
Opts->getOption(options::OPT_Z_reserved_lib_stdcxx));
 continue;
   }


Index: test/Driver/nostdlibxx.cpp
===
--- test/Driver/nostdlibxx.cpp
+++ test/Driver/nostdlibxx.cpp
@@ -6,3 +6,12 @@
 // CHECK-NOT: -lstdc++
 // CHECK-NOT: -lc++
 // CHECK: -lm
+
+// Make sure -lstdc++ isn't rewritten to the default stdlib when -nostdlib++ is
+// used.
+//
+// RUN: %clangxx -target i686-pc-linux-gnu -### \
+// RUN: -nostdlib++ -stdlib=libc++ -lstdc++ %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-RESERVED-LIB-REWRITE < %t %s
+// CHECK-RESERVED-LIB-REWRITE: -lstdc++
+// CHECK-RESERVED-LIB-REWRITE-NOT: -lc++
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -303,6 +303,7 @@
   DerivedArgList *DAL = new DerivedArgList(Args);
 
   bool HasNostdlib = Args.hasArg(options::OPT_nostdlib);
+  bool HasNostdlibxx = Args.hasArg(options::OPT_nostdlibxx);
   bool HasNodefaultlib = Args.hasArg(options::OPT_nodefaultlibs);
   for (Arg *A : Args) {
 // Unfortunately, we have to parse some forwarding options (-Xassembler,
@@ -347,7 +348,8 @@
   StringRef Value = A->getValue();
 
   // Rewrite unless -nostdlib is present.
-  if (!HasNostdlib && !HasNodefaultlib && Value == "stdc++") {
+  if (!HasNostdlib && !HasNodefaultlib && !HasNostdlibxx &&
+  Value == "stdc++") {
 DAL->AddFlagArg(A, Opts->getOption(options::OPT_Z_reserved_lib_stdcxx));
 continue;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55856: [Driver] Also obey -nostdlib++ when rewriting -lstdc++.

2018-12-18 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349570: [Driver] Also obey -nostdlib++ when rewriting 
-lstdc++. (authored by danalbert, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55856

Files:
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/nostdlibxx.cpp


Index: cfe/trunk/test/Driver/nostdlibxx.cpp
===
--- cfe/trunk/test/Driver/nostdlibxx.cpp
+++ cfe/trunk/test/Driver/nostdlibxx.cpp
@@ -6,3 +6,12 @@
 // CHECK-NOT: -lstdc++
 // CHECK-NOT: -lc++
 // CHECK: -lm
+
+// Make sure -lstdc++ isn't rewritten to the default stdlib when -nostdlib++ is
+// used.
+//
+// RUN: %clangxx -target i686-pc-linux-gnu -### \
+// RUN: -nostdlib++ -stdlib=libc++ -lstdc++ %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-RESERVED-LIB-REWRITE < %t %s
+// CHECK-RESERVED-LIB-REWRITE: -lstdc++
+// CHECK-RESERVED-LIB-REWRITE-NOT: -lc++
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -303,6 +303,7 @@
   DerivedArgList *DAL = new DerivedArgList(Args);
 
   bool HasNostdlib = Args.hasArg(options::OPT_nostdlib);
+  bool HasNostdlibxx = Args.hasArg(options::OPT_nostdlibxx);
   bool HasNodefaultlib = Args.hasArg(options::OPT_nodefaultlibs);
   for (Arg *A : Args) {
 // Unfortunately, we have to parse some forwarding options (-Xassembler,
@@ -347,7 +348,8 @@
   StringRef Value = A->getValue();
 
   // Rewrite unless -nostdlib is present.
-  if (!HasNostdlib && !HasNodefaultlib && Value == "stdc++") {
+  if (!HasNostdlib && !HasNodefaultlib && !HasNostdlibxx &&
+  Value == "stdc++") {
 DAL->AddFlagArg(A, 
Opts->getOption(options::OPT_Z_reserved_lib_stdcxx));
 continue;
   }


Index: cfe/trunk/test/Driver/nostdlibxx.cpp
===
--- cfe/trunk/test/Driver/nostdlibxx.cpp
+++ cfe/trunk/test/Driver/nostdlibxx.cpp
@@ -6,3 +6,12 @@
 // CHECK-NOT: -lstdc++
 // CHECK-NOT: -lc++
 // CHECK: -lm
+
+// Make sure -lstdc++ isn't rewritten to the default stdlib when -nostdlib++ is
+// used.
+//
+// RUN: %clangxx -target i686-pc-linux-gnu -### \
+// RUN: -nostdlib++ -stdlib=libc++ -lstdc++ %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-RESERVED-LIB-REWRITE < %t %s
+// CHECK-RESERVED-LIB-REWRITE: -lstdc++
+// CHECK-RESERVED-LIB-REWRITE-NOT: -lc++
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -303,6 +303,7 @@
   DerivedArgList *DAL = new DerivedArgList(Args);
 
   bool HasNostdlib = Args.hasArg(options::OPT_nostdlib);
+  bool HasNostdlibxx = Args.hasArg(options::OPT_nostdlibxx);
   bool HasNodefaultlib = Args.hasArg(options::OPT_nodefaultlibs);
   for (Arg *A : Args) {
 // Unfortunately, we have to parse some forwarding options (-Xassembler,
@@ -347,7 +348,8 @@
   StringRef Value = A->getValue();
 
   // Rewrite unless -nostdlib is present.
-  if (!HasNostdlib && !HasNodefaultlib && Value == "stdc++") {
+  if (!HasNostdlib && !HasNodefaultlib && !HasNostdlibxx &&
+  Value == "stdc++") {
 DAL->AddFlagArg(A, Opts->getOption(options::OPT_Z_reserved_lib_stdcxx));
 continue;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55953: Android is not GNU, so don't claim that it is.

2018-12-20 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added reviewers: pirama, srhines.

Repository:
  rC Clang

https://reviews.llvm.org/D55953

Files:
  lib/Basic/Targets/OSTargets.h
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9057,6 +9057,7 @@
 // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID %s
 // ANDROID-NOT:#define __ANDROID_API__
 // ANDROID:#define __ANDROID__ 1
+// ANDROID-NOT:#define __gnu_linux__
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
 // I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
@@ -9067,6 +9068,7 @@
 // RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID20 %s
 // ANDROID20:#define __ANDROID_API__ 20
 // ANDROID20:#define __ANDROID__ 1
+// ANDROID-NOT:#define __gnu_linux__
 //
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix LANAI %s
 // LANAI: #define __lanai__ 1
Index: lib/Basic/Targets/OSTargets.h
===
--- lib/Basic/Targets/OSTargets.h
+++ lib/Basic/Targets/OSTargets.h
@@ -345,7 +345,6 @@
 // Linux defines; list based off of gcc output
 DefineStd(Builder, "unix", Opts);
 DefineStd(Builder, "linux", Opts);
-Builder.defineMacro("__gnu_linux__");
 Builder.defineMacro("__ELF__");
 if (Triple.isAndroid()) {
   Builder.defineMacro("__ANDROID__", "1");
@@ -355,6 +354,8 @@
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
   if (Maj)
 Builder.defineMacro("__ANDROID_API__", Twine(Maj));
+} else {
+Builder.defineMacro("__gnu_linux__");
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9057,6 +9057,7 @@
 // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID %s
 // ANDROID-NOT:#define __ANDROID_API__
 // ANDROID:#define __ANDROID__ 1
+// ANDROID-NOT:#define __gnu_linux__
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
 // I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
@@ -9067,6 +9068,7 @@
 // RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID20 %s
 // ANDROID20:#define __ANDROID_API__ 20
 // ANDROID20:#define __ANDROID__ 1
+// ANDROID-NOT:#define __gnu_linux__
 //
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix LANAI %s
 // LANAI: #define __lanai__ 1
Index: lib/Basic/Targets/OSTargets.h
===
--- lib/Basic/Targets/OSTargets.h
+++ lib/Basic/Targets/OSTargets.h
@@ -345,7 +345,6 @@
 // Linux defines; list based off of gcc output
 DefineStd(Builder, "unix", Opts);
 DefineStd(Builder, "linux", Opts);
-Builder.defineMacro("__gnu_linux__");
 Builder.defineMacro("__ELF__");
 if (Triple.isAndroid()) {
   Builder.defineMacro("__ANDROID__", "1");
@@ -355,6 +354,8 @@
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
   if (Maj)
 Builder.defineMacro("__ANDROID_API__", Twine(Maj));
+} else {
+Builder.defineMacro("__gnu_linux__");
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56456: [Driver] Default to -fno-addrsig on Android.

2019-01-08 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added reviewers: srhines, pirama.

The Android NDK still uses GNU binutils by default.


Repository:
  rC Clang

https://reviews.llvm.org/D56456

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/addrsig.c


Index: test/Driver/addrsig.c
===
--- test/Driver/addrsig.c
+++ test/Driver/addrsig.c
@@ -8,6 +8,7 @@
 // RUN: %clang -### -target x86_64-unknown-linux -fno-addrsig -c %s 2>&1 | 
FileCheck -check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-apple-darwin -c %s 2>&1 | FileCheck 
-check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-scei-ps4 -c %s 2>&1 | FileCheck 
-check-prefix=NO-ADDRSIG %s
+// RUN: %clang -### -target x86_64-linux-android21 -c %s 2>&1 | FileCheck 
-check-prefix=NO-ADDRSIG %s
 
 // ADDRSIG: -faddrsig
 // NO-ADDRSIG-NOT: -faddrsig
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -5292,6 +5292,7 @@
   !TC.getTriple().isPS4() &&
   !TC.getTriple().isOSNetBSD() &&
   !Distro(D.getVFS()).IsGentoo() &&
+  !TC.getTriple().isAndroid() &&
TC.useIntegratedAs()))
 CmdArgs.push_back("-faddrsig");
 


Index: test/Driver/addrsig.c
===
--- test/Driver/addrsig.c
+++ test/Driver/addrsig.c
@@ -8,6 +8,7 @@
 // RUN: %clang -### -target x86_64-unknown-linux -fno-addrsig -c %s 2>&1 | FileCheck -check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-apple-darwin -c %s 2>&1 | FileCheck -check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-scei-ps4 -c %s 2>&1 | FileCheck -check-prefix=NO-ADDRSIG %s
+// RUN: %clang -### -target x86_64-linux-android21 -c %s 2>&1 | FileCheck -check-prefix=NO-ADDRSIG %s
 
 // ADDRSIG: -faddrsig
 // NO-ADDRSIG-NOT: -faddrsig
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -5292,6 +5292,7 @@
   !TC.getTriple().isPS4() &&
   !TC.getTriple().isOSNetBSD() &&
   !Distro(D.getVFS()).IsGentoo() &&
+  !TC.getTriple().isAndroid() &&
TC.useIntegratedAs()))
 CmdArgs.push_back("-faddrsig");
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55953: Android is not GNU, so don't claim that it is.

2019-01-08 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC350664: Android is not GNU, so don't claim that it is. 
(authored by danalbert, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55953?vs=179140&id=180741#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D55953

Files:
  lib/Basic/Targets/OSTargets.h
  test/Preprocessor/init.c


Index: lib/Basic/Targets/OSTargets.h
===
--- lib/Basic/Targets/OSTargets.h
+++ lib/Basic/Targets/OSTargets.h
@@ -345,7 +345,6 @@
 // Linux defines; list based off of gcc output
 DefineStd(Builder, "unix", Opts);
 DefineStd(Builder, "linux", Opts);
-Builder.defineMacro("__gnu_linux__");
 Builder.defineMacro("__ELF__");
 if (Triple.isAndroid()) {
   Builder.defineMacro("__ANDROID__", "1");
@@ -355,6 +354,8 @@
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
   if (Maj)
 Builder.defineMacro("__ANDROID_API__", Twine(Maj));
+} else {
+Builder.defineMacro("__gnu_linux__");
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9057,6 +9057,7 @@
 // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID %s
 // ANDROID-NOT:#define __ANDROID_API__
 // ANDROID:#define __ANDROID__ 1
+// ANDROID-NOT:#define __gnu_linux__
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
 // I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
@@ -9067,6 +9068,7 @@
 // RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID20 %s
 // ANDROID20:#define __ANDROID_API__ 20
 // ANDROID20:#define __ANDROID__ 1
+// ANDROID-NOT:#define __gnu_linux__
 //
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix LANAI %s
 // LANAI: #define __lanai__ 1


Index: lib/Basic/Targets/OSTargets.h
===
--- lib/Basic/Targets/OSTargets.h
+++ lib/Basic/Targets/OSTargets.h
@@ -345,7 +345,6 @@
 // Linux defines; list based off of gcc output
 DefineStd(Builder, "unix", Opts);
 DefineStd(Builder, "linux", Opts);
-Builder.defineMacro("__gnu_linux__");
 Builder.defineMacro("__ELF__");
 if (Triple.isAndroid()) {
   Builder.defineMacro("__ANDROID__", "1");
@@ -355,6 +354,8 @@
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
   if (Maj)
 Builder.defineMacro("__ANDROID_API__", Twine(Maj));
+} else {
+Builder.defineMacro("__gnu_linux__");
 }
 if (Opts.POSIXThreads)
   Builder.defineMacro("_REENTRANT");
Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9057,6 +9057,7 @@
 // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID %s
 // ANDROID-NOT:#define __ANDROID_API__
 // ANDROID:#define __ANDROID__ 1
+// ANDROID-NOT:#define __gnu_linux__
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
 // I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
@@ -9067,6 +9068,7 @@
 // RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID20 %s
 // ANDROID20:#define __ANDROID_API__ 20
 // ANDROID20:#define __ANDROID__ 1
+// ANDROID-NOT:#define __gnu_linux__
 //
 // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix LANAI %s
 // LANAI: #define __lanai__ 1
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56456: [Driver] Default to -fno-addrsig on Android.

2019-01-08 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350668: [Driver] Default to -fno-addrsig on Android. 
(authored by danalbert, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56456

Files:
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/addrsig.c


Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -5292,6 +5292,7 @@
   !TC.getTriple().isPS4() &&
   !TC.getTriple().isOSNetBSD() &&
   !Distro(D.getVFS()).IsGentoo() &&
+  !TC.getTriple().isAndroid() &&
TC.useIntegratedAs()))
 CmdArgs.push_back("-faddrsig");
 
Index: cfe/trunk/test/Driver/addrsig.c
===
--- cfe/trunk/test/Driver/addrsig.c
+++ cfe/trunk/test/Driver/addrsig.c
@@ -8,6 +8,7 @@
 // RUN: %clang -### -target x86_64-unknown-linux -fno-addrsig -c %s 2>&1 | 
FileCheck -check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-apple-darwin -c %s 2>&1 | FileCheck 
-check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-scei-ps4 -c %s 2>&1 | FileCheck 
-check-prefix=NO-ADDRSIG %s
+// RUN: %clang -### -target x86_64-linux-android21 -c %s 2>&1 | FileCheck 
-check-prefix=NO-ADDRSIG %s
 
 // ADDRSIG: -faddrsig
 // NO-ADDRSIG-NOT: -faddrsig


Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -5292,6 +5292,7 @@
   !TC.getTriple().isPS4() &&
   !TC.getTriple().isOSNetBSD() &&
   !Distro(D.getVFS()).IsGentoo() &&
+  !TC.getTriple().isAndroid() &&
TC.useIntegratedAs()))
 CmdArgs.push_back("-faddrsig");
 
Index: cfe/trunk/test/Driver/addrsig.c
===
--- cfe/trunk/test/Driver/addrsig.c
+++ cfe/trunk/test/Driver/addrsig.c
@@ -8,6 +8,7 @@
 // RUN: %clang -### -target x86_64-unknown-linux -fno-addrsig -c %s 2>&1 | FileCheck -check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-apple-darwin -c %s 2>&1 | FileCheck -check-prefix=NO-ADDRSIG %s
 // RUN: %clang -### -target x86_64-scei-ps4 -c %s 2>&1 | FileCheck -check-prefix=NO-ADDRSIG %s
+// RUN: %clang -### -target x86_64-linux-android21 -c %s 2>&1 | FileCheck -check-prefix=NO-ADDRSIG %s
 
 // ADDRSIG: -faddrsig
 // NO-ADDRSIG-NOT: -faddrsig
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45597: [Driver] Android triples are not aliases for other triples.

2018-04-12 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added a reviewer: srhines.

Android targets should never use tools/libraries for non-Android
targets or vice versa.


Repository:
  rC Clang

https://reviews.llvm.org/D45597

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/android-ndk-standalone.cpp

Index: test/Driver/android-ndk-standalone.cpp
===
--- test/Driver/android-ndk-standalone.cpp
+++ test/Driver/android-ndk-standalone.cpp
@@ -352,3 +352,38 @@
 // CHECK-X86_64: "-L{{.*}}/lib/gcc/x86_64-linux-android/4.9"
 // CHECK-X86_64: "-L{{.*}}/lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/lib"
 // CHECK-X86_64: "-L{{.*}}/sysroot/usr/lib"
+
+// We need two sets of tests to verify that we both don't find non-Android
+// toolchains installations and that we *do* find Android toolchains. We can't
+// do both at the same time in this environment because we need to pass
+// --sysroot to find the toolchains which would override searching in /usr. In a
+// production environment --sysroot is not used and the toolchains are instead
+// found relative to the clang binary, so both would be considered.
+
+// RUN: %clang -v --target=i686-linux-android \
+// RUN: 2>&1 | FileCheck --check-prefix=CHECK-I686-GCC-NOSYS %s
+//
+// CHECK-I686-GCC-NOSYS-NOT: Found candidate GCC installation: /usr{{.*}}
+//
+// RUN: %clang -v --target=i686-linux-android \
+// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree \
+// RUN: 2>&1 | FileCheck --check-prefix=CHECK-I686-GCC %s
+//
+// CHECK-I686-GCC-NOT: Found candidate GCC installation: /usr{{.*}}
+// CHECK-I686-GCC: Found candidate GCC installation: {{.*}}i686-linux-android/4.9
+// CHECK-I686-GCC-NEXT: Found candidate GCC installation: {{.*}}x86_64-linux-android/4.9
+// CHECK-I686-GCC-NEXT: Selected GCC installation: {{.*}}i686-linux-android/4.9
+
+// RUN: %clang -v --target=x86_64-linux-android \
+// RUN: 2>&1 | FileCheck --check-prefix=CHECK-X86_64-GCC-NOSYS %s
+//
+// CHECK-X86_64-GCC-NOSYS-NOT: Found candidate GCC installation: /usr{{.*}}
+
+// RUN: %clang -v --target=x86_64-linux-android \
+// RUN: --sysroot=%S/Inputs/basic_android_ndk_tree \
+// RUN: 2>&1 | FileCheck --check-prefix=CHECK-X86_64-GCC %s
+//
+// CHECK-X86_64-GCC-NOT: Found candidate GCC installation: /usr{{.*}}
+// CHECK-X86_64-GCC: Found candidate GCC installation: {{.*}}i686-linux-android/4.9
+// CHECK-X86_64-GCC-NEXT: Found candidate GCC installation: {{.*}}x86_64-linux-android/4.9
+// CHECK-X86_64-GCC-NEXT: Selected GCC installation: {{.*}}x86_64-linux-android/4.9
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -1805,22 +1805,20 @@
   // lifetime or initialization issues.
   static const char *const AArch64LibDirs[] = {"/lib64", "/lib"};
   static const char *const AArch64Triples[] = {
-  "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-linux-android",
-  "aarch64-redhat-linux", "aarch64-suse-linux"};
+  "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux",
+  "aarch64-suse-linux"};
   static const char *const AArch64beLibDirs[] = {"/lib"};
   static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu",
  "aarch64_be-linux-gnu"};
 
   static const char *const ARMLibDirs[] = {"/lib"};
-  static const char *const ARMTriples[] = {"arm-linux-gnueabi",
-   "arm-linux-androideabi"};
+  static const char *const ARMTriples[] = {"arm-linux-gnueabi"};
   static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf",
  "armv7hl-redhat-linux-gnueabi",
  "armv6hl-suse-linux-gnueabi",
  "armv7hl-suse-linux-gnueabi"};
   static const char *const ARMebLibDirs[] = {"/lib"};
-  static const char *const ARMebTriples[] = {"armeb-linux-gnueabi",
- "armeb-linux-androideabi"};
+  static const char *const ARMebTriples[] = {"armeb-linux-gnueabi"};
   static const char *const ARMebHFTriples[] = {
   "armeb-linux-gnueabihf", "armebv7hl-redhat-linux-gnueabi"};
 
@@ -1830,16 +1828,14 @@
   "x86_64-pc-linux-gnu","x86_64-redhat-linux6E",
   "x86_64-redhat-linux","x86_64-suse-linux",
   "x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
-  "x86_64-slackware-linux", "x86_64-linux-android",
-  "x86_64-unknown-linux"};
+  "x86_64-slackware-linux", "x86_64-unknown-linux"};
   static const char *const X32LibDirs[] = {"/libx32"};
   static const char *const X86LibDirs[] = {"/lib32", "/lib"};
   static const char *const X86Triples[] = {
   "i686-linux-gnu",   "i686-pc-linux-gnu", "i486-linux-gnu",
   "i386-linux-gnu",   "i386-redhat-linux6E",   "i686-redhat-

[PATCH] D45290: [Driver] Use the per-API level Android library directories.

2018-04-17 Thread Dan Albert via Phabricator via cfe-commits
danalbert marked an inline comment as done.
danalbert added inline comments.



Comment at: lib/Driver/ToolChains/Linux.cpp:25
 #include "llvm/Support/Path.h"
+#include "llvm/Support/ScopedPrinter.h"
 #include 

eugenis wrote:
> I don't see why this include is necessary.
`llvm::to_string`


Repository:
  rC Clang

https://reviews.llvm.org/D45290



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


[PATCH] D45290: [Driver] Use the per-API level Android library directories.

2018-04-17 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL330213: [Driver] Use the per-API level Android library 
directories. (authored by danalbert, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D45290

Files:
  cfe/trunk/lib/Driver/ToolChains/Linux.cpp
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/aarch64-linux-android/21/crtbegin_dynamic.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/aarch64-linux-android/21/crtbegin_so.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/aarch64-linux-android/21/crtbegin_static.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/aarch64-linux-android/21/crtend_android.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/aarch64-linux-android/21/crtend_so.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/aarch64-linux-android/21/libc.so
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/aarch64-linux-android/21/libdl.so
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/aarch64-linux-android/21/libm.so
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/aarch64-linux-android/21/libstdc++.so
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/aarch64-linux-android/libc.a
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/aarch64-linux-android/libdl.a
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/aarch64-linux-android/libm.a
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/aarch64-linux-android/libstdc++.a
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/14/crtbegin_dynamic.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/14/crtbegin_so.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/14/crtbegin_static.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/14/crtend_android.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/14/crtend_so.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/14/libc.so
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/14/libdl.so
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/14/libm.so
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/14/libstdc++.so
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/21/crtbegin_dynamic.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/21/crtbegin_so.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/21/crtbegin_static.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/21/crtend_android.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/21/crtend_so.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/21/libc.so
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/21/libdl.so
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/21/libm.so
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/21/libstdc++.so
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/libc.a
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/libdl.a
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/libm.a
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/arm-linux-androideabi/libstdc++.a
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/crtbegin_dynamic.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/crtbegin_so.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/crtbegin_static.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/crtend_android.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/crtend_so.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/i686-linux-android/14/crtbegin_dynamic.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/i686-linux-android/14/crtbegin_so.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/i686-linux-android/14/crtbegin_static.o
  
cfe/trunk/test/Driver/Inputs/basic_android_ndk_tree/sysroot/usr/lib/i686-linux-android/14/crtend_android.o
  
cfe/trunk/te

[PATCH] D45292: [Driver] Obey computed sysroot when finding libc++ headers.

2018-04-17 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

Ping?


Repository:
  rC Clang

https://reviews.llvm.org/D45292



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


[PATCH] D45291: [Driver] Infer Android sysroot location.

2018-04-17 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

Ping?


Repository:
  rC Clang

https://reviews.llvm.org/D45291



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


[PATCH] D45291: [Driver] Infer Android sysroot location.

2018-04-23 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

Ping.


Repository:
  rC Clang

https://reviews.llvm.org/D45291



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


[PATCH] D45597: [Driver] Android triples are not aliases for other triples.

2018-04-23 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

Ping.


Repository:
  rC Clang

https://reviews.llvm.org/D45597



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


[PATCH] D45292: [Driver] Obey computed sysroot when finding libc++ headers.

2018-04-23 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

Ping.


Repository:
  rC Clang

https://reviews.llvm.org/D45292



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


[PATCH] D45597: [Driver] Android triples are not aliases for other triples.

2018-04-24 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC330770: [Driver] Android triples are not aliases for other 
triples. (authored by danalbert, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45597?vs=142281&id=143807#toc

Repository:
  rC Clang

https://reviews.llvm.org/D45597

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/android-ndk-standalone.cpp

Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -1816,22 +1816,20 @@
   // lifetime or initialization issues.
   static const char *const AArch64LibDirs[] = {"/lib64", "/lib"};
   static const char *const AArch64Triples[] = {
-  "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-linux-android",
-  "aarch64-redhat-linux", "aarch64-suse-linux"};
+  "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux",
+  "aarch64-suse-linux"};
   static const char *const AArch64beLibDirs[] = {"/lib"};
   static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu",
  "aarch64_be-linux-gnu"};
 
   static const char *const ARMLibDirs[] = {"/lib"};
-  static const char *const ARMTriples[] = {"arm-linux-gnueabi",
-   "arm-linux-androideabi"};
+  static const char *const ARMTriples[] = {"arm-linux-gnueabi"};
   static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf",
  "armv7hl-redhat-linux-gnueabi",
  "armv6hl-suse-linux-gnueabi",
  "armv7hl-suse-linux-gnueabi"};
   static const char *const ARMebLibDirs[] = {"/lib"};
-  static const char *const ARMebTriples[] = {"armeb-linux-gnueabi",
- "armeb-linux-androideabi"};
+  static const char *const ARMebTriples[] = {"armeb-linux-gnueabi"};
   static const char *const ARMebHFTriples[] = {
   "armeb-linux-gnueabihf", "armebv7hl-redhat-linux-gnueabi"};
 
@@ -1841,16 +1839,14 @@
   "x86_64-pc-linux-gnu","x86_64-redhat-linux6E",
   "x86_64-redhat-linux","x86_64-suse-linux",
   "x86_64-manbo-linux-gnu", "x86_64-linux-gnu",
-  "x86_64-slackware-linux", "x86_64-linux-android",
-  "x86_64-unknown-linux"};
+  "x86_64-slackware-linux", "x86_64-unknown-linux"};
   static const char *const X32LibDirs[] = {"/libx32"};
   static const char *const X86LibDirs[] = {"/lib32", "/lib"};
   static const char *const X86Triples[] = {
   "i686-linux-gnu",   "i686-pc-linux-gnu", "i486-linux-gnu",
   "i386-linux-gnu",   "i386-redhat-linux6E",   "i686-redhat-linux",
   "i586-redhat-linux","i386-redhat-linux", "i586-suse-linux",
-  "i486-slackware-linux", "i686-montavista-linux", "i686-linux-android",
-  "i586-linux-gnu"};
+  "i486-slackware-linux", "i686-montavista-linux", "i586-linux-gnu"};
 
   static const char *const MIPSLibDirs[] = {"/lib"};
   static const char *const MIPSTriples[] = {"mips-linux-gnu", "mips-mti-linux",
@@ -1869,13 +1865,6 @@
   "mips64el-linux-gnu", "mips-mti-linux-gnu", "mips-img-linux-gnu",
   "mips64el-linux-gnuabi64"};
 
-  static const char *const MIPSELAndroidLibDirs[] = {"/lib", "/libr2",
- "/libr6"};
-  static const char *const MIPSELAndroidTriples[] = {"mipsel-linux-android"};
-  static const char *const MIPS64ELAndroidLibDirs[] = {"/lib64", "/lib",
-   "/libr2", "/libr6"};
-  static const char *const MIPS64ELAndroidTriples[] = {
-  "mips64el-linux-android"};
 
   static const char *const PPCLibDirs[] = {"/lib32", "/lib"};
   static const char *const PPCTriples[] = {
@@ -1952,6 +1941,66 @@
 return;
   }
 
+  // Android targets should not use GNU/Linux tools or libraries.
+  if (TargetTriple.isAndroid()) {
+static const char *const AArch64AndroidTriples[] = {
+"aarch64-linux-android"};
+static const char *const ARMAndroidTriples[] = {"arm-linux-androideabi"};
+static const char *const MIPSELAndroidTriples[] = {"mipsel-linux-android"};
+static const char *const MIPS64ELAndroidTriples[] = {
+"mips64el-linux-android"};
+static const char *const X86AndroidTriples[] = {"i686-linux-android"};
+static const char *const X86_64AndroidTriples[] = {"x86_64-linux-android"};
+
+switch (TargetTriple.getArch()) {
+case llvm::Triple::aarch64:
+  LibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs));
+  TripleAliases.append(begin(AArch64AndroidTriples),
+   end(AArch64AndroidTriples));
+  break;
+case llvm::Triple::arm:
+case llvm::Triple::thumb:
+  LibDirs.append(begin(ARMLibDirs), end(ARMLibDirs));
+  TripleAliases.append(begin(ARMAndro

[PATCH] D45291: [Driver] Infer Android sysroot location.

2018-04-30 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

Ping.


Repository:
  rC Clang

https://reviews.llvm.org/D45291



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


[PATCH] D45292: [Driver] Obey computed sysroot when finding libc++ headers.

2018-04-30 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

Ping.


Repository:
  rC Clang

https://reviews.llvm.org/D45292



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


[PATCH] D45292: [Driver] Obey computed sysroot when finding libc++ headers.

2018-05-02 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC331389: [Driver] Obey computed sysroot when finding libc++ 
headers. (authored by danalbert, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45292?vs=141069&id=144915#toc

Repository:
  rC Clang

https://reviews.llvm.org/D45292

Files:
  lib/Driver/ToolChains/Linux.cpp


Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -793,13 +793,14 @@
 
 void Linux::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const {
+  const std::string& SysRoot = computeSysRoot();
   const std::string LibCXXIncludePathCandidates[] = {
   DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"),
   // If this is a development, non-installed, clang, libcxx will
   // not be found at ../include/c++ but it likely to be found at
   // one of the following two locations:
-  DetectLibcxxIncludePath(getDriver().SysRoot + "/usr/local/include/c++"),
-  DetectLibcxxIncludePath(getDriver().SysRoot + "/usr/include/c++") };
+  DetectLibcxxIncludePath(SysRoot + "/usr/local/include/c++"),
+  DetectLibcxxIncludePath(SysRoot + "/usr/include/c++") };
   for (const auto &IncludePath : LibCXXIncludePathCandidates) {
 if (IncludePath.empty() || !getVFS().exists(IncludePath))
   continue;


Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -793,13 +793,14 @@
 
 void Linux::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const {
+  const std::string& SysRoot = computeSysRoot();
   const std::string LibCXXIncludePathCandidates[] = {
   DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"),
   // If this is a development, non-installed, clang, libcxx will
   // not be found at ../include/c++ but it likely to be found at
   // one of the following two locations:
-  DetectLibcxxIncludePath(getDriver().SysRoot + "/usr/local/include/c++"),
-  DetectLibcxxIncludePath(getDriver().SysRoot + "/usr/include/c++") };
+  DetectLibcxxIncludePath(SysRoot + "/usr/local/include/c++"),
+  DetectLibcxxIncludePath(SysRoot + "/usr/include/c++") };
   for (const auto &IncludePath : LibCXXIncludePathCandidates) {
 if (IncludePath.empty() || !getVFS().exists(IncludePath))
   continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45291: [Driver] Infer Android sysroot location.

2018-05-02 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC331390: [Driver] Infer Android sysroot location. (authored 
by danalbert, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45291?vs=141067&id=144916#toc

Repository:
  rC Clang

https://reviews.llvm.org/D45291

Files:
  lib/Driver/ToolChains/Linux.cpp


Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -429,6 +429,15 @@
   if (!getDriver().SysRoot.empty())
 return getDriver().SysRoot;
 
+  if (getTriple().isAndroid()) {
+// Android toolchains typically include a sysroot at ../sysroot relative to
+// the clang binary.
+const StringRef ClangDir = getDriver().getInstalledDir();
+std::string AndroidSysRootPath = (ClangDir + "/../sysroot").str();
+if (getVFS().exists(AndroidSysRootPath))
+  return AndroidSysRootPath;
+  }
+
   if (!GCCInstallation.isValid() || !tools::isMipsArch(getTriple().getArch()))
 return std::string();
 


Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -429,6 +429,15 @@
   if (!getDriver().SysRoot.empty())
 return getDriver().SysRoot;
 
+  if (getTriple().isAndroid()) {
+// Android toolchains typically include a sysroot at ../sysroot relative to
+// the clang binary.
+const StringRef ClangDir = getDriver().getInstalledDir();
+std::string AndroidSysRootPath = (ClangDir + "/../sysroot").str();
+if (getVFS().exists(AndroidSysRootPath))
+  return AndroidSysRootPath;
+  }
+
   if (!GCCInstallation.isValid() || !tools::isMipsArch(getTriple().getArch()))
 return std::string();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56456: [Driver] Default to -fno-addrsig on Android.

2020-05-21 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

The NDK still supports linkers other than LLD, but we are changing the default 
to LLD in the next release. I'd prefer to keep this for the time being, but 
don't feel strongly about it.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D56456



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


[PATCH] D81622: [Clang] Search computed sysroot for libc++ header paths

2020-06-17 Thread Dan Albert via Phabricator via cfe-commits
danalbert accepted this revision.
danalbert added a comment.

In D81622#2094409 , @ldionne wrote:

> While this doesn't look wrong to me -- and the correctness of this depends 
> entirely on where vendors decide to put their headers so it's hard for me to 
> verify -- I'm wondering why not all toolchains use this mechanism. We seem to 
> be adding an abstraction that's used only by some toolchains, but not all. I 
> think it would be great to have a single canonical way of representing the 
> system root.


Yeah, I agree that the inconsistencies between vendors in the driver are pretty 
odd. I think essentially the way we got into this situation is that it's not 
always clear what the right way to do things is, and if it's not even clear 
that there even is an existing mechanism we can easily end up creating our own 
per vendor :(

I'd be interested in seeing if there are things we can do to try to unify the 
behavior in this area. I suspect it could be difficult given that it 
necessarily involves all of the different vendors, but maybe we could come up 
with one recommended way of doing all this and any of us that don't fit that 
model can make the change at a pace convenient for us?

> Commenting out of curiosity, don't let this block you.

Thanks for making that clear :) We're going to go ahead and submit since this 
does fix a regression but I'm open to making changes here if (hopefully 
//when//) we find some cleanup that can be done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81622



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


[PATCH] D76452: Use LLD by default for Android.

2020-04-16 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

@MaskRay Any other ideas, or should I submit this? Reviewing all our options:

1. Installing LLD as simply "ld"

Rejected: Causes LLD to act in mach-o mode for Darwin

2. `-DCLANG_DEFAULT_LINKER=lld`

Rejected: Our host Darwin toolchain still uses the system's linker, not LLD, 
and this would change that too (and as you said, the mach-o support in LLD 
isn't ready and is about to be replaces, so we can't do this for our production 
toolchain).

3. Using a wrapper script to set `-flavor gnu`

Rejected: Wrappers don't work well on Windows hosts.

4. Teach LLD that Linux targets are `-flavor gnu`, regardless of host.

LLD doesn't seem to differentiate between Android and non-Android Linux, so 
this change would affect non-Android Linux targets as well. Is that a problem? 
Do non-Android Linux targets linked from Windows, Darwin, or WebASM want the 
host driver modes the //target// driver modes?

5. This patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76452



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


[PATCH] D76452: Use LLD by default for Android.

2020-04-16 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

Option 4 was (at least on the surface) super easy: 
https://reviews.llvm.org/D78328. lmk if you'd prefer that approach. I'm 
slightly less confident in it since it affects non-Android platforms as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76452



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


[PATCH] D76452: Use LLD by default for Android.

2020-04-24 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

In D76452#2000812 , @nickdesaulniers 
wrote:

> Can we use `-DCLANG_DEFAULT_LINKER=lld` to configure AOSP's distribution of 
> LLD, then require the use of `-fuse-ld= that is currently used>` when targeting OSX host tools?


It'd work (and might be a good short term solution here until we can get 
feedback from @ruiu, and @int3) but I'm not sure I like the idea of breaking 
the default Darwin configuration much more than the default Android 
configuration. It's less commonly used by our toolchain, but it's definitely 
used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76452



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


[PATCH] D76452: Use LLD by default for Android.

2020-04-24 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

In D76452#2002620 , @int3 wrote:

> I don't think I have enough context here to answer the question, but I'm 
> pretty sure that change wouldn't affect what I'm working on


Sorry, wasn't referring to that question specifically, but the LLD one that 
@MaskRay CC'd you for a little further up.

> But hope @ruiu or @int3 can clarify that we can't get rid of the __APPLE__ 
> special case in:
> 
>   // lld/tools/lld/lld.cpp
>   static Flavor parseProgname(StringRef progname) {
>   #if __APPLE__
> // Use Darwin driver for "ld" on Darwin.
> if (progname == "ld")
>   return Darwin;
>   #endif
>   
>   #if LLVM_ON_UNIX
> // Use GNU driver for "ld" on other Unix-like system.
> if (progname == "ld")
>   return Gnu;
>   #endif


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76452



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


[PATCH] D76452: Use LLD by default for Android.

2020-04-24 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

In D76452#2002856 , @int3 wrote:

> Yes, I was referring to that question too :) I'm working on the new lld-macho 
> implementation, under the `DarwinNew` flavor. I'm not sure if anything 
> depends on the old `Darwin` flavor, which is why we haven't removed it yet, 
> though we plan to do that once we get the new implementation to a more mature 
> stage.


Ah, gotcha :) Thanks! Will wait for @ruiu to chime in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76452



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


[PATCH] D76452: Use LLD by default for Android.

2020-04-24 Thread Dan Albert via Phabricator via cfe-commits
danalbert abandoned this revision.
danalbert added a comment.

In D76452#2002917 , @MaskRay wrote:

> In D76452#2002875 , @danalbert wrote:
>
> > In D76452#2002856 , @int3 wrote:
> >
> > > Yes, I was referring to that question too :) I'm working on the new 
> > > lld-macho implementation, under the `DarwinNew` flavor. I'm not sure if 
> > > anything depends on the old `Darwin` flavor, which is why we haven't 
> > > removed it yet, though we plan to do that once we get the new 
> > > implementation to a more mature stage.
> >
> >
> > Ah, gotcha :) Thanks! Will wait for @ruiu to chime in.
>
>
> I vote for deleting the `#ifdef __APPLE__` chunk so we don't have to add more 
> code to either clang or lld
>  The code owner of the existing lld darwin has explicitly expressed that we 
> can drop the existing `Darwin` flavor at any time.


SGTM. Abandoning this. I'll send a patch to remove the LLD side shortly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76452



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


[PATCH] D76452: Use LLD by default for Android.

2020-04-24 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

In D76452#2002981 , @danalbert wrote:

> In D76452#2002917 , @MaskRay wrote:
>
> > In D76452#2002875 , @danalbert 
> > wrote:
> >
> > > In D76452#2002856 , @int3 wrote:
> > >
> > > > Yes, I was referring to that question too :) I'm working on the new 
> > > > lld-macho implementation, under the `DarwinNew` flavor. I'm not sure if 
> > > > anything depends on the old `Darwin` flavor, which is why we haven't 
> > > > removed it yet, though we plan to do that once we get the new 
> > > > implementation to a more mature stage.
> > >
> > >
> > > Ah, gotcha :) Thanks! Will wait for @ruiu to chime in.
> >
> >
> > I vote for deleting the `#ifdef __APPLE__` chunk so we don't have to add 
> > more code to either clang or lld
> >  The code owner of the existing lld darwin has explicitly expressed that we 
> > can drop the existing `Darwin` flavor at any time.
>
>
> SGTM. Abandoning this. I'll send a patch to remove the LLD side shortly.


https://reviews.llvm.org/D78837


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76452



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


[PATCH] D40743: Make rehash(0) work with ubsan's unsigned-integer-overflow.

2017-12-01 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.

Repository:
  rCXX libc++

https://reviews.llvm.org/D40743

Files:
  include/__hash_table


Index: include/__hash_table
===
--- include/__hash_table
+++ include/__hash_table
@@ -2136,7 +2136,7 @@
 void
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n)
 {
-if (__n == 1)
+if (__n < 2)
 __n = 2;
 else if (__n & (__n - 1))
 __n = __next_prime(__n);


Index: include/__hash_table
===
--- include/__hash_table
+++ include/__hash_table
@@ -2136,7 +2136,7 @@
 void
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n)
 {
-if (__n == 1)
+if (__n < 2)
 __n = 2;
 else if (__n & (__n - 1))
 __n = __next_prime(__n);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40743: Make rehash(0) work with ubsan's unsigned-integer-overflow.

2017-12-11 Thread Dan Albert via Phabricator via cfe-commits
danalbert added inline comments.



Comment at: include/__hash_table:2141
 __n = 2;
 else if (__n & (__n - 1))
 __n = __next_prime(__n);

With `rehash(0)` this is `0 & (0 - 1)`, which triggers 
unsigned-integer-overflow.


Repository:
  rCXX libc++

https://reviews.llvm.org/D40743



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


[PATCH] D67200: Add -static-openmp driver option

2019-09-05 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

Otherwise LGTM




Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:503
 bool tools::addOpenMPRuntime(ArgStringList &CmdArgs, const ToolChain &TC,
- const ArgList &Args, bool IsOffloadingHost,
- bool GompNeedsRT) {
+ const ArgList &Args, bool StaticHostRuntime,
+ bool IsOffloadingHost, bool GompNeedsRT) {

Maybe `ForceStaticHostRuntime`? For configurations where there is only a static 
runtime available, `StaticHostRuntime = false` won't actually link the dynamic 
runtime.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67200



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


[PATCH] D35739: Fix LLVMgold plugin name/path for non-Linux.

2017-08-14 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310895: Fix LLVMgold plugin name/path for non-Linux. 
(authored by danalbert).

Repository:
  rL LLVM

https://reviews.llvm.org/D35739

Files:
  cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp


Index: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
@@ -376,8 +376,20 @@
   // as gold requires -plugin to come before any -plugin-opt that -Wl might
   // forward.
   CmdArgs.push_back("-plugin");
-  std::string Plugin =
-  ToolChain.getDriver().Dir + "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold.so";
+
+#if defined(LLVM_ON_WIN32)
+  const char *Suffix = ".dll";
+#elif defined(__APPLE__)
+  const char *Suffix = ".dylib";
+#else
+  const char *Suffix = ".so";
+#endif
+
+  SmallString<1024> Plugin;
+  llvm::sys::path::native(Twine(ToolChain.getDriver().Dir) +
+  "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold" +
+  Suffix,
+  Plugin);
   CmdArgs.push_back(Args.MakeArgString(Plugin));
 
   // Try to pass driver level flags relevant to LTO code generation down to


Index: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
@@ -376,8 +376,20 @@
   // as gold requires -plugin to come before any -plugin-opt that -Wl might
   // forward.
   CmdArgs.push_back("-plugin");
-  std::string Plugin =
-  ToolChain.getDriver().Dir + "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold.so";
+
+#if defined(LLVM_ON_WIN32)
+  const char *Suffix = ".dll";
+#elif defined(__APPLE__)
+  const char *Suffix = ".dylib";
+#else
+  const char *Suffix = ".so";
+#endif
+
+  SmallString<1024> Plugin;
+  llvm::sys::path::native(Twine(ToolChain.getDriver().Dir) +
+  "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold" +
+  Suffix,
+  Plugin);
   CmdArgs.push_back(Args.MakeArgString(Plugin));
 
   // Try to pass driver level flags relevant to LTO code generation down to
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36769: Revert "Revert "Fix LLVMgold plugin name/path for non-Linux.""

2017-08-15 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
Herald added subscribers: eraman, mehdi_amini, emaste.

Relanding https://reviews.llvm.org/D35739 which was reverted because
it broke the tests on non-Linux. The tests have been fixed to be
platform agnostic, and additional tests have been added to make sure
that the plugin has the correct extension on each platform
(%pluginext doesn't work in CHECK lines).


https://reviews.llvm.org/D36769

Files:
  lib/Driver/ToolChains/CommonArgs.cpp
  test/Driver/freebsd.c
  test/Driver/gold-lto.c
  test/Driver/lto-plugin-darwin.c
  test/Driver/lto-plugin-linux.c
  test/Driver/lto-plugin-windows.c
  test/Driver/lto.c
  test/Driver/thinlto.c

Index: test/Driver/thinlto.c
===
--- test/Driver/thinlto.c
+++ test/Driver/thinlto.c
@@ -19,19 +19,19 @@
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=full -fno-lto -flto=thin 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-THIN-ACTION < %t %s
 //
-// CHECK-LINK-THIN-ACTION: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-THIN-ACTION: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 // CHECK-LINK-THIN-ACTION: "-plugin-opt=thinlto"
 
 // Check that subsequent -flto=full takes precedence
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -flto=full 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-FULL-ACTION < %t %s
 //
-// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 // CHECK-LINK-FULL-ACTION-NOT: "-plugin-opt=thinlto"
 
 // Check that subsequent -fno-lto takes precedence
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin -fno-lto 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s
 //
-// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 // CHECK-LINK-NOLTO-ACTION-NOT: "-plugin-opt=thinlto"
Index: test/Driver/lto.c
===
--- test/Driver/lto.c
+++ test/Driver/lto.c
@@ -36,19 +36,19 @@
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-LTO-ACTION < %t %s
 //
-// CHECK-LINK-LTO-ACTION: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-LTO-ACTION: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 
 // -flto=full should cause link using gold plugin
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=full 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-FULL-ACTION < %t %s
 //
-// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-FULL-ACTION: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 
 // Check that subsequent -fno-lto takes precedence
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=full -fno-lto 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-NOLTO-ACTION < %t %s
 //
-// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-LINK-NOLTO-ACTION-NOT: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 
 // -flto passes along an explicit debugger tuning argument.
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto -glldb 2> %t
Index: test/Driver/lto-plugin-windows.c
===
--- /dev/null
+++ test/Driver/lto-plugin-windows.c
@@ -0,0 +1,6 @@
+// Check that Windows uses LLVMgold.dll.
+// REQUIRES: system-windows
+// RUN: %clang -### %s -flto 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
+//
+// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.dll"
Index: test/Driver/lto-plugin-linux.c
===
--- /dev/null
+++ test/Driver/lto-plugin-linux.c
@@ -0,0 +1,6 @@
+// Check that non-Windows, non-Darwin OSs use LLVMgold.so.
+// REQUIRES: !system-darwin && !system-windows
+// RUN: %clang -### %s -flto 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
+//
+// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.so"
Index: test/Driver/lto-plugin-darwin.c
===
--- /dev/null
+++ test/Driver/lto-plugin-darwin.c
@@ -0,0 +1,6 @@
+// Check that Darwin uses LLVMgold.dylib.
+// REQUIRES: system-darwin
+// RUN: %clang -### %s -flto 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
+//
+// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.dylib"
Index: test/Driver/gold-lto.c
===
--- test/Driver/gold-lto.c
+++ test/Driver/gold-lto.c
@@ -3,26 +3,26 @@
 // RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
 // RUN: -Wl,-plugin-opt=foo -O3 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-64-BASIC
-// CHECK-X86-64-BASIC: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-X86-64-BASIC: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 // CHECK-X86-64-BASIC: "-plugin-opt=O3"
 // CHECK-X86-64-BASIC: "-plugin-opt=foo"
 //
 // RUN: %clang -target x86_64-un

[PATCH] D36769: Revert "Revert "Fix LLVMgold plugin name/path for non-Linux.""

2017-08-15 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310960: Revert "Revert "Fix LLVMgold plugin name/path for 
non-Linux."" (authored by danalbert).

Repository:
  rL LLVM

https://reviews.llvm.org/D36769

Files:
  cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
  cfe/trunk/test/Driver/freebsd.c
  cfe/trunk/test/Driver/gold-lto.c
  cfe/trunk/test/Driver/lto-plugin-darwin.c
  cfe/trunk/test/Driver/lto-plugin-linux.c
  cfe/trunk/test/Driver/lto-plugin-windows.c
  cfe/trunk/test/Driver/lto.c
  cfe/trunk/test/Driver/thinlto.c

Index: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
@@ -376,8 +376,20 @@
   // as gold requires -plugin to come before any -plugin-opt that -Wl might
   // forward.
   CmdArgs.push_back("-plugin");
-  std::string Plugin =
-  ToolChain.getDriver().Dir + "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold.so";
+
+#if defined(LLVM_ON_WIN32)
+  const char *Suffix = ".dll";
+#elif defined(__APPLE__)
+  const char *Suffix = ".dylib";
+#else
+  const char *Suffix = ".so";
+#endif
+
+  SmallString<1024> Plugin;
+  llvm::sys::path::native(Twine(ToolChain.getDriver().Dir) +
+  "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold" +
+  Suffix,
+  Plugin);
   CmdArgs.push_back(Args.MakeArgString(Plugin));
 
   // Try to pass driver level flags relevant to LTO code generation down to
Index: cfe/trunk/test/Driver/lto-plugin-windows.c
===
--- cfe/trunk/test/Driver/lto-plugin-windows.c
+++ cfe/trunk/test/Driver/lto-plugin-windows.c
@@ -0,0 +1,6 @@
+// Check that Windows uses LLVMgold.dll.
+// REQUIRES: system-windows
+// RUN: %clang -### %s -flto 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
+//
+// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.dll"
Index: cfe/trunk/test/Driver/lto-plugin-linux.c
===
--- cfe/trunk/test/Driver/lto-plugin-linux.c
+++ cfe/trunk/test/Driver/lto-plugin-linux.c
@@ -0,0 +1,6 @@
+// Check that non-Windows, non-Darwin OSs use LLVMgold.so.
+// REQUIRES: !system-darwin && !system-windows
+// RUN: %clang -### %s -flto 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
+//
+// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.so"
Index: cfe/trunk/test/Driver/lto-plugin-darwin.c
===
--- cfe/trunk/test/Driver/lto-plugin-darwin.c
+++ cfe/trunk/test/Driver/lto-plugin-darwin.c
@@ -0,0 +1,6 @@
+// Check that Darwin uses LLVMgold.dylib.
+// REQUIRES: system-darwin
+// RUN: %clang -### %s -flto 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LTO-PLUGIN %s
+//
+// CHECK-LTO-PLUGIN: "-plugin" "{{.*}}/LLVMgold.dylib"
Index: cfe/trunk/test/Driver/gold-lto.c
===
--- cfe/trunk/test/Driver/gold-lto.c
+++ cfe/trunk/test/Driver/gold-lto.c
@@ -3,26 +3,26 @@
 // RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
 // RUN: -Wl,-plugin-opt=foo -O3 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-64-BASIC
-// CHECK-X86-64-BASIC: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-X86-64-BASIC: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 // CHECK-X86-64-BASIC: "-plugin-opt=O3"
 // CHECK-X86-64-BASIC: "-plugin-opt=foo"
 //
 // RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
 // RUN: -march=corei7 -Wl,-plugin-opt=foo -Ofast \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-64-COREI7
-// CHECK-X86-64-COREI7: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-X86-64-COREI7: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 // CHECK-X86-64-COREI7: "-plugin-opt=mcpu=corei7"
 // CHECK-X86-64-COREI7: "-plugin-opt=O3"
 // CHECK-X86-64-COREI7: "-plugin-opt=foo"
 //
 // RUN: %clang -target arm-unknown-linux -### %t.o -flto 2>&1 \
 // RUN: -march=armv7a -Wl,-plugin-opt=foo -O0 \
 // RUN: | FileCheck %s --check-prefix=CHECK-ARM-V7A
-// CHECK-ARM-V7A: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-ARM-V7A: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
 // CHECK-ARM-V7A: "-plugin-opt=mcpu=generic"
 // CHECK-ARM-V7A: "-plugin-opt=O0"
 // CHECK-ARM-V7A: "-plugin-opt=foo"
 //
 // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-ANDROID
-// CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.so"
+// CHECK-X86-ANDROID: "-plugin" "{{.*}}/LLVMgold.{{dll|dylib|so}}"
Index: cfe/trunk/test/Driver/thinlto.c
===
--- cfe/trunk/test/Driver/thinlto.c
+++ cfe/trunk/test/Driver/thinlto.c
@@ -19,19 +19,19 @@
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=full -fno-lto -flto=thin 2> %t
 // RUN: FileCheck -check-prefix=CHECK-LINK-THIN-A

[PATCH] D71848: Allow the discovery of Android NDK's triple-prefixed binaries.

2020-01-06 Thread Dan Albert via Phabricator via cfe-commits
danalbert accepted this revision.
danalbert added a comment.
This revision is now accepted and ready to land.

Just to clarify, this is needed for the triple-prefixed tools, but the 
triple-specific directory worked fine before this patch? If I'm understanding 
that correctly then LGTM, otherwise I'm confused as to why I haven't seen this 
problem before.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71848



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


[PATCH] D91664: Add a less ambiguous macro for Android version.

2020-12-14 Thread Dan Albert via Phabricator via cfe-commits
danalbert closed this revision.
danalbert added a comment.

https://github.com/llvm/llvm-project/commit/0849047860a343d8bcf1f828a82d585e89079943


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91664

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


[PATCH] D91664: Add a less ambiguous macro for Android version.

2020-11-17 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added reviewers: enh, srhines, jiyong.
Herald added a project: clang.
danalbert requested review of this revision.

Android has a handful of API levels relevant to developers described
here: https://developer.android.com/studio/build#module-level.
`__ANDROID_API__` is too vague and confuses a lot of people. Introduce
a new macro name that is explicit about which one it represents. Keep
the old name around because code has been using it for a decade.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91664

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/test/Preprocessor/init.c


Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -1580,6 +1580,7 @@
 //
 // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID %s
 // ANDROID-NOT:#define __ANDROID_API__
+// ANDROID-NOT:#define __ANDROID_MIN_SDK_VERSION__
 // ANDROID:#define __ANDROID__ 1
 // ANDROID-NOT:#define __gnu_linux__
 //
@@ -1590,7 +1591,8 @@
 // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
 //
 // RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix ANDROID20 %s
-// ANDROID20:#define __ANDROID_API__ 20
+// ANDROID20:#define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
+// ANDROID20:#define __ANDROID_MIN_SDK_VERSION__ 20
 // ANDROID20:#define __ANDROID__ 1
 // ANDROID-NOT:#define __gnu_linux__
 //
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -383,8 +383,12 @@
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
-  if (Maj)
-Builder.defineMacro("__ANDROID_API__", Twine(Maj));
+  if (Maj) {
+Builder.defineMacro("__ANDROID_MIN_SDK_VERSION__", Twine(Maj));
+// This historical but ambiguous name for the minSdkVersion macro. Keep
+// defined for compatibility.
+Builder.defineMacro("__ANDROID_API__", "__ANDROID_MIN_SDK_VERSION__");
+  }
 } else {
 Builder.defineMacro("__gnu_linux__");
 }


Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -1580,6 +1580,7 @@
 //
 // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID %s
 // ANDROID-NOT:#define __ANDROID_API__
+// ANDROID-NOT:#define __ANDROID_MIN_SDK_VERSION__
 // ANDROID:#define __ANDROID__ 1
 // ANDROID-NOT:#define __gnu_linux__
 //
@@ -1590,7 +1591,8 @@
 // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
 //
 // RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID20 %s
-// ANDROID20:#define __ANDROID_API__ 20
+// ANDROID20:#define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__
+// ANDROID20:#define __ANDROID_MIN_SDK_VERSION__ 20
 // ANDROID20:#define __ANDROID__ 1
 // ANDROID-NOT:#define __gnu_linux__
 //
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -383,8 +383,12 @@
   Triple.getEnvironmentVersion(Maj, Min, Rev);
   this->PlatformName = "android";
   this->PlatformMinVersion = VersionTuple(Maj, Min, Rev);
-  if (Maj)
-Builder.defineMacro("__ANDROID_API__", Twine(Maj));
+  if (Maj) {
+Builder.defineMacro("__ANDROID_MIN_SDK_VERSION__", Twine(Maj));
+// This historical but ambiguous name for the minSdkVersion macro. Keep
+// defined for compatibility.
+Builder.defineMacro("__ANDROID_API__", "__ANDROID_MIN_SDK_VERSION__");
+  }
 } else {
 Builder.defineMacro("__gnu_linux__");
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95166: Disable rosegment for old Android versions.

2021-01-21 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added a reviewer: srhines.
danalbert added a project: clang.
danalbert requested review of this revision.

The unwinder used by the crash handler on versions of Android prior to
API 29 did not correctly handle binaries built with rosegment, which is
enabled by default for LLD. Android only supports LLD, so it's not an
issue that this flag is not accepted by other linkers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95166

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/linux-ld.c


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1089,6 +1089,20 @@
 // CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu"
 
+// Check that we pass --no-rosegment for pre-29 Android versions and do not for
+// 29+.
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android28 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-ROSEGMENT-28 %s
+// CHECK-ANDROID-ROSEGMENT-28: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-ROSEGMENT-28: "--no-rosegment"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android29 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-ROSEGMENT-29 %s
+// CHECK-ANDROID-ROSEGMENT-29: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-ROSEGMENT-29-NOT: "--no-rosegment"
+
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN: --target=armv7-linux-android21 \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-NOEXECSTACK %s
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -236,6 +236,15 @@
 ExtraOpts.push_back("relro");
   }
 
+  if (Triple.isAndroid() && Triple.isAndroidVersionLT(29)) {
+// https://github.com/android/ndk/issues/1196
+// The unwinder used by the crash handler on versions of Android prior to
+// API 29 did not correctly handle binaries built with rosegment, which is
+// enabled by default for LLD. Android only supports LLD, so it's not an
+// issue that this flag is not accepted by other linkers.
+ExtraOpts.push_back("--no-rosegment");
+  }
+
   // Android ARM/AArch64 use max-page-size=4096 to reduce VMA usage. Note, lld
   // from 11 onwards default max-page-size to 65536 for both ARM and AArch64.
   if ((Triple.isARM() || Triple.isAArch64()) && Triple.isAndroid()) {


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1089,6 +1089,20 @@
 // CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu"
 
+// Check that we pass --no-rosegment for pre-29 Android versions and do not for
+// 29+.
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android28 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-ROSEGMENT-28 %s
+// CHECK-ANDROID-ROSEGMENT-28: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-ROSEGMENT-28: "--no-rosegment"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android29 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-ROSEGMENT-29 %s
+// CHECK-ANDROID-ROSEGMENT-29: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-ROSEGMENT-29-NOT: "--no-rosegment"
+
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN: --target=armv7-linux-android21 \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-NOEXECSTACK %s
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -236,6 +236,15 @@
 ExtraOpts.push_back("relro");
   }
 
+  if (Triple.isAndroid() && Triple.isAndroidVersionLT(29)) {
+// https://github.com/android/ndk/issues/1196
+// The unwinder used by the crash handler on versions of Android prior to
+// API 29 did not correctly handle binaries built with rosegment, which is
+// enabled by default for LLD. Android only supports LLD, so it's not an
+// issue that this flag is not accepted by other linkers.
+ExtraOpts.push_back("--no-rosegment");
+  }
+
   // Android ARM/AArch64 use max-page-size=4096 to reduce VMA usage. Note, lld
   // from 11 onwards default max-page-size to 65536 for both ARM and AArch64.
   if ((Triple.isARM() || Triple.isAArch64()) && Triple.isAndroid()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95166: Disable rosegment for old Android versions.

2021-01-26 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfae16fc0eed7: Disable rosegment for old Android versions. 
(authored by danalbert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95166

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/linux-ld.c


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1089,6 +1089,20 @@
 // CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu"
 
+// Check that we pass --no-rosegment for pre-29 Android versions and do not for
+// 29+.
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android28 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-ROSEGMENT-28 %s
+// CHECK-ANDROID-ROSEGMENT-28: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-ROSEGMENT-28: "--no-rosegment"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android29 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-ROSEGMENT-29 %s
+// CHECK-ANDROID-ROSEGMENT-29: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-ROSEGMENT-29-NOT: "--no-rosegment"
+
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN: --target=armv7-linux-android21 \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-NOEXECSTACK %s
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -236,6 +236,15 @@
 ExtraOpts.push_back("relro");
   }
 
+  if (Triple.isAndroid() && Triple.isAndroidVersionLT(29)) {
+// https://github.com/android/ndk/issues/1196
+// The unwinder used by the crash handler on versions of Android prior to
+// API 29 did not correctly handle binaries built with rosegment, which is
+// enabled by default for LLD. Android only supports LLD, so it's not an
+// issue that this flag is not accepted by other linkers.
+ExtraOpts.push_back("--no-rosegment");
+  }
+
   // Android ARM/AArch64 use max-page-size=4096 to reduce VMA usage. Note, lld
   // from 11 onwards default max-page-size to 65536 for both ARM and AArch64.
   if ((Triple.isARM() || Triple.isAArch64()) && Triple.isAndroid()) {


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1089,6 +1089,20 @@
 // CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu"
 
+// Check that we pass --no-rosegment for pre-29 Android versions and do not for
+// 29+.
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android28 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-ROSEGMENT-28 %s
+// CHECK-ANDROID-ROSEGMENT-28: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-ROSEGMENT-28: "--no-rosegment"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android29 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-ROSEGMENT-29 %s
+// CHECK-ANDROID-ROSEGMENT-29: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-ROSEGMENT-29-NOT: "--no-rosegment"
+
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN: --target=armv7-linux-android21 \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-NOEXECSTACK %s
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -236,6 +236,15 @@
 ExtraOpts.push_back("relro");
   }
 
+  if (Triple.isAndroid() && Triple.isAndroidVersionLT(29)) {
+// https://github.com/android/ndk/issues/1196
+// The unwinder used by the crash handler on versions of Android prior to
+// API 29 did not correctly handle binaries built with rosegment, which is
+// enabled by default for LLD. Android only supports LLD, so it's not an
+// issue that this flag is not accepted by other linkers.
+ExtraOpts.push_back("--no-rosegment");
+  }
+
   // Android ARM/AArch64 use max-page-size=4096 to reduce VMA usage. Note, lld
   // from 11 onwards default max-page-size to 65536 for both ARM and AArch64.
   if ((Triple.isARM() || Triple.isAArch64()) && Triple.isAndroid()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95492: Pack relocations for Android when possible.

2021-01-26 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added reviewers: rprichard, srhines, rahulchaudhry.
danalbert added a project: clang.
danalbert requested review of this revision.

First supported by API 28.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95492

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/linux-ld.c


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1103,6 +1103,22 @@
 // CHECK-ANDROID-ROSEGMENT-29: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ANDROID-ROSEGMENT-29-NOT: "--no-rosegment"
 
+// Check that we pass --pack-dyn-relocs=relr for API 28+ and not before.
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android27 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-RELR-27 %s
+// CHECK-ANDROID-RELR-27: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-RELR-27-NOT: "--pack-dyn-relocs=relr"
+// CHECK-ANDROID-RELR-27-NOT: "--pack-dyn-relocs=android+relr"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android28 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-RELR-28 %s
+// CHECK-ANDROID-RELR-28: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-RELR-28: "--use-android-relr-tags"
+// CHECK-ANDROID-RELR-28: "--pack-dyn-relocs=relr"
+// CHECK-ANDROID-RELR-28-NOT: "--pack-dyn-relocs=android+relr"
+
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN: --target=armv7-linux-android21 \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-NOEXECSTACK %s
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -245,6 +245,17 @@
 ExtraOpts.push_back("--no-rosegment");
   }
 
+  if (Triple.isAndroid() && !Triple.isAndroidVersionLT(28)) {
+// Android supports relr packing starting with API 28 and had its own 
flavor
+// (--pack-dyn-relocs=android) starting in API 23. It's possible to use 
both
+// with --pack-dyn-relocs=android+relr, but we need to gather some data on
+// the impact of that form before we can know if it's a good default.
+//
+// On the other hand, relr should always be an improvement.
+ExtraOpts.push_back("--use-android-relr-tags");
+ExtraOpts.push_back("--pack-dyn-relocs=relr");
+  }
+
   // Android ARM/AArch64 use max-page-size=4096 to reduce VMA usage. Note, lld
   // from 11 onwards default max-page-size to 65536 for both ARM and AArch64.
   if ((Triple.isARM() || Triple.isAArch64()) && Triple.isAndroid()) {


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1103,6 +1103,22 @@
 // CHECK-ANDROID-ROSEGMENT-29: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ANDROID-ROSEGMENT-29-NOT: "--no-rosegment"
 
+// Check that we pass --pack-dyn-relocs=relr for API 28+ and not before.
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android27 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-RELR-27 %s
+// CHECK-ANDROID-RELR-27: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-RELR-27-NOT: "--pack-dyn-relocs=relr"
+// CHECK-ANDROID-RELR-27-NOT: "--pack-dyn-relocs=android+relr"
+//
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN: --target=armv7-linux-android28 \
+// RUN:   | FileCheck --check-prefix=CHECK-ANDROID-RELR-28 %s
+// CHECK-ANDROID-RELR-28: "{{.*}}ld{{(.exe)?}}"
+// CHECK-ANDROID-RELR-28: "--use-android-relr-tags"
+// CHECK-ANDROID-RELR-28: "--pack-dyn-relocs=relr"
+// CHECK-ANDROID-RELR-28-NOT: "--pack-dyn-relocs=android+relr"
+
 // RUN: %clang %s -### -o %t.o 2>&1 \
 // RUN: --target=armv7-linux-android21 \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID-NOEXECSTACK %s
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -245,6 +245,17 @@
 ExtraOpts.push_back("--no-rosegment");
   }
 
+  if (Triple.isAndroid() && !Triple.isAndroidVersionLT(28)) {
+// Android supports relr packing starting with API 28 and had its own flavor
+// (--pack-dyn-relocs=android) starting in API 23. It's possible to use both
+// with --pack-dyn-relocs=android+relr, but we need to gather some data on
+// the impact of that form before we can know if it's a good default.
+//
+// On the other hand, relr should always be an improvement.
+ExtraOpts.push_back("--use-android-relr-tags");
+ExtraOpts.push_back("--pack-dyn-relocs=relr");
+  }
+
   // Android ARM/AArch64 use max-page-size=4096 to reduce VMA usage. Note, lld
   // from 11 onwards default max-page-size to 65536 for both ARM and AArch64.
   if ((Triple.isARM() || Triple.isAArch64()) && Triple.isAndroid()) {
___
cfe-commits mailing list

[PATCH] D95166: Disable rosegment for old Android versions.

2021-01-27 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

In D95166#2525131 , @dmajor wrote:

> Firefox has a build break from this change. In certain Android configurations 
> we use bfd or gold. The statement in the commit message "Android only 
> supports LLD" is news to me, could you point me to any references for this?

https://github.com/android/ndk/wiki/Changelog-r22

> GNU binutils is deprecated and will be removed in an upcoming NDK release.

TOT LLVM is the source for the //next// version of the NDK's compiler, which 
does remove support for bfd and gold: 
https://android.googlesource.com/platform/ndk/+/master/docs/changelogs/Changelog-r23.md


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95166

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


[PATCH] D95166: Disable rosegment for old Android versions.

2021-01-28 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

In D95166#2527437 , @vitalybuka wrote:

> Our Android build bot is broken after this patch 
> http://lab.llvm.org:8011/#/builders/77/builds/3234

Shouldn't that build be using lld?

In D95166#2526839 , @glandium wrote:

> "Android only supports lld" might be true now, but it hasn't always been 
> true, which means the change is not backwards compatible with versions of the 
> NDK that don't use lld.

If I'm understanding correctly, Firefox is building a custom toolchain for use 
with the NDK sysroot? That works as long as you're building the whole toolchain 
(though we can't guarantee that even that will work out of the box, because 
these things are developed in tandem and other configurations are not tested), 
but you'll need to build lld, llvm-ar, etc and use those as well.

> Also, `-fuse-ld` is still a valid flag that can allow to use a different 
> linker than lld.

We could check `-fuse-ld` for something other than `ld` or `lld` and not pass 
these flags in those cases. Would that be suitable? I see Clang did recently 
gain a `LinkerIsLLD` out param for `Toolchain::GetLinkerPath`. It's wrong for 
Android toolchains (because it assumes `ld` is not `lld`), but we could fix 
that. It'd be wrong whenever someone is using any toolchain other than the 
default NDK configuration (which would include Firefox), but at least it'd work 
for the common case.

A better solution IMO would be to let each target have its own default linker. 
We currently have this at the OS level, but that means that Android and GNU 
systems are assumed to have the same default linker. That's false. I'd tried 
fixing this with https://reviews.llvm.org/D76452 but the patch was not 
accepted. I'd be happy to revive and submit that if folks agree that it is the 
better choice.

Though TBH my favorite solution is still to make it clear that Android no 
longer supports anything but lld and skip all the special cases that will never 
get tested in practice. gold and bfd just barely worked for Android even when 
they were our defaults. One of the other fixes I suggest might fix your build 
today, but it's doubtful to me that it'd help you for long.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95166

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


[PATCH] D95166: Disable rosegment for old Android versions.

2021-01-28 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

In D95166#2529412 , @dmajor wrote:

> It does feel kind of awkward to me that _this_ is the patch that ends up 
> breaking the builds, versus something at the cmake level that says "you are 
> explicitly unsupported".

If you're using our CMake toolchain file you're automatically migrated to LLD 
unless you pass `-DANDROID_LD=deprecated` starting with NDK r22. If you're not 
using our toolchain file there unfortunately was no way for us to have any kind 
of input to that process.

r22 is fairly new, but this patch isn't expected to be in a stable NDK until 
several months from now. It takes us quite a while to move from a patch being 
submitted to clang to being shipped in a stable NDK, so that's why we're doing 
this now. We do try pretty hard to adhere to a deprecation window so people 
have time to adapt, but we're now working on Clang features that are beyond the 
end of the window (features we'd have preferred to land last summer, but didn't 
specifically to avoid breaking binutils compatibility). Clang is the //last// 
place that migration changes land, so using TOT clang but an older NDK means 
you started getting incompatible features before you got any of the warnings 
from the tools.

> Also it's unfortunate that this landed just hours before 12.0.0 branched. Had 
> it landed slightly later, release users could have six months to plan for the 
> change. You say that the next NDK compiler is based on ToT, in that case 
> would it make sense to revert this on the 12.x branch, and add a warning to 
> the 12.0.0 release notes that lld will be assumed in 13?

Would have waited if I'd known :( No objection to reverting in the 12.x release 
branch. We don't ship from the release branches anyway so reverting in 12.x 
keeps your next release the way you want it keeps ours the way we want it. Feel 
free to do that, or I can do it tomorrow.

FWIW, we gave //much// more than six months notice that Android was dropping 
support for binutils: https://github.com/android/ndk/wiki/Changelog-r19-beta1. 
We did even communicate it specifically to Firefox, I believe: 
https://github.com/android/ndk/issues/1063.

In D95166#2529432 , @glandium wrote:

> If clang _really_ wants to assume lld as the linker for android, then it 
> should make using -fuse-ld=somethingelse an error and invoke ld.lld rather 
> than ld, if it doesn't already do that.

The other patch I linked  does the second part 
of that and would make it possible to continue working with gold/bfd (even if 
Android has no intention to support that workflow). I'll rebase that and 
restore the review to try again. I'd also much prefer to be able to do this in 
a way that doesn't so forcibly break compatibility but that wasn't an option 
without that patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95166

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


[PATCH] D95166: Disable rosegment for old Android versions.

2021-01-29 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

In D95166#2530791 , @thakis wrote:

> Landed revert in 1608ba09462d877111230e9461b895f696f8fcb1 
> . 
> Someone should file a PR to make sure that gets merged to the 12.0 branch.
>
> We can then reland on trunk once there are clear instructions for folks 
> building with trunk clang but old NDK but without the toolchain file (either 
> "use toolchain file" or "set LLVM_USE_LLD" or something like that, I'm 
> guessing?)

The instructions would be "use the whole toolchain, don't mix and match". Where 
should that be documented?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95166

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


[PATCH] D95166: Disable rosegment for old Android versions.

2021-02-03 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

> We've since added -fuse-ld=lld to the three CMAKE_*_FLAGS so I think we're 
> likely set on our end.

https://reviews.llvm.org/D76452 not being accepted means that Android 
toolchains must have LLD installed as `ld`. I'm guessing this thread has shown 
that the patch is worth doing so I can fix this in a more compatible way.

> If there's some way to build android compiler-rt runtimes as part of a 
> regular linux llvm build, we'd love to learn about that :)

afaik CMake makes this impossible because one build has exactly one target :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95166

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


[PATCH] D95166: Disable rosegment for old Android versions.

2021-02-03 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

In D95166#2540705 , @thakis wrote:

> In D95166#2540399 , @danalbert wrote:
>
>>> We've since added -fuse-ld=lld to the three CMAKE_*_FLAGS so I think we're 
>>> likely set on our end.
>>
>> https://reviews.llvm.org/D76452 not being accepted means that Android 
>> toolchains must have LLD installed as `ld`.
>
> If you pass `-fuse-ld=lld` everwhere, that's not needed, right (?)

Yes, but the defaults should work for the NDK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95166

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


[PATCH] D93003: [libunwind] unw_* alias fixes for ELF and Mach-O

2021-02-19 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

It sounds like everyone is happy here but the tools. Could we get a libunwind 
reviewer (preferably @compnerd, since his review is the red one) to LGTM this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93003

___
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 Dan Albert via Phabricator via cfe-commits
danalbert added inline comments.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:1911
+  SmallVector Prefixes;
+  if (TargetTriple.isAndroid())
+Prefixes.assign(D.PrefixDirs.begin(), D.PrefixDirs.end());

I'm not entirely sure what `D.PrefixDirs` represents so maybe Android doesn't 
need this either.

The behavior the NDK depends on is being able to find tools co-located with the 
Clang driver location. Aside from `as`, these are all LLVM tools (lld and co).

The sysroot is expected to be in `$CLANG/../sysroot`. All our headers, 
libraries (aside from libgcc/libatomic), and CRT objects are located there.

The clang driver install location is expected to also be a GCC install 
directory, so libgcc/libatomic are expected at 
`$CLANG/../lib/gcc/$TRIPLE/$GCC_VERSION`.

Typical usage for the NDK does not involve `-gcc-toolchain` or `-B` at all.

If I've understood correctly, your change can be applied to Android as well 
without breaking any of those behaviors. @srhines will need to comment on 
whether the Android platform build needs this, but aiui anyone depending on 
this behavior just needs to fix their build to use `-gcc-toolchain` where they 
were previously using `-B`.

Of course, I can't speak to what our users with custom build systems that don't 
follow our docs might be doing.


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] D113840: [Driver][Android] Remove unneeded isNoExecStackDefault

2021-11-17 Thread Dan Albert via Phabricator via cfe-commits
danalbert accepted this revision.
danalbert added a comment.
This revision is now accepted and ready to land.

Fine by me if this is the default for LLD.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113840

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


[PATCH] D114163: Use VersionTuple for parsing versions in Triple. This makes it possible to distinguish between "16" and "16.0" after parsing, which previously was not possible.

2021-11-19 Thread Dan Albert via Phabricator via cfe-commits
danalbert accepted this revision.
danalbert added a comment.
This revision is now accepted and ready to land.

Nice, that's a lot of code cleaned up! LGTM, but probably should wait for 
someone from Apple to weigh in. I think the new formatting for those error 
messages is better for them too but that's not my call :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114163

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


[PATCH] D76452: Use LLD by default for Android.

2020-03-20 Thread Dan Albert via Phabricator via cfe-commits
danalbert abandoned this revision.
danalbert added a comment.

Looks like we don't actually need this. Can achieve the same effect by 
installing `ld.lld` to the same directory as Clang as `ld` and it'll be 
preferred over the other locations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76452



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


  1   2   >