Re: [PATCH] D38444: [compiler-rt] [cmake] Create dummy gtest target for stand-alone builds

2017-10-02 Thread Michał Górny via cfe-commits
W dniu pon, 02.10.2017 o godzinie 13∶33 -0700, użytkownik George
Karpenkov napisał:
> > On Oct 2, 2017, at 12:57 PM, Michał Górny via Phabricator 
> >  wrote:
> > 
> > mgorny added a comment.
> > 
> > In https://reviews.llvm.org/D38444#886138, @george.karpenkov wrote:
> > 
> > > > breaking stand-alone builds as a result
> > > 
> > > That's a strong statement. Could you clarify? We have a lot of buildbots 
> > > performing standalone builds, and they are still green.
> > 
> > 
> > I didn't know anyone actually added bots doing that. Are you sure we're 
> > talking about the same meaning of 'stand-alone'? Stand-alone == out of 
> > LLVM, against installed copy of LLVM.
> 
> Yes.
> You are right though that bots I was referring to do not run unit tests.
> 
> > 
> >  ninja -v -j16 -l0 check-all
> >  ninja: error: 
> > '/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/compiler-rt-sanitizers-/lib/asan/tests/gtest',
> >  needed by 'lib/asan/tests/dynamic/Asan-i386-calls-Dynamic-Test', missing 
> > and no known rule to make it
> > 
> > It's as broken as it could be since it depends on target that does not 
> > exist.
> 
> Right, by “works” I’ve meant that “it compiles”, not that “unit tests pass”.
> My understanding is that running unit tests never meant to work,
> as a freshly built clang is usually needed, and in standalone mode it is not 
> available.
> I could be wrong though, in that case I do not know.

Yes, it requires some extra work to prepare a local clang copy that
works correctly but it's certainly doable.

> 
> Does everything magically work with this dummy target?

Yes, the tests work as well as they used to before the refactor (there
are a few failures but those are unrelated to the change in question).

-- 
Best regards,
Michał Górny

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


Re: r344241 - [tests] Include Python binding tests in CMake rules

2019-01-15 Thread Michał Górny via cfe-commits
On Tue, 2019-01-15 at 13:10 -0500, Nico Weber wrote:
> The tests probably shouldn't run when LLVM_ENABLE_PIC=OFF is set, since
> they all fail there (due to lib/libclang.so not existing).

Hmm, maybe we could make them conditional to the existence
of libclang.so target?  Would that work for you?

> 
> On Thu, Oct 11, 2018 at 7:59 AM Michal Gorny via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> 
> > Author: mgorny
> > Date: Thu Oct 11 04:58:14 2018
> > New Revision: 344241
> > 
> > URL: http://llvm.org/viewvc/llvm-project?rev=344241&view=rev
> > Log:
> > [tests] Include Python binding tests in CMake rules
> > 
> > Add a new CMake rule check-clang-python to run the Python bindings'
> > test suite, and include it in check-all.
> > 
> > Differential Revision: https://reviews.llvm.org/D52840
> > 
> > Added:
> > cfe/trunk/bindings/python/tests/CMakeLists.txt
> > Modified:
> > cfe/trunk/CMakeLists.txt
> > 
> > Modified: cfe/trunk/CMakeLists.txt
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=344241&r1=344240&r2=344241&view=diff
> > 
> > ==
> > --- cfe/trunk/CMakeLists.txt (original)
> > +++ cfe/trunk/CMakeLists.txt Thu Oct 11 04:58:14 2018
> > @@ -502,6 +502,7 @@ if( CLANG_INCLUDE_TESTS )
> >)
> >endif()
> >add_subdirectory(utils/perf-training)
> > +  add_subdirectory(bindings/python/tests)
> >  endif()
> > 
> >  option(CLANG_INCLUDE_DOCS "Generate build targets for the Clang docs."
> > 
> > Added: cfe/trunk/bindings/python/tests/CMakeLists.txt
> > URL:
> > http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/CMakeLists.txt?rev=344241&view=auto
> > 
> > ==
> > --- cfe/trunk/bindings/python/tests/CMakeLists.txt (added)
> > +++ cfe/trunk/bindings/python/tests/CMakeLists.txt Thu Oct 11 04:58:14 2018
> > @@ -0,0 +1,7 @@
> > +# Test target to run Python test suite from main build.
> > +
> > +add_custom_target(check-clang-python
> > +   COMMAND CLANG_LIBRARY_PATH=$
> > ${PYTHON_EXECUTABLE} -m unittest discover
> > +   DEPENDS libclang
> > +   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
> > +add_dependencies(check-all check-clang-python)
> > 
> > 
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> > 

-- 
Best regards,
Michał Górny


signature.asc
Description: This is a digitally signed message part
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D60728: [clang] [test] Add a (xfailing) test for PR41027

2019-08-07 Thread Michał Górny via cfe-commits
On Wed, 2019-08-07 at 17:10 -0300, Adhemerval Zanella wrote:
> On 05/06/2019 05:19, Michał Górny via Phabricator via llvm-commits wrote:
> > This revision was automatically updated to reflect the committed changes.
> > Closed by commit rL362587: [clang] [test] Add a (xfailing) test for PR41027 
> > (authored by mgorny, committed by ).
> > Herald added a project: LLVM.
> > Herald added a subscriber: llvm-commits.
> > 
> > Changed prior to commit:
> >   https://reviews.llvm.org/D60728?vs=195518&id=203097#toc
> > 
> > Repository:
> >   rL LLVM
> > 
> > CHANGES SINCE LAST ACTION
> >   https://reviews.llvm.org/D60728/new/
> > 
> > https://reviews.llvm.org/D60728
> > 
> > Files:
> >   cfe/trunk/test/Sema/pr41027.c
> 
> This patch is failing on aarch64-linux bot [1], I think you need to add a 
> 'requires: x86_64'.
> 
> [1] http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/7694
> 

Thanks for the report.  You're probably right.  I'll verify the correct
REQUIRES for it, and commit it in a few minutes.


-- 
Best regards,
Michał Górny



signature.asc
Description: This is a digitally signed message part
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D60728: [clang] [test] Add a (xfailing) test for PR41027

2019-08-07 Thread Michał Górny via cfe-commits
On Wed, 2019-08-07 at 17:10 -0300, Adhemerval Zanella wrote:
> On 05/06/2019 05:19, Michał Górny via Phabricator via llvm-commits wrote:
> > This revision was automatically updated to reflect the committed changes.
> > Closed by commit rL362587: [clang] [test] Add a (xfailing) test for PR41027 
> > (authored by mgorny, committed by ).
> > Herald added a project: LLVM.
> > Herald added a subscriber: llvm-commits.
> > 
> > Changed prior to commit:
> >   https://reviews.llvm.org/D60728?vs=195518&id=203097#toc
> > 
> > Repository:
> >   rL LLVM
> > 
> > CHANGES SINCE LAST ACTION
> >   https://reviews.llvm.org/D60728/new/
> > 
> > https://reviews.llvm.org/D60728
> > 
> > Files:
> >   cfe/trunk/test/Sema/pr41027.c
> 
> This patch is failing on aarch64-linux bot [1], I think you need to add a 
> 'requires: x86_64'.
> 
> [1] http://lab.llvm.org:8011/builders/clang-cmake-aarch64-full/builds/7694
> 

Update: I see Bill Wendling already fixed it in r368202.

-- 
Best regards,
Michał Górny



signature.asc
Description: This is a digitally signed message part
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D55828: [clang] [Driver] Disable -faddrsig by default on NetBSD

2018-12-19 Thread Michał Górny via cfe-commits
On Wed, 2018-12-19 at 21:51 +0100, Joerg Sonnenberger wrote:
> On Tue, Dec 18, 2018 at 04:35:54PM +, Michał Górny via Phabricator via 
> cfe-commits wrote:
> > mgorny created this revision.
> > mgorny added reviewers: krytarowski, pcc.
> > 
> > Avoid passing -faddrsig by default on NetBSD.  This platform is still
> > using old GNU binutils that crashes on executables containing those
> > sections.
> 
> I find that a strange claim, given that many Linux distributions in the
> wild have much older GNU binutils.
> 

It only meant that newer versions don't crash, or so I have been told. 
Nothing more.

-- 
Best regards,
Michał Górny


signature.asc
Description: This is a digitally signed message part
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] d4f298c - [clang-tools-extra] Prevent linking to duplicate .a libs and dylib

2020-06-17 Thread Michał Górny via cfe-commits

Author: Michał Górny
Date: 2020-06-17T19:00:26+02:00
New Revision: d4f298c8206b435ce627b022efa0d5da620019cd

URL: 
https://github.com/llvm/llvm-project/commit/d4f298c8206b435ce627b022efa0d5da620019cd
DIFF: 
https://github.com/llvm/llvm-project/commit/d4f298c8206b435ce627b022efa0d5da620019cd.diff

LOG: [clang-tools-extra] Prevent linking to duplicate .a libs and dylib

Fix various tool libraries not to link to clang's .a libraries and dylib
simultaneously.  This may cause breakage, in particular through
duplicate command-line option declarations.

Differential Revision: https://reviews.llvm.org/D81967

Added: 


Modified: 
clang-tools-extra/clang-apply-replacements/CMakeLists.txt
clang-tools-extra/clang-change-namespace/CMakeLists.txt
clang-tools-extra/clang-doc/CMakeLists.txt
clang-tools-extra/clang-include-fixer/CMakeLists.txt
clang-tools-extra/clang-include-fixer/find-all-symbols/CMakeLists.txt
clang-tools-extra/clang-move/CMakeLists.txt
clang-tools-extra/clang-query/CMakeLists.txt
clang-tools-extra/clang-reorder-fields/CMakeLists.txt
clang-tools-extra/clang-tidy/CMakeLists.txt
clang-tools-extra/clang-tidy/abseil/CMakeLists.txt
clang-tools-extra/clang-tidy/android/CMakeLists.txt
clang-tools-extra/clang-tidy/boost/CMakeLists.txt
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/clang-tidy/cert/CMakeLists.txt
clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
clang-tools-extra/clang-tidy/darwin/CMakeLists.txt
clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
clang-tools-extra/clang-tidy/google/CMakeLists.txt
clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt
clang-tools-extra/clang-tidy/linuxkernel/CMakeLists.txt
clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
clang-tools-extra/clang-tidy/llvmlibc/CMakeLists.txt
clang-tools-extra/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/clang-tidy/mpi/CMakeLists.txt
clang-tools-extra/clang-tidy/objc/CMakeLists.txt
clang-tools-extra/clang-tidy/openmp/CMakeLists.txt
clang-tools-extra/clang-tidy/performance/CMakeLists.txt
clang-tools-extra/clang-tidy/plugin/CMakeLists.txt
clang-tools-extra/clang-tidy/portability/CMakeLists.txt
clang-tools-extra/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/clang-tidy/tool/CMakeLists.txt
clang-tools-extra/clang-tidy/utils/CMakeLists.txt
clang-tools-extra/clang-tidy/zircon/CMakeLists.txt
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/unittests/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clang-apply-replacements/CMakeLists.txt 
b/clang-tools-extra/clang-apply-replacements/CMakeLists.txt
index 5bfdcb487e17..27383b488e4d 100644
--- a/clang-tools-extra/clang-apply-replacements/CMakeLists.txt
+++ b/clang-tools-extra/clang-apply-replacements/CMakeLists.txt
@@ -4,8 +4,10 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_library(clangApplyReplacements
   lib/Tooling/ApplyReplacements.cpp
+)
 
-  LINK_LIBS
+clang_target_link_libraries(clangApplyReplacements
+  PRIVATE
   clangAST
   clangBasic
   clangRewrite

diff  --git a/clang-tools-extra/clang-change-namespace/CMakeLists.txt 
b/clang-tools-extra/clang-change-namespace/CMakeLists.txt
index 7c0363cd00d0..bfce9869dde8 100644
--- a/clang-tools-extra/clang-change-namespace/CMakeLists.txt
+++ b/clang-tools-extra/clang-change-namespace/CMakeLists.txt
@@ -5,8 +5,10 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_library(clangChangeNamespace
   ChangeNamespace.cpp
+)
 
-  LINK_LIBS
+clang_target_link_libraries(clangChangeNamespace
+  PRIVATE
   clangAST
   clangASTMatchers
   clangBasic

diff  --git a/clang-tools-extra/clang-doc/CMakeLists.txt 
b/clang-tools-extra/clang-doc/CMakeLists.txt
index 8df7d3ef9098..56ec9eb6e94e 100644
--- a/clang-tools-extra/clang-doc/CMakeLists.txt
+++ b/clang-tools-extra/clang-doc/CMakeLists.txt
@@ -15,8 +15,10 @@ add_clang_library(clangDoc
   Representation.cpp
   Serialize.cpp
   YAMLGenerator.cpp
+)
 
-  LINK_LIBS
+clang_target_link_libraries(clangDoc
+  PRIVATE
   clangAnalysis
   clangAST
   clangASTMatchers

diff  --git a/clang-tools-extra/clang-include-fixer/CMakeLists.txt 
b/clang-tools-extra/clang-include-fixer/CMakeLists.txt
index f27f7403ea6a..d8685cb20758 100644
--- a/clang-tools-extra/clang-include-fixer/CMakeLists.txt
+++ b/clang-tools-extra/clang-include-fixer/CMakeLists.txt
@@ -11,6 +11,11 @@ add_clang_library(clangIncludeFixer
   YamlSymbolIndex.cpp
 
   LINK_LIBS
+  findAllSymbols
+  )
+
+clang_target_link_libraries(clangIncludeFixer
+  PRIVATE
   clangAST
   clangBasic
   clangFormat
@@ -21,7 +26,6 @@ add_clang_library(clangIncludeFixer
   clangSerialization
   clangTooling
   clangToolingCore
-  findAllSymbols
   )
 
 add_subdirectory(plugin)

diff  --git 
a/clang-tools-extra/clang-include-fixer/find-all-sym

[clang] cac8cd0 - [clang] [unittest/AST] Fix linking to LLVMTestingSupport

2020-05-01 Thread Michał Górny via cfe-commits

Author: Michał Górny
Date: 2020-05-01T21:22:51+02:00
New Revision: cac8cd0a16e9c0410e33aaca93c760c503eeb68e

URL: 
https://github.com/llvm/llvm-project/commit/cac8cd0a16e9c0410e33aaca93c760c503eeb68e
DIFF: 
https://github.com/llvm/llvm-project/commit/cac8cd0a16e9c0410e33aaca93c760c503eeb68e.diff

LOG: [clang] [unittest/AST] Fix linking to LLVMTestingSupport

Link to LLVMTestingSupport via target_link_libraries() instead of
clang_target_link_libraries().  The latter is ineffective if tests
are linked to libclang.so.  This solution is consistent with what other
tests do.

Added: 


Modified: 
clang/unittests/AST/CMakeLists.txt

Removed: 




diff  --git a/clang/unittests/AST/CMakeLists.txt 
b/clang/unittests/AST/CMakeLists.txt
index 868635b6eea5..5d9ff5b97dbd 100644
--- a/clang/unittests/AST/CMakeLists.txt
+++ b/clang/unittests/AST/CMakeLists.txt
@@ -43,5 +43,9 @@ clang_target_link_libraries(ASTTests
   clangFrontend
   clangSerialization
   clangTooling
-  LLVMTestingSupport
   )
+
+target_link_libraries(ASTTests
+  PRIVATE
+  LLVMTestingSupport
+)



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


[clang] 21c165d - [CMake] Pass bugreport URL to standalone clang build

2020-08-01 Thread Michał Górny via cfe-commits

Author: Michał Górny
Date: 2020-08-02T08:32:05+02:00
New Revision: 21c165de2a1bcca9dceb452f637d9e8959fba113

URL: 
https://github.com/llvm/llvm-project/commit/21c165de2a1bcca9dceb452f637d9e8959fba113
DIFF: 
https://github.com/llvm/llvm-project/commit/21c165de2a1bcca9dceb452f637d9e8959fba113.diff

LOG: [CMake] Pass bugreport URL to standalone clang build

BUG_REPORT_URL is currently used both in LLVM and in Clang but declared
only in the latter.  This means that it's missing in standalone clang
builds and the driver ends up outputting:

  PLEASE submit a bug report to  and include [...]

(note the missing URL)

To fix this, include LLVM_PACKAGE_BUGREPORT in LLVMConfig.cmake
(similarly to how we pass PACKAGE_VERSION) and use it to fill
BUG_REPORT_URL when building clang standalone.

Differential Revision: https://reviews.llvm.org/D84987

Added: 


Modified: 
clang/CMakeLists.txt
llvm/cmake/modules/LLVMConfig.cmake.in

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 0f08538495fc..c487e506cae1 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -121,6 +121,8 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
   include(LLVMDistributionSupport)
 
   set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
+  set(BUG_REPORT_URL "${LLVM_PACKAGE_BUGREPORT}" CACHE STRING
+"Default URL where bug reports are to be submitted.")
 
   if (NOT DEFINED LLVM_INCLUDE_TESTS)
 set(LLVM_INCLUDE_TESTS ON)

diff  --git a/llvm/cmake/modules/LLVMConfig.cmake.in 
b/llvm/cmake/modules/LLVMConfig.cmake.in
index 17cc5eacc57b..a5c370bbc25e 100644
--- a/llvm/cmake/modules/LLVMConfig.cmake.in
+++ b/llvm/cmake/modules/LLVMConfig.cmake.in
@@ -7,6 +7,7 @@ set(LLVM_VERSION_MINOR @LLVM_VERSION_MINOR@)
 set(LLVM_VERSION_PATCH @LLVM_VERSION_PATCH@)
 set(LLVM_VERSION_SUFFIX @LLVM_VERSION_SUFFIX@)
 set(LLVM_PACKAGE_VERSION @PACKAGE_VERSION@)
+set(LLVM_PACKAGE_BUGREPORT @PACKAGE_BUGREPORT@)
 
 set(LLVM_BUILD_TYPE @CMAKE_BUILD_TYPE@)
 



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


[PATCH] D24809: [libcxx] [cmake] Stop stripping -m32 from compiler flags

2016-09-21 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added a reviewer: EricWF.
mgorny added a subscriber: cfe-commits.
Herald added subscribers: mgorny, beanz.

Stop stripping -m32 from the user-supplied flags. There is no valid reason to 
do that, stripping it silently is thoroughly confusing and makes it impossible 
to do distribution multi-ABI builds without resorting to ugly hacks.

Otherwise, in order to perform 32-bit builds the build scripts would have to 
use LIBCXX_BUILD_32_BITS. However, -m32 is only one of the many different ABI 
flags for different targets, and it really makes no sense to add separate CMake 
options for each possible -m* flag and then keep a mapping from well-known 
flags to the custom CMake options.


https://reviews.llvm.org/D24809

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -309,7 +309,7 @@
 
 # Remove flags that may have snuck in.
 remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG
- -stdlib=libc++ -stdlib=libstdc++ -lc++abi -m32)
+ -stdlib=libc++ -stdlib=libstdc++ -lc++abi)
 
 # FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC.
 # Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -309,7 +309,7 @@
 
 # Remove flags that may have snuck in.
 remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG
- -stdlib=libc++ -stdlib=libstdc++ -lc++abi -m32)
+ -stdlib=libc++ -stdlib=libstdc++ -lc++abi)
 
 # FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC.
 # Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24869: [cfe] [test] Fix detecting LLVM zlib support in stand-alone builds

2016-09-23 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: rsmith, beanz, samsonov.
mgorny added a subscriber: cfe-commits.
Herald added subscribers: mgorny, beanz.

Fix the test run to declare missing HAVE_LIBZ value in stand-alone builds, 
using the LLVM_ENABLE_ZLIB that is exported in LLVMConfig.cmake.

When using in-tree builds, HAVE_LIBZ is declared in cmake/config-ix.cmake as a 
result of LLVM's CMake checks. When building stand-alone, this value is not 
available and as a result caused clang to wrongly assume that LLVM was built 
without zlib support.

To fix it, set it to the value of LLVM_ENABLE_ZLIB. While this variable is 
originally used to control the user preference, LLVM updates its value to 0 if 
zlib checks fail. Therefore, we can use it to reliably determine whether LLVM 
was built with zlib support or not.


https://reviews.llvm.org/D24869

Files:
  test/CMakeLists.txt

Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -9,6 +9,15 @@
 
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR 
${LLVM_RUNTIME_OUTPUT_INTDIR})
 
+if(CLANG_BUILT_STANDALONE)
+  # Set HAVE_LIBZ according to recorded LLVM_ENABLE_ZLIB value. This
+  # value is forced to 0 if zlib was not found, so it is fine to use it
+  # instead of HAVE_LIBZ (not recorded).
+  if(LLVM_ENABLE_ZLIB)
+set(HAVE_LIBZ 1)
+  endif()
+endif()
+
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -9,6 +9,15 @@
 
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
 
+if(CLANG_BUILT_STANDALONE)
+  # Set HAVE_LIBZ according to recorded LLVM_ENABLE_ZLIB value. This
+  # value is forced to 0 if zlib was not found, so it is fine to use it
+  # instead of HAVE_LIBZ (not recorded).
+  if(LLVM_ENABLE_ZLIB)
+set(HAVE_LIBZ 1)
+  endif()
+endif()
+
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24869: [cfe] [test] Fix detecting LLVM zlib support in stand-alone builds

2016-09-23 Thread Michał Górny via cfe-commits
mgorny added a comment.

For the record: I've tested the patch with and without zlib installed, using 
in-tree and stand-alone builds.


https://reviews.llvm.org/D24869



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


[PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-25 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added a reviewer: EricWF.
mgorny added a subscriber: cfe-commits.

Declare __STDC_FORMAT_MACROS, __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS 
before including real inttypes.h/stdint.h when the wrapper-header is included 
in C++11, in order to enable the necessary macros in C99-compliant libc.

The C99 standard defined that the format macros in inttypes.h should be defined 
by the C++ implementations only when __STDC_FORMAT_MACROS is defined, and the 
limit and constant macros in stdint.h should be defined only when 
__STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS are defined appropriately. 
Following this specification, multiple old versions of glibc up to 2.17 do not 
define those macros by default for C++, rendering the libc++ headers 
non-compliant to the C++11 standard.

In order to achieve the necessary compliance, __STDC_FORMAT_MACROS is defined 
in wrapped inttypes.h just before including the system inttypes.h, when C++11 
or newer is used. Both __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS are 
defined in newly-wrapped stdint.h. This fixes the C++11 compliance while 
preserving the current behavior for C++03.


https://reviews.llvm.org/D24903

Files:
  include/inttypes.h
  include/stdint.h

Index: include/stdint.h
===
--- /dev/null
+++ include/stdint.h
@@ -0,0 +1,33 @@
+// -*- C++ -*-
+//=== stdint.h 
===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_STDINT_H
+#define _LIBCPP_STDINT_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed
+   for C++11 unless __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS
+   are defined
+*/
+#if __cplusplus >= 201103L && !defined(__STDC_LIMIT_MACROS)
+#  define __STDC_LIMIT_MACROS
+#endif
+#if __cplusplus >= 201103L && !defined(__STDC_CONSTANT_MACROS)
+#  define __STDC_CONSTANT_MACROS
+#endif
+
+#include_next 
+
+#endif  // _LIBCPP_STDINT_H
Index: include/inttypes.h
===
--- include/inttypes.h
+++ include/inttypes.h
@@ -237,6 +237,13 @@
 #pragma GCC system_header
 #endif
 
+/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed
+   for C++11 unless __STDC_FORMAT_MACROS is defined
+*/
+#if __cplusplus >= 201103L && !defined(__STDC_FORMAT_MACROS)
+#  define __STDC_FORMAT_MACROS
+#endif
+
 #include_next 
 
 #ifdef __cplusplus


Index: include/stdint.h
===
--- /dev/null
+++ include/stdint.h
@@ -0,0 +1,33 @@
+// -*- C++ -*-
+//=== stdint.h ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_STDINT_H
+#define _LIBCPP_STDINT_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed
+   for C++11 unless __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS
+   are defined
+*/
+#if __cplusplus >= 201103L && !defined(__STDC_LIMIT_MACROS)
+#	define __STDC_LIMIT_MACROS
+#endif
+#if __cplusplus >= 201103L && !defined(__STDC_CONSTANT_MACROS)
+#	define __STDC_CONSTANT_MACROS
+#endif
+
+#include_next 
+
+#endif  // _LIBCPP_STDINT_H
Index: include/inttypes.h
===
--- include/inttypes.h
+++ include/inttypes.h
@@ -237,6 +237,13 @@
 #pragma GCC system_header
 #endif
 
+/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed
+   for C++11 unless __STDC_FORMAT_MACROS is defined
+*/
+#if __cplusplus >= 201103L && !defined(__STDC_FORMAT_MACROS)
+#	define __STDC_FORMAT_MACROS
+#endif
+
 #include_next 
 
 #ifdef __cplusplus
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-25 Thread Michał Górny via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D24903#551890, @rmaprath wrote:

> When the `` headers where split into `` and `` headers in 
> https://reviews.llvm.org/D12747, we have left out `` and ``. 
> I was going to put up a patch to fix this but couldn't get to it. It's good 
> that you are adding ``, perhaps you can follow what was done in 
> https://reviews.llvm.org/D12747 and repeat the same for ``?


I'm sorry but could you be a little more specific, please? I've looked into 
that diff, and it seems that the cstdint resembles e.g. cinttypes already -- 
i.e. there's only the include, and 'using' lines there. Or do you mean that I 
should copy/update the synopsis over to stdint.h?


https://reviews.llvm.org/D24903



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


Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-26 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 72441.

https://reviews.llvm.org/D24903

Files:
  include/inttypes.h
  include/stdint.h

Index: include/stdint.h
===
--- /dev/null
+++ include/stdint.h
@@ -0,0 +1,121 @@
+// -*- C++ -*-
+//=== stdint.h ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_STDINT_H
+#define _LIBCPP_STDINT_H
+
+/*
+stdint.h synopsis
+
+Macros:
+
+INT8_MIN
+INT16_MIN
+INT32_MIN
+INT64_MIN
+
+INT8_MAX
+INT16_MAX
+INT32_MAX
+INT64_MAX
+
+UINT8_MAX
+UINT16_MAX
+UINT32_MAX
+UINT64_MAX
+
+INT_LEAST8_MIN
+INT_LEAST16_MIN
+INT_LEAST32_MIN
+INT_LEAST64_MIN
+
+INT_LEAST8_MAX
+INT_LEAST16_MAX
+INT_LEAST32_MAX
+INT_LEAST64_MAX
+
+UINT_LEAST8_MAX
+UINT_LEAST16_MAX
+UINT_LEAST32_MAX
+UINT_LEAST64_MAX
+
+INT_FAST8_MIN
+INT_FAST16_MIN
+INT_FAST32_MIN
+INT_FAST64_MIN
+
+INT_FAST8_MAX
+INT_FAST16_MAX
+INT_FAST32_MAX
+INT_FAST64_MAX
+
+UINT_FAST8_MAX
+UINT_FAST16_MAX
+UINT_FAST32_MAX
+UINT_FAST64_MAX
+
+INTPTR_MIN
+INTPTR_MAX
+UINTPTR_MAX
+
+INTMAX_MIN
+INTMAX_MAX
+
+UINTMAX_MAX
+
+PTRDIFF_MIN
+PTRDIFF_MAX
+
+SIG_ATOMIC_MIN
+SIG_ATOMIC_MAX
+
+SIZE_MAX
+
+WCHAR_MIN
+WCHAR_MAX
+
+WINT_MIN
+WINT_MAX
+
+INT8_C(value)
+INT16_C(value)
+INT32_C(value)
+INT64_C(value)
+
+UINT8_C(value)
+UINT16_C(value)
+UINT32_C(value)
+UINT64_C(value)
+
+INTMAX_C(value)
+UINTMAX_C(value)
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed
+   for C++11 unless __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS
+   are defined
+*/
+#if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS)
+#	define __STDC_LIMIT_MACROS
+#endif
+#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS)
+#	define __STDC_CONSTANT_MACROS
+#endif
+
+#include_next 
+
+#endif  // _LIBCPP_STDINT_H
Index: include/inttypes.h
===
--- include/inttypes.h
+++ include/inttypes.h
@@ -237,6 +237,13 @@
 #pragma GCC system_header
 #endif
 
+/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed
+   for C++11 unless __STDC_FORMAT_MACROS is defined
+*/
+#if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS)
+#	define __STDC_FORMAT_MACROS
+#endif
+
 #include_next 
 
 #ifdef __cplusplus
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-26 Thread Michał Górny via cfe-commits
mgorny marked an inline comment as done.
mgorny added a comment.

In https://reviews.llvm.org/D24903#551890, @rmaprath wrote:

> When the `` headers where split into `` and `` headers in 
> https://reviews.llvm.org/D12747, we have left out `` and ``. 
> I was going to put up a patch to fix this but couldn't get to it. It's good 
> that you are adding ``, perhaps you can follow what was done in 
> https://reviews.llvm.org/D12747 and repeat the same for ``?
>
> You will also need a test for the new header, https://reviews.llvm.org/D12747 
> has examples.


I see that libcxx already has a pretty complete test for stdint.h.

After consulting the standard, I've shamelessly copied the C part of synopsis 
to my stdint.h.


https://reviews.llvm.org/D24903



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


Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-26 Thread Michał Górny via cfe-commits
mgorny added inline comments.


Comment at: include/stdint.h:25
@@ +24,3 @@
+INT8_MAX
+INT16_MAX
+INT32_MAX

Are you referring to the way __STDC_LIMIT_MACROS etc. is handled there? Or 
something more?


https://reviews.llvm.org/D24903



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


Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-26 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 72492.

https://reviews.llvm.org/D24903

Files:
  include/inttypes.h
  include/stdint.h

Index: include/stdint.h
===
--- /dev/null
+++ include/stdint.h
@@ -0,0 +1,132 @@
+// -*- C++ -*-
+//=== stdint.h ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_STDINT_H
+#define _LIBCPP_STDINT_H
+
+/*
+stdint.h synopsis
+
+Macros:
+
+INT8_MIN
+INT16_MIN
+INT32_MIN
+INT64_MIN
+
+INT8_MAX
+INT16_MAX
+INT32_MAX
+INT64_MAX
+
+UINT8_MAX
+UINT16_MAX
+UINT32_MAX
+UINT64_MAX
+
+INT_LEAST8_MIN
+INT_LEAST16_MIN
+INT_LEAST32_MIN
+INT_LEAST64_MIN
+
+INT_LEAST8_MAX
+INT_LEAST16_MAX
+INT_LEAST32_MAX
+INT_LEAST64_MAX
+
+UINT_LEAST8_MAX
+UINT_LEAST16_MAX
+UINT_LEAST32_MAX
+UINT_LEAST64_MAX
+
+INT_FAST8_MIN
+INT_FAST16_MIN
+INT_FAST32_MIN
+INT_FAST64_MIN
+
+INT_FAST8_MAX
+INT_FAST16_MAX
+INT_FAST32_MAX
+INT_FAST64_MAX
+
+UINT_FAST8_MAX
+UINT_FAST16_MAX
+UINT_FAST32_MAX
+UINT_FAST64_MAX
+
+INTPTR_MIN
+INTPTR_MAX
+UINTPTR_MAX
+
+INTMAX_MIN
+INTMAX_MAX
+
+UINTMAX_MAX
+
+PTRDIFF_MIN
+PTRDIFF_MAX
+
+SIG_ATOMIC_MIN
+SIG_ATOMIC_MAX
+
+SIZE_MAX
+
+WCHAR_MIN
+WCHAR_MAX
+
+WINT_MIN
+WINT_MAX
+
+INT8_C(value)
+INT16_C(value)
+INT32_C(value)
+INT64_C(value)
+
+UINT8_C(value)
+UINT16_C(value)
+UINT32_C(value)
+UINT64_C(value)
+
+INTMAX_C(value)
+UINTMAX_C(value)
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed
+   for C++11 unless __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS
+   are defined
+*/
+#if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS)
+#   define __STDC_LIMIT_MACROS
+#   define __STDC_LIMIT_MACROS_DEFINED_BY_LIBCXX
+#endif
+#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS)
+#   define __STDC_CONSTANT_MACROS
+#   define __STDC_CONSTANT_MACROS_DEFINED_BY_LIBCXX
+#endif
+
+#include_next 
+
+#ifdef __STDC_CONSTANT_MACROS_DEFINED_BY_LIBCXX
+#   undef __STDC_CONSTANT_MACROS_DEFINED_BY_LIBCXX
+#   undef __STDC_CONSTANT_MACROS
+#endif
+#ifdef __STDC_LIMIT_MACROS_DEFINED_BY_LIBCXX
+#   undef __STDC_LIMIT_MACROS_DEFINED_BY_LIBCXX
+#   undef __STDC_LIMIT_MACROS
+#endif
+
+#endif  // _LIBCPP_STDINT_H
Index: include/inttypes.h
===
--- include/inttypes.h
+++ include/inttypes.h
@@ -237,8 +237,21 @@
 #pragma GCC system_header
 #endif
 
+/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed
+   for C++11 unless __STDC_FORMAT_MACROS is defined
+*/
+#if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS)
+#   define __STDC_FORMAT_MACROS
+#   define __STDC_FORMAT_MACROS_DEFINED_BY_LIBCXX
+#endif
+
 #include_next 
 
+#ifdef __STDC_FORMAT_MACROS_DEFINED_BY_LIBCXX
+#   undef __STDC_FORMAT_MACROS_DEFINED_BY_LIBCXX
+#   undef __STDC_FORMAT_MACROS
+#endif
+
 #ifdef __cplusplus
 
 #include 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-26 Thread Michał Górny via cfe-commits
mgorny added a comment.

@EricWF, I've copied the additional unset logic from clang. Does this address 
all of your concerns?

By the way, I think clang misses __STDC_FORMAT_MACROS for inttypes.h. I'll 
write a patch for that as well, for consistency.


https://reviews.llvm.org/D24903



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


[PATCH] D24921: [PATCH] [Headers] Fix inttypes.h macros visibility in C++ with C99-compliant libc

2016-09-26 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added a reviewer: rsmith.
mgorny added a subscriber: cfe-commits.

Define `__STDC_FORMAT_MACROS` in order to enable all macros defined by 
inttypes.h in C++ mode, as was required by the C99 standard and was enforced by 
multiple old glibc versions. This extends the fix from r179419 that covered 
only macros defined by stdint.h but not those in inttypes.h.


https://reviews.llvm.org/D24921

Files:
  lib/Headers/inttypes.h

Index: lib/Headers/inttypes.h
===
--- lib/Headers/inttypes.h
+++ lib/Headers/inttypes.h
@@ -27,8 +27,35 @@
 #error MSVC does not have inttypes.h prior to Visual Studio 2013
 #endif
 
+// C99 7.8.1 Macros for format specifiers
+//
+//  Footnote 191: C++ implementations should define these macros only when
+//  __STDC_FORMAT_MACROS is defined before  is included.
+//
+// C++11 [c.files]p3:
+//
+//  The macros defined by  are provided unconditionally.
+//  In particular, the symbol __STDC_FORMAT_MACROS (mentioned
+//  in footnote 182 of the C standard) plays no role in C++.
+//
+// C11 removed the problematic footnotes.
+//
+// Work around this inconsistency by always defining those macros in C++ mode,
+// so that a C library implementation which follows the C99 standard can be
+// used in C++.
+
+# if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS)
+#  define __STDC_FORMAT_MACROS
+#  define __STDC_FORMAT_MACROS_DEFINED_BY_CLANG
+# endif
+
 #include_next 
 
+# ifdef __STDC_FORMAT_MACROS_DEFINED_BY_CLANG
+#  undef __STDC_FORMAT_MACROS
+#  undef __STDC_FORMAT_MACROS_DEFINED_BY_CLANG
+# endif
+
 #if defined(_MSC_VER) && _MSC_VER < 1900
 /* MSVC headers define int32_t as int, but PRIx32 as "lx" instead of "x".
  * This triggers format warnings, so fix it up here. */


Index: lib/Headers/inttypes.h
===
--- lib/Headers/inttypes.h
+++ lib/Headers/inttypes.h
@@ -27,8 +27,35 @@
 #error MSVC does not have inttypes.h prior to Visual Studio 2013
 #endif
 
+// C99 7.8.1 Macros for format specifiers
+//
+//  Footnote 191: C++ implementations should define these macros only when
+//  __STDC_FORMAT_MACROS is defined before  is included.
+//
+// C++11 [c.files]p3:
+//
+//  The macros defined by  are provided unconditionally.
+//  In particular, the symbol __STDC_FORMAT_MACROS (mentioned
+//  in footnote 182 of the C standard) plays no role in C++.
+//
+// C11 removed the problematic footnotes.
+//
+// Work around this inconsistency by always defining those macros in C++ mode,
+// so that a C library implementation which follows the C99 standard can be
+// used in C++.
+
+# if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS)
+#  define __STDC_FORMAT_MACROS
+#  define __STDC_FORMAT_MACROS_DEFINED_BY_CLANG
+# endif
+
 #include_next 
 
+# ifdef __STDC_FORMAT_MACROS_DEFINED_BY_CLANG
+#  undef __STDC_FORMAT_MACROS
+#  undef __STDC_FORMAT_MACROS_DEFINED_BY_CLANG
+# endif
+
 #if defined(_MSC_VER) && _MSC_VER < 1900
 /* MSVC headers define int32_t as int, but PRIx32 as "lx" instead of "x".
  * This triggers format warnings, so fix it up here. */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24921: [PATCH] [Headers] Fix inttypes.h macros visibility in C++ with C99-compliant libc

2016-09-26 Thread Michał Górny via cfe-commits
mgorny added a comment.

By the way, if anyone happens to have a 'more final' copy of the standards 
handy, feel free to provide a more consistent footnote numbers ;-).


https://reviews.llvm.org/D24921



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


Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-26 Thread Michał Górny via cfe-commits
mgorny added a comment.

Ok. Thanks for the review.


https://reviews.llvm.org/D24903



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


Re: [PATCH] D24903: [libcxx] [include] Declare __STDC_*_MACROS for C++11 compat in old libc

2016-09-26 Thread Michał Górny via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282435: [include] Declare __STDC_*_MACROS for C++11 compat 
in old libc (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D24903?vs=72492&id=72552#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24903

Files:
  libcxx/trunk/include/inttypes.h
  libcxx/trunk/include/stdint.h

Index: libcxx/trunk/include/stdint.h
===
--- libcxx/trunk/include/stdint.h
+++ libcxx/trunk/include/stdint.h
@@ -0,0 +1,121 @@
+// -*- C++ -*-
+//=== stdint.h ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_STDINT_H
+#define _LIBCPP_STDINT_H
+
+/*
+stdint.h synopsis
+
+Macros:
+
+INT8_MIN
+INT16_MIN
+INT32_MIN
+INT64_MIN
+
+INT8_MAX
+INT16_MAX
+INT32_MAX
+INT64_MAX
+
+UINT8_MAX
+UINT16_MAX
+UINT32_MAX
+UINT64_MAX
+
+INT_LEAST8_MIN
+INT_LEAST16_MIN
+INT_LEAST32_MIN
+INT_LEAST64_MIN
+
+INT_LEAST8_MAX
+INT_LEAST16_MAX
+INT_LEAST32_MAX
+INT_LEAST64_MAX
+
+UINT_LEAST8_MAX
+UINT_LEAST16_MAX
+UINT_LEAST32_MAX
+UINT_LEAST64_MAX
+
+INT_FAST8_MIN
+INT_FAST16_MIN
+INT_FAST32_MIN
+INT_FAST64_MIN
+
+INT_FAST8_MAX
+INT_FAST16_MAX
+INT_FAST32_MAX
+INT_FAST64_MAX
+
+UINT_FAST8_MAX
+UINT_FAST16_MAX
+UINT_FAST32_MAX
+UINT_FAST64_MAX
+
+INTPTR_MIN
+INTPTR_MAX
+UINTPTR_MAX
+
+INTMAX_MIN
+INTMAX_MAX
+
+UINTMAX_MAX
+
+PTRDIFF_MIN
+PTRDIFF_MAX
+
+SIG_ATOMIC_MIN
+SIG_ATOMIC_MAX
+
+SIZE_MAX
+
+WCHAR_MIN
+WCHAR_MAX
+
+WINT_MIN
+WINT_MAX
+
+INT8_C(value)
+INT16_C(value)
+INT32_C(value)
+INT64_C(value)
+
+UINT8_C(value)
+UINT16_C(value)
+UINT32_C(value)
+UINT64_C(value)
+
+INTMAX_C(value)
+UINTMAX_C(value)
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+/* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed
+   for C++11 unless __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS
+   are defined
+*/
+#if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS)
+#   define __STDC_LIMIT_MACROS
+#endif
+#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS)
+#   define __STDC_CONSTANT_MACROS
+#endif
+
+#include_next 
+
+#endif  // _LIBCPP_STDINT_H
Index: libcxx/trunk/include/inttypes.h
===
--- libcxx/trunk/include/inttypes.h
+++ libcxx/trunk/include/inttypes.h
@@ -237,6 +237,13 @@
 #pragma GCC system_header
 #endif
 
+/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed
+   for C++11 unless __STDC_FORMAT_MACROS is defined
+*/
+#if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS)
+#   define __STDC_FORMAT_MACROS
+#endif
+
 #include_next 
 
 #ifdef __cplusplus
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24809: [libcxx] [cmake] Stop stripping -m32 from compiler flags

2016-09-26 Thread Michał Górny via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D24809#553415, @EricWF wrote:

> > Stop stripping -m32 from the user-supplied flags. There is no valid reason 
> > to do that, stripping it silently is thoroughly confusing and makes it 
> > impossible to do distribution multi-ABI builds without resorting to ugly 
> > hacks.
>
>
> The reason for stripping it is configurations like `-DLLVM_BUILD_32_BITS=ON 
> -DLIBCXX_BUILD_32_BITS=OFF`, where we inherit the incorrect set of flags from 
> the LLVM parent project. I understand your frustration with this behavior but 
> I'm not sure how else to handle that.


Well, I'm afraid this only proves that the whole concept is broken and 
shouldn't be there in the first place ;-).

However, if this is the only case, maybe the stripping should be made 
conditional to in-tree builds?


https://reviews.llvm.org/D24809



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


Re: [PATCH] D24809: [libcxx] [cmake] Strip possibly-inherited compiler flags in in-tree build only

2016-09-26 Thread Michał Górny via cfe-commits
mgorny retitled this revision from "[libcxx] [cmake] Stop stripping -m32 from 
compiler flags" to "[libcxx] [cmake] Strip possibly-inherited compiler flags in 
in-tree build only".
mgorny updated the summary for this revision.
mgorny added a reviewer: beanz.
mgorny updated this revision to Diff 72602.
mgorny added a comment.

Updated the patch to affect only stand-alone builds. Adding @beanz since he 
seems to have worked on out-of-tree LLVM build support.


https://reviews.llvm.org/D24809

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -307,9 +307,11 @@
 
 include(HandleLibCXXABI) # Setup the ABI library flags
 
-# Remove flags that may have snuck in.
-remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG
- -stdlib=libc++ -stdlib=libstdc++ -lc++abi -m32)
+if (LIBCXX_STANDALONE_BUILD)
+  # Remove flags that may have snuck in.
+  remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG
+   -stdlib=libc++ -stdlib=libstdc++ -lc++abi -m32)
+endif()
 
 # FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC.
 # Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -307,9 +307,11 @@
 
 include(HandleLibCXXABI) # Setup the ABI library flags
 
-# Remove flags that may have snuck in.
-remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG
- -stdlib=libc++ -stdlib=libstdc++ -lc++abi -m32)
+if (LIBCXX_STANDALONE_BUILD)
+  # Remove flags that may have snuck in.
+  remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG
+   -stdlib=libc++ -stdlib=libstdc++ -lc++abi -m32)
+endif()
 
 # FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC.
 # Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23754: cmake: Add CLANG_GOLD_LIBDIR_SUFFIX to specify loc of LLVMgold.so

2016-09-26 Thread Michał Górny via cfe-commits
mgorny added a comment.

@rafael, ping. Could you review this, please? This is the solution you 
suggested on the bug.


https://reviews.llvm.org/D23754



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


[PATCH] D24954: [ToolChains] Do not assume OpenSUSE for other SUSE variants

2016-09-27 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: rafael, theraven, ismail.
mgorny added a subscriber: cfe-commits.

Assume OpenSUSE distribution only when /etc/SuSE-release indicates OpenSUSE, 
rather than for any SUSE distribution. This reverts the behavior change from 
rL185537 which -- along with removing the version check -- also implicitly 
removed the check for OpenSUSE string. This fixes passing unsupported linker 
flags for old binutils on SLES10.


https://reviews.llvm.org/D24954

Files:
  lib/Driver/ToolChains.cpp

Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3912,8 +3912,11 @@
 return UnknownDistro;
   }
 
-  if (D.getVFS().exists("/etc/SuSE-release"))
-return OpenSUSE;
+  File = llvm::MemoryBuffer::getFile("/etc/SuSE-release");
+  if (File)
+return llvm::StringSwitch(File.get()->getBuffer())
+  .StartsWith("openSUSE", OpenSUSE)
+  .Default(UnknownDistro);
 
   if (D.getVFS().exists("/etc/exherbo-release"))
 return Exherbo;


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3912,8 +3912,11 @@
 return UnknownDistro;
   }
 
-  if (D.getVFS().exists("/etc/SuSE-release"))
-return OpenSUSE;
+  File = llvm::MemoryBuffer::getFile("/etc/SuSE-release");
+  if (File)
+return llvm::StringSwitch(File.get()->getBuffer())
+  .StartsWith("openSUSE", OpenSUSE)
+  .Default(UnknownDistro);
 
   if (D.getVFS().exists("/etc/exherbo-release"))
 return Exherbo;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24809: [libcxx] [cmake] Strip possibly-inherited compiler flags in in-tree build only

2016-09-27 Thread Michał Górny via cfe-commits
This revision was automatically updated to reflect the committed changes.
mgorny marked an inline comment as done.
Closed by commit rL282475: [cmake] Strip possibly-inherited compiler flags in 
in-tree build only (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D24809?vs=72602&id=72611#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24809

Files:
  libcxx/trunk/CMakeLists.txt

Index: libcxx/trunk/CMakeLists.txt
===
--- libcxx/trunk/CMakeLists.txt
+++ libcxx/trunk/CMakeLists.txt
@@ -307,9 +307,12 @@
 
 include(HandleLibCXXABI) # Setup the ABI library flags
 
-# Remove flags that may have snuck in.
-remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG
- -stdlib=libc++ -stdlib=libstdc++ -lc++abi -m32)
+if (NOT LIBCXX_STANDALONE_BUILD)
+  # Remove flags that may have snuck in.
+  remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG
+   -lc++abi -m32)
+endif()
+remove_flags(-stdlib=libc++ -stdlib=libstdc++)
 
 # FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC.
 # Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors


Index: libcxx/trunk/CMakeLists.txt
===
--- libcxx/trunk/CMakeLists.txt
+++ libcxx/trunk/CMakeLists.txt
@@ -307,9 +307,12 @@
 
 include(HandleLibCXXABI) # Setup the ABI library flags
 
-# Remove flags that may have snuck in.
-remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG
- -stdlib=libc++ -stdlib=libstdc++ -lc++abi -m32)
+if (NOT LIBCXX_STANDALONE_BUILD)
+  # Remove flags that may have snuck in.
+  remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG
+   -lc++abi -m32)
+endif()
+remove_flags(-stdlib=libc++ -stdlib=libstdc++)
 
 # FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC.
 # Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24809: [libcxx] [cmake] Strip possibly-inherited compiler flags in in-tree build only

2016-09-27 Thread Michał Górny via cfe-commits
mgorny marked an inline comment as done.
mgorny added a comment.

Thanks for the review. Tested and committing now.



Comment at: CMakeLists.txt:310
@@ -309,4 +309,3 @@
 
-# Remove flags that may have snuck in.
-remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG
- -stdlib=libc++ -stdlib=libstdc++ -lc++abi -m32)
+if (LIBCXX_STANDALONE_BUILD)
+  # Remove flags that may have snuck in.

EricWF wrote:
> We always want to strip `-stdlib=` because it's just nonsense to enable 
> the STL while building the STL.
Ok, moved it below the endif().


https://reviews.llvm.org/D24809



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


Re: [PATCH] D24954: [ToolChains] Disable OpenSUSE rules for SLES10

2016-09-27 Thread Michał Górny via cfe-commits
mgorny retitled this revision from "[ToolChains] Do not assume OpenSUSE for 
other SUSE variants" to "[ToolChains] Disable OpenSUSE rules for SLES10".
mgorny updated the summary for this revision.
mgorny updated this revision to Diff 72609.
mgorny added a comment.

Does this one look better for you? Yes, I know it's unsupported, that's why I 
don't really want to put any more effort on it than it is absolutely necessary 
to make clang work somehow.


https://reviews.llvm.org/D24954

Files:
  lib/Driver/ToolChains.cpp

Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3912,8 +3912,11 @@
 return UnknownDistro;
   }
 
-  if (D.getVFS().exists("/etc/SuSE-release"))
-return OpenSUSE;
+  File = llvm::MemoryBuffer::getFile("/etc/SuSE-release");
+  if (File)
+return llvm::StringSwitch(File.get()->getBuffer())
+  .StartsWith("SUSE Linux Enterprise Server 10", UnknownDistro)
+  .Default(OpenSUSE);
 
   if (D.getVFS().exists("/etc/exherbo-release"))
 return Exherbo;


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3912,8 +3912,11 @@
 return UnknownDistro;
   }
 
-  if (D.getVFS().exists("/etc/SuSE-release"))
-return OpenSUSE;
+  File = llvm::MemoryBuffer::getFile("/etc/SuSE-release");
+  if (File)
+return llvm::StringSwitch(File.get()->getBuffer())
+  .StartsWith("SUSE Linux Enterprise Server 10", UnknownDistro)
+  .Default(OpenSUSE);
 
   if (D.getVFS().exists("/etc/exherbo-release"))
 return Exherbo;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24119: [libc++] add linker option "-Wl, -z, defs" in standalone build

2016-09-27 Thread Michał Górny via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL282483: [cmake] Add linker option "-Wl,-z,defs" in 
standalone build (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D24119?vs=69944&id=72632#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24119

Files:
  libcxx/trunk/CMakeLists.txt

Index: libcxx/trunk/CMakeLists.txt
===
--- libcxx/trunk/CMakeLists.txt
+++ libcxx/trunk/CMakeLists.txt
@@ -319,6 +319,18 @@
 # so they don't get transformed into -Wno and -errors respectivly.
 remove_flags(-Wno-pedantic -pedantic-errors -pedantic)
 
+# FIXME: this is cribbed from HandleLLVMOptions.cmake.
+if(LIBCXX_STANDALONE_BUILD)
+  # Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO
+  # build might work on ELF but fail on MachO/COFF.
+  if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32 OR CYGWIN OR
+  ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR
+  ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") AND
+ NOT LLVM_USE_SANITIZER)
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
+  endif()
+endif()
+
 # Required flags ==
 set(LIBCXX_STANDARD_VER c++11 CACHE INTERNAL "internal option to change build 
dialect")
 add_compile_flags_if_supported(-std=${LIBCXX_STANDARD_VER})


Index: libcxx/trunk/CMakeLists.txt
===
--- libcxx/trunk/CMakeLists.txt
+++ libcxx/trunk/CMakeLists.txt
@@ -319,6 +319,18 @@
 # so they don't get transformed into -Wno and -errors respectivly.
 remove_flags(-Wno-pedantic -pedantic-errors -pedantic)
 
+# FIXME: this is cribbed from HandleLLVMOptions.cmake.
+if(LIBCXX_STANDALONE_BUILD)
+  # Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO
+  # build might work on ELF but fail on MachO/COFF.
+  if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32 OR CYGWIN OR
+  ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR
+  ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") AND
+ NOT LLVM_USE_SANITIZER)
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
+  endif()
+endif()
+
 # Required flags ==
 set(LIBCXX_STANDARD_VER c++11 CACHE INTERNAL "internal option to change build dialect")
 add_compile_flags_if_supported(-std=${LIBCXX_STANDARD_VER})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24119: [libc++] add linker option "-Wl, -z, defs" in standalone build

2016-09-27 Thread Michał Górny via cfe-commits
mgorny reopened this revision.
mgorny added a comment.
This revision is now accepted and ready to land.

I'm starting to regret that I've committed this. It breaks horribly any 
pure-LLVM build, i.e. without linking to libgcc_s. It seems that the build 
system is completely unprepared to link to compiler-rt or libunwind when 
linking the shared library, and with -DLIBCXX_HAS_GCC_S_LIB=OFF, it fails due 
to a lot of missing symbols. I am going to revert this until we get the build 
system working completely.


Repository:
  rL LLVM

https://reviews.llvm.org/D24119



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


Re: [PATCH] D24119: [libc++] add linker option "-Wl, -z, defs" in standalone build

2016-09-27 Thread Michał Górny via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D24119#554251, @rmaprath wrote:

> Doesn't `-DLIBCXXABI_USE_LLVM_UNWINDER=ON` make it possible to build without 
> `libgcc_s`? Or is this something else?


It's supposed to but it doesn't add the necessary libraries when linking 
libc++.so.


Repository:
  rL LLVM

https://reviews.llvm.org/D24119



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


[PATCH] D25003: [libcxxabi] [cmake] Update LLVM_CMAKE_PATH following install layout change

2016-09-28 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: danalbert, EricWF.
mgorny added a subscriber: cfe-commits.
Herald added subscribers: mgorny, beanz.

Update LLVM_CMAKE_PATH in stand-alone builds to match the new install layout 
used by LLVM 3.9+ where CMake files are installed into lib*/cmake/llvm rather 
than share/llvm/cmake.


https://reviews.llvm.org/D25003

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -49,7 +49,7 @@
 set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
 set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
 set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source 
tree")
-set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/share/llvm/cmake")
+set(LLVM_CMAKE_PATH 
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
 set(LLVM_LIT_PATH "${LLVM_PATH}/utils/lit/lit.py")
   else()
 message(FATAL_ERROR "llvm-config not found and LLVM_MAIN_SRC_DIR not 
defined. "


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -49,7 +49,7 @@
 set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
 set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
 set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
-set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/share/llvm/cmake")
+set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
 set(LLVM_LIT_PATH "${LLVM_PATH}/utils/lit/lit.py")
   else()
 message(FATAL_ERROR "llvm-config not found and LLVM_MAIN_SRC_DIR not defined. "
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25008: [libcxx] Include unwinder library in the linker script

2016-09-28 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added a reviewer: EricWF.
mgorny added a subscriber: cfe-commits.
Herald added subscribers: mgorny, beanz.

Include an appropriate unwinder library (-lunwind or -lgcc_s) when constructing 
a linker script for libc++. This is necessary since otherwise clang++ set for 
pure LLVM stack (compiler-rt + libc++) does not link against -lgcc_s and 
linking any C++ program fails due to missing unwinder symbols.

In order to handle additional libraries, the linker script generator has been 
modified to accept any number of libraries as the second argument. The ABI 
library name check has been removed as it is redundant to the checks done in 
CMake, and additional check for empty SCRIPT_ABI_LIBNAME has been added in 
CMake (the empty value resulted in wrong usage error in the script before).

The change has been tested with all four C++ ABI library variants. In each 
case, clang++ failed to link a simple "Hello world" program without either of 
the unwinder libraries.


https://reviews.llvm.org/D25008

Files:
  lib/CMakeLists.txt
  utils/gen_link_script/gen_link_script.py

Index: utils/gen_link_script/gen_link_script.py
===
--- utils/gen_link_script/gen_link_script.py
+++ utils/gen_link_script/gen_link_script.py
@@ -16,23 +16,24 @@
 sys.exit(1)
 
 def usage_and_exit():
-print_and_exit("Usage: ./gen_link_script.py [--help] [--dryrun] 
 ")
+print_and_exit("Usage: ./gen_link_script.py [--help] [--dryrun] 
 ")
 
 def help_and_exit():
 help_msg = \
 """Usage
 
-  gen_link_script.py [--help] [--dryrun]  
+  gen_link_script.py [--help] [--dryrun]  
 
-  Generate a linker script that links libc++ to the proper ABI library.
+  Generate a linker script that links libc++ to the proper ABI library
+  (and other dependant libraries).
   The script replaces the specified libc++ symlink.
   An example script for c++abi would look like "INPUT(libc++.so.1 -lc++abi)".
 
 Arguments
- The top level symlink to the versioned libc++ shared
 library. This file is replaced with a linker script.
- - The name of the ABI library to use in the linker 
script.
-The name must be one of [c++abi, stdc++, supc++, 
cxxrt].
+- The list of libraries (-l flags) to use in the linker
+script.
 
 Exit Status:
   0 if OK,
@@ -53,28 +54,22 @@
 if len(args) != 2:
 usage_and_exit()
 symlink_file = args[0]
-abi_libname = args[1]
-return dryrun, symlink_file, abi_libname
+abi_libs = args[1]
+return dryrun, symlink_file, abi_libs
 
 def main():
-dryrun, symlink_file, abi_libname = parse_args()
+dryrun, symlink_file, abi_libs = parse_args()
 
 # Check that the given libc++.so file is a valid symlink.
 if not os.path.islink(symlink_file):
 print_and_exit("symlink file %s is not a symlink" % symlink_file)
 
 # Read the symlink so we know what libc++ to link to in the linker script.
 linked_libcxx = os.readlink(symlink_file)
 
-# Check that the abi_libname is one of the supported values.
-supported_abi_list = ['c++abi', 'stdc++', 'supc++', 'cxxrt']
-if abi_libname not in supported_abi_list:
-print_and_exit("abi name '%s' is not supported: Use one of %r" %
-(abi_libname, supported_abi_list))
-
 # Generate the linker script contents and print the script and destination
 # information.
-contents = "INPUT(%s -l%s)" % (linked_libcxx, abi_libname)
+contents = "INPUT(%s %s)" % (linked_libcxx, abi_libs)
 print("GENERATING SCRIPT: '%s' as file %s" % (contents, symlink_file))
 
 # Remove the existing libc++ symlink and replace it with the script.
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -230,15 +230,26 @@
   set(SCRIPT_ABI_LIBNAME "${LIBCXX_CXX_ABI_LIBRARY}")
   if (SCRIPT_ABI_LIBNAME STREQUAL "cxxabi_shared")
 set(SCRIPT_ABI_LIBNAME "c++abi")
+  elseif(SCRIPT_ABI_LIBNAME STREQUAL "")
+message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT can not find an ABI 
library")
   endif()
+
+  # Prepare a complete list of dependant libraries for linking.
+  set(SCRIPT_LINKED_LIBS "-l${SCRIPT_ABI_LIBNAME}")
+  if (LIBCXXABI_USE_LLVM_UNWINDER)
+set(SCRIPT_LINKED_LIBS "${SCRIPT_LINKED_LIBS} -lunwind")
+  elseif (LIBCXX_HAS_GCC_S_LIB)
+set(SCRIPT_LINKED_LIBS "${SCRIPT_LINKED_LIBS} -lgcc_s")
+  endif()
+
   # Generate a linker script inplace of a libc++.so symlink. Rerun this command
   # after cxx builds.
   add_custom_command(TARGET cxx_shared POST_BUILD
 COMMAND
   ${PYTHON_EXECUTABLE} 
${LIBCXX_SOURCE_DIR}/utils/gen_link_script/gen_link_script.py
 ARGS
   "$"
-  "${SCRIPT_ABI_LIBNAME}"
+  "${SCRIPT_LINKED_LIBS}"
 WORKING_DIRECTORY ${LIBCXX_BUILD_DIR}
   )
 endif()


Index: utils/gen_link_script/gen_link_

Re: [PATCH] D25008: [libcxx] Include unwinder library in the linker script

2016-09-28 Thread Michał Górny via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D25008#555041, @rmaprath wrote:

> The patch generally makes sense to me.
>
> I wonder if the test configuration can also benefit from this; 
> `test/libcxx/test/target_info.py` manually updates the link line to use 
> `-lgcc_s` or `-lunwind` depending on how the build is configured. Presumably, 
> this workaround will no longer be needed if the linker script does that for 
> us?


I was originally thinking about that but we don't use the linker script on 
APPLE and I have no clue how that system is handled or whether it suffers from 
the same issue at all.

> (Note:- `-lgcc_s` is linked twice there to satisfy some weird dependency, 
> it's not a mistake)


Thanks for letting me know. I almost prepared a patch for that ;-D.


https://reviews.llvm.org/D25008



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


[PATCH] [Commented On] D25008: [libcxx] Include unwinder library in the linker script

2016-09-29 Thread Michał Górny via cfe-commits
mgorny added a comment.

Side note: I see that gcc is solving similar problem via .spec files for its 
libraries, e.g.:

  $ cat /usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/libgomp.spec 
  # This spec file is read by gcc when linking.  It is used to specify the
  # standard libraries we need in order to link with libgomp.
  *link_gomp: -lgomp %{static: -ldl }

If we wanted to be more portable, I guess we could establish something similar 
for clang, and install such a file along with libc++. However, I don't know if 
that's a problem.


https://reviews.llvm.org/D25008



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


[PATCH] [Commented On] D24954: [ToolChains] Disable OpenSUSE rules for SLES10

2016-09-29 Thread Michał Górny via cfe-commits
mgorny added a comment.

@ismail, ping.


https://reviews.llvm.org/D24954



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


[PATCH] D25093: [libcxx] [cmake] Allow testing against installed LLVM with no sources

2016-09-30 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: EricWF, beanz.
mgorny added a subscriber: cfe-commits.

Adjust the stand-alone build files to accept either CMake files from 
LLVM_CMAKE_PATH or from LLVM_MAIN_SRC_DIR instead of requiring both.  This 
makes it possible to run libcxx  tests on top of installed LLVM and lit, 
without having to unpack a copy of LLVM sources. Furthermore, it avoids adding 
duplicate paths.


https://reviews.llvm.org/D25093

Files:
  cmake/Modules/HandleOutOfTreeLLVM.cmake


Index: cmake/Modules/HandleOutOfTreeLLVM.cmake
===
--- cmake/Modules/HandleOutOfTreeLLVM.cmake
+++ cmake/Modules/HandleOutOfTreeLLVM.cmake
@@ -43,21 +43,16 @@
 return()
   endif()
 
-  if (NOT EXISTS ${LLVM_MAIN_SRC_DIR})
-set(LLVM_FOUND OFF)
-message(WARNING "Not found: ${LLVM_MAIN_SRC_DIR}")
-return()
-  endif()
-
-  if(NOT EXISTS ${LLVM_CMAKE_PATH})
+  if (EXISTS "${LLVM_CMAKE_PATH}")
+list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
+  elseif (EXISTS "${LLVM_MAIN_SRC_DIR}/cmake/modules")
+list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
+  else()
 set(LLVM_FOUND OFF)
-message(WARNING "Not found: ${LLVM_CMAKE_PATH}")
+message(WARNING "Neither ${LLVM_CMAKE_PATH} nor 
${LLVM_MAIN_SRC_DIR}/cmake/modules found")
 return()
   endif()
 
-  list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
-  list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
-
   set(LLVM_FOUND ON)
 endmacro(find_llvm_parts)
 


Index: cmake/Modules/HandleOutOfTreeLLVM.cmake
===
--- cmake/Modules/HandleOutOfTreeLLVM.cmake
+++ cmake/Modules/HandleOutOfTreeLLVM.cmake
@@ -43,21 +43,16 @@
 return()
   endif()
 
-  if (NOT EXISTS ${LLVM_MAIN_SRC_DIR})
-set(LLVM_FOUND OFF)
-message(WARNING "Not found: ${LLVM_MAIN_SRC_DIR}")
-return()
-  endif()
-
-  if(NOT EXISTS ${LLVM_CMAKE_PATH})
+  if (EXISTS "${LLVM_CMAKE_PATH}")
+list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
+  elseif (EXISTS "${LLVM_MAIN_SRC_DIR}/cmake/modules")
+list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
+  else()
 set(LLVM_FOUND OFF)
-message(WARNING "Not found: ${LLVM_CMAKE_PATH}")
+message(WARNING "Neither ${LLVM_CMAKE_PATH} nor ${LLVM_MAIN_SRC_DIR}/cmake/modules found")
 return()
   endif()
 
-  list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
-  list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
-
   set(LLVM_FOUND ON)
 endmacro(find_llvm_parts)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25093: [libcxx] [cmake] Allow testing against installed LLVM with no sources

2016-09-30 Thread Michał Górny via cfe-commits
mgorny added a comment.

Combined with https://reviews.llvm.org/D25076 (on llvm), this lets me run 
libcxx test suite on top of installed LLVM+lit, without LLVM sources.


https://reviews.llvm.org/D25093



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


[PATCH] D23745: [cmake] Update lit search to match the one in LLVM

2016-10-01 Thread Michał Górny via cfe-commits
mgorny retitled this revision from "cmake: Adjust llvm-lit search to match the 
one in LLVM" to "[cmake] Update lit search to match the one in LLVM".
mgorny updated the summary for this revision.
mgorny updated this revision to Diff 73192.
Herald added a subscriber: beanz.

https://reviews.llvm.org/D23745

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -124,6 +124,7 @@
 endif()
 
 if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
+  # Note: path not really used, except for checking if lit was found
   set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
   if(NOT LLVM_UTILS_PROVIDED)
 add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/FileCheck utils/FileCheck)
@@ -140,8 +141,10 @@
   endif()
 else()
   # Seek installed Lit.
-  find_program(LLVM_LIT "lit.py" ${LLVM_MAIN_SRC_DIR}/utils/lit
-DOC "Path to lit.py")
+  find_program(LLVM_LIT
+   NAMES llvm-lit lit.py lit
+   PATHS "${LLVM_MAIN_SRC_DIR}/utils/lit"
+   DOC "Path to lit.py")
 endif()
 
 if(LLVM_LIT)


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -124,6 +124,7 @@
 endif()
 
 if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
+  # Note: path not really used, except for checking if lit was found
   set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
   if(NOT LLVM_UTILS_PROVIDED)
 add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/FileCheck utils/FileCheck)
@@ -140,8 +141,10 @@
   endif()
 else()
   # Seek installed Lit.
-  find_program(LLVM_LIT "lit.py" ${LLVM_MAIN_SRC_DIR}/utils/lit
-DOC "Path to lit.py")
+  find_program(LLVM_LIT
+   NAMES llvm-lit lit.py lit
+   PATHS "${LLVM_MAIN_SRC_DIR}/utils/lit"
+   DOC "Path to lit.py")
 endif()
 
 if(LLVM_LIT)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25157: [compiler-rt] [cmake] Respect COMPILER_RT_BUILD_* consistently for libs & tests

2016-10-01 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: beanz, samsonov.
mgorny added a subscriber: cfe-commits.
Herald added subscribers: dberris, kubabrecka, srhines, danalbert, tberghammer.

Refactor the code to respect COMPILER_RT_BUILD_SANITIZERS and 
COMPILER_RT_BUILD_XRAY consistently for both libraries and tests. In order to 
achieve that, factor those variables in when setting COMPILER_RT_* in 
config-ix.cmake. This makes the COMPILER_RT_* variables suitable for 
determining both whether to build libraries and whether to run tests.

Update the conditionals in lib/CMakeLists.txt appropriately to remove 
unnecessary double-use of COMPILER_RT_BUILD_* variables when COMPILER_RT_HAS_* 
already controls the particular component.

Fix sanitizer_common tests to respect COMPILER_RT_HAS_* when determining which 
tools are supported.


https://reviews.llvm.org/D25157

Files:
  cmake/config-ix.cmake
  lib/CMakeLists.txt
  test/sanitizer_common/CMakeLists.txt

Index: test/sanitizer_common/CMakeLists.txt
===
--- test/sanitizer_common/CMakeLists.txt
+++ test/sanitizer_common/CMakeLists.txt
@@ -4,13 +4,20 @@
 set(SANITIZER_COMMON_TESTSUITES)
 
 set(SUPPORTED_TOOLS)
-if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD" AND NOT ANDROID)
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD" AND NOT ANDROID AND
+   COMPILER_RT_HAS_ASAN)
   list(APPEND SUPPORTED_TOOLS asan)
 endif()
 if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT ANDROID)
-  list(APPEND SUPPORTED_TOOLS tsan)
-  list(APPEND SUPPORTED_TOOLS msan)
-  list(APPEND SUPPORTED_TOOLS lsan)
+  if(COMPILER_RT_HAS_TSAN)
+list(APPEND SUPPORTED_TOOLS tsan)
+  endif()
+  if(COMPILER_RT_HAS_MSAN)
+list(APPEND SUPPORTED_TOOLS msan)
+  endif()
+  if(COMPILER_RT_HAS_LSAN)
+list(APPEND SUPPORTED_TOOLS lsan)
+  endif()
 endif()
 
 # Create a separate config for each tool we support.
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -8,8 +8,7 @@
 # sanitizers or xray (or both).
 #
 #TODO: Refactor sanitizer_common into smaller pieces (e.g. flag parsing, utils).
-if (COMPILER_RT_HAS_SANITIZER_COMMON AND
-(COMPILER_RT_BUILD_SANITIZERS OR COMPILER_RT_BUILD_XRAY))
+if (COMPILER_RT_HAS_SANITIZER_COMMON)
   add_subdirectory(sanitizer_common)
 endif()
 
@@ -36,27 +35,27 @@
   endif()
 endfunction()
 
-if(COMPILER_RT_BUILD_SANITIZERS)
-  compiler_rt_build_runtime(interception)
+# the following set is conditional to COMPILER_RT_BUILD_SANITIZERS
+# (via COMPILER_RT_HAS_* in config-ix.cmake)
+compiler_rt_build_runtime(interception)
 
-  if(COMPILER_RT_HAS_SANITIZER_COMMON)
-add_subdirectory(stats)
-add_subdirectory(lsan)
-add_subdirectory(ubsan)
-  endif()
+if(COMPILER_RT_BUILD_SANITIZERS AND COMPILER_RT_HAS_SANITIZER_COMMON)
+  add_subdirectory(stats)
+  add_subdirectory(lsan)
+  add_subdirectory(ubsan)
+endif()
 
-  compiler_rt_build_sanitizer(asan)
-  compiler_rt_build_sanitizer(dfsan)
-  compiler_rt_build_sanitizer(msan)
-  compiler_rt_build_sanitizer(tsan tsan/dd)
-  compiler_rt_build_sanitizer(safestack)
-  compiler_rt_build_sanitizer(cfi)
-  compiler_rt_build_sanitizer(esan)
-  compiler_rt_build_sanitizer(scudo)
+compiler_rt_build_sanitizer(asan)
+compiler_rt_build_sanitizer(dfsan)
+compiler_rt_build_sanitizer(msan)
+compiler_rt_build_sanitizer(tsan tsan/dd)
+compiler_rt_build_sanitizer(safestack)
+compiler_rt_build_sanitizer(cfi)
+compiler_rt_build_sanitizer(esan)
+compiler_rt_build_sanitizer(scudo)
 
-  compiler_rt_build_runtime(profile)
-endif()
+compiler_rt_build_runtime(profile)
 
-if(COMPILER_RT_BUILD_XRAY)
-  compiler_rt_build_runtime(xray)
-endif()
+# the following set is conditional to COMPILER_RT_BUILD_XRAY
+# (via COMPILER_RT_HAS_* in config-ix.cmake)
+compiler_rt_build_runtime(xray)
Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -416,20 +416,23 @@
 list_replace(COMPILER_RT_SANITIZERS_TO_BUILD all "${ALL_SANITIZERS}")
 
 if (SANITIZER_COMMON_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
+(COMPILER_RT_BUILD_SANITIZERS OR COMPILER_RT_BUILD_XRAY) AND
 (OS_NAME MATCHES "Android|Darwin|Linux|FreeBSD" OR
 (OS_NAME MATCHES "Windows" AND (NOT MINGW AND NOT CYGWIN
   set(COMPILER_RT_HAS_SANITIZER_COMMON TRUE)
 else()
   set(COMPILER_RT_HAS_SANITIZER_COMMON FALSE)
 endif()
 
-if (COMPILER_RT_HAS_SANITIZER_COMMON)
+if (COMPILER_RT_HAS_SANITIZER_COMMON AND
+COMPILER_RT_BUILD_SANITIZERS)
   set(COMPILER_RT_HAS_INTERCEPTION TRUE)
 else()
   set(COMPILER_RT_HAS_INTERCEPTION FALSE)
 endif()
 
-if (COMPILER_RT_HAS_SANITIZER_COMMON AND ASAN_SUPPORTED_ARCH)
+if (COMPILER_RT_HAS_SANITIZER_COMMON AND ASAN_SUPPORTED_ARCH AND
+COMPILER_RT_BUILD_SANITIZERS)
   set(COMPILER_RT_HAS_ASAN TRUE)
 else()
   set(COMPILER_RT_HAS_ASAN FALSE)
@@ -444,76 +447,87 @@
 # TODO: Add builtins support.
 

[PATCH] D25157: [compiler-rt] [cmake] Respect COMPILER_RT_BUILD_* for libs, headers and tests

2016-10-01 Thread Michał Górny via cfe-commits
mgorny retitled this revision from "[compiler-rt] [cmake] Respect 
COMPILER_RT_BUILD_* consistently for libs & tests" to "[compiler-rt] [cmake] 
Respect COMPILER_RT_BUILD_* for libs, headers and tests".
mgorny updated the summary for this revision.
mgorny updated this revision to Diff 73198.
mgorny added a comment.

Updated to control installing tests as well.


https://reviews.llvm.org/D25157

Files:
  cmake/config-ix.cmake
  include/CMakeLists.txt
  lib/CMakeLists.txt
  test/sanitizer_common/CMakeLists.txt

Index: test/sanitizer_common/CMakeLists.txt
===
--- test/sanitizer_common/CMakeLists.txt
+++ test/sanitizer_common/CMakeLists.txt
@@ -4,13 +4,20 @@
 set(SANITIZER_COMMON_TESTSUITES)
 
 set(SUPPORTED_TOOLS)
-if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD" AND NOT ANDROID)
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD" AND NOT ANDROID AND
+   COMPILER_RT_HAS_ASAN)
   list(APPEND SUPPORTED_TOOLS asan)
 endif()
 if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT ANDROID)
-  list(APPEND SUPPORTED_TOOLS tsan)
-  list(APPEND SUPPORTED_TOOLS msan)
-  list(APPEND SUPPORTED_TOOLS lsan)
+  if(COMPILER_RT_HAS_TSAN)
+list(APPEND SUPPORTED_TOOLS tsan)
+  endif()
+  if(COMPILER_RT_HAS_MSAN)
+list(APPEND SUPPORTED_TOOLS msan)
+  endif()
+  if(COMPILER_RT_HAS_LSAN)
+list(APPEND SUPPORTED_TOOLS lsan)
+  endif()
 endif()
 
 # Create a separate config for each tool we support.
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -8,8 +8,7 @@
 # sanitizers or xray (or both).
 #
 #TODO: Refactor sanitizer_common into smaller pieces (e.g. flag parsing, utils).
-if (COMPILER_RT_HAS_SANITIZER_COMMON AND
-(COMPILER_RT_BUILD_SANITIZERS OR COMPILER_RT_BUILD_XRAY))
+if (COMPILER_RT_HAS_SANITIZER_COMMON)
   add_subdirectory(sanitizer_common)
 endif()
 
@@ -36,27 +35,27 @@
   endif()
 endfunction()
 
-if(COMPILER_RT_BUILD_SANITIZERS)
-  compiler_rt_build_runtime(interception)
+# the following set is conditional to COMPILER_RT_BUILD_SANITIZERS
+# (via COMPILER_RT_HAS_* in config-ix.cmake)
+compiler_rt_build_runtime(interception)
 
-  if(COMPILER_RT_HAS_SANITIZER_COMMON)
-add_subdirectory(stats)
-add_subdirectory(lsan)
-add_subdirectory(ubsan)
-  endif()
+if(COMPILER_RT_BUILD_SANITIZERS AND COMPILER_RT_HAS_SANITIZER_COMMON)
+  add_subdirectory(stats)
+  add_subdirectory(lsan)
+  add_subdirectory(ubsan)
+endif()
 
-  compiler_rt_build_sanitizer(asan)
-  compiler_rt_build_sanitizer(dfsan)
-  compiler_rt_build_sanitizer(msan)
-  compiler_rt_build_sanitizer(tsan tsan/dd)
-  compiler_rt_build_sanitizer(safestack)
-  compiler_rt_build_sanitizer(cfi)
-  compiler_rt_build_sanitizer(esan)
-  compiler_rt_build_sanitizer(scudo)
+compiler_rt_build_sanitizer(asan)
+compiler_rt_build_sanitizer(dfsan)
+compiler_rt_build_sanitizer(msan)
+compiler_rt_build_sanitizer(tsan tsan/dd)
+compiler_rt_build_sanitizer(safestack)
+compiler_rt_build_sanitizer(cfi)
+compiler_rt_build_sanitizer(esan)
+compiler_rt_build_sanitizer(scudo)
 
-  compiler_rt_build_runtime(profile)
-endif()
+compiler_rt_build_runtime(profile)
 
-if(COMPILER_RT_BUILD_XRAY)
-  compiler_rt_build_runtime(xray)
-endif()
+# the following set is conditional to COMPILER_RT_BUILD_XRAY
+# (via COMPILER_RT_HAS_* in config-ix.cmake)
+compiler_rt_build_runtime(xray)
Index: include/CMakeLists.txt
===
--- include/CMakeLists.txt
+++ include/CMakeLists.txt
@@ -1,17 +1,41 @@
-set(SANITIZER_HEADERS
-  sanitizer/allocator_interface.h
-  sanitizer/asan_interface.h
-  sanitizer/common_interface_defs.h
-  sanitizer/coverage_interface.h
-  sanitizer/dfsan_interface.h
-  sanitizer/esan_interface.h
-  sanitizer/linux_syscall_hooks.h
-  sanitizer/lsan_interface.h
-  sanitizer/msan_interface.h
-  sanitizer/tsan_interface_atomic.h)
+set(SANITIZER_HEADERS)
+if(COMPILER_RT_HAS_SANITIZER_COMMON)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/allocator_interface.h
+   sanitizer/common_interface_defs.h
+   sanitizer/coverage_interface.h
+   sanitizer/linux_syscall_hooks.h)
+endif()
+if(COMPILER_RT_HAS_ASAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/asan_interface.h)
+endif()
+if(COMPILER_RT_HAS_DFSAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/dfsan_interface.h)
+endif()
+if(COMPILER_RT_HAS_ESAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/esan_interface.h)
+endif()
+if(COMPILER_RT_HAS_LSAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/lsan_interface.h)
+endif()
+if(COMPILER_RT_HAS_MSAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/msan_interface.h)
+endif()
+if(COMPILER_RT_HAS_TSAN)
+  list(APPEND SANITIZER_HEADERS
+   sanitizer/tsan_interface_atomic.h)
+endif()
 
-set(XRAY_HEADERS
-  xray/xray_interface.h)
+set(XRAY_HEADERS)
+if(COMPILER_RT_BUILD_XRAY)
+  list(APPEND XRAY_HEADERS
+   xray/xray_interface.h)
+endif()

[PATCH] D25161: [cmake] Install 'clang-cpp' symlink

2016-10-02 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: beanz, doug.gregor.
mgorny added a subscriber: cfe-commits.
Herald added a subscriber: emaste.

Install the 'clang-cpp' symlink used to spawn the preprocessor. The code 
handling this suffix is already included in Driver. FreeBSD is already creating 
such a symlink in ports, and a similar one was requested by Gentoo/FreeBSD 
team. The goal is to handle software that takes a C preprocessor via a variable 
but does not handle passing options correctly (i.e. 'clang -E' does not work).

Bug: https://bugs.gentoo.org/478810


https://reviews.llvm.org/D25161

Files:
  tools/driver/CMakeLists.txt


Index: tools/driver/CMakeLists.txt
===
--- tools/driver/CMakeLists.txt
+++ tools/driver/CMakeLists.txt
@@ -52,7 +52,7 @@
 add_dependencies(clang clang-headers)
 
 if(NOT CLANG_LINKS_TO_CREATE)
-  set(CLANG_LINKS_TO_CREATE clang++ clang-cl)
+  set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp)
 
   if (WIN32)
 list(APPEND CLANG_LINKS_TO_CREATE ../msbuild-bin/cl)


Index: tools/driver/CMakeLists.txt
===
--- tools/driver/CMakeLists.txt
+++ tools/driver/CMakeLists.txt
@@ -52,7 +52,7 @@
 add_dependencies(clang clang-headers)
 
 if(NOT CLANG_LINKS_TO_CREATE)
-  set(CLANG_LINKS_TO_CREATE clang++ clang-cl)
+  set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp)
 
   if (WIN32)
 list(APPEND CLANG_LINKS_TO_CREATE ../msbuild-bin/cl)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25008: [libcxx] Include unwinder library in the linker script

2016-10-02 Thread Michał Górny via cfe-commits
mgorny planned changes to this revision.
mgorny added a comment.

I will be reworking this to use CMake's PRIVATE and PUBLIC linked libs 
consistently across the build, linker scripts and possibly tests.

@EricWF, would you prefer if I killed the `add_library_flags*` macros or 
extended them to support specifying PRIVATE and PUBLIC libs separately?


https://reviews.llvm.org/D25008



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


[PATCH] D24933: Enable configuration files in clang

2016-10-02 Thread Michał Górny via cfe-commits
mgorny requested changes to this revision.
mgorny added a reviewer: mgorny.
mgorny added a comment.
This revision now requires changes to proceed.

Few minor nits. However, I'd like to say that I like the idea in general and 
see forward to deploy it in Gentoo.

One use case which doesn't seem to have been mentioned yes is setting the 
default -rtlib= and -stdlib=. Currently we're only able to set the defaults at 
compile-time but it generally sucks to rebuild the compiler to change the 
default. With this, we'd be able to set them via the system config file ;-).



> driver.cpp:334
> +  // Try reading options from configuration file.
> +  static const char * const SearchDirs[] = { "~/.llvm", "/etc/llvm" };
> +  llvm::SmallString<128> ConfigFile;

1. I'm not sure if others would agree with me but I think it would be better to 
move those default paths straight to LLVM. If others tools are to adopt those 
configuration files, it would only be reasonable to use the same search paths 
consistently and not repeat them in every tool.

2. I think the `/etc` prefix should be made configurable via CMake options. One 
case that would benefit from this is Gentoo Prefix where the Gentoo system root 
is located in a subdirectory of /.

> driver.cpp:336
> +  llvm::SmallString<128> ConfigFile;
> +  auto SRes = llvm::cl::findConfigFile(ConfigFile, argv, SearchDirs, 
> "clang");
> +  llvm::cl::reportConfigFileSearchError(SRes, ConfigFile, SearchDirs, 
> ProgName);

1. You need to update this, following your update on 
https://reviews.llvm.org/D24926.
2. I think you need to use `clang.cfg` here.

https://reviews.llvm.org/D24933



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


[PATCH] D25161: [cmake] Install 'clang-cpp' symlink

2016-10-02 Thread Michał Górny via cfe-commits
mgorny added a comment.

Thanks for the review. Proceeding with the commit now.


https://reviews.llvm.org/D25161



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


[PATCH] D25161: [cmake] Install 'clang-cpp' symlink

2016-10-03 Thread Michał Górny via cfe-commits
mgorny closed this revision.
mgorny added a comment.

I'm going to close this manually since it seems that Phabricator commit 
processing is stuck somehow.


https://reviews.llvm.org/D25161



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


[PATCH] D25003: [libcxxabi] [cmake] Update LLVM_CMAKE_PATH following install layout change

2016-10-03 Thread Michał Górny via cfe-commits
mgorny abandoned this revision.
mgorny added a comment.

Independently fixed in rL283100.


https://reviews.llvm.org/D25003



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


Re: [llvm-dev] Upgrading phabricator

2016-10-03 Thread Michał Górny via cfe-commits
On Mon, 3 Oct 2016 13:47:08 +
Sjoerd Meijer via cfe-commits  wrote:

> I just committed to Clang and noticed that the corresponding Phabricator 
> ticket does not get automatically closed (I have "Differential Revision:" in 
> my commit message and believe I didn't make a typo).
> Is it just me, or is this is broken after the upgrade? For committing to LLVM 
> this still seems to work.

Just to clarify, it seems that Phabricator stopped processing
(receiving?) new commits one or two days ago. However, it used to work
after the upgrade, so that's probably unrelated.

-- 
Best regards,
Michał Górny



pgpDCvljLQbKn.pgp
Description: OpenPGP digital signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23832: cmake: Add ordering dep between HTML Sphinx docs and manpages

2016-10-03 Thread Michał Górny via cfe-commits
mgorny abandoned this revision.
mgorny added a comment.

This is no longer necessary since updated patch to 
https://reviews.llvm.org/D23755 handles all the projects using the functions.


https://reviews.llvm.org/D23832



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


[PATCH] D24933: Enable configuration files in clang

2016-10-04 Thread Michał Górny via cfe-commits
mgorny added inline comments.


> driver.cpp:314
> +
> +static llvm::cl::SearchResult findConfigFileFromProgramName(
> +llvm::SmallVectorImpl &ConfigName, StringRef ProgramName) {

Please document what this function does, exactly. I see you've documented it in 
call site but a doc here would be helpful as well.

> driver.cpp:376
> +  // implicitly. First try deduce configuration from executable. For 
> instance,
> +  // file 'armv7l-clang' applies config file 'armv7l.cfg'.
> +  if (SRes == llvm::cl::SearchResult::NotSpecified) {

Are you sure about the name? I would rather see `TARGET-clang.cfg` than a name 
that doesn't explicitly mention that the file is for clang.

https://reviews.llvm.org/D24933



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


[PATCH] D25267: cmake: Set CMAKE_INSTALL_RPATH in Clang when building separately from LLVM

2016-10-05 Thread Michał Górny via cfe-commits
mgorny added a comment.

I presume you copied it out of LLVM. If that's the case, please add an comment 
above stating where it's been copied from.


https://reviews.llvm.org/D25267



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


[PATCH] D25314: [libcxxabi] [cmake] Handle missing LIBUNWIND_* directories gracefully

2016-10-06 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: EricWF, asl.
mgorny added a subscriber: cfe-commits.
Herald added a subscriber: beanz.

Add LIBUNWIND_* directories to include path only if they were actually
found, in order to fix the CMake error. Both of the directories are
usually unnecessary since libcxxabi uses only the common part of
unwind.h that is supplied both by GCC and Clang.


https://reviews.llvm.org/D25314

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -390,8 +390,12 @@
 set(LIBCXXABI_LIBUNWIND_SOURCES "")
   endif()
 
-  include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
-  include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
+  if (NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL 
"LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
+include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
+  endif()
+  if (NOT LIBCXXABI_LIBUNWIND_SOURCES STREQUAL "")
+include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
+  endif()
 endif()
 
 # Add source code. This also contains all of the logic for deciding linker 
flags


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -390,8 +390,12 @@
 set(LIBCXXABI_LIBUNWIND_SOURCES "")
   endif()
 
-  include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
-  include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
+  if (NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
+include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
+  endif()
+  if (NOT LIBCXXABI_LIBUNWIND_SOURCES STREQUAL "")
+include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
+  endif()
 endif()
 
 # Add source code. This also contains all of the logic for deciding linker flags
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-06 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added a reviewer: ddunbar.
mgorny added a subscriber: cfe-commits.
Herald added a subscriber: dberris.

Make the -print-libgcc-file-name option print an appropriate compiler
runtime library, that is libgcc.a if gcc runtime is used
and an appropriate compiler-rt library if that runtime is used.

The main use for this is to allow linking executables built with
-nodefaultlibs (e.g. to avoid linking to the standard C++ library) to
the compiler runtime library, e.g. using:

  clang++ ... -nodefaultlibs $(clang++ ... -print-libgcc-file-name)

in which case currently a program built like this linked to the gcc
runtime unconditionally. The patch fixes it to use compiler-rt libraries
instead when compiler-rt is the active runtime.


https://reviews.llvm.org/D25338

Files:
  docs/CommandGuide/clang.rst
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -994,7 +994,15 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  llvm::outs() << TC.getCompilerRTArgString(C.getArgs(), "builtins") << 
"\n";
+  break;
+case ToolChain::RLT_Libgcc:
+  llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+  break;
+}
 return false;
   }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1861,7 +1861,8 @@
 def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>,
   HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
 def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">,
-  HelpText<"Print the library path for \"libgcc.a\"">;
+  HelpText<"Print the library path for the currently used compiler runtime "
+   "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\" 
appropriately)">;
 def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;
 def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
 def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -394,7 +394,8 @@
 
 .. option:: -print-libgcc-file-name
 
-  Print the library path for "libgcc.a".
+  Print the library path for the currently used compiler runtime library
+  ("libgcc.a" or "libclang_rt.builtins.*.a" appropriately).
 
 .. option:: -print-prog-name=
 


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -994,7 +994,15 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  llvm::outs() << TC.getCompilerRTArgString(C.getArgs(), "builtins") << "\n";
+  break;
+case ToolChain::RLT_Libgcc:
+  llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+  break;
+}
 return false;
   }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1861,7 +1861,8 @@
 def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>,
   HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
 def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">,
-  HelpText<"Print the library path for \"libgcc.a\"">;
+  HelpText<"Print the library path for the currently used compiler runtime "
+   "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\" appropriately)">;
 def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;
 def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
 def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -394,7 +394,8 @@
 
 .. option:: -print-libgcc-file-name
 
-  Print the library path for "libgcc.a".
+  Print the library path for the currently used compiler runtime library
+  ("libgcc.a" or "libclang_rt.builtins.*.a" appropriately).
 
 .. option:: -print-prog-name=
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25008: [cmake] Split linked libraries into private & public, for linker script

2016-10-06 Thread Michał Górny via cfe-commits
mgorny retitled this revision from "[libcxx] Include unwinder library in the 
linker script" to "[cmake] Split linked libraries into private & public, for 
linker script".
mgorny updated the summary for this revision.
mgorny updated this revision to Diff 73840.
mgorny added a comment.
Herald added a subscriber: modocache.

Here's my patch v2. I have to admit it's not very different from the original 
one but the goal is to provide a more generic interface for future improvement.


https://reviews.llvm.org/D25008

Files:
  CMakeLists.txt
  lib/CMakeLists.txt
  utils/gen_link_script/gen_link_script.py

Index: utils/gen_link_script/gen_link_script.py
===
--- utils/gen_link_script/gen_link_script.py
+++ utils/gen_link_script/gen_link_script.py
@@ -22,17 +22,16 @@
 help_msg = \
 """Usage
 
-  gen_link_script.py [--help] [--dryrun]  
+  gen_link_script.py [--help] [--dryrun]  
 
   Generate a linker script that links libc++ to the proper ABI library.
   The script replaces the specified libc++ symlink.
   An example script for c++abi would look like "INPUT(libc++.so.1 -lc++abi)".
 
 Arguments
- The top level symlink to the versioned libc++ shared
 library. This file is replaced with a linker script.
- - The name of the ABI library to use in the linker script.
-The name must be one of [c++abi, stdc++, supc++, cxxrt].
+ - List of library names to include in linker script.
 
 Exit Status:
   0 if OK,
@@ -53,28 +52,25 @@
 if len(args) != 2:
 usage_and_exit()
 symlink_file = args[0]
-abi_libname = args[1]
-return dryrun, symlink_file, abi_libname
+public_libs = args[1].split(';')
+return dryrun, symlink_file, public_libs
 
 def main():
-dryrun, symlink_file, abi_libname = parse_args()
+dryrun, symlink_file, public_libs = parse_args()
 
 # Check that the given libc++.so file is a valid symlink.
 if not os.path.islink(symlink_file):
 print_and_exit("symlink file %s is not a symlink" % symlink_file)
 
 # Read the symlink so we know what libc++ to link to in the linker script.
 linked_libcxx = os.readlink(symlink_file)
 
-# Check that the abi_libname is one of the supported values.
-supported_abi_list = ['c++abi', 'stdc++', 'supc++', 'cxxrt']
-if abi_libname not in supported_abi_list:
-print_and_exit("abi name '%s' is not supported: Use one of %r" %
-(abi_libname, supported_abi_list))
+# Prepare the list of public libraries to link.
+public_libs = ['-l%s' % l for l in public_libs]
 
 # Generate the linker script contents and print the script and destination
 # information.
-contents = "INPUT(%s -l%s)" % (linked_libcxx, abi_libname)
+contents = "INPUT(%s %s)" % (linked_libcxx, ' '.join(public_libs))
 print("GENERATING SCRIPT: '%s' as file %s" % (contents, symlink_file))
 
 # Remove the existing libc++ symlink and replace it with the script.
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -33,9 +33,13 @@
 
 add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}")
 
-add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,--whole-archive" "-Wl,-Bstatic")
-add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
-add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,-Bdynamic" "-Wl,--no-whole-archive")
+if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
+  add_library_flags("-Wl,--whole-archive" "-Wl,-Bstatic")
+  add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
+  add_library_flags("-Wl,-Bdynamic" "-Wl,--no-whole-archive")
+else()
+  list(APPEND LIBCXX_LIBRARIES_PUBLIC "${LIBCXX_CXX_ABI_LIBRARY}")
+endif()
 
 if (APPLE AND LLVM_USE_SANITIZER)
   if (("${LLVM_USE_SANITIZER}" STREQUAL "Address") OR
@@ -67,14 +71,21 @@
   endif()
 endif()
 
-# Generate library list.
+# Generate private library list.
 add_library_flags_if(LIBCXX_HAS_PTHREAD_LIB pthread)
 add_library_flags_if(LIBCXX_HAS_C_LIB c)
 add_library_flags_if(LIBCXX_HAS_M_LIB m)
 add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
 add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
 add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
 
+# Determine the correct EH library.
+if (LIBCXXABI_USE_LLVM_UNWINDER)
+  list(APPEND LIBCXX_LIBRARIES_PUBLIC unwind)
+elseif (LIBCXX_HAS_GCC_S_LIB)
+  list(APPEND LIBCXX_LIBRARIES_PUBLIC gcc_s)
+endif()
+
 # Setup flags.
 if (NOT WIN32)
   add_flags_if_supported(-fPIC)
@@ -151,7 +162,7 @@
 # Build the shared library.
 if (LIBCXX_ENABLE_SHARED)
   add_library(cxx_shared SHARED $)
-  target_link_libraries(cxx_shared ${LIBCXX_LIBRARIES})
+  target_link_libraries(cxx_shared ${LIBCXX_LIBRARIES} ${LIBCXX_LIBRARIES_PUBLIC})
   set_target_properties(cxx_shared
 PROPERTIES
   LINK_FLAGS"${LIBCXX_LINK_FLAGS}"
@@ -165,7 +176,7 @@
 # Build the static library.
 if (LIBCXX_ENA

[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-06 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 73855.

https://reviews.llvm.org/D25338

Files:
  docs/CommandGuide/clang.rst
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -994,7 +994,15 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  llvm::outs() << TC.getCompilerRTArgString(C.getArgs(), "builtins") << 
"\n";
+  break;
+case ToolChain::RLT_Libgcc:
+  llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+  break;
+}
 return false;
   }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1861,7 +1861,8 @@
 def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>,
   HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
 def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">,
-  HelpText<"Print the library path for \"libgcc.a\"">;
+  HelpText<"Print the library path for the currently used compiler runtime "
+   "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\")">;
 def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;
 def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
 def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -394,7 +394,8 @@
 
 .. option:: -print-libgcc-file-name
 
-  Print the library path for "libgcc.a".
+  Print the library path for the currently used compiler runtime library
+  ("libgcc.a" or "libclang_rt.builtins.*.a").
 
 .. option:: -print-prog-name=
 


Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -994,7 +994,15 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  llvm::outs() << TC.getCompilerRTArgString(C.getArgs(), "builtins") << "\n";
+  break;
+case ToolChain::RLT_Libgcc:
+  llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+  break;
+}
 return false;
   }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1861,7 +1861,8 @@
 def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>,
   HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
 def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">,
-  HelpText<"Print the library path for \"libgcc.a\"">;
+  HelpText<"Print the library path for the currently used compiler runtime "
+   "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\")">;
 def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;
 def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
 def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -394,7 +394,8 @@
 
 .. option:: -print-libgcc-file-name
 
-  Print the library path for "libgcc.a".
+  Print the library path for the currently used compiler runtime library
+  ("libgcc.a" or "libclang_rt.builtins.*.a").
 
 .. option:: -print-prog-name=
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-06 Thread Michał Górny via cfe-commits
mgorny marked 2 inline comments as done.
mgorny added a comment.

Updated the docs. I'll look into the test case tomorrow.


https://reviews.llvm.org/D25338



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


[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-07 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 73887.
mgorny added a comment.

A simple test case included.


https://reviews.llvm.org/D25338

Files:
  docs/CommandGuide/clang.rst
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp
  test/Driver/print-libgcc-file-name.c


Index: test/Driver/print-libgcc-file-name.c
===
--- /dev/null
+++ test/Driver/print-libgcc-file-name.c
@@ -0,0 +1,15 @@
+// Test that -print-libgcc-file-name correctly respects -rtlib=.
+
+// RUN: %clang -rtlib=libgcc -print-libgcc-file-name 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LIBGCC %s
+// CHECK-LIBGCC: libgcc.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=x86_64-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-X8664 %s
+// CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=i686-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I686 %s
+// CHECK-CLANGRT-I686: libclang_rt.builtins-i686.a
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -994,7 +994,15 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  llvm::outs() << TC.getCompilerRTArgString(C.getArgs(), "builtins") << 
"\n";
+  break;
+case ToolChain::RLT_Libgcc:
+  llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+  break;
+}
 return false;
   }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1861,7 +1861,8 @@
 def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>,
   HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
 def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">,
-  HelpText<"Print the library path for \"libgcc.a\"">;
+  HelpText<"Print the library path for the currently used compiler runtime "
+   "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\")">;
 def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;
 def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
 def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -394,7 +394,8 @@
 
 .. option:: -print-libgcc-file-name
 
-  Print the library path for "libgcc.a".
+  Print the library path for the currently used compiler runtime library
+  ("libgcc.a" or "libclang_rt.builtins.*.a").
 
 .. option:: -print-prog-name=
 


Index: test/Driver/print-libgcc-file-name.c
===
--- /dev/null
+++ test/Driver/print-libgcc-file-name.c
@@ -0,0 +1,15 @@
+// Test that -print-libgcc-file-name correctly respects -rtlib=.
+
+// RUN: %clang -rtlib=libgcc -print-libgcc-file-name 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LIBGCC %s
+// CHECK-LIBGCC: libgcc.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=x86_64-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-X8664 %s
+// CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=i686-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I686 %s
+// CHECK-CLANGRT-I686: libclang_rt.builtins-i686.a
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -994,7 +994,15 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  llvm::outs() << TC.getCompilerRTArgString(C.getArgs(), "builtins") << "\n";
+  break;
+case ToolChain::RLT_Libgcc:
+  llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+  break;
+}
 return false;
   }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1861,7 +1861,8 @@
 def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>,
   HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
 def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">,
-  HelpText<"Print the library path

[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-07 Thread Michał Górny via cfe-commits
mgorny added a comment.

Thanks for the review.


https://reviews.llvm.org/D25338



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


[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-07 Thread Michał Górny via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283572: [Driver] Make -print-libgcc-file-name print 
compiler-rt lib when used (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D25338?vs=73887&id=73953#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25338

Files:
  cfe/trunk/docs/CommandGuide/clang.rst
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/print-libgcc-file-name.c


Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -994,7 +994,15 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  llvm::outs() << TC.getCompilerRTArgString(C.getArgs(), "builtins") << 
"\n";
+  break;
+case ToolChain::RLT_Libgcc:
+  llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+  break;
+}
 return false;
   }
 
Index: cfe/trunk/docs/CommandGuide/clang.rst
===
--- cfe/trunk/docs/CommandGuide/clang.rst
+++ cfe/trunk/docs/CommandGuide/clang.rst
@@ -394,7 +394,8 @@
 
 .. option:: -print-libgcc-file-name
 
-  Print the library path for "libgcc.a".
+  Print the library path for the currently used compiler runtime library
+  ("libgcc.a" or "libclang_rt.builtins.*.a").
 
 .. option:: -print-prog-name=
 
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1861,7 +1861,8 @@
 def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>,
   HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
 def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">,
-  HelpText<"Print the library path for \"libgcc.a\"">;
+  HelpText<"Print the library path for the currently used compiler runtime "
+   "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\")">;
 def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;
 def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
 def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
Index: cfe/trunk/test/Driver/print-libgcc-file-name.c
===
--- cfe/trunk/test/Driver/print-libgcc-file-name.c
+++ cfe/trunk/test/Driver/print-libgcc-file-name.c
@@ -0,0 +1,15 @@
+// Test that -print-libgcc-file-name correctly respects -rtlib=.
+
+// RUN: %clang -rtlib=libgcc -print-libgcc-file-name 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LIBGCC %s
+// CHECK-LIBGCC: libgcc.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=x86_64-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-X8664 %s
+// CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=i686-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I686 %s
+// CHECK-CLANGRT-I686: libclang_rt.builtins-i686.a


Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -994,7 +994,15 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  llvm::outs() << TC.getCompilerRTArgString(C.getArgs(), "builtins") << "\n";
+  break;
+case ToolChain::RLT_Libgcc:
+  llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+  break;
+}
 return false;
   }
 
Index: cfe/trunk/docs/CommandGuide/clang.rst
===
--- cfe/trunk/docs/CommandGuide/clang.rst
+++ cfe/trunk/docs/CommandGuide/clang.rst
@@ -394,7 +394,8 @@
 
 .. option:: -print-libgcc-file-name
 
-  Print the library path for "libgcc.a".
+  Print the library path for the currently used compiler runtime library
+  ("libgcc.a" or "libclang_rt.builtins.*.a").
 
 .. option:: -print-prog-name=
 
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1861,7 +1861,8 @@
 def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>,
   HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
 def print_libgcc_file_name : Flag<["-", "-

[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-07 Thread Michał Górny via cfe-commits
mgorny added a comment.

It seems that my test doesn't work on Darwin, and I should exclude the libgcc 
part there. Do you happen to have any suggestion how to do that?

I'm going to wait for other buildbots to finish to see if I haven't broken any 
other platform, then revert it and look for a proper way to restrict the tests.


Repository:
  rL LLVM

https://reviews.llvm.org/D25338



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


[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-07 Thread Michał Górny via cfe-commits
mgorny planned changes to this revision.
mgorny added a comment.

Reverted, I need to update it to run libgcc part of the test only on platforms 
supporting that.


Repository:
  rL LLVM

https://reviews.llvm.org/D25338



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


[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-07 Thread Michał Górny via cfe-commits
mgorny removed rL LLVM as the repository for this revision.
mgorny updated this revision to Diff 73979.
This revision is now accepted and ready to land.

https://reviews.llvm.org/D25338

Files:
  docs/CommandGuide/clang.rst
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp
  test/Driver/print-libgcc-file-name-clangrt.c
  test/Driver/print-libgcc-file-name-libgcc.c
  test/lit.cfg


Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -375,6 +375,11 @@
 if platform.system() not in ['Windows']:
 config.available_features.add('utf8-capable-terminal')
 
+# Support for libgcc runtime. Used to rule out tests that require
+# clang to run with -rtlib=libgcc.
+if platform.system() not in ['Darwin', 'Fuchsia']:
+config.available_features.add('libgcc')
+
 # Native compilation: Check if triples match.
 # FIXME: Consider cases that target can be executed
 # even if host_triple were different from target_triple.
Index: test/Driver/print-libgcc-file-name-libgcc.c
===
--- /dev/null
+++ test/Driver/print-libgcc-file-name-libgcc.c
@@ -0,0 +1,7 @@
+// Test that -print-libgcc-file-name correctly respects -rtlib=libgcc.
+
+// REQUIRES: libgcc
+
+// RUN: %clang -rtlib=libgcc -print-libgcc-file-name 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LIBGCC %s
+// CHECK-LIBGCC: libgcc.a
Index: test/Driver/print-libgcc-file-name-clangrt.c
===
--- /dev/null
+++ test/Driver/print-libgcc-file-name-clangrt.c
@@ -0,0 +1,11 @@
+// Test that -print-libgcc-file-name correctly respects -rtlib=compiler-rt.
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=x86_64-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-X8664 %s
+// CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=i686-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I686 %s
+// CHECK-CLANGRT-I686: libclang_rt.builtins-i686.a
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -994,7 +994,15 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  llvm::outs() << TC.getCompilerRTArgString(C.getArgs(), "builtins") << 
"\n";
+  break;
+case ToolChain::RLT_Libgcc:
+  llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+  break;
+}
 return false;
   }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1861,7 +1861,8 @@
 def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>,
   HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
 def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">,
-  HelpText<"Print the library path for \"libgcc.a\"">;
+  HelpText<"Print the library path for the currently used compiler runtime "
+   "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\")">;
 def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;
 def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
 def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -394,7 +394,8 @@
 
 .. option:: -print-libgcc-file-name
 
-  Print the library path for "libgcc.a".
+  Print the library path for the currently used compiler runtime library
+  ("libgcc.a" or "libclang_rt.builtins.*.a").
 
 .. option:: -print-prog-name=
 


Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -375,6 +375,11 @@
 if platform.system() not in ['Windows']:
 config.available_features.add('utf8-capable-terminal')
 
+# Support for libgcc runtime. Used to rule out tests that require
+# clang to run with -rtlib=libgcc.
+if platform.system() not in ['Darwin', 'Fuchsia']:
+config.available_features.add('libgcc')
+
 # Native compilation: Check if triples match.
 # FIXME: Consider cases that target can be executed
 # even if host_triple were different from target_triple.
Index: test/Driver/print-libgcc-file-name-libgcc.c
===
--- /dev/null
+++ test/Driver/print-libgcc-file-name-libgcc.c
@@ -0,0 +1,7 @@
+// Test that -print-libgcc-file-name correctly respects -rtlib=libgcc.
+
+// REQUIRES: libgcc
+
+// RUN: 

[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-07 Thread Michał Górny via cfe-commits
mgorny requested a review of this revision.
mgorny added a comment.

I have updated the patch to include a feature check for platforms rejecting 
`-rtlib=libgcc` and split the test appropriately. Could you re-review, please?


https://reviews.llvm.org/D25338



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


[PATCH] D25008: [cmake] Split linked libraries into private & public, for linker script

2016-10-08 Thread Michał Górny via cfe-commits
mgorny marked 2 inline comments as done.
mgorny added inline comments.



Comment at: lib/CMakeLists.txt:86
+elseif (LIBCXX_HAS_GCC_S_LIB)
+  list(APPEND LIBCXX_LIBRARIES_PUBLIC gcc_s)
+endif()

EricWF wrote:
> I don't think `libgcc_s` should be considered a public library like 
> `libunwind` because both Clang and GCC link it as a default system library.
However, clang doesn't add it if you use compiler-rt. In which case you are 
left without an unwinder.


https://reviews.llvm.org/D25008



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


[PATCH] D25008: [cmake] Split linked libraries into private & public, for linker script

2016-10-08 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 74019.
mgorny added a comment.

Apple re-export and PRIVATE/PUBLIC covered.


https://reviews.llvm.org/D25008

Files:
  CMakeLists.txt
  lib/CMakeLists.txt
  utils/gen_link_script/gen_link_script.py

Index: utils/gen_link_script/gen_link_script.py
===
--- utils/gen_link_script/gen_link_script.py
+++ utils/gen_link_script/gen_link_script.py
@@ -22,17 +22,16 @@
 help_msg = \
 """Usage
 
-  gen_link_script.py [--help] [--dryrun]  
+  gen_link_script.py [--help] [--dryrun]  
 
   Generate a linker script that links libc++ to the proper ABI library.
   The script replaces the specified libc++ symlink.
   An example script for c++abi would look like "INPUT(libc++.so.1 -lc++abi)".
 
 Arguments
- The top level symlink to the versioned libc++ shared
 library. This file is replaced with a linker script.
- - The name of the ABI library to use in the linker script.
-The name must be one of [c++abi, stdc++, supc++, cxxrt].
+ - List of library names to include in linker script.
 
 Exit Status:
   0 if OK,
@@ -53,28 +52,25 @@
 if len(args) != 2:
 usage_and_exit()
 symlink_file = args[0]
-abi_libname = args[1]
-return dryrun, symlink_file, abi_libname
+public_libs = args[1].split(';')
+return dryrun, symlink_file, public_libs
 
 def main():
-dryrun, symlink_file, abi_libname = parse_args()
+dryrun, symlink_file, public_libs = parse_args()
 
 # Check that the given libc++.so file is a valid symlink.
 if not os.path.islink(symlink_file):
 print_and_exit("symlink file %s is not a symlink" % symlink_file)
 
 # Read the symlink so we know what libc++ to link to in the linker script.
 linked_libcxx = os.readlink(symlink_file)
 
-# Check that the abi_libname is one of the supported values.
-supported_abi_list = ['c++abi', 'stdc++', 'supc++', 'cxxrt']
-if abi_libname not in supported_abi_list:
-print_and_exit("abi name '%s' is not supported: Use one of %r" %
-(abi_libname, supported_abi_list))
+# Prepare the list of public libraries to link.
+public_libs = ['-l%s' % l for l in public_libs]
 
 # Generate the linker script contents and print the script and destination
 # information.
-contents = "INPUT(%s -l%s)" % (linked_libcxx, abi_libname)
+contents = "INPUT(%s %s)" % (linked_libcxx, ' '.join(public_libs))
 print("GENERATING SCRIPT: '%s' as file %s" % (contents, symlink_file))
 
 # Remove the existing libc++ symlink and replace it with the script.
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -33,9 +33,17 @@
 
 add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}")
 
-add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,--whole-archive" "-Wl,-Bstatic")
-add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
-add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,-Bdynamic" "-Wl,--no-whole-archive")
+if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
+  add_library_flags("-Wl,--whole-archive" "-Wl,-Bstatic")
+  add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
+  add_library_flags("-Wl,-Bdynamic" "-Wl,--no-whole-archive")
+elseif (APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
+   LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"))
+  # Apple re-exports libc++abi in libc++, so don't make it public
+  add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
+else()
+  list(APPEND LIBCXX_LIBRARIES_PUBLIC "${LIBCXX_CXX_ABI_LIBRARY}")
+endif()
 
 if (APPLE AND LLVM_USE_SANITIZER)
   if (("${LLVM_USE_SANITIZER}" STREQUAL "Address") OR
@@ -67,14 +75,21 @@
   endif()
 endif()
 
-# Generate library list.
+# Generate private library list.
 add_library_flags_if(LIBCXX_HAS_PTHREAD_LIB pthread)
 add_library_flags_if(LIBCXX_HAS_C_LIB c)
 add_library_flags_if(LIBCXX_HAS_M_LIB m)
 add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
 add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
 add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
 
+# Determine the correct EH library.
+if (LIBCXXABI_USE_LLVM_UNWINDER)
+  list(APPEND LIBCXX_LIBRARIES_PUBLIC unwind)
+elseif (LIBCXX_HAS_GCC_S_LIB)
+  list(APPEND LIBCXX_LIBRARIES_PUBLIC gcc_s)
+endif()
+
 # Setup flags.
 if (NOT WIN32)
   add_flags_if_supported(-fPIC)
@@ -151,7 +166,9 @@
 # Build the shared library.
 if (LIBCXX_ENABLE_SHARED)
   add_library(cxx_shared SHARED $)
-  target_link_libraries(cxx_shared ${LIBCXX_LIBRARIES})
+  target_link_libraries(cxx_shared
+PRIVATE ${LIBCXX_LIBRARIES}
+PUBLIC ${LIBCXX_LIBRARIES_PUBLIC})
   set_target_properties(cxx_shared
 PROPERTIES
   LINK_FLAGS"${LIBCXX_LINK_FLAGS}"
@@ -165,7 +182,9 @@
 # Build the static library.
 if (LIBCXX_ENABLE_STATIC)
   add_library(cxx_static STATIC $)
-  target_link_libraries(cxx_static ${LIBCXX_LIBRARIE

[PATCH] D25008: [cmake] Split linked libraries into private & public, for linker script

2016-10-08 Thread Michał Górny via cfe-commits
mgorny updated the summary for this revision.
mgorny updated this revision to Diff 74020.

https://reviews.llvm.org/D25008

Files:
  CMakeLists.txt
  lib/CMakeLists.txt
  utils/gen_link_script/gen_link_script.py

Index: utils/gen_link_script/gen_link_script.py
===
--- utils/gen_link_script/gen_link_script.py
+++ utils/gen_link_script/gen_link_script.py
@@ -22,17 +22,16 @@
 help_msg = \
 """Usage
 
-  gen_link_script.py [--help] [--dryrun]  
+  gen_link_script.py [--help] [--dryrun]  
 
   Generate a linker script that links libc++ to the proper ABI library.
   The script replaces the specified libc++ symlink.
   An example script for c++abi would look like "INPUT(libc++.so.1 -lc++abi)".
 
 Arguments
- The top level symlink to the versioned libc++ shared
 library. This file is replaced with a linker script.
- - The name of the ABI library to use in the linker script.
-The name must be one of [c++abi, stdc++, supc++, cxxrt].
+ - List of library names to include in linker script.
 
 Exit Status:
   0 if OK,
@@ -53,28 +52,25 @@
 if len(args) != 2:
 usage_and_exit()
 symlink_file = args[0]
-abi_libname = args[1]
-return dryrun, symlink_file, abi_libname
+public_libs = args[1].split(';')
+return dryrun, symlink_file, public_libs
 
 def main():
-dryrun, symlink_file, abi_libname = parse_args()
+dryrun, symlink_file, public_libs = parse_args()
 
 # Check that the given libc++.so file is a valid symlink.
 if not os.path.islink(symlink_file):
 print_and_exit("symlink file %s is not a symlink" % symlink_file)
 
 # Read the symlink so we know what libc++ to link to in the linker script.
 linked_libcxx = os.readlink(symlink_file)
 
-# Check that the abi_libname is one of the supported values.
-supported_abi_list = ['c++abi', 'stdc++', 'supc++', 'cxxrt']
-if abi_libname not in supported_abi_list:
-print_and_exit("abi name '%s' is not supported: Use one of %r" %
-(abi_libname, supported_abi_list))
+# Prepare the list of public libraries to link.
+public_libs = ['-l%s' % l for l in public_libs]
 
 # Generate the linker script contents and print the script and destination
 # information.
-contents = "INPUT(%s -l%s)" % (linked_libcxx, abi_libname)
+contents = "INPUT(%s %s)" % (linked_libcxx, ' '.join(public_libs))
 print("GENERATING SCRIPT: '%s' as file %s" % (contents, symlink_file))
 
 # Remove the existing libc++ symlink and replace it with the script.
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -33,9 +33,17 @@
 
 add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}")
 
-add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,--whole-archive" "-Wl,-Bstatic")
-add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
-add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,-Bdynamic" "-Wl,--no-whole-archive")
+if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
+  add_library_flags("-Wl,--whole-archive" "-Wl,-Bstatic")
+  add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
+  add_library_flags("-Wl,-Bdynamic" "-Wl,--no-whole-archive")
+elseif (APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
+   LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"))
+  # Apple re-exports libc++abi in libc++, so don't make it public
+  add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
+else()
+  list(APPEND LIBCXX_LIBRARIES_PUBLIC "${LIBCXX_CXX_ABI_LIBRARY}")
+endif()
 
 if (APPLE AND LLVM_USE_SANITIZER)
   if (("${LLVM_USE_SANITIZER}" STREQUAL "Address") OR
@@ -67,14 +75,19 @@
   endif()
 endif()
 
-# Generate library list.
+# Generate private library list.
 add_library_flags_if(LIBCXX_HAS_PTHREAD_LIB pthread)
 add_library_flags_if(LIBCXX_HAS_C_LIB c)
 add_library_flags_if(LIBCXX_HAS_M_LIB m)
 add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
 add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
 add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
 
+# Add the unwinder library.
+if (LIBCXXABI_USE_LLVM_UNWINDER)
+  list(APPEND LIBCXX_LIBRARIES_PUBLIC unwind)
+endif()
+
 # Setup flags.
 if (NOT WIN32)
   add_flags_if_supported(-fPIC)
@@ -151,7 +164,9 @@
 # Build the shared library.
 if (LIBCXX_ENABLE_SHARED)
   add_library(cxx_shared SHARED $)
-  target_link_libraries(cxx_shared ${LIBCXX_LIBRARIES})
+  target_link_libraries(cxx_shared
+PRIVATE ${LIBCXX_LIBRARIES}
+PUBLIC ${LIBCXX_LIBRARIES_PUBLIC})
   set_target_properties(cxx_shared
 PROPERTIES
   LINK_FLAGS"${LIBCXX_LINK_FLAGS}"
@@ -165,7 +180,9 @@
 # Build the static library.
 if (LIBCXX_ENABLE_STATIC)
   add_library(cxx_static STATIC $)
-  target_link_libraries(cxx_static ${LIBCXX_LIBRARIES})
+  target_link_libraries(cxx_static
+PRIVATE ${LIBCXX_LIBRARIES}
+PUBLIC ${LIBCXX_LIBRARIES_PUBLI

[PATCH] D25008: [cmake] Split linked libraries into private & public, for linker script

2016-10-08 Thread Michał Górny via cfe-commits
mgorny marked 2 inline comments as done.
mgorny added a comment.

As discussed on IRC, limited the unwinder deps to -lunwind, and I'll work on 
making clang include -lunwind by default.


https://reviews.llvm.org/D25008



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


[PATCH] D25008: [cmake] Split linked libraries into private & public, for linker script

2016-10-08 Thread Michał Górny via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283659: [cmake] Split linked libraries into private & 
public, for linker script (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D25008?vs=74020&id=74034#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25008

Files:
  libcxx/trunk/CMakeLists.txt
  libcxx/trunk/lib/CMakeLists.txt
  libcxx/trunk/utils/gen_link_script/gen_link_script.py

Index: libcxx/trunk/utils/gen_link_script/gen_link_script.py
===
--- libcxx/trunk/utils/gen_link_script/gen_link_script.py
+++ libcxx/trunk/utils/gen_link_script/gen_link_script.py
@@ -22,17 +22,16 @@
 help_msg = \
 """Usage
 
-  gen_link_script.py [--help] [--dryrun]  
+  gen_link_script.py [--help] [--dryrun]  
 
   Generate a linker script that links libc++ to the proper ABI library.
   The script replaces the specified libc++ symlink.
   An example script for c++abi would look like "INPUT(libc++.so.1 -lc++abi)".
 
 Arguments
- The top level symlink to the versioned libc++ shared
 library. This file is replaced with a linker script.
- - The name of the ABI library to use in the linker script.
-The name must be one of [c++abi, stdc++, supc++, cxxrt].
+ - List of library names to include in linker script.
 
 Exit Status:
   0 if OK,
@@ -53,28 +52,25 @@
 if len(args) != 2:
 usage_and_exit()
 symlink_file = args[0]
-abi_libname = args[1]
-return dryrun, symlink_file, abi_libname
+public_libs = args[1].split(';')
+return dryrun, symlink_file, public_libs
 
 def main():
-dryrun, symlink_file, abi_libname = parse_args()
+dryrun, symlink_file, public_libs = parse_args()
 
 # Check that the given libc++.so file is a valid symlink.
 if not os.path.islink(symlink_file):
 print_and_exit("symlink file %s is not a symlink" % symlink_file)
 
 # Read the symlink so we know what libc++ to link to in the linker script.
 linked_libcxx = os.readlink(symlink_file)
 
-# Check that the abi_libname is one of the supported values.
-supported_abi_list = ['c++abi', 'stdc++', 'supc++', 'cxxrt']
-if abi_libname not in supported_abi_list:
-print_and_exit("abi name '%s' is not supported: Use one of %r" %
-(abi_libname, supported_abi_list))
+# Prepare the list of public libraries to link.
+public_libs = ['-l%s' % l for l in public_libs]
 
 # Generate the linker script contents and print the script and destination
 # information.
-contents = "INPUT(%s -l%s)" % (linked_libcxx, abi_libname)
+contents = "INPUT(%s %s)" % (linked_libcxx, ' '.join(public_libs))
 print("GENERATING SCRIPT: '%s' as file %s" % (contents, symlink_file))
 
 # Remove the existing libc++ symlink and replace it with the script.
Index: libcxx/trunk/CMakeLists.txt
===
--- libcxx/trunk/CMakeLists.txt
+++ libcxx/trunk/CMakeLists.txt
@@ -270,9 +270,13 @@
 # LIBCXX_CXX_FLAGS: General flags for both the compiler and linker.
 # LIBCXX_COMPILE_FLAGS: Compile only flags.
 # LIBCXX_LINK_FLAGS: Linker only flags.
+# LIBCXX_LIBRARIES: Private libraries libc++ is linked to.
+# LIBCXX_LIBRARIES_PUBLIC: Public libraries libc++ is linked to,
+#  also exposed in the linker script.
 set(LIBCXX_COMPILE_FLAGS "")
 set(LIBCXX_LINK_FLAGS "")
 set(LIBCXX_LIBRARIES "")
+set(LIBCXX_LIBRARIES_PUBLIC "")
 
 # Include macros for adding and removing libc++ flags.
 include(HandleLibcxxFlags)
Index: libcxx/trunk/lib/CMakeLists.txt
===
--- libcxx/trunk/lib/CMakeLists.txt
+++ libcxx/trunk/lib/CMakeLists.txt
@@ -33,9 +33,17 @@
 
 add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}")
 
-add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,--whole-archive" "-Wl,-Bstatic")
-add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
-add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,-Bdynamic" "-Wl,--no-whole-archive")
+if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
+  add_library_flags("-Wl,--whole-archive" "-Wl,-Bstatic")
+  add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
+  add_library_flags("-Wl,-Bdynamic" "-Wl,--no-whole-archive")
+elseif (APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
+   LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"))
+  # Apple re-exports libc++abi in libc++, so don't make it public
+  add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
+else()
+  list(APPEND LIBCXX_LIBRARIES_PUBLIC "${LIBCXX_CXX_ABI_LIBRARY}")
+endif()
 
 if (APPLE AND LLVM_USE_SANITIZER)
   if (("${LLVM_USE_SANITIZER}" STREQUAL "Address") OR
@@ -67,14 +75,19 @@
   endif()
 endif()
 
-# Generate library list.
+# Generate private library list.
 add_library_flags_if(LIBCXX_HAS_PTHREAD_LIB pthread)
 add_library_fl

[PATCH] D25402: [Driver] Pass -lunwind when using libc++ + compiler-rt

2016-10-08 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: ddunbar, EricWF, rsmith, phosek.
mgorny added a subscriber: cfe-commits.
Herald added a subscriber: dberris.

Include -lunwind by default when libc++ is used as the standard C++
library and compiler-rt used as the runtime library. This aims to make
it possible to build programs using '-rtlib=compiler-rt -stdlib=libc++'
out-of-the-box on platforms not having those by default, since clang
missed an unlinker library so far in this case.

This aims to match the current '-rtlib=libgcc' behavior which includes
the gcc unwinder library unconditionally (libgcc_s or libgcc_eh).
However, the unwind library is added only if libc++ is used as
the standard C++ library since libstdc++ implicitly includes
the unwinder. Furthermore, -lunwind is only used for C++ to avoid adding
unnecessary dependencies for C builds that could make bootstrap harder.


https://reviews.llvm.org/D25402

Files:
  lib/Driver/ToolChain.cpp


Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -646,6 +646,8 @@
   switch (Type) {
   case ToolChain::CST_Libcxx:
 CmdArgs.push_back("-lc++");
+if (GetRuntimeLibType(Args) == ToolChain::RLT_CompilerRT)
+CmdArgs.push_back("-lunwind");
 break;
 
   case ToolChain::CST_Libstdcxx:


Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -646,6 +646,8 @@
   switch (Type) {
   case ToolChain::CST_Libcxx:
 CmdArgs.push_back("-lc++");
+if (GetRuntimeLibType(Args) == ToolChain::RLT_CompilerRT)
+CmdArgs.push_back("-lunwind");
 break;
 
   case ToolChain::CST_Libstdcxx:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25402: [Driver] Pass -lunwind when using libc++ + compiler-rt

2016-10-08 Thread Michał Górny via cfe-commits
mgorny planned changes to this revision.
mgorny added a comment.

I knew this looked too easy ;-).


https://reviews.llvm.org/D25402



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


[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-09 Thread Michał Górny via cfe-commits
mgorny added a reviewer: ggreif.
mgorny updated this revision to Diff 74062.
mgorny added a comment.

Including a fix for montavista toolchain checks that miss passing -rtlib= and 
therefore could fail depending on DEFAULT_* value.


https://reviews.llvm.org/D25338

Files:
  docs/CommandGuide/clang.rst
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp
  test/Driver/montavista-gcc-toolchain.c
  test/Driver/print-libgcc-file-name.c


Index: test/Driver/print-libgcc-file-name.c
===
--- /dev/null
+++ test/Driver/print-libgcc-file-name.c
@@ -0,0 +1,15 @@
+// Test that -print-libgcc-file-name correctly respects -rtlib=.
+
+// RUN: %clang -rtlib=libgcc -print-libgcc-file-name 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LIBGCC %s
+// CHECK-LIBGCC: libgcc.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=x86_64-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-X8664 %s
+// CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=i686-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I686 %s
+// CHECK-CLANGRT-I686: libclang_rt.builtins-i686.a
Index: test/Driver/montavista-gcc-toolchain.c
===
--- test/Driver/montavista-gcc-toolchain.c
+++ test/Driver/montavista-gcc-toolchain.c
@@ -1,6 +1,6 @@
 // Test that the montavista gcc-toolchain is correctly detected
 //
-// RUN: %clang -print-libgcc-file-name 2>&1 \
+// RUN: %clang -rtlib=platform -print-libgcc-file-name 2>&1 \
 // RUN: --target=i686-montavista-linux \
 // RUN: --gcc-toolchain=%S/Inputs/montavista_i686_tree/usr \
 // RUN:   | FileCheck %s
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -994,7 +994,15 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  llvm::outs() << TC.getCompilerRTArgString(C.getArgs(), "builtins") << 
"\n";
+  break;
+case ToolChain::RLT_Libgcc:
+  llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+  break;
+}
 return false;
   }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1861,7 +1861,8 @@
 def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>,
   HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
 def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">,
-  HelpText<"Print the library path for \"libgcc.a\"">;
+  HelpText<"Print the library path for the currently used compiler runtime "
+   "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\")">;
 def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;
 def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
 def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -394,7 +394,8 @@
 
 .. option:: -print-libgcc-file-name
 
-  Print the library path for "libgcc.a".
+  Print the library path for the currently used compiler runtime library
+  ("libgcc.a" or "libclang_rt.builtins.*.a").
 
 .. option:: -print-prog-name=
 


Index: test/Driver/print-libgcc-file-name.c
===
--- /dev/null
+++ test/Driver/print-libgcc-file-name.c
@@ -0,0 +1,15 @@
+// Test that -print-libgcc-file-name correctly respects -rtlib=.
+
+// RUN: %clang -rtlib=libgcc -print-libgcc-file-name 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LIBGCC %s
+// CHECK-LIBGCC: libgcc.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=x86_64-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-X8664 %s
+// CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=i686-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I686 %s
+// CHECK-CLANGRT-I686: libclang_rt.builtins-i686.a
Index: test/Driver/montavista-gcc-toolchain.c
===
--- test/Driver/montavista-gcc-toolchain.c
+++ test/Driver/montavista-gcc-toolchain.c
@@ -1,6 +1,6 @@
 // Test that the montavista gcc-toolchain is correctly detected
 //
-// RUN: %clang -print-libgcc-file-name 2>&1 \
+// RUN: %clang -rtlib=platform -print-libgcc-file-name 2>&1 \
 // RUN: --targe

[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-09 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 74063.
mgorny added a comment.

I'm sorry, I mixed branches up. Here's the correct patch with both updates.


https://reviews.llvm.org/D25338

Files:
  docs/CommandGuide/clang.rst
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp
  test/Driver/montavista-gcc-toolchain.c
  test/Driver/print-libgcc-file-name-clangrt.c
  test/Driver/print-libgcc-file-name-libgcc.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -375,6 +375,11 @@
 if platform.system() not in ['Windows']:
 config.available_features.add('utf8-capable-terminal')
 
+# Support for libgcc runtime. Used to rule out tests that require
+# clang to run with -rtlib=libgcc.
+if platform.system() not in ['Darwin', 'Fuchsia']:
+config.available_features.add('libgcc')
+
 # Native compilation: Check if triples match.
 # FIXME: Consider cases that target can be executed
 # even if host_triple were different from target_triple.
Index: test/Driver/print-libgcc-file-name-libgcc.c
===
--- /dev/null
+++ test/Driver/print-libgcc-file-name-libgcc.c
@@ -0,0 +1,7 @@
+// Test that -print-libgcc-file-name correctly respects -rtlib=libgcc.
+
+// REQUIRES: libgcc
+
+// RUN: %clang -rtlib=libgcc -print-libgcc-file-name 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LIBGCC %s
+// CHECK-LIBGCC: libgcc.a
Index: test/Driver/print-libgcc-file-name-clangrt.c
===
--- /dev/null
+++ test/Driver/print-libgcc-file-name-clangrt.c
@@ -0,0 +1,11 @@
+// Test that -print-libgcc-file-name correctly respects -rtlib=compiler-rt.
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=x86_64-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-X8664 %s
+// CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=i686-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I686 %s
+// CHECK-CLANGRT-I686: libclang_rt.builtins-i686.a
Index: test/Driver/montavista-gcc-toolchain.c
===
--- test/Driver/montavista-gcc-toolchain.c
+++ test/Driver/montavista-gcc-toolchain.c
@@ -1,6 +1,6 @@
 // Test that the montavista gcc-toolchain is correctly detected
 //
-// RUN: %clang -print-libgcc-file-name 2>&1 \
+// RUN: %clang -rtlib=platform -print-libgcc-file-name 2>&1 \
 // RUN: --target=i686-montavista-linux \
 // RUN: --gcc-toolchain=%S/Inputs/montavista_i686_tree/usr \
 // RUN:   | FileCheck %s
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -994,7 +994,15 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  llvm::outs() << TC.getCompilerRTArgString(C.getArgs(), "builtins") << "\n";
+  break;
+case ToolChain::RLT_Libgcc:
+  llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+  break;
+}
 return false;
   }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1861,7 +1861,8 @@
 def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>,
   HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
 def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">,
-  HelpText<"Print the library path for \"libgcc.a\"">;
+  HelpText<"Print the library path for the currently used compiler runtime "
+   "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\")">;
 def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;
 def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
 def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -394,7 +394,8 @@
 
 .. option:: -print-libgcc-file-name
 
-  Print the library path for "libgcc.a".
+  Print the library path for the currently used compiler runtime library
+  ("libgcc.a" or "libclang_rt.builtins.*.a").
 
 .. option:: -print-prog-name=
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25402: [Driver] Pass -lunwind when using libc++ + compiler-rt

2016-10-09 Thread Michał Górny via cfe-commits
mgorny added a reviewer: joerg.
mgorny updated this revision to Diff 74064.
mgorny added a comment.

I've updated the NetBSD tests (@joerg, please confirm if it's desired), and 
added a Linux test for the case. AFAICS most of the other targets override the 
method, some of them adding -lunwind already. I'd rather not modify the other 
targets that I don't really know.


https://reviews.llvm.org/D25402

Files:
  lib/Driver/ToolChain.cpp
  test/Driver/linux-ld.c
  test/Driver/netbsd.cpp

Index: test/Driver/netbsd.cpp
===
--- test/Driver/netbsd.cpp
+++ test/Driver/netbsd.cpp
@@ -93,13 +93,13 @@
 // X86_64: clang{{.*}}" "-cc1" "-triple" "x86_64--netbsd"
 // X86_64: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
 // X86_64: "-o" "a.out" "{{.*}}/usr/lib{{/|}}crt0.o" "{{.*}}/usr/lib{{/|}}crti.o"
-// X86_64: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc++"
+// X86_64: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc++" "-lunwind"
 // X86_64: "-lm" "-lc" "{{.*}}/usr/lib{{/|}}crtend.o" "{{.*}}/usr/lib{{/|}}crtn.o"
 
 // X86_64-7: clang{{.*}}" "-cc1" "-triple" "x86_64--netbsd7.0.0"
 // X86_64-7: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
 // X86_64-7: "-o" "a.out" "{{.*}}/usr/lib{{/|}}crt0.o" "{{.*}}/usr/lib{{/|}}crti.o"
-// X86_64-7: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc++"
+// X86_64-7: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc++" "-lunwind"
 // X86_64-7: "-lm" "-lc" "{{.*}}/usr/lib{{/|}}crtend.o" "{{.*}}/usr/lib{{/|}}crtn.o"
 
 // X86_64-6: clang{{.*}}" "-cc1" "-triple" "x86_64--netbsd6.0.0"
@@ -119,36 +119,36 @@
 // ARM-7: clang{{.*}}" "-cc1" "-triple" "armv5e--netbsd7.0.0-eabi"
 // ARM-7: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
 // ARM-7: "-o" "a.out" "{{.*}}/usr/lib{{/|}}crt0.o" "{{.*}}/usr/lib{{/|}}eabi{{/|}}crti.o"
-// ARM-7: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc++" "-lm" "-lc"
+// ARM-7: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc++" "-lunwind" "-lm" "-lc"
 // ARM-7: "{{.*}}/usr/lib{{/|}}crtend.o" "{{.*}}/usr/lib{{/|}}crtn.o"
 
 // AARCH64: clang{{.*}}" "-cc1" "-triple" "aarch64--netbsd"
 // AARCH64: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
 // AARCH64: "-o" "a.out" "{{.*}}/usr/lib{{/|}}crt0.o" "{{.*}}/usr/lib{{/|}}crti.o"
-// AARCH64: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc++"
+// AARCH64: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc++" "-lunwind"
 // AARCH64: "-lm" "-lc"
 // AARCH64: "{{.*}}/usr/lib{{/|}}crtend.o" "{{.*}}/usr/lib{{/|}}crtn.o"
 
 // AARCH64-7: clang{{.*}}" "-cc1" "-triple" "aarch64--netbsd7.0.0"
 // AARCH64-7: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
 // AARCH64-7: "-o" "a.out" "{{.*}}/usr/lib{{/|}}crt0.o" "{{.*}}/usr/lib{{/|}}crti.o"
-// AARCH64-7: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc++"
+// AARCH64-7: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc++" "-lunwind"
 // AARCH64-7: "-lm" "-lc"
 // AARCH64-7: "{{.*}}/usr/lib{{/|}}crtend.o" "{{.*}}/usr/lib{{/|}}crtn.o"
 
 // SPARC: clang{{.*}}" "-cc1" "-triple" "sparc--netbsd"
 // SPARC: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
 // SPARC: "-o" "a.out" "{{.*}}/usr/lib{{/|}}crt0.o"
 // SPARC: "{{.*}}/usr/lib{{/|}}sparc{{/|}}crti.o"
-// SPARC: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc++"
+// SPARC: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc++" "-lunwind"
 // SPARC: "-lm" "-lc"
 // SPARC: "{{.*}}/usr/lib{{/|}}crtend.o" "{{.*}}/usr/lib{{/|}}crtn.o"
 
 // SPARC-7: clang{{.*}}" "-cc1" "-triple" "sparc--netbsd7.0.0"
 // SPARC-7: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
 // SPARC-7: "-o" "a.out" "{{.*}}/usr/lib{{/|}}crt0.o"
 // SPARC-7: "{{.*}}/usr/lib{{/|}}sparc{{/|}}crti.o"
-// SPARC-7: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc++"
+// SPARC-7: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc++" "-lunwind"
 // SPARC-7: "-lm" "-lc"
 // SPARC-7: "{{.*}}/usr/lib{{/|}}crtend.o" "{{.*}}/usr/lib{{/|}}crtn.o"
 
@@ -163,14 +163,14 @@
 // SPARC64: clang{{.*}}" "-cc1" "-triple" "sparc64--netbsd"
 // SPARC64: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
 // SPARC64: "-o" "a.out" "{{.*}}/usr/lib{{/|}}crt0.o" "{{.*}}/usr/lib{{/|}}crti.o"
-// SPARC64: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc++"
+// SPARC64: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc++" "-lunwind"
 // SPARC64: "-lm" "-lc"
 // SPARC64: "{{.*}}/usr/lib{{/|}}crtend.o" "{{.*}}/usr/lib{{/|}}crtn.o"
 
 // SPARC64-7: clang{{.*}}" "-cc1" "-triple" "sparc64--netbsd7.0.0"
 // SPARC64-7: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
 // SPARC64-7: "-o" "a.out" "{{.*}}/usr/lib{{/|}}crt0.o" "{{.*}}/usr/lib{{/|}}crti.o"
-// SPARC64-7: "{{.*}}/u

[PATCH] D24933: Enable configuration files in clang

2016-10-09 Thread Michał Górny via cfe-commits
mgorny resigned from this revision.
mgorny removed a reviewer: mgorny.
mgorny added a comment.

I have no further comments. However, I'm quite a fresh contributor, so I'm not 
really in a position to accept it.


https://reviews.llvm.org/D24933



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


[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-10 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 74111.
mgorny added a comment.

Updated to use TC.getCompilerRT().


https://reviews.llvm.org/D25338

Files:
  docs/CommandGuide/clang.rst
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp
  test/Driver/montavista-gcc-toolchain.c
  test/Driver/print-libgcc-file-name-clangrt.c
  test/Driver/print-libgcc-file-name-libgcc.c
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -375,6 +375,11 @@
 if platform.system() not in ['Windows']:
 config.available_features.add('utf8-capable-terminal')
 
+# Support for libgcc runtime. Used to rule out tests that require
+# clang to run with -rtlib=libgcc.
+if platform.system() not in ['Darwin', 'Fuchsia']:
+config.available_features.add('libgcc')
+
 # Native compilation: Check if triples match.
 # FIXME: Consider cases that target can be executed
 # even if host_triple were different from target_triple.
Index: test/Driver/print-libgcc-file-name-libgcc.c
===
--- /dev/null
+++ test/Driver/print-libgcc-file-name-libgcc.c
@@ -0,0 +1,7 @@
+// Test that -print-libgcc-file-name correctly respects -rtlib=libgcc.
+
+// REQUIRES: libgcc
+
+// RUN: %clang -rtlib=libgcc -print-libgcc-file-name 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-LIBGCC %s
+// CHECK-LIBGCC: libgcc.a
Index: test/Driver/print-libgcc-file-name-clangrt.c
===
--- /dev/null
+++ test/Driver/print-libgcc-file-name-clangrt.c
@@ -0,0 +1,11 @@
+// Test that -print-libgcc-file-name correctly respects -rtlib=compiler-rt.
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=x86_64-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-X8664 %s
+// CHECK-CLANGRT-X8664: libclang_rt.builtins-x86_64.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \
+// RUN: --target=i686-pc-linux \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-I686 %s
+// CHECK-CLANGRT-I686: libclang_rt.builtins-i686.a
Index: test/Driver/montavista-gcc-toolchain.c
===
--- test/Driver/montavista-gcc-toolchain.c
+++ test/Driver/montavista-gcc-toolchain.c
@@ -1,6 +1,6 @@
 // Test that the montavista gcc-toolchain is correctly detected
 //
-// RUN: %clang -print-libgcc-file-name 2>&1 \
+// RUN: %clang -rtlib=platform -print-libgcc-file-name 2>&1 \
 // RUN: --target=i686-montavista-linux \
 // RUN: --gcc-toolchain=%S/Inputs/montavista_i686_tree/usr \
 // RUN:   | FileCheck %s
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -994,7 +994,15 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) {
-llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs());
+switch (RLT) {
+case ToolChain::RLT_CompilerRT:
+  llvm::outs() << TC.getCompilerRT(C.getArgs(), "builtins") << "\n";
+  break;
+case ToolChain::RLT_Libgcc:
+  llvm::outs() << GetFilePath("libgcc.a", TC) << "\n";
+  break;
+}
 return false;
   }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1861,7 +1861,8 @@
 def print_ivar_layout : Flag<["-"], "print-ivar-layout">, Flags<[CC1Option]>,
   HelpText<"Enable Objective-C Ivar layout bitmap print trace">;
 def print_libgcc_file_name : Flag<["-", "--"], "print-libgcc-file-name">,
-  HelpText<"Print the library path for \"libgcc.a\"">;
+  HelpText<"Print the library path for the currently used compiler runtime "
+   "library (\"libgcc.a\" or \"libclang_rt.builtins.*.a\")">;
 def print_multi_directory : Flag<["-", "--"], "print-multi-directory">;
 def print_multi_lib : Flag<["-", "--"], "print-multi-lib">;
 def print_multi_os_directory : Flag<["-", "--"], "print-multi-os-directory">,
Index: docs/CommandGuide/clang.rst
===
--- docs/CommandGuide/clang.rst
+++ docs/CommandGuide/clang.rst
@@ -394,7 +394,8 @@
 
 .. option:: -print-libgcc-file-name
 
-  Print the library path for "libgcc.a".
+  Print the library path for the currently used compiler runtime library
+  ("libgcc.a" or "libclang_rt.builtins.*.a").
 
 .. option:: -print-prog-name=
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25263: [Driver] Allow setting the default linker during build

2016-10-10 Thread Michał Górny via cfe-commits
mgorny added inline comments.



Comment at: CMakeLists.txt:198
 
+set(CLANG_DEFAULT_LINKER "" CACHE STRING
+  "Default linker to use (\"bfd\" or \"gold\" or \"lld\", empty for platform 
default")

Is there a reason not to allow using the absolute path here, like for the 
command-line option?


Repository:
  rL LLVM

https://reviews.llvm.org/D25263



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


[PATCH] D25402: [Driver] Pass -lunwind when using libc++ + compiler-rt

2016-10-10 Thread Michał Górny via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D25402#565557, @joerg wrote:

> No, they are not desirable, in fact, they pretty much break clang. That's why 
> I wanted to see the test diff...


Thank you for your feedback. However, I would really appreciate if you kindly 
said what you meant up front next time instead of requesting me to perform 
pointless work. You should note that your behavior as well as tone is strongly 
discouraging to contributors like me, and I doubt this is really of any benefit 
to anyone.


https://reviews.llvm.org/D25402



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


[PATCH] D25402: [Driver] Pass -lunwind when using libc++ + compiler-rt on Linux

2016-10-10 Thread Michał Górny via cfe-commits
mgorny retitled this revision from "[Driver] Pass -lunwind when using libc++ + 
compiler-rt" to "[Driver] Pass -lunwind when using libc++ + compiler-rt on 
Linux".
mgorny updated the summary for this revision.
mgorny updated this revision to Diff 74115.

https://reviews.llvm.org/D25402

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


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -443,6 +443,20 @@
 // CHECK-BASIC-LIBCXX-C-LINK: "--sysroot=[[SYSROOT]]"
 // CHECK-BASIC-LIBCXX-C-LINK: "-L[[SYSROOT]]/usr/bin/../lib"
 //
+// Test that libc++ combined with compiler-rt includes -lunwind
+// (and no gcc libraries).
+// RUN: %clangxx -no-canonical-prefixes -x c++ %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu \
+// RUN: -stdlib=libc++ -rtlib=compiler-rt \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxx_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-BASIC-LIBCXX-CLANGRT %s
+// CHECK-BASIC-LIBCXX-CLANGRT: "-lc++" "-lunwind"
+// CHECK-BASIC-LIBCXX-CLANGRT-NOT: "-lgcc_s"
+// CHECK-BASIC-LIBCXX-CLANGRT-NOT: "-lgcc"
+// CHECK-BASIC-LIBCXX-CLANGRT-NOT: "-lgcc_eh"
+//
 // Test a very broken version of multiarch that shipped in Ubuntu 11.04.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=i386-unknown-linux \
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -830,6 +830,8 @@
   void AddClangCXXStdlibIncludeArgs(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
+  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
+   llvm::opt::ArgStringList &CmdArgs) const override;
   void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -4692,6 +4692,18 @@
   }
 }
 
+void Linux::AddCXXStdlibLibArgs(const ArgList &Args,
+ArgStringList &CmdArgs) const {
+  ToolChain::AddCXXStdlibLibArgs(Args, CmdArgs);
+
+  // Append -lunwind if using libc++ along with compiler-rt.
+  // With libgcc, gcc_s/gcc_eh already provides the unwinding interface,
+  // and with libstdc++ the unwinding interface is linked in implicitly.
+  if (GetCXXStdlibType(Args) == ToolChain::CST_Libcxx &&
+  GetRuntimeLibType(Args) == ToolChain::RLT_CompilerRT)
+CmdArgs.push_back("-lunwind");
+}
+
 void Linux::AddCudaIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
   if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -443,6 +443,20 @@
 // CHECK-BASIC-LIBCXX-C-LINK: "--sysroot=[[SYSROOT]]"
 // CHECK-BASIC-LIBCXX-C-LINK: "-L[[SYSROOT]]/usr/bin/../lib"
 //
+// Test that libc++ combined with compiler-rt includes -lunwind
+// (and no gcc libraries).
+// RUN: %clangxx -no-canonical-prefixes -x c++ %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu \
+// RUN: -stdlib=libc++ -rtlib=compiler-rt \
+// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_libcxx_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-BASIC-LIBCXX-CLANGRT %s
+// CHECK-BASIC-LIBCXX-CLANGRT: "-lc++" "-lunwind"
+// CHECK-BASIC-LIBCXX-CLANGRT-NOT: "-lgcc_s"
+// CHECK-BASIC-LIBCXX-CLANGRT-NOT: "-lgcc"
+// CHECK-BASIC-LIBCXX-CLANGRT-NOT: "-lgcc_eh"
+//
 // Test a very broken version of multiarch that shipped in Ubuntu 11.04.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=i386-unknown-linux \
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -830,6 +830,8 @@
   void AddClangCXXStdlibIncludeArgs(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
+  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
+   llvm::opt::ArgStringList &CmdArgs) const override;
   void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
   void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
Index: lib/Driver/ToolChains.cpp
==

[PATCH] D25402: [Driver] Pass -lunwind when using libc++ + compiler-rt on Linux

2016-10-10 Thread Michał Górny via cfe-commits
mgorny added a comment.

I've updated the patch to apply to Linux toolchain only.


https://reviews.llvm.org/D25402



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


[PATCH] D25402: [Driver] Pass -lunwind when using libc++ + compiler-rt on Linux

2016-10-10 Thread Michał Górny via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D25402#566070, @joerg wrote:

> It's difficult to say whether if one change to certain driver functions 
> affect some target or not. That's one reason why the test change is so 
> important.
>
> Looking at the latest version, I still don't understand why the change for 
> Linux is needed. libc++ should provide a linker script now and that should 
> include -lunwind as appropriate.


Most importantly, the linker script can't predict which -rtlib will be used and 
therefore whether -lgcc_s or -lunwind should be used.


https://reviews.llvm.org/D25402



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


[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-10 Thread Michał Górny via cfe-commits
mgorny added a comment.

Thanks for the review.


https://reviews.llvm.org/D25338



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


[PATCH] D25431: [libcxx] [CMake] Build Solaris compat as separate C lib, to avoid -std= issues

2016-10-10 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: EricWF, theraven.
mgorny added a subscriber: cfe-commits.
Herald added a subscriber: beanz.

Build the Solaris compatibility code (C) as a separate static library
rather than appending it to libc++ sources, in order to prevent
the -std=c++11 flag from being used for C code as it causes build
failure with clang.


https://reviews.llvm.org/D25431

Files:
  lib/CMakeLists.txt


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -7,7 +7,8 @@
   list(APPEND LIBCXX_SOURCES ${LIBCXX_WIN32_SOURCES})
 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
   file(GLOB LIBCXX_SOLARIS_SOURCES ../src/support/solaris/*.c)
-  list(APPEND LIBCXX_SOURCES ${LIBCXX_SOLARIS_SOURCES})
+  add_library(libcxx_solaris_compat STATIC ${LIBCXX_SOLARIS_SOURCES})
+  add_library_flags(libcxx_solaris_compat)
 endif()
 
 # Add all the headers to the project for IDEs.


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -7,7 +7,8 @@
   list(APPEND LIBCXX_SOURCES ${LIBCXX_WIN32_SOURCES})
 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
   file(GLOB LIBCXX_SOLARIS_SOURCES ../src/support/solaris/*.c)
-  list(APPEND LIBCXX_SOURCES ${LIBCXX_SOLARIS_SOURCES})
+  add_library(libcxx_solaris_compat STATIC ${LIBCXX_SOLARIS_SOURCES})
+  add_library_flags(libcxx_solaris_compat)
 endif()
 
 # Add all the headers to the project for IDEs.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25431: [libcxx] [CMake] Build Solaris compat as separate C lib, to avoid -std= issues

2016-10-10 Thread Michał Górny via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D25431#566096, @theraven wrote:

> It sounds as if the bug here is either that the .c files are being treated as 
> c++, or that we're sticking -std=c++{whatever} in CFLAGS as well as CXXFLAGS. 
>  This is probably the bug that should be fixed.


We're sticking them into LIBCXX_COMPILE_FLAGS, to be more precise. And this is 
the only C file in the whole libcxx, so I'm not sure if anyone even remember 
about that ;-).


https://reviews.llvm.org/D25431



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


[PATCH] D25338: [Driver] Make -print-libgcc-file-name print compiler-rt lib when used

2016-10-10 Thread Michał Górny via cfe-commits
mgorny closed this revision.
mgorny added a comment.

r283746


https://reviews.llvm.org/D25338



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


[PATCH] D24954: [ToolChains] Disable OpenSUSE rules for SLES10

2016-10-10 Thread Michał Górny via cfe-commits
mgorny added inline comments.



Comment at: lib/Driver/ToolChains.cpp:3915
 
-  if (D.getVFS().exists("/etc/SuSE-release"))
-return OpenSUSE;
+  File = llvm::MemoryBuffer::getFile("/etc/SuSE-release");
+  if (File)

bruno wrote:
> You should keep using the VFS to obtain the file.  You probably also want to 
> add a comment here to describe what you mentioned in the patch Summary.
Hmm, this method is consistent with all the other distributions in the method. 
It seems that `getVFS()` is only used for `exists()` checks there. Are you sure 
I should change this, without touching the other reads first?


https://reviews.llvm.org/D24954



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


[PATCH] D25568: [libcxx] [cmake] Use -print-libgcc-file-name option to find compiler runtime

2016-10-13 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added a reviewer: EricWF.
mgorny added a subscriber: cfe-commits.
Herald added subscribers: modocache, beanz.

Use the -print-libgcc-file-name compiler option to obtain the path to
libgcc or an equivalent compiler runtime library, rather than hardcoding
-lgcc_s. This aims to make it possible to avoid linking with -lgcc_s
when -rtlib=compiler-rt is used along with libunwind.


https://reviews.llvm.org/D25568

Files:
  cmake/Modules/HandleLibcxxFlags.cmake
  lib/CMakeLists.txt


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -83,7 +83,7 @@
 add_library_flags_if(LIBCXX_HAS_C_LIB c)
 add_library_flags_if(LIBCXX_HAS_M_LIB m)
 add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
-add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+add_libgcc_library()
 add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
 
 # Add the unwinder library.
@@ -95,6 +95,8 @@
   else()
 add_interface_library(unwind)
   endif()
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
 endif()
 
 # Setup flags.
Index: cmake/Modules/HandleLibcxxFlags.cmake
===
--- cmake/Modules/HandleLibcxxFlags.cmake
+++ cmake/Modules/HandleLibcxxFlags.cmake
@@ -196,6 +196,29 @@
   endforeach()
 endmacro()
 
+# Attempt to detect the correct compiler runtime library and add it
+# to 'LIBCXX_LIBRARIES'. Fall back to gcc_s if available.
+macro(add_libgcc_library)
+  # split space-separated vars into a list
+  set(libgcc_cmd ${CMAKE_C_COMPILER}
+ ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}
+ ${CMAKE_CXX_FLAGS}
+ ${CMAKE_SHARED_LINKER_FLAGS}
+ -print-libgcc-file-name)
+
+  execute_process(
+COMMAND "${libgcc_cmd}"
+RESULT_VARIABLE libgcc_check_ret
+OUTPUT_VARIABLE libgcc_path
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+if (${libgcc_check_ret} EQUAL 0)
+  add_library_flags("${libgcc_path}")
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+endif()
+endmacro()
+
 # Turn a comma separated CMake list into a space separated string.
 macro(split_list listname)
   string(REPLACE ";" " " ${listname} "${${listname}}")


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -83,7 +83,7 @@
 add_library_flags_if(LIBCXX_HAS_C_LIB c)
 add_library_flags_if(LIBCXX_HAS_M_LIB m)
 add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
-add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+add_libgcc_library()
 add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
 
 # Add the unwinder library.
@@ -95,6 +95,8 @@
   else()
 add_interface_library(unwind)
   endif()
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
 endif()
 
 # Setup flags.
Index: cmake/Modules/HandleLibcxxFlags.cmake
===
--- cmake/Modules/HandleLibcxxFlags.cmake
+++ cmake/Modules/HandleLibcxxFlags.cmake
@@ -196,6 +196,29 @@
   endforeach()
 endmacro()
 
+# Attempt to detect the correct compiler runtime library and add it
+# to 'LIBCXX_LIBRARIES'. Fall back to gcc_s if available.
+macro(add_libgcc_library)
+  # split space-separated vars into a list
+  set(libgcc_cmd ${CMAKE_C_COMPILER}
+ ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}
+ ${CMAKE_CXX_FLAGS}
+ ${CMAKE_SHARED_LINKER_FLAGS}
+ -print-libgcc-file-name)
+
+  execute_process(
+COMMAND "${libgcc_cmd}"
+RESULT_VARIABLE libgcc_check_ret
+OUTPUT_VARIABLE libgcc_path
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+if (${libgcc_check_ret} EQUAL 0)
+  add_library_flags("${libgcc_path}")
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+endif()
+endmacro()
+
 # Turn a comma separated CMake list into a space separated string.
 macro(split_list listname)
   string(REPLACE ";" " " ${listname} "${${listname}}")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25568: [libcxx] [cmake] Use -print-libgcc-file-name option to find compiler runtime

2016-10-13 Thread Michał Górny via cfe-commits
mgorny updated the summary for this revision.
mgorny updated this revision to Diff 74536.

https://reviews.llvm.org/D25568

Files:
  cmake/Modules/HandleLibcxxFlags.cmake
  lib/CMakeLists.txt


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -83,7 +83,7 @@
 add_library_flags_if(LIBCXX_HAS_C_LIB c)
 add_library_flags_if(LIBCXX_HAS_M_LIB m)
 add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
-add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+add_libgcc_library()
 add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
 
 # Add the unwinder library.
@@ -95,6 +95,8 @@
   else()
 add_interface_library(unwind)
   endif()
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
 endif()
 
 # Setup flags.
Index: cmake/Modules/HandleLibcxxFlags.cmake
===
--- cmake/Modules/HandleLibcxxFlags.cmake
+++ cmake/Modules/HandleLibcxxFlags.cmake
@@ -196,6 +196,29 @@
   endforeach()
 endmacro()
 
+# Attempt to detect the correct compiler runtime library and add it
+# to 'LIBCXX_LIBRARIES'. Fall back to gcc_s if available.
+macro(add_libgcc_library)
+  # split space-separated vars into a list
+  set(libgcc_cmd ${CMAKE_CXX_COMPILER}
+ ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}
+ ${CMAKE_CXX_FLAGS}
+ ${CMAKE_SHARED_LINKER_FLAGS}
+ -print-libgcc-file-name)
+
+  execute_process(
+COMMAND "${libgcc_cmd}"
+RESULT_VARIABLE libgcc_check_ret
+OUTPUT_VARIABLE libgcc_path
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+if (${libgcc_check_ret} EQUAL 0)
+  add_library_flags("${libgcc_path}")
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+endif()
+endmacro()
+
 # Turn a comma separated CMake list into a space separated string.
 macro(split_list listname)
   string(REPLACE ";" " " ${listname} "${${listname}}")


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -83,7 +83,7 @@
 add_library_flags_if(LIBCXX_HAS_C_LIB c)
 add_library_flags_if(LIBCXX_HAS_M_LIB m)
 add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
-add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+add_libgcc_library()
 add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
 
 # Add the unwinder library.
@@ -95,6 +95,8 @@
   else()
 add_interface_library(unwind)
   endif()
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
 endif()
 
 # Setup flags.
Index: cmake/Modules/HandleLibcxxFlags.cmake
===
--- cmake/Modules/HandleLibcxxFlags.cmake
+++ cmake/Modules/HandleLibcxxFlags.cmake
@@ -196,6 +196,29 @@
   endforeach()
 endmacro()
 
+# Attempt to detect the correct compiler runtime library and add it
+# to 'LIBCXX_LIBRARIES'. Fall back to gcc_s if available.
+macro(add_libgcc_library)
+  # split space-separated vars into a list
+  set(libgcc_cmd ${CMAKE_CXX_COMPILER}
+ ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}
+ ${CMAKE_CXX_FLAGS}
+ ${CMAKE_SHARED_LINKER_FLAGS}
+ -print-libgcc-file-name)
+
+  execute_process(
+COMMAND "${libgcc_cmd}"
+RESULT_VARIABLE libgcc_check_ret
+OUTPUT_VARIABLE libgcc_path
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+if (${libgcc_check_ret} EQUAL 0)
+  add_library_flags("${libgcc_path}")
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+endif()
+endmacro()
+
 # Turn a comma separated CMake list into a space separated string.
 macro(split_list listname)
   string(REPLACE ";" " " ${listname} "${${listname}}")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25568: [libcxx] [cmake] Use -print-libgcc-file-name option to find compiler runtime

2016-10-13 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 74538.
mgorny added a comment.

Fixed indentation.


https://reviews.llvm.org/D25568

Files:
  cmake/Modules/HandleLibcxxFlags.cmake
  lib/CMakeLists.txt


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -83,7 +83,7 @@
 add_library_flags_if(LIBCXX_HAS_C_LIB c)
 add_library_flags_if(LIBCXX_HAS_M_LIB m)
 add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
-add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+add_libgcc_library()
 add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
 
 # Add the unwinder library.
@@ -95,6 +95,8 @@
   else()
 add_interface_library(unwind)
   endif()
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
 endif()
 
 # Setup flags.
Index: cmake/Modules/HandleLibcxxFlags.cmake
===
--- cmake/Modules/HandleLibcxxFlags.cmake
+++ cmake/Modules/HandleLibcxxFlags.cmake
@@ -196,6 +196,29 @@
   endforeach()
 endmacro()
 
+# Attempt to detect the correct compiler runtime library and add it
+# to 'LIBCXX_LIBRARIES'. Fall back to gcc_s if available.
+macro(add_libgcc_library)
+  # split space-separated vars into a list
+  set(libgcc_cmd ${CMAKE_CXX_COMPILER}
+ ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}
+ ${CMAKE_CXX_FLAGS}
+ ${CMAKE_SHARED_LINKER_FLAGS}
+ -print-libgcc-file-name)
+
+  execute_process(
+COMMAND "${libgcc_cmd}"
+RESULT_VARIABLE libgcc_check_ret
+OUTPUT_VARIABLE libgcc_path
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+  if (${libgcc_check_ret} EQUAL 0)
+add_library_flags("${libgcc_path}")
+  else()
+add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+  endif()
+endmacro()
+
 # Turn a comma separated CMake list into a space separated string.
 macro(split_list listname)
   string(REPLACE ";" " " ${listname} "${${listname}}")


Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -83,7 +83,7 @@
 add_library_flags_if(LIBCXX_HAS_C_LIB c)
 add_library_flags_if(LIBCXX_HAS_M_LIB m)
 add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
-add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+add_libgcc_library()
 add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
 
 # Add the unwinder library.
@@ -95,6 +95,8 @@
   else()
 add_interface_library(unwind)
   endif()
+else()
+  add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
 endif()
 
 # Setup flags.
Index: cmake/Modules/HandleLibcxxFlags.cmake
===
--- cmake/Modules/HandleLibcxxFlags.cmake
+++ cmake/Modules/HandleLibcxxFlags.cmake
@@ -196,6 +196,29 @@
   endforeach()
 endmacro()
 
+# Attempt to detect the correct compiler runtime library and add it
+# to 'LIBCXX_LIBRARIES'. Fall back to gcc_s if available.
+macro(add_libgcc_library)
+  # split space-separated vars into a list
+  set(libgcc_cmd ${CMAKE_CXX_COMPILER}
+ ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}
+ ${CMAKE_CXX_FLAGS}
+ ${CMAKE_SHARED_LINKER_FLAGS}
+ -print-libgcc-file-name)
+
+  execute_process(
+COMMAND "${libgcc_cmd}"
+RESULT_VARIABLE libgcc_check_ret
+OUTPUT_VARIABLE libgcc_path
+OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+  if (${libgcc_check_ret} EQUAL 0)
+add_library_flags("${libgcc_path}")
+  else()
+add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
+  endif()
+endmacro()
+
 # Turn a comma separated CMake list into a space separated string.
 macro(split_list listname)
   string(REPLACE ";" " " ${listname} "${${listname}}")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25568: [libcxx] [cmake] Use -print-libgcc-file-name option to find compiler runtime

2016-10-14 Thread Michał Górny via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D25568#570222, @EricWF wrote:

> This doesn't seem right seeing as `print-libgcc_file-name`  prints the 
> `libgcc.a` path, and we were previously linking `libgcc_s`.


Do you have any other solution in mind? There is no switch to print the shared 
library path. Should I modify it to detect whether the printed path matches 
`libgcc.a` and use `libgcc_s` in that case?

Just to be clear, since libgcc_s is the shared version of libgcc (+ libgcc_eh), 
this is mostly a matter of replacing dynamic linking with static. However, it 
doesn't matter much since in most of the cases no library function is actually 
used. From my experience, throughout 3.8.1 .. HEAD, no builtin functions were 
needed on amd64 and only one (__udiv3, if I recall correctly) was needed on 
32-bit x86. In this case, I dare say using the static library may actually be 
less problematic as it makes libc++ less dependent on compiler runtime.

Of course, on the other hand we have the unwinder library which still can be 
`gcc_s` and there is no easy way to solve this dependency.


https://reviews.llvm.org/D25568



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


[PATCH] D25431: [libcxx] [CMake] Build Solaris compat as separate C lib, to avoid -std= issues

2016-10-14 Thread Michał Górny via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D25431#570227, @EricWF wrote:

> Why not just compile the sources files as C++ by changing their extensions? 
> This change seems all kinds of wrong because we're throwing away *all* of our 
> flags, including things like `-m32` or `-target `.


That's another option. Having a lot of other problems on Solaris at the time, 
using a separate library was simpler to test. I will try this alternative today.


https://reviews.llvm.org/D25431



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


[PATCH] D25431: [libcxx] Convert Solaris support library to C++ to fix -std=c++11 build

2016-10-14 Thread Michał Górny via cfe-commits
mgorny retitled this revision from "[libcxx] [CMake] Build Solaris compat as 
separate C lib, to avoid -std= issues" to "[libcxx] Convert Solaris support 
library to C++ to fix -std=c++11 build
".
mgorny updated the summary for this revision.
mgorny updated this revision to Diff 74666.
mgorny added a comment.
Herald added a subscriber: modocache.

Ok, here's an updated patch that changes the code to C++. Since C++ is more 
strict than C, I also had to remove some conflicting declarations -- and while 
at it, I updated the header to avoid any collisions and redundancy on SunOS 
5.11 (OpenIndiana). I don't have access to any older system, and considering 
that the support for SunOS in clang is still incomplete, I don't think it 
important to support older systems.


https://reviews.llvm.org/D25431

Files:
  include/support/solaris/xlocale.h
  lib/CMakeLists.txt
  src/support/solaris/mbsnrtowcs.inc
  src/support/solaris/wcsnrtombs.inc
  src/support/solaris/xlocale.c
  src/support/solaris/xlocale.cpp

Index: src/support/solaris/xlocale.cpp
===
--- src/support/solaris/xlocale.cpp
+++ src/support/solaris/xlocale.cpp
@@ -12,20 +12,15 @@
 #include "support/solaris/xlocale.h"
 #include 
 #include 
+#include 
 #include 
 
 
-int isxdigit_l(int __c, locale_t __l) {
-return isxdigit(__c);
-}
-
-int iswxdigit_l(wchar_t __c, locale_t __l) {
-return isxdigit(__c);
-}
+extern "C" {
 
 // FIXME: This disregards the locale, which is Very Wrong
 #define vsnprintf_l(__s, __n, __l, __format, __va)  \
-vsnprintf(__s, __n, __format, __va) 
+vsnprintf(__s, __n, __format, __va)
 
 int snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...)
 {
@@ -54,13 +49,10 @@
   return __res;
 }
 
-size_t mbrtowc_l(wchar_t *__pwc, const char *__pmb,
- size_t __max, mbstate_t *__ps, locale_t __loc) {
-  return mbrtowc(__pwc, __pmb, __max, __ps);
-}
-
-struct lconv *localeconv_l(locale_t __l) {
+lconv *localeconv_l(locale_t __l) {
   return localeconv();
 }
 
+};
+
 #endif // __sun__
Index: src/support/solaris/wcsnrtombs.inc
===
--- src/support/solaris/wcsnrtombs.inc
+++ /dev/null
@@ -1,93 +0,0 @@
-/*-
- * Copyright (c) 2002-2004 Tim J. Robbins.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *notice, this list of conditions and the following disclaimer in the
- *documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-
-size_t
-wcsnrtombs_l(char * __restrict dst, const wchar_t ** __restrict src,
-size_t nwc, size_t len, mbstate_t * __restrict ps, locale_t loc)
-{
-  FIX_LOCALE(loc);
-  mbstate_t mbsbak;
-  char buf[MB_CUR_MAX_L(loc)];
-  const wchar_t *s;
-  size_t nbytes;
-  size_t nb;
-
-  s = *src;
-  nbytes = 0;
-
-  if (dst == NULL) {
-while (nwc-- > 0) {
-  if ((nb = wcrtomb_l(buf, *s, ps, loc)) == (size_t)-1)
-/* Invalid character - wcrtomb() sets errno. */
-return ((size_t)-1);
-  else if (*s == L'\0')
-return (nbytes + nb - 1);
-  s++;
-  nbytes += nb;
-}
-return (nbytes);
-  }
-
-  while (len > 0 && nwc-- > 0) {
-if (len > (size_t)MB_CUR_MAX_L(loc)) {
-  /* Enough space to translate in-place. */
-  if ((nb = wcrtomb_l(dst, *s, ps, loc)) == (size_t)-1) {
-*src = s;
-return ((size_t)-1);
-  }
-} else {
-  /*
-   * May not be enough space; use temp. buffer.
-   *
-   * We need to save a copy of the conversion state
-   * here so we can restore it if the multibyte
-   * character is too long for the buffer.
-   */
-  mbsbak = *ps;
-  if ((nb = wcrtomb_l(buf, *s, ps, loc)) == (size_t)-1) {
-*src = s;
-return ((size_t)-1);
-  }
-  if (nb > (int)len) {
-/* MB sequence for character won't fit. 

[PATCH] D25641: [Driver] Use VFS to perform all distribution checks

2016-10-15 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: bruno, rafael, bkramer.
mgorny added subscribers: cfe-commits, bruno.

Use the VFS provided by D.getVFS() for all distribution checks,
including those performing read of the release file. Requested
by @bruno on https://reviews.llvm.org/D24954.


https://reviews.llvm.org/D25641

Files:
  lib/Driver/ToolChains.cpp


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3844,7 +3844,7 @@
 
 static Distro DetectDistro(const Driver &D, llvm::Triple::ArchType Arch) {
   llvm::ErrorOr> File =
-  llvm::MemoryBuffer::getFile("/etc/lsb-release");
+  D.getVFS().getBufferForFile("/etc/lsb-release");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 SmallVector Lines;
@@ -3876,7 +3876,7 @@
   return Version;
   }
 
-  File = llvm::MemoryBuffer::getFile("/etc/redhat-release");
+  File = D.getVFS().getBufferForFile("/etc/redhat-release");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 if (Data.startswith("Fedora release"))
@@ -3894,7 +3894,7 @@
 return UnknownDistro;
   }
 
-  File = llvm::MemoryBuffer::getFile("/etc/debian_version");
+  File = D.getVFS().getBufferForFile("/etc/debian_version");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 if (Data[0] == '5')


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3844,7 +3844,7 @@
 
 static Distro DetectDistro(const Driver &D, llvm::Triple::ArchType Arch) {
   llvm::ErrorOr> File =
-  llvm::MemoryBuffer::getFile("/etc/lsb-release");
+  D.getVFS().getBufferForFile("/etc/lsb-release");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 SmallVector Lines;
@@ -3876,7 +3876,7 @@
   return Version;
   }
 
-  File = llvm::MemoryBuffer::getFile("/etc/redhat-release");
+  File = D.getVFS().getBufferForFile("/etc/redhat-release");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 if (Data.startswith("Fedora release"))
@@ -3894,7 +3894,7 @@
 return UnknownDistro;
   }
 
-  File = llvm::MemoryBuffer::getFile("/etc/debian_version");
+  File = D.getVFS().getBufferForFile("/etc/debian_version");
   if (File) {
 StringRef Data = File.get()->getBuffer();
 if (Data[0] == '5')
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25661: [Driver] Support obtaining active toolchain from gcc-config on Gentoo

2016-10-16 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: rafael, chandlerc, bruno, bkramer.
mgorny added a subscriber: cfe-commits.

Support using gcc-config to determine the correct GCC toolchain location
on Gentoo. In order to do that, attempt to read gcc-config configuration
form [[sysroot]]/etc/env.d/gcc, if no custom toolchain location is
provided.


https://reviews.llvm.org/D25661

Files:
  lib/Driver/ToolChains.cpp
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
  test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
  test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/include/.keep
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtbegin.o
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5.4.0/.keep
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/x86_64-pc-linux-gnu/lib/.keep
  test/Driver/linux-header-search.cpp


Index: test/Driver/linux-header-search.cpp
===
--- test/Driver/linux-header-search.cpp
+++ test/Driver/linux-header-search.cpp
@@ -301,6 +301,15 @@
 // CHECK-GENTOO-4-9-3: "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-GENTOO-4-9-3: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 //
+// Test support for Gentoo's gcc-config -- clang should prefer the older
+// (4.9.3) version over the newer (5.4.0) due to preference specified
+// in /etc/env.d/gcc/x86_64-pc-linux-gnu.
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu -stdlib=libstdc++ \
+// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_multi_version_tree \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-GENTOO-4-9-3 %s
+//
 // Check header search on Debian 6 / MIPS64
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN: -target mips64-unknown-linux-gnuabi64 -stdlib=libstdc++ \
Index: test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
===
--- /dev/null
+++ test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
@@ -0,0 +1 @@
+Gentoo Base System release 2.3
Index: 
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
===
--- /dev/null
+++ 
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
@@ -0,0 +1,10 @@
+PATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3"
+ROOTPATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3"
+GCC_PATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3"
+LDPATH="/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3:/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/32"
+MANPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.3/man"
+INFOPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.3/info"
+STDCXX_INCDIR="g++-v4"
+CTARGET="x86_64-pc-linux-gnu"
+GCC_SPECS=""
+MULTIOSDIRS="../lib64:../lib32"
Index: 
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
===
--- /dev/null
+++ 
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
@@ -0,0 +1 @@
+CURRENT=x86_64-pc-linux-gnu-4.9.3
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1430,6 +1430,43 @@
 }
   }
 
+  // Try to respect gcc-config on Gentoo. However, do that only
+  // if --gcc-toolchain is not provided or equal to the Gentoo install
+  // in /usr. This avoids accidentally enforcing the system GCC version
+  // when using a custom toolchain.
+  if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+for (unsigned k = 0, ke = CandidateTripleAliases.size(); k < ke; ++k) {
+  llvm::ErrorOr> File =
+  D.getVFS().getBufferForFile(D.SysRoot + "/etc/env.d/gcc/config-" +
+  CandidateTripleAliases[k].str());
+  if (File) {
+SmallVector Lines;
+File.get()->getBuffer().split(Lines, "\n");
+for (StringRef& Line : Lines) {
+  // CURRENT=triple-version
+  if (Line.startswith("CURRENT=")) {
+const std::pair ActiveVersion =
+  Line.substr(8).rsplit('-');
+// Note: Strictly speaking, we should be reading
+// /etc/env.d/gcc/${CURRENT} now. However, t

[PATCH] D25661: [Driver] Support obtaining active toolchain from gcc-config on Gentoo

2016-10-17 Thread Michał Górny via cfe-commits
mgorny added inline comments.



Comment at: lib/Driver/ToolChains.cpp:1446-1463
+  // CURRENT=triple-version
+  if (Line.startswith("CURRENT=")) {
+const std::pair ActiveVersion =
+  Line.substr(8).rsplit('-');
+// Note: Strictly speaking, we should be reading
+// /etc/env.d/gcc/${CURRENT} now. However, the file doesn't
+// contain anything new or especially useful to us.

ABataev wrote:
> I think it is better to use `llvm::Triple` class here for parsing 
> `ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT` string rather than 
> `StringRef::split()`
This is not parsing the triple but detaching the version appended to it.


https://reviews.llvm.org/D25661



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


[clang] [Clang] Remove NetBSD/i386 workaround for FP eval method with older versions (PR #74025)

2023-12-02 Thread Michał Górny via cfe-commits

https://github.com/mgorny approved this pull request.

Code LGTM but please add a note to the release notes, as was requested.

https://github.com/llvm/llvm-project/pull/74025
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] bc96aa9 - [clang] Fix typos in Options.td and regen ClangCommandLineReference.rst.

2021-07-29 Thread Michał Górny via cfe-commits

Author: Frederic Cambus
Date: 2021-07-29T20:33:39+02:00
New Revision: bc96aa9f2c9b25ae65a7e05dbbff8c28079db9c9

URL: 
https://github.com/llvm/llvm-project/commit/bc96aa9f2c9b25ae65a7e05dbbff8c28079db9c9
DIFF: 
https://github.com/llvm/llvm-project/commit/bc96aa9f2c9b25ae65a7e05dbbff8c28079db9c9.diff

LOG: [clang] Fix typos in Options.td and regen ClangCommandLineReference.rst.

Differential Revision: https://reviews.llvm.org/D106664

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 35a3fdd382b41..41f2dc70c052f 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -263,7 +263,7 @@ Build this module as a system module. Only used with 
-emit-module
 
 .. option:: -fuse-cuid=
 
-Method to generate ID's for compilation units for single source offloading 
languages CUDA and HIP: 'hash' (ID's generated by hashing file path and command 
line options) \| 'random' (ID's generated as random numbers) \| 'none' 
(disabled). Default is 'hash'. This option will be overriden by option 
'-cuid=\[ID\]' if it is specified.
+Method to generate ID's for compilation units for single source offloading 
languages CUDA and HIP: 'hash' (ID's generated by hashing file path and command 
line options) \| 'random' (ID's generated as random numbers) \| 'none' 
(disabled). Default is 'hash'. This option will be overridden by option 
'-cuid=\[ID\]' if it is specified.
 
 .. option:: --gcc-toolchain=, -gcc-toolchain 
 
@@ -2507,7 +2507,7 @@ Enables dead virtual function elimination optimization. 
Requires -flto=full
 
 .. option:: -fvisibility-dllexport=
 
-The visibility for dllexport defintions \[-fvisibility-from-dllstorageclass\]
+The visibility for dllexport definitions \[-fvisibility-from-dllstorageclass\]
 
 .. option:: -fvisibility-externs-dllimport=
 
@@ -2519,7 +2519,7 @@ The visibility for external declarations without an 
explicit DLL dllstorageclass
 
 .. option:: -fvisibility-from-dllstorageclass, 
-fno-visibility-from-dllstorageclass
 
-Set the visiblity of symbols in the generated code from their DLL storage class
+Set the visibility of symbols in the generated code from their DLL storage 
class
 
 .. option:: -fvisibility-global-new-delete-hidden
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 6284fde4d52df..7ae775c2e00ba 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1006,7 +1006,7 @@ def fuse_cuid_EQ : Joined<["-"], "fuse-cuid=">,
"offloading languages CUDA and HIP: 'hash' (ID's generated by 
hashing "
"file path and command line options) | 'random' (ID's generated as "
"random numbers) | 'none' (disabled). Default is 'hash'. This 
option "
-   "will be overriden by option '-cuid=[ID]' if it is specified." >;
+   "will be overridden by option '-cuid=[ID]' if it is specified." >;
 def libomptarget_amdgcn_bc_path_EQ : Joined<["--"], 
"libomptarget-amdgcn-bc-path=">, Group,
   HelpText<"Path to libomptarget-amdgcn bitcode library">;
 def libomptarget_nvptx_bc_path_EQ : Joined<["--"], 
"libomptarget-nvptx-bc-path=">, Group,
@@ -2693,10 +2693,10 @@ def fverbose_asm : Flag<["-"], "fverbose-asm">, 
Group,
 def dA : Flag<["-"], "dA">, Alias;
 defm visibility_from_dllstorageclass : 
BoolFOption<"visibility-from-dllstorageclass",
   LangOpts<"VisibilityFromDLLStorageClass">, DefaultFalse,
-  PosFlag,
+  PosFlag,
   NegFlag>;
 def fvisibility_dllexport_EQ : Joined<["-"], "fvisibility-dllexport=">, 
Group, Flags<[CC1Option]>,
-  HelpText<"The visibility for dllexport defintions 
[-fvisibility-from-dllstorageclass]">,
+  HelpText<"The visibility for dllexport definitions 
[-fvisibility-from-dllstorageclass]">,
   MarshallingInfoVisibility, 
"DefaultVisibility">,
   ShouldParseIf;
 def fvisibility_nodllstorageclass_EQ : Joined<["-"], 
"fvisibility-nodllstorageclass=">, Group, Flags<[CC1Option]>,



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


[clang] 1862ffe - [clang] Fix a typo in the manual page: s/contraint/constraint.

2021-07-29 Thread Michał Górny via cfe-commits

Author: Frederic Cambus
Date: 2021-07-29T20:34:43+02:00
New Revision: 1862ffe25a2e927ecae012f5f0c4cdf7c3fc1b67

URL: 
https://github.com/llvm/llvm-project/commit/1862ffe25a2e927ecae012f5f0c4cdf7c3fc1b67
DIFF: 
https://github.com/llvm/llvm-project/commit/1862ffe25a2e927ecae012f5f0c4cdf7c3fc1b67.diff

LOG: [clang] Fix a typo in the manual page: s/contraint/constraint.

While there, update hardcoded Clang version from 3.5 to 13.

Differential Revision: https://reviews.llvm.org/D106867

Added: 


Modified: 
clang/tools/scan-build/man/scan-build.1

Removed: 




diff  --git a/clang/tools/scan-build/man/scan-build.1 
b/clang/tools/scan-build/man/scan-build.1
index 4f3cd8d10333a..824037f3b30cb 100644
--- a/clang/tools/scan-build/man/scan-build.1
+++ b/clang/tools/scan-build/man/scan-build.1
@@ -2,9 +2,9 @@
 .\" See https://llvm.org/LICENSE.txt for license information.
 .\" SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 .\" $Id$
-.Dd May 25, 2012
+.Dd Jul 27, 2021
 .Dt SCAN-BUILD 1
-.Os "clang" "3.5"
+.Os "clang" "13"
 .Sh NAME
 .Nm scan-build
 .Nd Clang static analyzer
@@ -110,7 +110,7 @@ increases verbosity.
 .It Fl V , Fl Fl view
 View analysis results in a web browser when the build completes.
 .It Fl constraints Op Ar model
-Specify the contraint engine used by the analyzer.  By default the
+Specify the constraint engine used by the analyzer.  By default the
 .Ql range
 model is used.  Specifying
 .Ql basic



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


[clang] [clang] [cmake] Add cmake module dir before using GetDarwinLinkerVersion (PR #86386)

2024-03-23 Thread Michał Górny via cfe-commits

https://github.com/mgorny created 
https://github.com/llvm/llvm-project/pull/86386

Move the code adding top-level cmake/Modules directory to CMAKE_MODULE_PATH 
prior to including `GetDarwinLinkerVersion`, in order to fix standalone builds.

Fixes a regression introduced by 3bc71c2abfa00413fd15cf0e5c08af6ec0d4768b.

From 1639e99721c2aeee584437d8987f0633010c401f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= 
Date: Sat, 23 Mar 2024 10:33:38 +0100
Subject: [PATCH] [clang] [cmake] Add cmake module dir before using
 GetDarwinLinkerVersion

Move the code adding top-level cmake/Modules directory
to CMAKE_MODULE_PATH prior to including `GetDarwinLinkerVersion`,
in order to fix standalone builds.

Fixes a regression introduced by 3bc71c2abfa00413fd15cf0e5c08af6ec0d4768b.
---
 clang/CMakeLists.txt | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index ee783d52e4a4e2..284b2af24ddaa0 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -13,6 +13,13 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   set(CLANG_BUILT_STANDALONE TRUE)
 endif()
 
+# Make sure that our source directory is on the current cmake module path so 
that
+# we can include cmake files from this directory.
+list(INSERT CMAKE_MODULE_PATH 0
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
+  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
+  )
+
 # Must go below project(..)
 include(GNUInstallDirs)
 include(GetDarwinLinkerVersion)
@@ -141,13 +148,6 @@ if(CLANG_BUILT_STANDALONE)
   endif() # LLVM_INCLUDE_TESTS
 endif() # standalone
 
-# Make sure that our source directory is on the current cmake module path so 
that
-# we can include cmake files from this directory.
-list(INSERT CMAKE_MODULE_PATH 0
-  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
-  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
-  )
-
 # This allows disabling clang's XML dependency even if LLVM finds libxml2.
 # By default, clang depends on libxml2 if LLVM does.
 option(CLANG_ENABLE_LIBXML2 "Whether libclang may depend on libxml2"

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


[clang] [clang] [cmake] Add cmake module dir before using GetDarwinLinkerVersion (PR #86386)

2024-03-23 Thread Michał Górny via cfe-commits

mgorny wrote:

Thanks!

https://github.com/llvm/llvm-project/pull/86386
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   >