[PATCH] D38441: [compiler-rt] [cmake] Add a separate CMake var to control profile runtime

2017-09-30 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
Herald added a subscriber: dberris.

Make it possible to control building profile runtime separately from
other options. Before r313549, the profile runtime building was
controlled along with sanitizers. However, since that commit it is built
unconditionally which results in multiple builds for people building
different runtimes separately.


Repository:
  rL LLVM

https://reviews.llvm.org/D38441

Files:
  CMakeLists.txt
  lib/CMakeLists.txt
  test/CMakeLists.txt


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -10,7 +10,7 @@
 
 set(SANITIZER_COMMON_LIT_TEST_DEPS)
 
-if (COMPILER_RT_HAS_PROFILE)
+if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
   list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS profile)
 endif()
 
@@ -72,7 +72,7 @@
   endif()
 endforeach()
   endif()
-  if (COMPILER_RT_HAS_PROFILE)
+  if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
 compiler_rt_test_runtime(profile)
   endif()
   if(COMPILER_RT_BUILD_XRAY)
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -41,7 +41,7 @@
   endforeach()
 endif()
 
-if (COMPILER_RT_HAS_PROFILE)
+if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
   compiler_rt_build_runtime(profile)
 endif()
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -38,6 +38,8 @@
 mark_as_advanced(COMPILER_RT_BUILD_XRAY)
 option(COMPILER_RT_BUILD_LIBFUZZER "Build libFuzzer" ON)
 mark_as_advanced(COMPILER_RT_BUILD_LIBFUZZER)
+option(COMPILER_RT_BUILD_PROFILE "Build profile runtime" ON)
+mark_as_advanced(COMPILER_RT_BUILD_PROFILE)
 option(COMPILER_RT_BUILD_XRAY_NO_PREINIT "Build xray with no preinit patching" 
OFF)
 mark_as_advanced(COMPILER_RT_BUILD_XRAY_NO_PREINIT)
 


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -10,7 +10,7 @@
 
 set(SANITIZER_COMMON_LIT_TEST_DEPS)
 
-if (COMPILER_RT_HAS_PROFILE)
+if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
   list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS profile)
 endif()
 
@@ -72,7 +72,7 @@
   endif()
 endforeach()
   endif()
-  if (COMPILER_RT_HAS_PROFILE)
+  if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
 compiler_rt_test_runtime(profile)
   endif()
   if(COMPILER_RT_BUILD_XRAY)
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -41,7 +41,7 @@
   endforeach()
 endif()
 
-if (COMPILER_RT_HAS_PROFILE)
+if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
   compiler_rt_build_runtime(profile)
 endif()
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -38,6 +38,8 @@
 mark_as_advanced(COMPILER_RT_BUILD_XRAY)
 option(COMPILER_RT_BUILD_LIBFUZZER "Build libFuzzer" ON)
 mark_as_advanced(COMPILER_RT_BUILD_LIBFUZZER)
+option(COMPILER_RT_BUILD_PROFILE "Build profile runtime" ON)
+mark_as_advanced(COMPILER_RT_BUILD_PROFILE)
 option(COMPILER_RT_BUILD_XRAY_NO_PREINIT "Build xray with no preinit patching" OFF)
 mark_as_advanced(COMPILER_RT_BUILD_XRAY_NO_PREINIT)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2017-10-01 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
Herald added a subscriber: dberris.

Create a dummy 'gtest' target to satisfy the test dependencies while
doing stand-alone builds. Historically those dependencies were
conditional to non-stand-alone builds but the refactoring
in https://reviews.llvm.org/rL310971 has made them unconditional, breaking 
stand-alone builds
as a result.

Given the added complexity of maintaining a large number of conditionals
scattered around the different CMakeLists.txt files and the likeliness
of people mistakenly adding more unconditional dependencies, adding
a dummy target seems an easier way forward.


Repository:
  rL LLVM

https://reviews.llvm.org/D38444

Files:
  cmake/Modules/AddCompilerRT.cmake


Index: cmake/Modules/AddCompilerRT.cmake
===
--- cmake/Modules/AddCompilerRT.cmake
+++ cmake/Modules/AddCompilerRT.cmake
@@ -291,6 +291,12 @@
   -I${COMPILER_RT_GTEST_PATH}
 )
 
+if(COMPILER_RT_STANDALONE_BUILD)
+  # Add a dummy target to satisfy dependencies on GTest when building
+  # stand-alone. GTest itself is provided via COMPILER_RT_GTEST_SOURCES.
+  add_custom_target(gtest)
+endif()
+
 append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 
COMPILER_RT_UNITTEST_CFLAGS)
 append_list_if(COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG 
-Wno-covered-switch-default COMPILER_RT_UNITTEST_CFLAGS)
 


Index: cmake/Modules/AddCompilerRT.cmake
===
--- cmake/Modules/AddCompilerRT.cmake
+++ cmake/Modules/AddCompilerRT.cmake
@@ -291,6 +291,12 @@
   -I${COMPILER_RT_GTEST_PATH}
 )
 
+if(COMPILER_RT_STANDALONE_BUILD)
+  # Add a dummy target to satisfy dependencies on GTest when building
+  # stand-alone. GTest itself is provided via COMPILER_RT_GTEST_SOURCES.
+  add_custom_target(gtest)
+endif()
+
 append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 COMPILER_RT_UNITTEST_CFLAGS)
 append_list_if(COMPILER_RT_HAS_WCOVERED_SWITCH_DEFAULT_FLAG -Wno-covered-switch-default COMPILER_RT_UNITTEST_CFLAGS)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38441: [compiler-rt] [cmake] Add a separate CMake var to control profile runtime

2017-10-01 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314646: [cmake] Add a separate CMake var to control profile 
runtime (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D38441?vs=117255&id=117299#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38441

Files:
  compiler-rt/trunk/CMakeLists.txt
  compiler-rt/trunk/lib/CMakeLists.txt
  compiler-rt/trunk/test/CMakeLists.txt


Index: compiler-rt/trunk/lib/CMakeLists.txt
===
--- compiler-rt/trunk/lib/CMakeLists.txt
+++ compiler-rt/trunk/lib/CMakeLists.txt
@@ -41,7 +41,7 @@
   endforeach()
 endif()
 
-if (COMPILER_RT_HAS_PROFILE)
+if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
   compiler_rt_build_runtime(profile)
 endif()
 
Index: compiler-rt/trunk/test/CMakeLists.txt
===
--- compiler-rt/trunk/test/CMakeLists.txt
+++ compiler-rt/trunk/test/CMakeLists.txt
@@ -10,7 +10,7 @@
 
 set(SANITIZER_COMMON_LIT_TEST_DEPS)
 
-if (COMPILER_RT_HAS_PROFILE)
+if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
   list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS profile)
 endif()
 
@@ -72,7 +72,7 @@
   endif()
 endforeach()
   endif()
-  if (COMPILER_RT_HAS_PROFILE)
+  if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
 compiler_rt_test_runtime(profile)
   endif()
   if(COMPILER_RT_BUILD_XRAY)
Index: compiler-rt/trunk/CMakeLists.txt
===
--- compiler-rt/trunk/CMakeLists.txt
+++ compiler-rt/trunk/CMakeLists.txt
@@ -38,6 +38,8 @@
 mark_as_advanced(COMPILER_RT_BUILD_XRAY)
 option(COMPILER_RT_BUILD_LIBFUZZER "Build libFuzzer" ON)
 mark_as_advanced(COMPILER_RT_BUILD_LIBFUZZER)
+option(COMPILER_RT_BUILD_PROFILE "Build profile runtime" ON)
+mark_as_advanced(COMPILER_RT_BUILD_PROFILE)
 option(COMPILER_RT_BUILD_XRAY_NO_PREINIT "Build xray with no preinit patching" 
OFF)
 mark_as_advanced(COMPILER_RT_BUILD_XRAY_NO_PREINIT)
 


Index: compiler-rt/trunk/lib/CMakeLists.txt
===
--- compiler-rt/trunk/lib/CMakeLists.txt
+++ compiler-rt/trunk/lib/CMakeLists.txt
@@ -41,7 +41,7 @@
   endforeach()
 endif()
 
-if (COMPILER_RT_HAS_PROFILE)
+if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
   compiler_rt_build_runtime(profile)
 endif()
 
Index: compiler-rt/trunk/test/CMakeLists.txt
===
--- compiler-rt/trunk/test/CMakeLists.txt
+++ compiler-rt/trunk/test/CMakeLists.txt
@@ -10,7 +10,7 @@
 
 set(SANITIZER_COMMON_LIT_TEST_DEPS)
 
-if (COMPILER_RT_HAS_PROFILE)
+if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
   list(APPEND SANITIZER_COMMON_LIT_TEST_DEPS profile)
 endif()
 
@@ -72,7 +72,7 @@
   endif()
 endforeach()
   endif()
-  if (COMPILER_RT_HAS_PROFILE)
+  if(COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
 compiler_rt_test_runtime(profile)
   endif()
   if(COMPILER_RT_BUILD_XRAY)
Index: compiler-rt/trunk/CMakeLists.txt
===
--- compiler-rt/trunk/CMakeLists.txt
+++ compiler-rt/trunk/CMakeLists.txt
@@ -38,6 +38,8 @@
 mark_as_advanced(COMPILER_RT_BUILD_XRAY)
 option(COMPILER_RT_BUILD_LIBFUZZER "Build libFuzzer" ON)
 mark_as_advanced(COMPILER_RT_BUILD_LIBFUZZER)
+option(COMPILER_RT_BUILD_PROFILE "Build profile runtime" ON)
+mark_as_advanced(COMPILER_RT_BUILD_PROFILE)
 option(COMPILER_RT_BUILD_XRAY_NO_PREINIT "Build xray with no preinit patching" OFF)
 mark_as_advanced(COMPILER_RT_BUILD_XRAY_NO_PREINIT)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2017-10-02 Thread Michał Górny via Phabricator via cfe-commits
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.

  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.

>> and the likeliness of people mistakenly adding more unconditional 
>> dependencies
> 
> That's a good point, however I'm not sure how your change would fix the 
> problem.
>  As far as I remember targets in compiler-rt had quite a few dependencies 
> which required checking for whether it is a standalone build.
> 
> In general, I'm not sure what this change would achieve, and the added 
> complexity can always cause more bugs in the future.

My goal is to make things work again.


Repository:
  rL LLVM

https://reviews.llvm.org/D38444



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


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

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

In https://reviews.llvm.org/D38444#895403, @george.karpenkov wrote:

> @mgorny I've replied via email, but the message didn't seem to appear here.
>
> From my (maybe limited) understanding, running tests on standalone 
> compiler-rt builds was never something which was supported, as that required 
> a fresh compiler.
>  I've just tried running them, and for me even `check-*` targets don't exist.
>
> How do you create the standalone build? I've checked out `compiler-rt` 
> separately, and ran
>
>   cmake -GNinja 
> -DLLVM_CONFIG=/Users/george/code/llvm/release-build/bin/llvm-config  ../.
>


Our command-line is:

  cmake -C 
/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/compiler-rt-sanitizers-_build/gentoo_common_config.cmake
 -G Ninja -DCMAKE_INSTALL_PREFIX=/usr 
-DCOMPILER_RT_INSTALL_PATH=/usr/lib/clang/6.0.0 
-DCOMPILER_RT_OUTPUT_DIR=/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/compiler-rt-sanitizers-_build/lib/clang/6.0.0
 -DCOMPILER_RT_INCLUDE_TESTS=yes -DCOMPILER_RT_BUILD_BUILTINS=OFF 
-DCOMPILER_RT_BUILD_LIBFUZZER=ON -DCOMPILER_RT_BUILD_SANITIZERS=ON 
-DCOMPILER_RT_BUILD_XRAY=ON 
-DLLVM_MAIN_SRC_DIR=/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/llvm
 -DLLVM_EXTERNAL_LIT=/usr/bin/lit -DLLVM_LIT_ARGS=-vv 
-DCOMPILER_RT_TEST_COMPILER=/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/compiler-rt-sanitizers-_build/lib/llvm/6/bin/clang
 
-DCOMPILER_RT_TEST_CXX_COMPILER=/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/compiler-rt-sanitizers-_build/lib/llvm/6/bin/clang++
 -DCMAKE_BUILD_TYPE=RelWithDebInfo 
-DCMAKE_USER_MAKE_RULES_OVERRIDE=/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/compiler-rt-sanitizers-_build/gentoo_rules.cmake
 
-DCMAKE_TOOLCHAIN_FILE=/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/compiler-rt-sanitizers-_build/gentoo_toolchain.cmake
  
/var/tmp/portage/sys-libs/compiler-rt-sanitizers-/work/compiler-rt-sanitizers-



> but the resulting build directory does not have any `check-*` targets.

I think the `-DCOMPILER_RT_INCLUDE_TESTS=yes` may be relevant here.

> In the refactoring I did try to make the dependence conditional: all 
> compilation goes through `sanitizer_test_compile`,
>  but looking into the `sanitizer_test_compile` macro there is an obvious bug.
>  Would it be better to fix that instead?

Indeed there is. I'll check if fixing that solves the issue.


Repository:
  rL LLVM

https://reviews.llvm.org/D38444



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


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

2017-10-12 Thread Michał Górny via Phabricator via cfe-commits
mgorny abandoned this revision.
mgorny added a comment.

Ok, I think I've found a better solution. Will start submitting patches soonish.


Repository:
  rL LLVM

https://reviews.llvm.org/D38444



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


[PATCH] D38838: [compiler-rt] [cmake] Fix skipping DEPS (typo) in sanitizer_test_compile()

2017-10-12 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
Herald added a subscriber: dberris.

Fix typo in variable assignment inside sanitizer_test_compile() that
resulted in TEST_DEPS parameter not being included in the clang_compile()
call. Spotted by George Karpenkov in https://reviews.llvm.org/D38444.


https://reviews.llvm.org/D38838

Files:
  cmake/Modules/CompilerRTCompile.cmake


Index: cmake/Modules/CompilerRTCompile.cmake
===
--- cmake/Modules/CompilerRTCompile.cmake
+++ cmake/Modules/CompilerRTCompile.cmake
@@ -51,7 +51,7 @@
   endif()
   clang_compile(${output_obj} ${source}
 CFLAGS ${TEST_CFLAGS} ${TARGET_CFLAGS}
-DEPS ${TEST_COMPILE_DEPS})
+DEPS ${COMPILE_DEPS})
   list(APPEND ${obj_list} ${output_obj})
   set("${obj_list}" "${${obj_list}}" PARENT_SCOPE)
 endfunction()


Index: cmake/Modules/CompilerRTCompile.cmake
===
--- cmake/Modules/CompilerRTCompile.cmake
+++ cmake/Modules/CompilerRTCompile.cmake
@@ -51,7 +51,7 @@
   endif()
   clang_compile(${output_obj} ${source}
 CFLAGS ${TEST_CFLAGS} ${TARGET_CFLAGS}
-DEPS ${TEST_COMPILE_DEPS})
+DEPS ${COMPILE_DEPS})
   list(APPEND ${obj_list} ${output_obj})
   set("${obj_list}" "${${obj_list}}" PARENT_SCOPE)
 endfunction()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38839: [compiler-rt] [cmake] [interception] Remove duplicate gtest from test COMPILE_DEPS

2017-10-12 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
Herald added a subscriber: dberris.

Fix the gtest dependency to be included in DEPS only, rather than
in COMPILE_DEPS + DEPS. The former variable is apparently used to
provide unconditional dependencies, while the latter are only used
for non-standalone builds. Since they are concatenated, specifying gtest
in both is redundant. Furthermore, including it in COMPILE_DEPS causes
build failure for standalone builds where 'gtest' target is not present.


https://reviews.llvm.org/D38839

Files:
  lib/interception/tests/CMakeLists.txt


Index: lib/interception/tests/CMakeLists.txt
===
--- lib/interception/tests/CMakeLists.txt
+++ lib/interception/tests/CMakeLists.txt
@@ -89,7 +89,7 @@
 InterceptionUnitTests "Interception-${arch}-Test" ${arch}
 RUNTIME ${INTERCEPTION_COMMON_LIB}
 SOURCES ${INTERCEPTION_UNITTESTS} ${COMPILER_RT_GTEST_SOURCE}
-COMPILE_DEPS gtest ${INTERCEPTION_TEST_HEADERS}
+COMPILE_DEPS ${INTERCEPTION_TEST_HEADERS}
 DEPS gtest
 CFLAGS ${INTERCEPTION_TEST_CFLAGS_COMMON}
 LINK_FLAGS ${INTERCEPTION_TEST_LINK_FLAGS_COMMON})


Index: lib/interception/tests/CMakeLists.txt
===
--- lib/interception/tests/CMakeLists.txt
+++ lib/interception/tests/CMakeLists.txt
@@ -89,7 +89,7 @@
 InterceptionUnitTests "Interception-${arch}-Test" ${arch}
 RUNTIME ${INTERCEPTION_COMMON_LIB}
 SOURCES ${INTERCEPTION_UNITTESTS} ${COMPILER_RT_GTEST_SOURCE}
-COMPILE_DEPS gtest ${INTERCEPTION_TEST_HEADERS}
+COMPILE_DEPS ${INTERCEPTION_TEST_HEADERS}
 DEPS gtest
 CFLAGS ${INTERCEPTION_TEST_CFLAGS_COMMON}
 LINK_FLAGS ${INTERCEPTION_TEST_LINK_FLAGS_COMMON})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38840: [compiler-rt] [cmake] [asan] Reuse generate_asan_tests for dynamic tests

2017-10-12 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
Herald added subscribers: dberris, kubamracek.

Unify the ASAN dynamic test logic to use generate_asan_tests() in both
MSVC and non-MSVC branch. It is unclear why this particular branch used
add_compiler_rt_test() directly. However, it skipped
the COMPILE_DEPS/DEPS logic which resulted in 'gtest' target being
included in standalone builds, causing build failures due to missing
target.


https://reviews.llvm.org/D38840

Files:
  lib/asan/tests/CMakeLists.txt


Index: lib/asan/tests/CMakeLists.txt
===
--- lib/asan/tests/CMakeLists.txt
+++ lib/asan/tests/CMakeLists.txt
@@ -202,9 +202,9 @@
 else()
 
   # Otherwise, reuse ASAN_INST_TEST_OBJECTS.
-  add_compiler_rt_test(AsanDynamicUnitTests "${dynamic_test_name}" 
"${arch}"
+  generate_asan_tests(ASAN_INST_TEST_OBJECTS
+AsanDynamicUnitTests "${dynamic_test_name}"
 SUBDIR "dynamic"
-OBJECTS ${ASAN_INST_TEST_OBJECTS}
 DEPS gtest asan ${ASAN_INST_TEST_OBJECTS}
 LINK_FLAGS ${ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINK_FLAGS}
 )


Index: lib/asan/tests/CMakeLists.txt
===
--- lib/asan/tests/CMakeLists.txt
+++ lib/asan/tests/CMakeLists.txt
@@ -202,9 +202,9 @@
 else()
 
   # Otherwise, reuse ASAN_INST_TEST_OBJECTS.
-  add_compiler_rt_test(AsanDynamicUnitTests "${dynamic_test_name}" "${arch}"
+  generate_asan_tests(ASAN_INST_TEST_OBJECTS
+AsanDynamicUnitTests "${dynamic_test_name}"
 SUBDIR "dynamic"
-OBJECTS ${ASAN_INST_TEST_OBJECTS}
 DEPS gtest asan ${ASAN_INST_TEST_OBJECTS}
 LINK_FLAGS ${ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINK_FLAGS}
 )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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

https://reviews.llvm.org/D38838 addresses the typo. Now that I know how it's 
supposed to work, https://reviews.llvm.org/D38839 and 
https://reviews.llvm.org/D38840 address the issues, and fix it for me.


Repository:
  rL LLVM

https://reviews.llvm.org/D38444



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


[PATCH] D38838: [compiler-rt] [cmake] Fix skipping DEPS (typo) in sanitizer_test_compile()

2017-10-12 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315604: [cmake] Fix skipping DEPS (typo) in 
sanitizer_test_compile() (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D38838?vs=118752&id=118820#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38838

Files:
  compiler-rt/trunk/cmake/Modules/CompilerRTCompile.cmake


Index: compiler-rt/trunk/cmake/Modules/CompilerRTCompile.cmake
===
--- compiler-rt/trunk/cmake/Modules/CompilerRTCompile.cmake
+++ compiler-rt/trunk/cmake/Modules/CompilerRTCompile.cmake
@@ -51,7 +51,7 @@
   endif()
   clang_compile(${output_obj} ${source}
 CFLAGS ${TEST_CFLAGS} ${TARGET_CFLAGS}
-DEPS ${TEST_COMPILE_DEPS})
+DEPS ${COMPILE_DEPS})
   list(APPEND ${obj_list} ${output_obj})
   set("${obj_list}" "${${obj_list}}" PARENT_SCOPE)
 endfunction()


Index: compiler-rt/trunk/cmake/Modules/CompilerRTCompile.cmake
===
--- compiler-rt/trunk/cmake/Modules/CompilerRTCompile.cmake
+++ compiler-rt/trunk/cmake/Modules/CompilerRTCompile.cmake
@@ -51,7 +51,7 @@
   endif()
   clang_compile(${output_obj} ${source}
 CFLAGS ${TEST_CFLAGS} ${TARGET_CFLAGS}
-DEPS ${TEST_COMPILE_DEPS})
+DEPS ${COMPILE_DEPS})
   list(APPEND ${obj_list} ${output_obj})
   set("${obj_list}" "${${obj_list}}" PARENT_SCOPE)
 endfunction()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38839: [compiler-rt] [cmake] [interception] Remove duplicate gtest from test COMPILE_DEPS

2017-10-12 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315605: [cmake] [interception] Remove duplicate gtest from 
test COMPILE_DEPS (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D38839?vs=118754&id=118821#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38839

Files:
  compiler-rt/trunk/lib/interception/tests/CMakeLists.txt


Index: compiler-rt/trunk/lib/interception/tests/CMakeLists.txt
===
--- compiler-rt/trunk/lib/interception/tests/CMakeLists.txt
+++ compiler-rt/trunk/lib/interception/tests/CMakeLists.txt
@@ -89,7 +89,7 @@
 InterceptionUnitTests "Interception-${arch}-Test" ${arch}
 RUNTIME ${INTERCEPTION_COMMON_LIB}
 SOURCES ${INTERCEPTION_UNITTESTS} ${COMPILER_RT_GTEST_SOURCE}
-COMPILE_DEPS gtest ${INTERCEPTION_TEST_HEADERS}
+COMPILE_DEPS ${INTERCEPTION_TEST_HEADERS}
 DEPS gtest
 CFLAGS ${INTERCEPTION_TEST_CFLAGS_COMMON}
 LINK_FLAGS ${INTERCEPTION_TEST_LINK_FLAGS_COMMON})


Index: compiler-rt/trunk/lib/interception/tests/CMakeLists.txt
===
--- compiler-rt/trunk/lib/interception/tests/CMakeLists.txt
+++ compiler-rt/trunk/lib/interception/tests/CMakeLists.txt
@@ -89,7 +89,7 @@
 InterceptionUnitTests "Interception-${arch}-Test" ${arch}
 RUNTIME ${INTERCEPTION_COMMON_LIB}
 SOURCES ${INTERCEPTION_UNITTESTS} ${COMPILER_RT_GTEST_SOURCE}
-COMPILE_DEPS gtest ${INTERCEPTION_TEST_HEADERS}
+COMPILE_DEPS ${INTERCEPTION_TEST_HEADERS}
 DEPS gtest
 CFLAGS ${INTERCEPTION_TEST_CFLAGS_COMMON}
 LINK_FLAGS ${INTERCEPTION_TEST_LINK_FLAGS_COMMON})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38840: [compiler-rt] [cmake] [asan] Remove unnecessary gtest dep from dynamic tests

2017-10-12 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 118826.
mgorny retitled this revision from "[compiler-rt] [cmake] [asan] Reuse 
generate_asan_tests for dynamic tests" to "[compiler-rt] [cmake] [asan] Remove 
unnecessary gtest dep from dynamic tests".
mgorny edited the summary of this revision.
mgorny added a comment.

Ok, here's another idea. Since the objects have been compiled already (and they 
explicitly depend on gtest via their own deps), let's just remove the 
extraneous gtest dep.


https://reviews.llvm.org/D38840

Files:
  lib/asan/tests/CMakeLists.txt


Index: lib/asan/tests/CMakeLists.txt
===
--- lib/asan/tests/CMakeLists.txt
+++ lib/asan/tests/CMakeLists.txt
@@ -205,7 +205,7 @@
   add_compiler_rt_test(AsanDynamicUnitTests "${dynamic_test_name}" 
"${arch}"
 SUBDIR "dynamic"
 OBJECTS ${ASAN_INST_TEST_OBJECTS}
-DEPS gtest asan ${ASAN_INST_TEST_OBJECTS}
+DEPS asan ${ASAN_INST_TEST_OBJECTS}
 LINK_FLAGS ${ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINK_FLAGS}
 )
 endif()


Index: lib/asan/tests/CMakeLists.txt
===
--- lib/asan/tests/CMakeLists.txt
+++ lib/asan/tests/CMakeLists.txt
@@ -205,7 +205,7 @@
   add_compiler_rt_test(AsanDynamicUnitTests "${dynamic_test_name}" "${arch}"
 SUBDIR "dynamic"
 OBJECTS ${ASAN_INST_TEST_OBJECTS}
-DEPS gtest asan ${ASAN_INST_TEST_OBJECTS}
+DEPS asan ${ASAN_INST_TEST_OBJECTS}
 LINK_FLAGS ${ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINK_FLAGS}
 )
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38840: [compiler-rt] [cmake] [asan] Remove unnecessary gtest dep from dynamic tests

2017-10-12 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315620: [cmake] [asan] Remove unnecessary gtest dep from 
dynamic tests (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D38840?vs=118826&id=118842#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38840

Files:
  compiler-rt/trunk/lib/asan/tests/CMakeLists.txt


Index: compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
===
--- compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
+++ compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
@@ -205,7 +205,7 @@
   add_compiler_rt_test(AsanDynamicUnitTests "${dynamic_test_name}" 
"${arch}"
 SUBDIR "dynamic"
 OBJECTS ${ASAN_INST_TEST_OBJECTS}
-DEPS gtest asan ${ASAN_INST_TEST_OBJECTS}
+DEPS asan ${ASAN_INST_TEST_OBJECTS}
 LINK_FLAGS ${ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINK_FLAGS}
 )
 endif()


Index: compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
===
--- compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
+++ compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
@@ -205,7 +205,7 @@
   add_compiler_rt_test(AsanDynamicUnitTests "${dynamic_test_name}" "${arch}"
 SUBDIR "dynamic"
 OBJECTS ${ASAN_INST_TEST_OBJECTS}
-DEPS gtest asan ${ASAN_INST_TEST_OBJECTS}
+DEPS asan ${ASAN_INST_TEST_OBJECTS}
 LINK_FLAGS ${ASAN_DYNAMIC_UNITTEST_INSTRUMENTED_LINK_FLAGS}
 )
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51714: CMake: Deprecate using llvm-config to detect llvm installation

2018-09-05 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Is LLVM_CONFIG dropped from cache here? I suspect the warning might fire for 
everyone who has LLVM configured.


Repository:
  rC Clang

https://reviews.llvm.org/D51714



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


[PATCH] D51714: CMake: Deprecate using llvm-config to detect llvm installation

2018-09-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

I don't have a strong opinion here.


Repository:
  rC Clang

https://reviews.llvm.org/D51714



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


[PATCH] D50171: [python] [tests] Update test_code_completion

2018-09-11 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Ping.


Repository:
  rC Clang

https://reviews.llvm.org/D50171



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


[PATCH] D50171: [python] [tests] Update test_code_completion

2018-09-11 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 164871.
mgorny added a comment.

Ai, sorry about that. Uploaded the proper diff now. I suppose it's not going to 
make it for 7.0.0 anymore, so it's not a priority. I'll try to bisect it today 
once I finish testing RC3.


https://reviews.llvm.org/D50171

Files:
  bindings/python/tests/cindex/test_code_completion.py


Index: bindings/python/tests/cindex/test_code_completion.py
===
--- bindings/python/tests/cindex/test_code_completion.py
+++ bindings/python/tests/cindex/test_code_completion.py
@@ -61,11 +61,11 @@
 cr = tu.codeComplete('fake.cpp', 12, 5, unsaved_files=files)
 
 expected = [
-  "{'const', TypedText} || Priority: 40 || Availability: Available || 
Brief comment: None",
-  "{'volatile', TypedText} || Priority: 40 || Availability: Available 
|| Brief comment: None",
+  "{'const', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None",
+  "{'volatile', TypedText} || Priority: 50 || Availability: Available 
|| Brief comment: None",
   "{'operator', TypedText} || Priority: 40 || Availability: Available 
|| Brief comment: None",
-  "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: 
Available || Brief comment: None",
-  "{'Q', TypedText} | {'::', Text} || Priority: 75 || Availability: 
Available || Brief comment: None"
+  "{'P', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None",
+  "{'Q', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None"
 ]
 self.check_completion_results(cr, expected)
 


Index: bindings/python/tests/cindex/test_code_completion.py
===
--- bindings/python/tests/cindex/test_code_completion.py
+++ bindings/python/tests/cindex/test_code_completion.py
@@ -61,11 +61,11 @@
 cr = tu.codeComplete('fake.cpp', 12, 5, unsaved_files=files)
 
 expected = [
-  "{'const', TypedText} || Priority: 40 || Availability: Available || Brief comment: None",
-  "{'volatile', TypedText} || Priority: 40 || Availability: Available || Brief comment: None",
+  "{'const', TypedText} || Priority: 50 || Availability: Available || Brief comment: None",
+  "{'volatile', TypedText} || Priority: 50 || Availability: Available || Brief comment: None",
   "{'operator', TypedText} || Priority: 40 || Availability: Available || Brief comment: None",
-  "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: Available || Brief comment: None",
-  "{'Q', TypedText} | {'::', Text} || Priority: 75 || Availability: Available || Brief comment: None"
+  "{'P', TypedText} || Priority: 50 || Availability: Available || Brief comment: None",
+  "{'Q', TypedText} || Priority: 50 || Availability: Available || Brief comment: None"
 ]
 self.check_completion_results(cr, expected)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50171: [python] [tests] Update test_code_completion

2018-09-11 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Apparently the first change changing the completion results is:

  commit a408f8d27bfd5bab55c39ef2a6fff6850be4a351
  Author: Ilya Biryukov 
  Date:   Tue Apr 24 15:48:53 2018
  
  [CodeComplete] Fix completion at the end of keywords
  
  Summary:
  Make completion behave consistently no matter if it is run at the
  start, in the middle or at the end of an identifier that happens to
  be a keyword or a macro name. Since completion is often ran on
  incomplete identifiers, they may turn into keywords by accident.
  
  For example, we should produce same results for all of these
  completion points:
  
  // ^ is completion point.
  ^class
  cla^ss
  class^
  
  Previously clang produced different results for the last case (as if
  the completion point was after a space: `class ^`).
  
  This change also updates some offsets in tests that (unintentionally?)
  relied on the old behavior.
  
  Reviewers: sammccall, bkramer, arphaman, aaron.ballman
  
  Reviewed By: sammccall
  
  Subscribers: cfe-commits
  
  Differential Revision: https://reviews.llvm.org/D45887
  
  git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330717 
91177308-0d34-0410-b5e6-96231b3b80d8


https://reviews.llvm.org/D50171



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


[PATCH] D50171: [python] [tests] Update test_code_completion

2018-09-11 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

...and unless I'm mistaken, this commit is responsible for both changes (that 
is, I need to apply all of this patch to make tests pass at its point).


https://reviews.llvm.org/D50171



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


[PATCH] D49765: [CMake] Use LIBCXXABI_LIBDIR_SUFFIX in libc++abi build

2018-07-24 Thread Michał Górny via Phabricator via cfe-commits
mgorny accepted this revision.
mgorny added a comment.
This revision is now accepted and ready to land.

Looks good, thanks!


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D49765



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


[PATCH] D50156: [test] Fix %hmaptool path for standalone builds

2018-08-01 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: bkramer, bruno.

Fix %hmaptool path to refer to clang_tools_dir instead of
llvm_tools_dir, in order to fix standalone builds.  The tool is built
as part of clang, so it won't be found in installed LLVM tools.


Repository:
  rC Clang

https://reviews.llvm.org/D50156

Files:
  test/lit.cfg.py


Index: test/lit.cfg.py
===
--- test/lit.cfg.py
+++ test/lit.cfg.py
@@ -71,7 +71,7 @@
 
 config.substitutions.append(
 ('%hmaptool', "'%s' %s" % (config.python_executable,
- os.path.join(config.llvm_tools_dir, 'hmaptool'
+ os.path.join(config.clang_tools_dir, 
'hmaptool'
 
 # Plugins (loadable modules)
 # TODO: This should be supplied by Makefile or autoconf.


Index: test/lit.cfg.py
===
--- test/lit.cfg.py
+++ test/lit.cfg.py
@@ -71,7 +71,7 @@
 
 config.substitutions.append(
 ('%hmaptool', "'%s' %s" % (config.python_executable,
- os.path.join(config.llvm_tools_dir, 'hmaptool'
+ os.path.join(config.clang_tools_dir, 'hmaptool'
 
 # Plugins (loadable modules)
 # TODO: This should be supplied by Makefile or autoconf.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50156: [test] Fix %hmaptool path for standalone builds

2018-08-01 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC338627: [test] Fix %hmaptool path for standalone builds 
(authored by mgorny, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D50156

Files:
  test/lit.cfg.py


Index: test/lit.cfg.py
===
--- test/lit.cfg.py
+++ test/lit.cfg.py
@@ -71,7 +71,7 @@
 
 config.substitutions.append(
 ('%hmaptool', "'%s' %s" % (config.python_executable,
- os.path.join(config.llvm_tools_dir, 'hmaptool'
+ os.path.join(config.clang_tools_dir, 
'hmaptool'
 
 # Plugins (loadable modules)
 # TODO: This should be supplied by Makefile or autoconf.


Index: test/lit.cfg.py
===
--- test/lit.cfg.py
+++ test/lit.cfg.py
@@ -71,7 +71,7 @@
 
 config.substitutions.append(
 ('%hmaptool', "'%s' %s" % (config.python_executable,
- os.path.join(config.llvm_tools_dir, 'hmaptool'
+ os.path.join(config.clang_tools_dir, 'hmaptool'
 
 # Plugins (loadable modules)
 # TODO: This should be supplied by Makefile or autoconf.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50171: [python] [tests] Update test_code_completion

2018-08-02 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: ilya-biryukov, arphaman, bkramer, gribozavr.

Update expected completions to match output generated by clang-7.0.

Disclaimer: I have no clue if the results are correct. I'm kinda wondering why 
the '::' part is no longer included immediately.

Also PR38417 .


Repository:
  rC Clang

https://reviews.llvm.org/D50171

Files:
  bindings/python/tests/cindex/test_code_completion.py


Index: bindings/python/tests/cindex/test_code_completion.py
===
--- bindings/python/tests/cindex/test_code_completion.py
+++ bindings/python/tests/cindex/test_code_completion.py
@@ -61,11 +61,11 @@
 cr = tu.codeComplete('fake.cpp', 12, 5, unsaved_files=files)
 
 expected = [
-  "{'const', TypedText} || Priority: 40 || Availability: Available || 
Brief comment: None",
-  "{'volatile', TypedText} || Priority: 40 || Availability: Available 
|| Brief comment: None",
+  "{'const', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None",
+  "{'volatile', TypedText} || Priority: 50 || Availability: Available 
|| Brief comment: None",
   "{'operator', TypedText} || Priority: 40 || Availability: Available 
|| Brief comment: None",
-  "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: 
Available || Brief comment: None",
-  "{'Q', TypedText} | {'::', Text} || Priority: 75 || Availability: 
Available || Brief comment: None"
+  "{'P', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None",
+  "{'Q', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None"
 ]
 self.check_completion_results(cr, expected)
 


Index: bindings/python/tests/cindex/test_code_completion.py
===
--- bindings/python/tests/cindex/test_code_completion.py
+++ bindings/python/tests/cindex/test_code_completion.py
@@ -61,11 +61,11 @@
 cr = tu.codeComplete('fake.cpp', 12, 5, unsaved_files=files)
 
 expected = [
-  "{'const', TypedText} || Priority: 40 || Availability: Available || Brief comment: None",
-  "{'volatile', TypedText} || Priority: 40 || Availability: Available || Brief comment: None",
+  "{'const', TypedText} || Priority: 50 || Availability: Available || Brief comment: None",
+  "{'volatile', TypedText} || Priority: 50 || Availability: Available || Brief comment: None",
   "{'operator', TypedText} || Priority: 40 || Availability: Available || Brief comment: None",
-  "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: Available || Brief comment: None",
-  "{'Q', TypedText} | {'::', Text} || Priority: 75 || Availability: Available || Brief comment: None"
+  "{'P', TypedText} || Priority: 50 || Availability: Available || Brief comment: None",
+  "{'Q', TypedText} || Priority: 50 || Availability: Available || Brief comment: None"
 ]
 self.check_completion_results(cr, expected)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34365: [FrontEnd] Allow overriding the default C/C++ -std via CMake vars

2018-02-19 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Ping for the third time.


https://reviews.llvm.org/D34365



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


[PATCH] D32595: CMakeLists: Don't set LLVM_MAIN_SRC_DIR when building stand-alone clang

2017-05-31 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

This is going to break Gentoo. We're relying on the ability to specify 
LLVM_MAIN_SRC_DIR to provide unpacked LLVM sources with gtest. Without that, I 
don't see how we can use tests.


https://reviews.llvm.org/D32595



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


[PATCH] D32595: CMakeLists: Don't set LLVM_MAIN_SRC_DIR when building stand-alone clang

2017-05-31 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

(note that I don't mind removing the llvm-config bit for it; but we need the 
cache variable to stay)


https://reviews.llvm.org/D32595



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


[PATCH] D33259: Don't defer to the GCC driver for linking arm-baremetal

2017-06-03 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

This causes a test failure with non-standard CLANG_RESOURCE_DIR:

  Command Output (stderr):
  --
  
/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/test/Driver/baremetal.cpp:8:22:
 error: expected string not found in input
  // CHECK-V6M-C-SAME: "-resource-dir" 
"[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION:[^"]*]]"
   ^
  :5:128: note: scanning from here
   
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/./bin/clang"
 "-cc1" "-triple" "thumbv6m-none--eabi" "-emit-obj" "-mrelax-all" 
"-disable-free" "-disable-llvm-verifier" "-discard-value-names" 
"-main-file-name" "baremetal.cpp" "-mrelocation-model" "static" 
"-mthread-model" "single" "-mdisable-fp-elim" "-fmath-errno" 
"-no-integrated-as" "-mconstructor-aliases" "-nostdsysteminc" "-target-cpu" 
"cortex-m0" "-target-feature" "+soft-float-abi" "-target-feature" 
"+strict-align" "-target-abi" "aapcs" "-mfloat-abi" "soft" "-dwarf-column-info" 
"-debugger-tuning=gdb" "-resource-dir" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/./bin/../../../../lib/clang/5.0.0"
 "-isysroot" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/test/Driver/Inputs/baremetal_arm"
 "-internal-isystem" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/test/Driver/Inputs/baremetal_arm/include/c++/v1"
 "-internal-isystem" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/./bin/../../../../lib/clang/5.0.0/include"
 "-internal-isystem" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/test/Driver/Inputs/baremetal_arm/include"
 "-fdeprecated-macro" "-fdebug-compilation-dir" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/test/Driver"
 "-ferror-limit" "19" "-fmessage-length" "0" 
"-fallow-half-arguments-and-returns" "-fno-signed-char" "-fobjc-runtime=gcc" 
"-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-o" 
"/var/tmp/portage/sys-devel/clang-/temp/baremetal-6b1d37.o" "-x" "c++" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/test/Driver/baremetal.cpp"

 ^
  :5:128: note: with variable "PREFIX_DIR" equal to 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/."
   
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/./bin/clang"
 "-cc1" "-triple" "thumbv6m-none--eabi" "-emit-obj" "-mrelax-all" 
"-disable-free" "-disable-llvm-verifier" "-discard-value-names" 
"-main-file-name" "baremetal.cpp" "-mrelocation-model" "static" 
"-mthread-model" "single" "-mdisable-fp-elim" "-fmath-errno" 
"-no-integrated-as" "-mconstructor-aliases" "-nostdsysteminc" "-target-cpu" 
"cortex-m0" "-target-feature" "+soft-float-abi" "-target-feature" 
"+strict-align" "-target-abi" "aapcs" "-mfloat-abi" "soft" "-dwarf-column-info" 
"-debugger-tuning=gdb" "-resource-dir" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/./bin/../../../../lib/clang/5.0.0"
 "-isysroot" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/test/Driver/Inputs/baremetal_arm"
 "-internal-isystem" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/test/Driver/Inputs/baremetal_arm/include/c++/v1"
 "-internal-isystem" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/./bin/../../../../lib/clang/5.0.0/include"
 "-internal-isystem" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/test/Driver/Inputs/baremetal_arm/include"
 "-fdeprecated-macro" "-fdebug-compilation-dir" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/test/Driver"
 "-ferror-limit" "19" "-fmessage-length" "0" 
"-fallow-half-arguments-and-returns" "-fno-signed-char" "-fobjc-runtime=gcc" 
"-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-o" 
"/var/tmp/portage/sys-devel/clang-/temp/baremetal-6b1d37.o" "-x" "c++" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang-/test/Driver/baremetal.cpp"

 ^
  :5:588: note: possible intended match here
   
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/./bin/clang"
 "-cc1" "-triple" "thumbv6m-none--eabi" "-emit-obj" "-mrelax-all" 
"-disable-free" "-disable-llvm-verifier" "-discard-value-names" 
"-main-file-name" "baremetal.cpp" "-mrelocation-model" "static" 
"-mthread-model" "single" "-mdisable-fp-elim" "-fmath-errno" 
"-no-integrated-as" "-mconstructor-aliases" "-nostdsysteminc" "-target-cpu" 
"cortex-m0" "-target-feature" "+soft-float-abi" "-target-feature" 
"+strict-align" "-target-abi" "aapcs" "-mfloat-abi" "soft" "-dwarf-column-info" 
"-debugger-tuning=gdb" "-resource-dir" 
"/var/tmp/portage/sys-devel/clang-/work/x/y/clang--abi_x86_32.x86/./bin

[PATCH] D33877: [test] Fix baremetal test to allow any -resource-dir

2017-06-04 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.

The baremetal test (r303873) has been added with expectance of very
specific -resource-dir. However, the test itself nor the BareMetal
driver does not enforce any specific -resource-dir, making this
constraint invalid. It already has been altered twice -- in r303910 for
Windows compatibility, and in r304085 for systems using lib64. To
account for even more systems, just use [[RESOURCE_DIR]] like a number
of other tests do. This is needed for Gentoo where RESOURCE_DIR starts
with ../ (uses relative path to a parent directory).


Repository:
  rL LLVM

https://reviews.llvm.org/D33877

Files:
  test/Driver/baremetal.cpp


Index: test/Driver/baremetal.cpp
===
--- test/Driver/baremetal.cpp
+++ test/Driver/baremetal.cpp
@@ -5,13 +5,13 @@
 // RUN: --sysroot=%S/Inputs/baremetal_arm \
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-C %s
 // CHECK-V6M-C: "[[PREFIX_DIR:.*]]{{[/\\]+}}{{[^/^\\]+}}{{[/\\]+}}clang{{.*}}" 
"-cc1" "-triple" "thumbv6m-none--eabi"
-// CHECK-V6M-C-SAME: "-resource-dir" 
"[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION:[^"]*]]"
+// CHECK-V6M-C-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-V6M-C-SAME: "-isysroot" "[[SYSROOT:[^"]*]]"
 // CHECK-V6M-C-SAME: "-internal-isystem" 
"[[SYSROOT]]{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECk-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include"
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld.lld" "{{.*}}.o" "-Bstatic"
-// CHECK-V6M-C-SAME: 
"-L[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" 
"-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
 // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"


Index: test/Driver/baremetal.cpp
===
--- test/Driver/baremetal.cpp
+++ test/Driver/baremetal.cpp
@@ -5,13 +5,13 @@
 // RUN: --sysroot=%S/Inputs/baremetal_arm \
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-C %s
 // CHECK-V6M-C: "[[PREFIX_DIR:.*]]{{[/\\]+}}{{[^/^\\]+}}{{[/\\]+}}clang{{.*}}" "-cc1" "-triple" "thumbv6m-none--eabi"
-// CHECK-V6M-C-SAME: "-resource-dir" "[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION:[^"]*]]"
+// CHECK-V6M-C-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-V6M-C-SAME: "-isysroot" "[[SYSROOT:[^"]*]]"
 // CHECK-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECk-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include"
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld.lld" "{{.*}}.o" "-Bstatic"
-// CHECK-V6M-C-SAME: "-L[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" "-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
 // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33877: [test] Fix baremetal test to allow any -resource-dir

2017-06-05 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304715: [test] Fix baremetal test to allow any -resource-dir 
(authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D33877?vs=101351&id=101403#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33877

Files:
  cfe/trunk/test/Driver/baremetal.cpp


Index: cfe/trunk/test/Driver/baremetal.cpp
===
--- cfe/trunk/test/Driver/baremetal.cpp
+++ cfe/trunk/test/Driver/baremetal.cpp
@@ -5,13 +5,13 @@
 // RUN: --sysroot=%S/Inputs/baremetal_arm \
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-C %s
 // CHECK-V6M-C: "[[PREFIX_DIR:.*]]{{[/\\]+}}{{[^/^\\]+}}{{[/\\]+}}clang{{.*}}" 
"-cc1" "-triple" "thumbv6m-none--eabi"
-// CHECK-V6M-C-SAME: "-resource-dir" 
"[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION:[^"]*]]"
+// CHECK-V6M-C-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-V6M-C-SAME: "-isysroot" "[[SYSROOT:[^"]*]]"
 // CHECK-V6M-C-SAME: "-internal-isystem" 
"[[SYSROOT]]{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECk-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include"
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld.lld" "{{.*}}.o" "-Bstatic"
-// CHECK-V6M-C-SAME: 
"-L[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" 
"-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
 // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"


Index: cfe/trunk/test/Driver/baremetal.cpp
===
--- cfe/trunk/test/Driver/baremetal.cpp
+++ cfe/trunk/test/Driver/baremetal.cpp
@@ -5,13 +5,13 @@
 // RUN: --sysroot=%S/Inputs/baremetal_arm \
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-C %s
 // CHECK-V6M-C: "[[PREFIX_DIR:.*]]{{[/\\]+}}{{[^/^\\]+}}{{[/\\]+}}clang{{.*}}" "-cc1" "-triple" "thumbv6m-none--eabi"
-// CHECK-V6M-C-SAME: "-resource-dir" "[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION:[^"]*]]"
+// CHECK-V6M-C-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-V6M-C-SAME: "-isysroot" "[[SYSROOT:[^"]*]]"
 // CHECK-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECk-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include"
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld.lld" "{{.*}}.o" "-Bstatic"
-// CHECK-V6M-C-SAME: "-L[[PREFIX_DIR]]{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}[[VERSION]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" "-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
 // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m.a"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34365: [FrontEnd] Allow overriding the default C/C++ -std via CMake vars

2017-06-19 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.

Provide two new CMake cache variables -- CLANG_DEFAULT_STD_C
and CLANG_DEFAULT_STD_CXX -- that can be used to override the default
C/ObjC and C++/ObjC++ standards appropriately. They can be set to one of
the identifiers from LangStandards.def, or left unset (the default) to
respect the current platform default.

This option is mostly intended for compiler vendors that do not wish to
continue defaulting to C++98. We are preparing a new Gentoo release that
requires GCC 6, and therefore defaults to -std=gnu++14. Since we want to
maintain as much compatibility between GCC and clang by default, we
would like to adjust the default for clang appropriately.

The code relies on explicit identifiers rather than the string aliases
for simplicity. This saves us from the necessity of parsing aliases at
build-time or adding additional processing at runtime. For the latter
case, it also adds trivial value check -- if incorrect value is passed,
the code simply fails to compile through referencing an undefined
constant.

If the variable is used to redefine the default standard, the explicit
value overrides the special case for PS4. It is done this way mostly
following other kinds of variables where 'platform defaults' are
redefined.

I'm going to submit more test fixes that add explicit -std=
whenever necessary once this is approved.


https://reviews.llvm.org/D34365

Files:
  CMakeLists.txt
  include/clang/Config/config.h.cmake
  lib/Frontend/CompilerInvocation.cpp


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1626,22 +1626,34 @@
   break;
 case InputKind::Asm:
 case InputKind::C:
+#if defined(CLANG_DEFAULT_STD_C)
+  LangStd = CLANG_DEFAULT_STD_C;
+#else
   // The PS4 uses C99 as the default C standard.
   if (T.isPS4())
 LangStd = LangStandard::lang_gnu99;
   else
 LangStd = LangStandard::lang_gnu11;
+#endif
   break;
 case InputKind::ObjC:
+#if defined(CLANG_DEFAULT_STD_C)
+  LangStd = CLANG_DEFAULT_STD_C;
+#else
   LangStd = LangStandard::lang_gnu11;
+#endif
   break;
 case InputKind::CXX:
 case InputKind::ObjCXX:
+#if defined(CLANG_DEFAULT_STD_CXX)
+  LangStd = CLANG_DEFAULT_STD_CXX;
+#else
   // The PS4 uses C++11 as the default C++ standard.
   if (T.isPS4())
 LangStd = LangStandard::lang_gnucxx11;
   else
 LangStd = LangStandard::lang_gnucxx98;
+#endif
   break;
 case InputKind::RenderScript:
   LangStd = LangStandard::lang_c99;
Index: include/clang/Config/config.h.cmake
===
--- include/clang/Config/config.h.cmake
+++ include/clang/Config/config.h.cmake
@@ -11,6 +11,12 @@
 /* Default linker to use. */
 #define CLANG_DEFAULT_LINKER "${CLANG_DEFAULT_LINKER}"
 
+/* Default C/ObjC standard to use. */
+#cmakedefine CLANG_DEFAULT_STD_C LangStandard::lang_${CLANG_DEFAULT_STD_C}
+
+/* Default C++/ObjC++ standard to use. */
+#cmakedefine CLANG_DEFAULT_STD_CXX LangStandard::lang_${CLANG_DEFAULT_STD_CXX}
+
 /* Default C++ stdlib to use. */
 #define CLANG_DEFAULT_CXX_STDLIB "${CLANG_DEFAULT_CXX_STDLIB}"
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -206,6 +206,12 @@
 set(ENABLE_X86_RELAX_RELOCATIONS OFF CACHE BOOL
 "enable x86 relax relocations by default")
 
+# TODO: verify the values against LangStandards.def?
+set(CLANG_DEFAULT_STD_C "" CACHE STRING
+  "Default standard to use for C/ObjC code (IDENT from LangStandards.def, 
empty for platform default)")
+set(CLANG_DEFAULT_STD_CXX "" CACHE STRING
+  "Default standard to use for C++/ObjC++ code (IDENT from LangStandards.def, 
empty for platform default)")
+
 set(CLANG_DEFAULT_LINKER "" CACHE STRING
   "Default linker to use (linker name or absolute path, empty for platform 
default)")
 


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1626,22 +1626,34 @@
   break;
 case InputKind::Asm:
 case InputKind::C:
+#if defined(CLANG_DEFAULT_STD_C)
+  LangStd = CLANG_DEFAULT_STD_C;
+#else
   // The PS4 uses C99 as the default C standard.
   if (T.isPS4())
 LangStd = LangStandard::lang_gnu99;
   else
 LangStd = LangStandard::lang_gnu11;
+#endif
   break;
 case InputKind::ObjC:
+#if defined(CLANG_DEFAULT_STD_C)
+  LangStd = CLANG_DEFAULT_STD_C;
+#else
   LangStd = LangStandard::lang_gnu11;
+#endif
   break;
 case InputKind::CXX:
 case InputKind::ObjCXX:
+#if defined(CLANG_DEFAULT_STD_CXX)
+  LangStd = CLANG_DEFAULT_STD_CXX;
+#else
   // The PS4 uses C++11 as the default C++ standard.
   if (T.isPS4())
 LangS

[PATCH] D34365: [FrontEnd] Allow overriding the default C/C++ -std via CMake vars

2018-03-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 137227.
mgorny added a comment.

@rnk, could you confirm the rebased patch? I'm not sure if I should override 
`InputKind::RenderScript` as well.


https://reviews.llvm.org/D34365

Files:
  CMakeLists.txt
  include/clang/Config/config.h.cmake
  lib/Frontend/CompilerInvocation.cpp


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1809,18 +1809,30 @@
   break;
 case InputKind::Asm:
 case InputKind::C:
+#if defined(CLANG_DEFAULT_STD_C)
+  LangStd = CLANG_DEFAULT_STD_C;
+#else
   // The PS4 uses C99 as the default C standard.
   if (T.isPS4())
 LangStd = LangStandard::lang_gnu99;
   else
 LangStd = LangStandard::lang_gnu11;
+#endif
   break;
 case InputKind::ObjC:
+#if defined(CLANG_DEFAULT_STD_C)
+  LangStd = CLANG_DEFAULT_STD_C;
+#else
   LangStd = LangStandard::lang_gnu11;
+#endif
   break;
 case InputKind::CXX:
 case InputKind::ObjCXX:
+#if defined(CLANG_DEFAULT_STD_CXX)
+  LangStd = CLANG_DEFAULT_STD_CXX;
+#else
   LangStd = LangStandard::lang_gnucxx14;
+#endif
   break;
 case InputKind::RenderScript:
   LangStd = LangStandard::lang_c99;
Index: include/clang/Config/config.h.cmake
===
--- include/clang/Config/config.h.cmake
+++ include/clang/Config/config.h.cmake
@@ -11,6 +11,12 @@
 /* Default linker to use. */
 #define CLANG_DEFAULT_LINKER "${CLANG_DEFAULT_LINKER}"
 
+/* Default C/ObjC standard to use. */
+#cmakedefine CLANG_DEFAULT_STD_C LangStandard::lang_${CLANG_DEFAULT_STD_C}
+
+/* Default C++/ObjC++ standard to use. */
+#cmakedefine CLANG_DEFAULT_STD_CXX LangStandard::lang_${CLANG_DEFAULT_STD_CXX}
+
 /* Default C++ stdlib to use. */
 #define CLANG_DEFAULT_CXX_STDLIB "${CLANG_DEFAULT_CXX_STDLIB}"
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -212,6 +212,12 @@
 set(ENABLE_X86_RELAX_RELOCATIONS OFF CACHE BOOL
 "enable x86 relax relocations by default")
 
+# TODO: verify the values against LangStandards.def?
+set(CLANG_DEFAULT_STD_C "" CACHE STRING
+  "Default standard to use for C/ObjC code (IDENT from LangStandards.def, 
empty for platform default)")
+set(CLANG_DEFAULT_STD_CXX "" CACHE STRING
+  "Default standard to use for C++/ObjC++ code (IDENT from LangStandards.def, 
empty for platform default)")
+
 set(CLANG_DEFAULT_LINKER "" CACHE STRING
   "Default linker to use (linker name or absolute path, empty for platform 
default)")
 


Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1809,18 +1809,30 @@
   break;
 case InputKind::Asm:
 case InputKind::C:
+#if defined(CLANG_DEFAULT_STD_C)
+  LangStd = CLANG_DEFAULT_STD_C;
+#else
   // The PS4 uses C99 as the default C standard.
   if (T.isPS4())
 LangStd = LangStandard::lang_gnu99;
   else
 LangStd = LangStandard::lang_gnu11;
+#endif
   break;
 case InputKind::ObjC:
+#if defined(CLANG_DEFAULT_STD_C)
+  LangStd = CLANG_DEFAULT_STD_C;
+#else
   LangStd = LangStandard::lang_gnu11;
+#endif
   break;
 case InputKind::CXX:
 case InputKind::ObjCXX:
+#if defined(CLANG_DEFAULT_STD_CXX)
+  LangStd = CLANG_DEFAULT_STD_CXX;
+#else
   LangStd = LangStandard::lang_gnucxx14;
+#endif
   break;
 case InputKind::RenderScript:
   LangStd = LangStandard::lang_c99;
Index: include/clang/Config/config.h.cmake
===
--- include/clang/Config/config.h.cmake
+++ include/clang/Config/config.h.cmake
@@ -11,6 +11,12 @@
 /* Default linker to use. */
 #define CLANG_DEFAULT_LINKER "${CLANG_DEFAULT_LINKER}"
 
+/* Default C/ObjC standard to use. */
+#cmakedefine CLANG_DEFAULT_STD_C LangStandard::lang_${CLANG_DEFAULT_STD_C}
+
+/* Default C++/ObjC++ standard to use. */
+#cmakedefine CLANG_DEFAULT_STD_CXX LangStandard::lang_${CLANG_DEFAULT_STD_CXX}
+
 /* Default C++ stdlib to use. */
 #define CLANG_DEFAULT_CXX_STDLIB "${CLANG_DEFAULT_CXX_STDLIB}"
 
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -212,6 +212,12 @@
 set(ENABLE_X86_RELAX_RELOCATIONS OFF CACHE BOOL
 "enable x86 relax relocations by default")
 
+# TODO: verify the values against LangStandards.def?
+set(CLANG_DEFAULT_STD_C "" CACHE STRING
+  "Default standard to use for C/ObjC code (IDENT from LangStandards.def, empty for platform default)")
+set(CLANG_DEFAULT_STD_CXX "" CACHE STRING
+  "Default standard to use for C++/ObjC++ code (IDENT from LangStandards.def, empty for platform default)")
+
 set(CLANG_DEFAULT_LINKER "" CACHE ST

[PATCH] D34365: [FrontEnd] Allow overriding the default C/C++ -std via CMake vars

2018-03-06 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326836: [FrontEnd] Allow overriding the default C/C++ -std 
via CMake vars (authored by mgorny, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D34365?vs=137227&id=137258#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34365

Files:
  cfe/trunk/CMakeLists.txt
  cfe/trunk/include/clang/Config/config.h.cmake
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp


Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -1809,18 +1809,30 @@
   break;
 case InputKind::Asm:
 case InputKind::C:
+#if defined(CLANG_DEFAULT_STD_C)
+  LangStd = CLANG_DEFAULT_STD_C;
+#else
   // The PS4 uses C99 as the default C standard.
   if (T.isPS4())
 LangStd = LangStandard::lang_gnu99;
   else
 LangStd = LangStandard::lang_gnu11;
+#endif
   break;
 case InputKind::ObjC:
+#if defined(CLANG_DEFAULT_STD_C)
+  LangStd = CLANG_DEFAULT_STD_C;
+#else
   LangStd = LangStandard::lang_gnu11;
+#endif
   break;
 case InputKind::CXX:
 case InputKind::ObjCXX:
+#if defined(CLANG_DEFAULT_STD_CXX)
+  LangStd = CLANG_DEFAULT_STD_CXX;
+#else
   LangStd = LangStandard::lang_gnucxx14;
+#endif
   break;
 case InputKind::RenderScript:
   LangStd = LangStandard::lang_c99;
Index: cfe/trunk/include/clang/Config/config.h.cmake
===
--- cfe/trunk/include/clang/Config/config.h.cmake
+++ cfe/trunk/include/clang/Config/config.h.cmake
@@ -11,6 +11,12 @@
 /* Default linker to use. */
 #define CLANG_DEFAULT_LINKER "${CLANG_DEFAULT_LINKER}"
 
+/* Default C/ObjC standard to use. */
+#cmakedefine CLANG_DEFAULT_STD_C LangStandard::lang_${CLANG_DEFAULT_STD_C}
+
+/* Default C++/ObjC++ standard to use. */
+#cmakedefine CLANG_DEFAULT_STD_CXX LangStandard::lang_${CLANG_DEFAULT_STD_CXX}
+
 /* Default C++ stdlib to use. */
 #define CLANG_DEFAULT_CXX_STDLIB "${CLANG_DEFAULT_CXX_STDLIB}"
 
Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -212,6 +212,12 @@
 set(ENABLE_X86_RELAX_RELOCATIONS OFF CACHE BOOL
 "enable x86 relax relocations by default")
 
+# TODO: verify the values against LangStandards.def?
+set(CLANG_DEFAULT_STD_C "" CACHE STRING
+  "Default standard to use for C/ObjC code (IDENT from LangStandards.def, 
empty for platform default)")
+set(CLANG_DEFAULT_STD_CXX "" CACHE STRING
+  "Default standard to use for C++/ObjC++ code (IDENT from LangStandards.def, 
empty for platform default)")
+
 set(CLANG_DEFAULT_LINKER "" CACHE STRING
   "Default linker to use (linker name or absolute path, empty for platform 
default)")
 


Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -1809,18 +1809,30 @@
   break;
 case InputKind::Asm:
 case InputKind::C:
+#if defined(CLANG_DEFAULT_STD_C)
+  LangStd = CLANG_DEFAULT_STD_C;
+#else
   // The PS4 uses C99 as the default C standard.
   if (T.isPS4())
 LangStd = LangStandard::lang_gnu99;
   else
 LangStd = LangStandard::lang_gnu11;
+#endif
   break;
 case InputKind::ObjC:
+#if defined(CLANG_DEFAULT_STD_C)
+  LangStd = CLANG_DEFAULT_STD_C;
+#else
   LangStd = LangStandard::lang_gnu11;
+#endif
   break;
 case InputKind::CXX:
 case InputKind::ObjCXX:
+#if defined(CLANG_DEFAULT_STD_CXX)
+  LangStd = CLANG_DEFAULT_STD_CXX;
+#else
   LangStd = LangStandard::lang_gnucxx14;
+#endif
   break;
 case InputKind::RenderScript:
   LangStd = LangStandard::lang_c99;
Index: cfe/trunk/include/clang/Config/config.h.cmake
===
--- cfe/trunk/include/clang/Config/config.h.cmake
+++ cfe/trunk/include/clang/Config/config.h.cmake
@@ -11,6 +11,12 @@
 /* Default linker to use. */
 #define CLANG_DEFAULT_LINKER "${CLANG_DEFAULT_LINKER}"
 
+/* Default C/ObjC standard to use. */
+#cmakedefine CLANG_DEFAULT_STD_C LangStandard::lang_${CLANG_DEFAULT_STD_C}
+
+/* Default C++/ObjC++ standard to use. */
+#cmakedefine CLANG_DEFAULT_STD_CXX LangStandard::lang_${CLANG_DEFAULT_STD_CXX}
+
 /* Default C++ stdlib to use. */
 #define CLANG_DEFAULT_CXX_STDLIB "${CLANG_DEFAULT_CXX_STDLIB}"
 
Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -212,6 +212,12 @@
 set(ENABLE_X86_RELAX_RELOCATIONS OFF CACHE BOOL
 "enable x86 relax relocations by default")
 
+# TODO: ver

[PATCH] D44645: [test] Fix Cross-DSO CFI Android sanitizer test for -rtlib=compiler-rt

2018-03-19 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added a reviewer: eugenis.
Herald added subscribers: dberris, srhines.
mgorny added inline comments.



Comment at: test/Driver/sanitizer-ld.c:517
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"
 // CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.
 

(an alternative would be to replace this 'NOT' clause with more specific 
library name — but I don't know which library could 'accidentally' appear here)


Fix the CHECK-CFI-CROSS-DSO-ANDROID test to force -rtlib=libgcc.
Otherwise, if clang is built with CLANG_DEFAULT_RTLIB=compiler-rt,
the clang_rt.builtins library gets added to the command-line and causes
the 'clang_rt.' substring to unexpectedly match.


Repository:
  rC Clang

https://reviews.llvm.org/D44645

Files:
  test/Driver/sanitizer-ld.c


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -510,7 +510,7 @@
 
 // Cross-DSO CFI on Android does not link runtime libraries.
 // RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
-// RUN: -target aarch64-linux-android -fuse-ld=ld \
+// RUN: -target aarch64-linux-android -fuse-ld=ld -rtlib=libgcc \
 // RUN: --sysroot=%S/Inputs/basic_android_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-ANDROID %s
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -510,7 +510,7 @@
 
 // Cross-DSO CFI on Android does not link runtime libraries.
 // RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
-// RUN: -target aarch64-linux-android -fuse-ld=ld \
+// RUN: -target aarch64-linux-android -fuse-ld=ld -rtlib=libgcc \
 // RUN: --sysroot=%S/Inputs/basic_android_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-ANDROID %s
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44645: [test] Fix Cross-DSO CFI Android sanitizer test for -rtlib=compiler-rt

2018-03-19 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: test/Driver/sanitizer-ld.c:517
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"
 // CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.
 

(an alternative would be to replace this 'NOT' clause with more specific 
library name — but I don't know which library could 'accidentally' appear here)


Repository:
  rC Clang

https://reviews.llvm.org/D44645



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


[PATCH] D44645: [test] Fix Cross-DSO CFI Android sanitizer test for -rtlib=compiler-rt

2018-03-20 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 139135.
mgorny edited the summary of this revision.

https://reviews.llvm.org/D44645

Files:
  test/Driver/sanitizer-ld.c


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -514,7 +514,7 @@
 // RUN: --sysroot=%S/Inputs/basic_android_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-ANDROID %s
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"
-// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.
+// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.cfi
 
 // Cross-DSO CFI with diagnostics on Android links just the UBSAN runtime.
 // RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -514,7 +514,7 @@
 // RUN: --sysroot=%S/Inputs/basic_android_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-ANDROID %s
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"
-// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.
+// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.cfi
 
 // Cross-DSO CFI with diagnostics on Android links just the UBSAN runtime.
 // RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44645: [test] Fix Cross-DSO CFI Android sanitizer test for -rtlib=compiler-rt

2018-03-20 Thread Michał Górny via Phabricator via cfe-commits
mgorny marked 2 inline comments as done.
mgorny added a comment.

@eugenis, updated.


https://reviews.llvm.org/D44645



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


[PATCH] D47817: [sanitizer_common] Fix using libtirpc on Linux

2018-06-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: ygribov, kcc.
mgorny added a project: Sanitizers.
Herald added subscribers: Sanitizers, llvm-commits, kubamracek.
mgorny added a reviewer: samsonov.

Fix using libtirpc on Linux by using pkg-config to detect it, and append
appropriate include directory.  The libtirpc headers reference one
another via '#include ', so attempting to include it via
'#include ' just failed and resulted in RPC headers not being
detected at all.

Additionally, perform the header check without -nodefaultlibs as that
apparently causes it to fail.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D47817

Files:
  lib/sanitizer_common/CMakeLists.txt
  lib/sanitizer_common/sanitizer_platform_limits_posix.cc


Index: lib/sanitizer_common/sanitizer_platform_limits_posix.cc
===
--- lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ lib/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -146,8 +146,6 @@
 #include 
 #if HAVE_RPC_XDR_H
 # include 
-#elif HAVE_TIRPC_RPC_XDR_H
-# include 
 #endif
 #include 
 #include 
@@ -1242,7 +1240,7 @@
 CHECK_SIZE_AND_OFFSET(group, gr_gid);
 CHECK_SIZE_AND_OFFSET(group, gr_mem);
 
-#if HAVE_RPC_XDR_H || HAVE_TIRPC_RPC_XDR_H
+#if HAVE_RPC_XDR_H
 CHECK_TYPE_SIZE(XDR);
 CHECK_SIZE_AND_OFFSET(XDR, x_op);
 CHECK_SIZE_AND_OFFSET(XDR, x_ops);
Index: lib/sanitizer_common/CMakeLists.txt
===
--- lib/sanitizer_common/CMakeLists.txt
+++ lib/sanitizer_common/CMakeLists.txt
@@ -168,9 +168,18 @@
 
 set(SANITIZER_COMMON_DEFINITIONS)
 
+include(FindPkgConfig)
+pkg_check_modules(TIRPC libtirpc)
+if (TIRPC_FOUND)
+  include_directories(${TIRPC_INCLUDE_DIRS})
+  set(CMAKE_REQUIRED_INCLUDES ${TIRPC_INCLUDE_DIRS})
+endif()
+
 include(CheckIncludeFile)
+cmake_push_check_state()
+string(REPLACE "-nodefaultlibs" "" CMAKE_REQUIRED_FLAGS 
${CMAKE_REQUIRED_FLAGS})
 append_have_file_definition(rpc/xdr.h HAVE_RPC_XDR_H 
SANITIZER_COMMON_DEFINITIONS)
-append_have_file_definition(tirpc/rpc/xdr.h HAVE_TIRPC_RPC_XDR_H 
SANITIZER_COMMON_DEFINITIONS)
+cmake_pop_check_state()
 
 set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SANITIZER_CFLAGS)


Index: lib/sanitizer_common/sanitizer_platform_limits_posix.cc
===
--- lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ lib/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -146,8 +146,6 @@
 #include 
 #if HAVE_RPC_XDR_H
 # include 
-#elif HAVE_TIRPC_RPC_XDR_H
-# include 
 #endif
 #include 
 #include 
@@ -1242,7 +1240,7 @@
 CHECK_SIZE_AND_OFFSET(group, gr_gid);
 CHECK_SIZE_AND_OFFSET(group, gr_mem);
 
-#if HAVE_RPC_XDR_H || HAVE_TIRPC_RPC_XDR_H
+#if HAVE_RPC_XDR_H
 CHECK_TYPE_SIZE(XDR);
 CHECK_SIZE_AND_OFFSET(XDR, x_op);
 CHECK_SIZE_AND_OFFSET(XDR, x_ops);
Index: lib/sanitizer_common/CMakeLists.txt
===
--- lib/sanitizer_common/CMakeLists.txt
+++ lib/sanitizer_common/CMakeLists.txt
@@ -168,9 +168,18 @@
 
 set(SANITIZER_COMMON_DEFINITIONS)
 
+include(FindPkgConfig)
+pkg_check_modules(TIRPC libtirpc)
+if (TIRPC_FOUND)
+  include_directories(${TIRPC_INCLUDE_DIRS})
+  set(CMAKE_REQUIRED_INCLUDES ${TIRPC_INCLUDE_DIRS})
+endif()
+
 include(CheckIncludeFile)
+cmake_push_check_state()
+string(REPLACE "-nodefaultlibs" "" CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
 append_have_file_definition(rpc/xdr.h HAVE_RPC_XDR_H SANITIZER_COMMON_DEFINITIONS)
-append_have_file_definition(tirpc/rpc/xdr.h HAVE_TIRPC_RPC_XDR_H SANITIZER_COMMON_DEFINITIONS)
+cmake_pop_check_state()
 
 set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SANITIZER_CFLAGS)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47819: [test] Support using libtirpc on Linux

2018-06-06 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: ygribov, kcc, samsonov.
mgorny added a project: Sanitizers.
Herald added subscribers: Sanitizers, llvm-commits, kubamracek.

Add compiler flags necessary for using libtirpc on Linux (RPC headers
split out of glibc).  The flags are obtained via pkg-config.  This fixes
test failures due to tests being unable to find  includes.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D47819

Files:
  cmake/base-config-ix.cmake
  lib/sanitizer_common/CMakeLists.txt
  test/msan/lit.cfg
  test/msan/lit.site.cfg.in
  test/tsan/lit.cfg
  test/tsan/lit.site.cfg.in


Index: test/tsan/lit.site.cfg.in
===
--- test/tsan/lit.site.cfg.in
+++ test/tsan/lit.site.cfg.in
@@ -7,6 +7,7 @@
 config.iossim = @TSAN_TEST_IOSSIM_PYBOOL@
 config.target_cflags = "@TSAN_TEST_TARGET_CFLAGS@"
 config.target_arch = "@TSAN_TEST_TARGET_ARCH@"
+config.rpc_cflags = "@TIRPC_CFLAGS@"
 
 # Load common config for all compiler-rt lit tests.
 lit_config.load_config(config, 
"@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
Index: test/tsan/lit.cfg
===
--- test/tsan/lit.cfg
+++ test/tsan/lit.cfg
@@ -49,7 +49,8 @@
   [config.target_cflags] +
   config.debug_info_flags +
   extra_cflags +
-  ["-I%s" % tsan_incdir])
+  ["-I%s" % tsan_incdir] +
+  [config.rpc_cflags])
 clang_tsan_cxxflags = config.cxx_mode_flags + clang_tsan_cflags + 
["-std=c++11"] + ["-I%s" % tsan_incdir]
 # Add additional flags if we're using instrumented libc++.
 # Instrumented libcxx currently not supported on Darwin.
Index: test/msan/lit.site.cfg.in
===
--- test/msan/lit.site.cfg.in
+++ test/msan/lit.site.cfg.in
@@ -6,6 +6,7 @@
 config.target_arch = "@MSAN_TEST_TARGET_ARCH@"
 config.use_lld = @MSAN_TEST_USE_LLD@
 config.use_thinlto = @MSAN_TEST_USE_THINLTO@
+config.rpc_cflags = "@TIRPC_CFLAGS@"
 
 # Load common config for all compiler-rt lit tests.
 lit_config.load_config(config, 
"@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
Index: test/msan/lit.cfg
===
--- test/msan/lit.cfg
+++ test/msan/lit.cfg
@@ -14,7 +14,8 @@
   "-fno-omit-frame-pointer",
   "-fno-optimize-sibling-calls"] +
   [config.target_cflags] +
-  config.debug_info_flags)
+  config.debug_info_flags +
+  [config.rpc_cflags])
 # Some Msan tests leverage backtrace() which requires libexecinfo on FreeBSD.
 if config.host_os == 'FreeBSD':
   clang_msan_cflags += ["-lexecinfo"]
Index: lib/sanitizer_common/CMakeLists.txt
===
--- lib/sanitizer_common/CMakeLists.txt
+++ lib/sanitizer_common/CMakeLists.txt
@@ -168,8 +168,6 @@
 
 set(SANITIZER_COMMON_DEFINITIONS)
 
-include(FindPkgConfig)
-pkg_check_modules(TIRPC libtirpc)
 if (TIRPC_FOUND)
   include_directories(${TIRPC_INCLUDE_DIRS})
   set(CMAKE_REQUIRED_INCLUDES ${TIRPC_INCLUDE_DIRS})
Index: cmake/base-config-ix.cmake
===
--- cmake/base-config-ix.cmake
+++ cmake/base-config-ix.cmake
@@ -8,6 +8,10 @@
 
 check_include_file(unwind.h HAVE_UNWIND_H)
 
+# used in sanitizer_common and tests
+include(FindPkgConfig)
+pkg_check_modules(TIRPC libtirpc)
+
 # Top level target used to build all compiler-rt libraries.
 add_custom_target(compiler-rt ALL)
 add_custom_target(install-compiler-rt)


Index: test/tsan/lit.site.cfg.in
===
--- test/tsan/lit.site.cfg.in
+++ test/tsan/lit.site.cfg.in
@@ -7,6 +7,7 @@
 config.iossim = @TSAN_TEST_IOSSIM_PYBOOL@
 config.target_cflags = "@TSAN_TEST_TARGET_CFLAGS@"
 config.target_arch = "@TSAN_TEST_TARGET_ARCH@"
+config.rpc_cflags = "@TIRPC_CFLAGS@"
 
 # Load common config for all compiler-rt lit tests.
 lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
Index: test/tsan/lit.cfg
===
--- test/tsan/lit.cfg
+++ test/tsan/lit.cfg
@@ -49,7 +49,8 @@
   [config.target_cflags] +
   config.debug_info_flags +
   extra_cflags +
-  ["-I%s" % tsan_incdir])
+  ["-I%s" % tsan_incdir] +
+  [config.rpc_cflags])
 clang_tsan_cxxflags = config.cxx_mode_flags + clang_tsan_cflags + ["-std=c++11"] + ["-I%s" % tsan_incdir]
 # Add additional flags if we're using instrumented libc++.
 # Instrumented libcxx currently not supported on Darwin.
Index: test/msan/lit.site.cfg.in
==

[PATCH] D47817: [sanitizer_common] Fix using libtirpc on Linux

2018-06-15 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Gentle ping.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D47817



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


[PATCH] D47819: [test] Support using libtirpc on Linux

2018-06-15 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Gentle ping.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D47819



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


[PATCH] D52806: [python] Support overriding library path via environment

2018-10-10 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a reviewer: steveire.
mgorny added a comment.

Gentle ping.


https://reviews.llvm.org/D52806



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


[PATCH] D42242: Make libc++abi work with gcc's ARM unwind library

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

@bebuch, I agree with @mclow.lists here that the new errors are completely 
unrelated to the problem solved by this patch, and the fix to it belongs in a 
separate changeset. Can we get the original problem fixed first then?


https://reviews.llvm.org/D42242



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


[PATCH] D53125: Detect Clear Linux and apply Clear's default linker options

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



Comment at: lib/Driver/Distro.cpp:139
 
+  File = VFS.getBufferForFile("/usr/lib/os-release");
+  if (File) {

Technically speaking, the spec says you are supposed to read `/etc/os-release` 
first and fall back to `/usr/lib/os-release` only if the former does not exist.


https://reviews.llvm.org/D53125



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


[PATCH] D52840: Include Python binding tests in CMake rules

2018-10-11 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344241: [tests] Include Python binding tests in CMake rules 
(authored by mgorny, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52840?vs=168147&id=169194#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52840

Files:
  cfe/trunk/CMakeLists.txt
  cfe/trunk/bindings/python/tests/CMakeLists.txt


Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -502,6 +502,7 @@
   )
   endif()
   add_subdirectory(utils/perf-training)
+  add_subdirectory(bindings/python/tests)
 endif()
 
 option(CLANG_INCLUDE_DOCS "Generate build targets for the Clang docs."
Index: cfe/trunk/bindings/python/tests/CMakeLists.txt
===
--- cfe/trunk/bindings/python/tests/CMakeLists.txt
+++ cfe/trunk/bindings/python/tests/CMakeLists.txt
@@ -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)


Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -502,6 +502,7 @@
   )
   endif()
   add_subdirectory(utils/perf-training)
+  add_subdirectory(bindings/python/tests)
 endif()
 
 option(CLANG_INCLUDE_DOCS "Generate build targets for the Clang docs."
Index: cfe/trunk/bindings/python/tests/CMakeLists.txt
===
--- cfe/trunk/bindings/python/tests/CMakeLists.txt
+++ cfe/trunk/bindings/python/tests/CMakeLists.txt
@@ -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


[PATCH] D52806: [python] [tests] Support overriding library path via environment

2018-10-11 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344240: [python] [tests] Support overriding library path via 
environment (authored by mgorny, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D52806?vs=168079&id=169195#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52806

Files:
  cfe/trunk/bindings/python/README.txt
  cfe/trunk/bindings/python/tests/cindex/test_access_specifiers.py
  cfe/trunk/bindings/python/tests/cindex/test_cdb.py
  cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
  cfe/trunk/bindings/python/tests/cindex/test_comment.py
  cfe/trunk/bindings/python/tests/cindex/test_cursor.py
  cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py
  cfe/trunk/bindings/python/tests/cindex/test_diagnostics.py
  cfe/trunk/bindings/python/tests/cindex/test_exception_specification_kind.py
  cfe/trunk/bindings/python/tests/cindex/test_file.py
  cfe/trunk/bindings/python/tests/cindex/test_index.py
  cfe/trunk/bindings/python/tests/cindex/test_linkage.py
  cfe/trunk/bindings/python/tests/cindex/test_location.py
  cfe/trunk/bindings/python/tests/cindex/test_tls_kind.py
  cfe/trunk/bindings/python/tests/cindex/test_token_kind.py
  cfe/trunk/bindings/python/tests/cindex/test_tokens.py
  cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py
  cfe/trunk/bindings/python/tests/cindex/test_type.py

Index: cfe/trunk/bindings/python/README.txt
===
--- cfe/trunk/bindings/python/README.txt
+++ cfe/trunk/bindings/python/README.txt
@@ -4,12 +4,12 @@
 
 This directory implements Python bindings for Clang.
 
-You may need to alter LD_LIBRARY_PATH so that the Clang library can be
+You may need to set CLANG_LIBRARY_PATH so that the Clang library can be
 found. The unit tests are designed to be run with any standard test
 runner. For example:
 --
 $ env PYTHONPATH=$(echo ~/llvm/tools/clang/bindings/python/) \
-  LD_LIBRARY_PATH=$(llvm-config --libdir) \
+  CLANG_LIBRARY_PATH=$(llvm-config --libdir) \
   python -m unittest discover -v
 tests.cindex.test_index.test_create ... ok
 ...
Index: cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py
+++ cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py
@@ -1,3 +1,8 @@
+import os
+from clang.cindex import Config
+if 'CLANG_LIBRARY_PATH' in os.environ:
+Config.set_library_path(os.environ['CLANG_LIBRARY_PATH'])
+
 from contextlib import contextmanager
 import gc
 import os
Index: cfe/trunk/bindings/python/tests/cindex/test_cdb.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_cdb.py
+++ cfe/trunk/bindings/python/tests/cindex/test_cdb.py
@@ -1,3 +1,8 @@
+import os
+from clang.cindex import Config
+if 'CLANG_LIBRARY_PATH' in os.environ:
+Config.set_library_path(os.environ['CLANG_LIBRARY_PATH'])
+
 from clang.cindex import CompilationDatabase
 from clang.cindex import CompilationDatabaseError
 from clang.cindex import CompileCommands
Index: cfe/trunk/bindings/python/tests/cindex/test_token_kind.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_token_kind.py
+++ cfe/trunk/bindings/python/tests/cindex/test_token_kind.py
@@ -1,3 +1,8 @@
+import os
+from clang.cindex import Config
+if 'CLANG_LIBRARY_PATH' in os.environ:
+Config.set_library_path(os.environ['CLANG_LIBRARY_PATH'])
+
 from clang.cindex import TokenKind
 
 import unittest
Index: cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py
+++ cfe/trunk/bindings/python/tests/cindex/test_cursor_kind.py
@@ -1,3 +1,8 @@
+import os
+from clang.cindex import Config
+if 'CLANG_LIBRARY_PATH' in os.environ:
+Config.set_library_path(os.environ['CLANG_LIBRARY_PATH'])
+
 from clang.cindex import CursorKind
 
 import unittest
Index: cfe/trunk/bindings/python/tests/cindex/test_type.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_type.py
+++ cfe/trunk/bindings/python/tests/cindex/test_type.py
@@ -1,3 +1,8 @@
+import os
+from clang.cindex import Config
+if 'CLANG_LIBRARY_PATH' in os.environ:
+Config.set_library_path(os.environ['CLANG_LIBRARY_PATH'])
+
 import gc
 import unittest
 
Index: cfe/trunk/bindings/python/tests/cindex/test_file.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_file.py
+++ cfe/trunk/bindings/python/tests/cindex/test_file.py
@@ -1,3 +1,8 @@
+import os
+from clang.cindex import Config
+if 'CLANG_LIBRARY_PATH' in os.environ:
+Config.set_libr

[PATCH] D52840: Include Python binding tests in CMake rules

2018-10-11 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 169218.
mgorny added a comment.

v2: fixed appending to check-all to make it compatible both with in-tree and 
standalone builds


https://reviews.llvm.org/D52840

Files:
  CMakeLists.txt
  bindings/python/tests/CMakeLists.txt


Index: bindings/python/tests/CMakeLists.txt
===
--- /dev/null
+++ bindings/python/tests/CMakeLists.txt
@@ -0,0 +1,8 @@
+# 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}/..)
+
+set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS 
check-clang-python)
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -485,6 +485,7 @@
   )
   endif()
   add_subdirectory(test)
+  add_subdirectory(bindings/python/tests)
 
   if(CLANG_BUILT_STANDALONE)
 # Add a global check rule now that all subdirectories have been traversed
@@ -497,7 +498,7 @@
   "Running all regression tests"
   ${LLVM_LIT_TESTSUITES}
   PARAMS ${LLVM_LIT_PARAMS}
-  DEPENDS ${LLVM_LIT_DEPENDS}
+  DEPENDS ${LLVM_LIT_DEPENDS} ${LLVM_ADDITIONAL_TEST_TARGETS}
   ARGS ${LLVM_LIT_EXTRA_ARGS}
   )
   endif()


Index: bindings/python/tests/CMakeLists.txt
===
--- /dev/null
+++ bindings/python/tests/CMakeLists.txt
@@ -0,0 +1,8 @@
+# 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}/..)
+
+set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python)
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -485,6 +485,7 @@
   )
   endif()
   add_subdirectory(test)
+  add_subdirectory(bindings/python/tests)
 
   if(CLANG_BUILT_STANDALONE)
 # Add a global check rule now that all subdirectories have been traversed
@@ -497,7 +498,7 @@
   "Running all regression tests"
   ${LLVM_LIT_TESTSUITES}
   PARAMS ${LLVM_LIT_PARAMS}
-  DEPENDS ${LLVM_LIT_DEPENDS}
+  DEPENDS ${LLVM_LIT_DEPENDS} ${LLVM_ADDITIONAL_TEST_TARGETS}
   ARGS ${LLVM_LIT_EXTRA_ARGS}
   )
   endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52840: Include Python binding tests in CMake rules

2018-10-11 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 169219.
mgorny added a comment.

v3: one more correction for stand-alone builds.


https://reviews.llvm.org/D52840

Files:
  CMakeLists.txt
  bindings/python/tests/CMakeLists.txt


Index: bindings/python/tests/CMakeLists.txt
===
--- /dev/null
+++ bindings/python/tests/CMakeLists.txt
@@ -0,0 +1,8 @@
+# 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}/..)
+
+set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS 
check-clang-python)
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -485,19 +485,22 @@
   )
   endif()
   add_subdirectory(test)
+  add_subdirectory(bindings/python/tests)
 
   if(CLANG_BUILT_STANDALONE)
 # Add a global check rule now that all subdirectories have been traversed
 # and we know the total set of lit testsuites.
 get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES)
 get_property(LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS)
 get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS)
 get_property(LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS)
+get_property(LLVM_ADDITIONAL_TEST_TARGETS
+ GLOBAL PROPERTY LLVM_ADDITIONAL_TEST_TARGETS)
 add_lit_target(check-all
   "Running all regression tests"
   ${LLVM_LIT_TESTSUITES}
   PARAMS ${LLVM_LIT_PARAMS}
-  DEPENDS ${LLVM_LIT_DEPENDS}
+  DEPENDS ${LLVM_LIT_DEPENDS} ${LLVM_ADDITIONAL_TEST_TARGETS}
   ARGS ${LLVM_LIT_EXTRA_ARGS}
   )
   endif()


Index: bindings/python/tests/CMakeLists.txt
===
--- /dev/null
+++ bindings/python/tests/CMakeLists.txt
@@ -0,0 +1,8 @@
+# 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}/..)
+
+set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python)
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -485,19 +485,22 @@
   )
   endif()
   add_subdirectory(test)
+  add_subdirectory(bindings/python/tests)
 
   if(CLANG_BUILT_STANDALONE)
 # Add a global check rule now that all subdirectories have been traversed
 # and we know the total set of lit testsuites.
 get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES)
 get_property(LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS)
 get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS)
 get_property(LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS)
+get_property(LLVM_ADDITIONAL_TEST_TARGETS
+ GLOBAL PROPERTY LLVM_ADDITIONAL_TEST_TARGETS)
 add_lit_target(check-all
   "Running all regression tests"
   ${LLVM_LIT_TESTSUITES}
   PARAMS ${LLVM_LIT_PARAMS}
-  DEPENDS ${LLVM_LIT_DEPENDS}
+  DEPENDS ${LLVM_LIT_DEPENDS} ${LLVM_ADDITIONAL_TEST_TARGETS}
   ARGS ${LLVM_LIT_EXTRA_ARGS}
   )
   endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52840: Include Python binding tests in CMake rules

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

Please review the new version, addressing the issue caught by buildbots.


https://reviews.llvm.org/D52840



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


[PATCH] D52840: Include Python binding tests in CMake rules

2018-10-11 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC344258: [tests] Include Python binding tests in CMake rules 
(authored by mgorny, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D52840

Files:
  CMakeLists.txt
  bindings/python/tests/CMakeLists.txt


Index: bindings/python/tests/CMakeLists.txt
===
--- bindings/python/tests/CMakeLists.txt
+++ bindings/python/tests/CMakeLists.txt
@@ -0,0 +1,8 @@
+# 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}/..)
+
+set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS 
check-clang-python)
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -485,19 +485,22 @@
   )
   endif()
   add_subdirectory(test)
+  add_subdirectory(bindings/python/tests)
 
   if(CLANG_BUILT_STANDALONE)
 # Add a global check rule now that all subdirectories have been traversed
 # and we know the total set of lit testsuites.
 get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES)
 get_property(LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS)
 get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS)
 get_property(LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS)
+get_property(LLVM_ADDITIONAL_TEST_TARGETS
+ GLOBAL PROPERTY LLVM_ADDITIONAL_TEST_TARGETS)
 add_lit_target(check-all
   "Running all regression tests"
   ${LLVM_LIT_TESTSUITES}
   PARAMS ${LLVM_LIT_PARAMS}
-  DEPENDS ${LLVM_LIT_DEPENDS}
+  DEPENDS ${LLVM_LIT_DEPENDS} ${LLVM_ADDITIONAL_TEST_TARGETS}
   ARGS ${LLVM_LIT_EXTRA_ARGS}
   )
   endif()


Index: bindings/python/tests/CMakeLists.txt
===
--- bindings/python/tests/CMakeLists.txt
+++ bindings/python/tests/CMakeLists.txt
@@ -0,0 +1,8 @@
+# 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}/..)
+
+set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-clang-python)
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -485,19 +485,22 @@
   )
   endif()
   add_subdirectory(test)
+  add_subdirectory(bindings/python/tests)
 
   if(CLANG_BUILT_STANDALONE)
 # Add a global check rule now that all subdirectories have been traversed
 # and we know the total set of lit testsuites.
 get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES)
 get_property(LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS)
 get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS)
 get_property(LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS)
+get_property(LLVM_ADDITIONAL_TEST_TARGETS
+ GLOBAL PROPERTY LLVM_ADDITIONAL_TEST_TARGETS)
 add_lit_target(check-all
   "Running all regression tests"
   ${LLVM_LIT_TESTSUITES}
   PARAMS ${LLVM_LIT_PARAMS}
-  DEPENDS ${LLVM_LIT_DEPENDS}
+  DEPENDS ${LLVM_LIT_DEPENDS} ${LLVM_ADDITIONAL_TEST_TARGETS}
   ARGS ${LLVM_LIT_EXTRA_ARGS}
   )
   endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53151: [python] [tests] Fix calling pytest on Windows (hopefully)

2018-10-11 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added a reviewer: rnk.

Fix passing arguments to the pytest command to use 'env' builtin CMake
command, in order to fix compatibility with Windows.

NB: I don't have a Windows environment to test it


Repository:
  rC Clang

https://reviews.llvm.org/D53151

Files:
  bindings/python/tests/CMakeLists.txt


Index: bindings/python/tests/CMakeLists.txt
===
--- bindings/python/tests/CMakeLists.txt
+++ bindings/python/tests/CMakeLists.txt
@@ -1,7 +1,9 @@
 # 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
+COMMAND ${CMAKE_COMMAND} -E env
+CLANG_LIBRARY_PATH=$
+${PYTHON_EXECUTABLE} -m unittest discover
 DEPENDS libclang
 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
 


Index: bindings/python/tests/CMakeLists.txt
===
--- bindings/python/tests/CMakeLists.txt
+++ bindings/python/tests/CMakeLists.txt
@@ -1,7 +1,9 @@
 # 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
+COMMAND ${CMAKE_COMMAND} -E env
+CLANG_LIBRARY_PATH=$
+${PYTHON_EXECUTABLE} -m unittest discover
 DEPENDS libclang
 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53151: [python] [tests] Fix calling tests on Windows (hopefully)

2018-10-11 Thread Michał Górny via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344288: [python] [tests] Fix calling tests on Windows 
(authored by mgorny, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53151?vs=169253&id=169292#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53151

Files:
  cfe/trunk/bindings/python/tests/CMakeLists.txt


Index: cfe/trunk/bindings/python/tests/CMakeLists.txt
===
--- cfe/trunk/bindings/python/tests/CMakeLists.txt
+++ cfe/trunk/bindings/python/tests/CMakeLists.txt
@@ -1,7 +1,9 @@
 # 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
+COMMAND ${CMAKE_COMMAND} -E env
+CLANG_LIBRARY_PATH=$
+${PYTHON_EXECUTABLE} -m unittest discover
 DEPENDS libclang
 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
 


Index: cfe/trunk/bindings/python/tests/CMakeLists.txt
===
--- cfe/trunk/bindings/python/tests/CMakeLists.txt
+++ cfe/trunk/bindings/python/tests/CMakeLists.txt
@@ -1,7 +1,9 @@
 # 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
+COMMAND ${CMAKE_COMMAND} -E env
+CLANG_LIBRARY_PATH=$
+${PYTHON_EXECUTABLE} -m unittest discover
 DEPENDS libclang
 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D51729: [Tooling] JSONCompilationDatabasePlugin infers compile commands for missing files

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

Unless my bisect is mistaken, this broke Clang Python binding test:
https://github.com/llvm-mirror/clang/blob/master/bindings/python/tests/cindex/test_cdb.py#L34

The test apparently assumes that compilation database will not return anything 
for a file that does not exist. Could you please suggest how the test should be 
adjusted for this change?


Repository:
  rC Clang

https://reviews.llvm.org/D51729



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


[PATCH] D53202: [python] [tests] Remove cdb lookup failure test

2018-10-12 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: sammccall, bkramer, aadg.
Herald added a subscriber: arphaman.

Remove the test checking for compilation db lookup failure.
Since r342228, JSONCompilationDatabasePlugin infers compile commands for
missing files, therefore making the lookup always succeed.


Repository:
  rC Clang

https://reviews.llvm.org/D53202

Files:
  bindings/python/tests/cindex/test_cdb.py


Index: bindings/python/tests/cindex/test_cdb.py
===
--- bindings/python/tests/cindex/test_cdb.py
+++ bindings/python/tests/cindex/test_cdb.py
@@ -31,11 +31,6 @@
 """Check we can load a compilation database"""
 cdb = CompilationDatabase.fromDirectory(kInputsDir)
 
-def test_lookup_fail(self):
-"""Check file lookup failure"""
-cdb = CompilationDatabase.fromDirectory(kInputsDir)
-self.assertIsNone(cdb.getCompileCommands('file_do_not_exist.cpp'))
-
 def test_lookup_succeed(self):
 """Check we get some results if the file exists in the db"""
 cdb = CompilationDatabase.fromDirectory(kInputsDir)


Index: bindings/python/tests/cindex/test_cdb.py
===
--- bindings/python/tests/cindex/test_cdb.py
+++ bindings/python/tests/cindex/test_cdb.py
@@ -31,11 +31,6 @@
 """Check we can load a compilation database"""
 cdb = CompilationDatabase.fromDirectory(kInputsDir)
 
-def test_lookup_fail(self):
-"""Check file lookup failure"""
-cdb = CompilationDatabase.fromDirectory(kInputsDir)
-self.assertIsNone(cdb.getCompileCommands('file_do_not_exist.cpp'))
-
 def test_lookup_succeed(self):
 """Check we get some results if the file exists in the db"""
 cdb = CompilationDatabase.fromDirectory(kInputsDir)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53202: [python] [tests] Remove cdb lookup failure test

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

Thanks for the review!


Repository:
  rC Clang

https://reviews.llvm.org/D53202



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


[PATCH] D53202: [python] [tests] Remove cdb lookup failure test

2018-10-12 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344364: [python] [tests] Remove cdb lookup failure test 
(authored by mgorny, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53202?vs=169427&id=169446#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53202

Files:
  cfe/trunk/bindings/python/tests/cindex/test_cdb.py


Index: cfe/trunk/bindings/python/tests/cindex/test_cdb.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_cdb.py
+++ cfe/trunk/bindings/python/tests/cindex/test_cdb.py
@@ -31,11 +31,6 @@
 """Check we can load a compilation database"""
 cdb = CompilationDatabase.fromDirectory(kInputsDir)
 
-def test_lookup_fail(self):
-"""Check file lookup failure"""
-cdb = CompilationDatabase.fromDirectory(kInputsDir)
-self.assertIsNone(cdb.getCompileCommands('file_do_not_exist.cpp'))
-
 def test_lookup_succeed(self):
 """Check we get some results if the file exists in the db"""
 cdb = CompilationDatabase.fromDirectory(kInputsDir)


Index: cfe/trunk/bindings/python/tests/cindex/test_cdb.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_cdb.py
+++ cfe/trunk/bindings/python/tests/cindex/test_cdb.py
@@ -31,11 +31,6 @@
 """Check we can load a compilation database"""
 cdb = CompilationDatabase.fromDirectory(kInputsDir)
 
-def test_lookup_fail(self):
-"""Check file lookup failure"""
-cdb = CompilationDatabase.fromDirectory(kInputsDir)
-self.assertIsNone(cdb.getCompileCommands('file_do_not_exist.cpp'))
-
 def test_lookup_succeed(self):
 """Check we get some results if the file exists in the db"""
 cdb = CompilationDatabase.fromDirectory(kInputsDir)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53212: inhereit LLVM_ENABLE_LIBXML2

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



Comment at: CMakeLists.txt:92
   option(CLANG_ENABLE_BOOTSTRAP "Generate the clang bootstrap target" OFF)
+  option(LLVM_ENABLE_LIBXM2 "Use libxml2 if available." ON)
 

I suppose it will work better without typos.


Repository:
  rC Clang

https://reviews.llvm.org/D53212



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


[PATCH] D53239: [python] [tests] Disable python binding tests when building with LLVM_USE_SANITIZER=Address

2018-10-13 Thread Michał Górny via Phabricator via cfe-commits
mgorny accepted this revision.
mgorny added a comment.

WFM. Thanks for analyzing the problem.




Comment at: bindings/python/tests/CMakeLists.txt:27
+# with ASan.
+if((NOT WIN32) AND (NOT LLVM_USE_ASAN))
 set_property(GLOBAL APPEND PROPERTY

Hmm, I don't think you need to parenthesize the `(NOT FOO)` thing (and it looks 
bit weird to me).


Repository:
  rC Clang

https://reviews.llvm.org/D53239



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


[PATCH] D52840: Include Python binding tests in CMake rules

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

The first one seems to indicate that your `libclang.so` is broken in release 
mode (optimization error?). The second one is correct (some of the tests test 
for errors, and apparently don't silence the messages).


Repository:
  rC Clang

https://reviews.llvm.org/D52840



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


[PATCH] D53326: [python] [tests] Disable on known-broken arches

2018-10-16 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: uweigand, yroux, kparzysz, steveire, aaron.ballman.
Herald added a reviewer: javed.absar.
Herald added a subscriber: kristof.beyls.

Disable the Python binding tests on AArch64, Hexagon and SystemZ
following reports on test failures.  The first two yield different
results, possibly indicating test case problems.  The last one seems
to have broken FFI in Python.

While at it, refactor the code to make adding future test restrictions
easier.


Repository:
  rC Clang

https://reviews.llvm.org/D53326

Files:
  bindings/python/tests/CMakeLists.txt


Index: bindings/python/tests/CMakeLists.txt
===
--- bindings/python/tests/CMakeLists.txt
+++ bindings/python/tests/CMakeLists.txt
@@ -7,24 +7,34 @@
 DEPENDS libclang
 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-# Check if we are building with ASan
-list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX)
-if (LLVM_USE_ASAN_INDEX EQUAL -1)
-  set(LLVM_USE_ASAN FALSE)
-else()
-  set(LLVM_USE_ASAN TRUE)
-endif()
+set(RUN_PYTHON_TESTS TRUE)
 
-# Tests fail on Windows, and need someone knowledgeable to fix.
-# It's not clear whether it's a test or a valid binding problem.
-#
 # Do not try to run if libclang was built with ASan because
 # the sanitizer library will likely be loaded too late to perform
 # interception and will then fail.
 # We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't
 # portable so its easier just to not run the tests when building
 # with ASan.
-if((NOT WIN32) AND (NOT LLVM_USE_ASAN))
+list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX)
+if(NOT LLVM_USE_ASAN_INDEX EQUAL -1)
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
+# Tests fail on Windows, and need someone knowledgeable to fix.
+# It's not clear whether it's a test or a valid binding problem.
+if(WIN32)
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
+# AArch64 and Hexagon have known test failures that need to be
+# addressed.
+# SystemZ has broken Python/FFI interface:
+# https://reviews.llvm.org/D52840#1265716
+if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$")
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
+if(RUN_PYTHON_TESTS)
 set_property(GLOBAL APPEND PROPERTY
  LLVM_ADDITIONAL_TEST_TARGETS check-clang-python)
 endif()


Index: bindings/python/tests/CMakeLists.txt
===
--- bindings/python/tests/CMakeLists.txt
+++ bindings/python/tests/CMakeLists.txt
@@ -7,24 +7,34 @@
 DEPENDS libclang
 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-# Check if we are building with ASan
-list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX)
-if (LLVM_USE_ASAN_INDEX EQUAL -1)
-  set(LLVM_USE_ASAN FALSE)
-else()
-  set(LLVM_USE_ASAN TRUE)
-endif()
+set(RUN_PYTHON_TESTS TRUE)
 
-# Tests fail on Windows, and need someone knowledgeable to fix.
-# It's not clear whether it's a test or a valid binding problem.
-#
 # Do not try to run if libclang was built with ASan because
 # the sanitizer library will likely be loaded too late to perform
 # interception and will then fail.
 # We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't
 # portable so its easier just to not run the tests when building
 # with ASan.
-if((NOT WIN32) AND (NOT LLVM_USE_ASAN))
+list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX)
+if(NOT LLVM_USE_ASAN_INDEX EQUAL -1)
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
+# Tests fail on Windows, and need someone knowledgeable to fix.
+# It's not clear whether it's a test or a valid binding problem.
+if(WIN32)
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
+# AArch64 and Hexagon have known test failures that need to be
+# addressed.
+# SystemZ has broken Python/FFI interface:
+# https://reviews.llvm.org/D52840#1265716
+if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$")
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
+if(RUN_PYTHON_TESTS)
 set_property(GLOBAL APPEND PROPERTY
  LLVM_ADDITIONAL_TEST_TARGETS check-clang-python)
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52840: Include Python binding tests in CMake rules

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

Thanks for all your reports. I have filed https://reviews.llvm.org/D53326 to 
disable the tests on all three known-broken arches.


Repository:
  rC Clang

https://reviews.llvm.org/D52840



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


[PATCH] D53326: [python] [tests] Disable on known-broken arches

2018-10-16 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC344666: [python] [tests] Disable on known-broken arches 
(authored by mgorny, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D53326

Files:
  bindings/python/tests/CMakeLists.txt


Index: bindings/python/tests/CMakeLists.txt
===
--- bindings/python/tests/CMakeLists.txt
+++ bindings/python/tests/CMakeLists.txt
@@ -7,24 +7,34 @@
 DEPENDS libclang
 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-# Check if we are building with ASan
-list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX)
-if (LLVM_USE_ASAN_INDEX EQUAL -1)
-  set(LLVM_USE_ASAN FALSE)
-else()
-  set(LLVM_USE_ASAN TRUE)
-endif()
+set(RUN_PYTHON_TESTS TRUE)
 
-# Tests fail on Windows, and need someone knowledgeable to fix.
-# It's not clear whether it's a test or a valid binding problem.
-#
 # Do not try to run if libclang was built with ASan because
 # the sanitizer library will likely be loaded too late to perform
 # interception and will then fail.
 # We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't
 # portable so its easier just to not run the tests when building
 # with ASan.
-if((NOT WIN32) AND (NOT LLVM_USE_ASAN))
+list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX)
+if(NOT LLVM_USE_ASAN_INDEX EQUAL -1)
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
+# Tests fail on Windows, and need someone knowledgeable to fix.
+# It's not clear whether it's a test or a valid binding problem.
+if(WIN32)
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
+# AArch64 and Hexagon have known test failures that need to be
+# addressed.
+# SystemZ has broken Python/FFI interface:
+# https://reviews.llvm.org/D52840#1265716
+if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$")
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
+if(RUN_PYTHON_TESTS)
 set_property(GLOBAL APPEND PROPERTY
  LLVM_ADDITIONAL_TEST_TARGETS check-clang-python)
 endif()


Index: bindings/python/tests/CMakeLists.txt
===
--- bindings/python/tests/CMakeLists.txt
+++ bindings/python/tests/CMakeLists.txt
@@ -7,24 +7,34 @@
 DEPENDS libclang
 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-# Check if we are building with ASan
-list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX)
-if (LLVM_USE_ASAN_INDEX EQUAL -1)
-  set(LLVM_USE_ASAN FALSE)
-else()
-  set(LLVM_USE_ASAN TRUE)
-endif()
+set(RUN_PYTHON_TESTS TRUE)
 
-# Tests fail on Windows, and need someone knowledgeable to fix.
-# It's not clear whether it's a test or a valid binding problem.
-#
 # Do not try to run if libclang was built with ASan because
 # the sanitizer library will likely be loaded too late to perform
 # interception and will then fail.
 # We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't
 # portable so its easier just to not run the tests when building
 # with ASan.
-if((NOT WIN32) AND (NOT LLVM_USE_ASAN))
+list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX)
+if(NOT LLVM_USE_ASAN_INDEX EQUAL -1)
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
+# Tests fail on Windows, and need someone knowledgeable to fix.
+# It's not clear whether it's a test or a valid binding problem.
+if(WIN32)
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
+# AArch64 and Hexagon have known test failures that need to be
+# addressed.
+# SystemZ has broken Python/FFI interface:
+# https://reviews.llvm.org/D52840#1265716
+if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$")
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
+if(RUN_PYTHON_TESTS)
 set_property(GLOBAL APPEND PROPERTY
  LLVM_ADDITIONAL_TEST_TARGETS check-clang-python)
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53326: [python] [tests] Disable on known-broken arches

2018-10-16 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344666: [python] [tests] Disable on known-broken arches 
(authored by mgorny, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53326?vs=169832&id=169944#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53326

Files:
  cfe/trunk/bindings/python/tests/CMakeLists.txt


Index: cfe/trunk/bindings/python/tests/CMakeLists.txt
===
--- cfe/trunk/bindings/python/tests/CMakeLists.txt
+++ cfe/trunk/bindings/python/tests/CMakeLists.txt
@@ -7,24 +7,34 @@
 DEPENDS libclang
 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-# Check if we are building with ASan
-list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX)
-if (LLVM_USE_ASAN_INDEX EQUAL -1)
-  set(LLVM_USE_ASAN FALSE)
-else()
-  set(LLVM_USE_ASAN TRUE)
-endif()
+set(RUN_PYTHON_TESTS TRUE)
 
-# Tests fail on Windows, and need someone knowledgeable to fix.
-# It's not clear whether it's a test or a valid binding problem.
-#
 # Do not try to run if libclang was built with ASan because
 # the sanitizer library will likely be loaded too late to perform
 # interception and will then fail.
 # We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't
 # portable so its easier just to not run the tests when building
 # with ASan.
-if((NOT WIN32) AND (NOT LLVM_USE_ASAN))
+list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX)
+if(NOT LLVM_USE_ASAN_INDEX EQUAL -1)
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
+# Tests fail on Windows, and need someone knowledgeable to fix.
+# It's not clear whether it's a test or a valid binding problem.
+if(WIN32)
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
+# AArch64 and Hexagon have known test failures that need to be
+# addressed.
+# SystemZ has broken Python/FFI interface:
+# https://reviews.llvm.org/D52840#1265716
+if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$")
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
+if(RUN_PYTHON_TESTS)
 set_property(GLOBAL APPEND PROPERTY
  LLVM_ADDITIONAL_TEST_TARGETS check-clang-python)
 endif()


Index: cfe/trunk/bindings/python/tests/CMakeLists.txt
===
--- cfe/trunk/bindings/python/tests/CMakeLists.txt
+++ cfe/trunk/bindings/python/tests/CMakeLists.txt
@@ -7,24 +7,34 @@
 DEPENDS libclang
 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/..)
 
-# Check if we are building with ASan
-list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX)
-if (LLVM_USE_ASAN_INDEX EQUAL -1)
-  set(LLVM_USE_ASAN FALSE)
-else()
-  set(LLVM_USE_ASAN TRUE)
-endif()
+set(RUN_PYTHON_TESTS TRUE)
 
-# Tests fail on Windows, and need someone knowledgeable to fix.
-# It's not clear whether it's a test or a valid binding problem.
-#
 # Do not try to run if libclang was built with ASan because
 # the sanitizer library will likely be loaded too late to perform
 # interception and will then fail.
 # We could use LD_PRELOAD/DYLD_INSERT_LIBRARIES but this isn't
 # portable so its easier just to not run the tests when building
 # with ASan.
-if((NOT WIN32) AND (NOT LLVM_USE_ASAN))
+list(FIND LLVM_USE_SANITIZER "Address" LLVM_USE_ASAN_INDEX)
+if(NOT LLVM_USE_ASAN_INDEX EQUAL -1)
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
+# Tests fail on Windows, and need someone knowledgeable to fix.
+# It's not clear whether it's a test or a valid binding problem.
+if(WIN32)
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
+# AArch64 and Hexagon have known test failures that need to be
+# addressed.
+# SystemZ has broken Python/FFI interface:
+# https://reviews.llvm.org/D52840#1265716
+if(${LLVM_NATIVE_ARCH} MATCHES "^(AArch64|Hexagon|SystemZ)$")
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
+if(RUN_PYTHON_TESTS)
 set_property(GLOBAL APPEND PROPERTY
  LLVM_ADDITIONAL_TEST_TARGETS check-clang-python)
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53326: [python] [tests] Disable on known-broken arches

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

Thanks for the review. I'm going to be away most of the day today, so if it 
breaks something (worse), feel free to revert.


Repository:
  rL LLVM

https://reviews.llvm.org/D53326



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


[PATCH] D47819: [test] Support using libtirpc on Linux

2018-10-30 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 171647.
mgorny added a comment.

Rebased.


https://reviews.llvm.org/D47819

Files:
  cmake/base-config-ix.cmake
  lib/sanitizer_common/CMakeLists.txt
  test/msan/lit.cfg
  test/msan/lit.site.cfg.in
  test/tsan/lit.cfg
  test/tsan/lit.site.cfg.in


Index: test/tsan/lit.site.cfg.in
===
--- test/tsan/lit.site.cfg.in
+++ test/tsan/lit.site.cfg.in
@@ -6,6 +6,7 @@
 config.apple_platform = "@TSAN_TEST_APPLE_PLATFORM@"
 config.target_cflags = "@TSAN_TEST_TARGET_CFLAGS@"
 config.target_arch = "@TSAN_TEST_TARGET_ARCH@"
+config.rpc_cflags = "@TIRPC_CFLAGS@"
 
 # Load common config for all compiler-rt lit tests.
 lit_config.load_config(config, 
"@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
Index: test/tsan/lit.cfg
===
--- test/tsan/lit.cfg
+++ test/tsan/lit.cfg
@@ -49,7 +49,8 @@
   [config.target_cflags] +
   config.debug_info_flags +
   extra_cflags +
-  ["-I%s" % tsan_incdir])
+  ["-I%s" % tsan_incdir] +
+  [config.rpc_cflags])
 clang_tsan_cxxflags = config.cxx_mode_flags + clang_tsan_cflags + 
["-std=c++11"] + ["-I%s" % tsan_incdir]
 # Add additional flags if we're using instrumented libc++.
 # Instrumented libcxx currently not supported on Darwin.
Index: test/msan/lit.site.cfg.in
===
--- test/msan/lit.site.cfg.in
+++ test/msan/lit.site.cfg.in
@@ -6,6 +6,7 @@
 config.target_arch = "@MSAN_TEST_TARGET_ARCH@"
 config.use_lld = @MSAN_TEST_USE_LLD@
 config.use_thinlto = @MSAN_TEST_USE_THINLTO@
+config.rpc_cflags = "@TIRPC_CFLAGS@"
 
 # Load common config for all compiler-rt lit tests.
 lit_config.load_config(config, 
"@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
Index: test/msan/lit.cfg
===
--- test/msan/lit.cfg
+++ test/msan/lit.cfg
@@ -14,7 +14,8 @@
   "-fno-omit-frame-pointer",
   "-fno-optimize-sibling-calls"] +
   [config.target_cflags] +
-  config.debug_info_flags)
+  config.debug_info_flags +
+  [config.rpc_cflags])
 # Some Msan tests leverage backtrace() which requires libexecinfo on FreeBSD.
 if config.host_os == 'FreeBSD':
   clang_msan_cflags += ["-lexecinfo", "-fPIC"]
Index: lib/sanitizer_common/CMakeLists.txt
===
--- lib/sanitizer_common/CMakeLists.txt
+++ lib/sanitizer_common/CMakeLists.txt
@@ -191,8 +191,6 @@
 
 set(SANITIZER_COMMON_DEFINITIONS)
 
-include(FindPkgConfig)
-pkg_check_modules(TIRPC libtirpc)
 if (TIRPC_FOUND)
   include_directories(${TIRPC_INCLUDE_DIRS})
   set(CMAKE_REQUIRED_INCLUDES ${TIRPC_INCLUDE_DIRS})
Index: cmake/base-config-ix.cmake
===
--- cmake/base-config-ix.cmake
+++ cmake/base-config-ix.cmake
@@ -8,6 +8,10 @@
 
 check_include_file(unwind.h HAVE_UNWIND_H)
 
+# used in sanitizer_common and tests
+include(FindPkgConfig)
+pkg_check_modules(TIRPC libtirpc)
+
 # Top level target used to build all compiler-rt libraries.
 add_custom_target(compiler-rt ALL)
 add_custom_target(install-compiler-rt)


Index: test/tsan/lit.site.cfg.in
===
--- test/tsan/lit.site.cfg.in
+++ test/tsan/lit.site.cfg.in
@@ -6,6 +6,7 @@
 config.apple_platform = "@TSAN_TEST_APPLE_PLATFORM@"
 config.target_cflags = "@TSAN_TEST_TARGET_CFLAGS@"
 config.target_arch = "@TSAN_TEST_TARGET_ARCH@"
+config.rpc_cflags = "@TIRPC_CFLAGS@"
 
 # Load common config for all compiler-rt lit tests.
 lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
Index: test/tsan/lit.cfg
===
--- test/tsan/lit.cfg
+++ test/tsan/lit.cfg
@@ -49,7 +49,8 @@
   [config.target_cflags] +
   config.debug_info_flags +
   extra_cflags +
-  ["-I%s" % tsan_incdir])
+  ["-I%s" % tsan_incdir] +
+  [config.rpc_cflags])
 clang_tsan_cxxflags = config.cxx_mode_flags + clang_tsan_cflags + ["-std=c++11"] + ["-I%s" % tsan_incdir]
 # Add additional flags if we're using instrumented libc++.
 # Instrumented libcxx currently not supported on Darwin.
Index: test/msan/lit.site.cfg.in
===
--- test/msan/lit.site.cfg.in
+++ test/msan/lit.site.cfg.in
@@ -6,6 +6,7 @@
 config.target_arch = "@MSAN_TEST_TARGET_ARCH@"
 config.use_lld = @MSAN_TEST_USE_LLD@
 config.use_thinlto = @MSAN_TEST_USE_THINLTO@
+config.rpc_cflags = "@TIRPC_CFLAGS@"
 
 # Load common config for all compiler

[PATCH] D47817: [sanitizer_common] Fix using libtirpc on Linux

2018-10-30 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 171646.
mgorny added a comment.

Rebased.


https://reviews.llvm.org/D47817

Files:
  lib/sanitizer_common/CMakeLists.txt
  lib/sanitizer_common/sanitizer_platform_limits_posix.cc


Index: lib/sanitizer_common/sanitizer_platform_limits_posix.cc
===
--- lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ lib/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -146,8 +146,6 @@
 #include 
 #if HAVE_RPC_XDR_H
 # include 
-#elif HAVE_TIRPC_RPC_XDR_H
-# include 
 #endif
 #include 
 #include 
@@ -1243,7 +1241,7 @@
 CHECK_SIZE_AND_OFFSET(group, gr_gid);
 CHECK_SIZE_AND_OFFSET(group, gr_mem);
 
-#if HAVE_RPC_XDR_H || HAVE_TIRPC_RPC_XDR_H
+#if HAVE_RPC_XDR_H
 CHECK_TYPE_SIZE(XDR);
 CHECK_SIZE_AND_OFFSET(XDR, x_op);
 CHECK_SIZE_AND_OFFSET(XDR, x_ops);
Index: lib/sanitizer_common/CMakeLists.txt
===
--- lib/sanitizer_common/CMakeLists.txt
+++ lib/sanitizer_common/CMakeLists.txt
@@ -191,9 +191,18 @@
 
 set(SANITIZER_COMMON_DEFINITIONS)
 
+include(FindPkgConfig)
+pkg_check_modules(TIRPC libtirpc)
+if (TIRPC_FOUND)
+  include_directories(${TIRPC_INCLUDE_DIRS})
+  set(CMAKE_REQUIRED_INCLUDES ${TIRPC_INCLUDE_DIRS})
+endif()
+
 include(CheckIncludeFile)
+cmake_push_check_state()
+string(REPLACE "-nodefaultlibs" "" CMAKE_REQUIRED_FLAGS 
${CMAKE_REQUIRED_FLAGS})
 append_have_file_definition(rpc/xdr.h HAVE_RPC_XDR_H 
SANITIZER_COMMON_DEFINITIONS)
-append_have_file_definition(tirpc/rpc/xdr.h HAVE_TIRPC_RPC_XDR_H 
SANITIZER_COMMON_DEFINITIONS)
+cmake_pop_check_state()
 
 set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SANITIZER_CFLAGS)


Index: lib/sanitizer_common/sanitizer_platform_limits_posix.cc
===
--- lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ lib/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -146,8 +146,6 @@
 #include 
 #if HAVE_RPC_XDR_H
 # include 
-#elif HAVE_TIRPC_RPC_XDR_H
-# include 
 #endif
 #include 
 #include 
@@ -1243,7 +1241,7 @@
 CHECK_SIZE_AND_OFFSET(group, gr_gid);
 CHECK_SIZE_AND_OFFSET(group, gr_mem);
 
-#if HAVE_RPC_XDR_H || HAVE_TIRPC_RPC_XDR_H
+#if HAVE_RPC_XDR_H
 CHECK_TYPE_SIZE(XDR);
 CHECK_SIZE_AND_OFFSET(XDR, x_op);
 CHECK_SIZE_AND_OFFSET(XDR, x_ops);
Index: lib/sanitizer_common/CMakeLists.txt
===
--- lib/sanitizer_common/CMakeLists.txt
+++ lib/sanitizer_common/CMakeLists.txt
@@ -191,9 +191,18 @@
 
 set(SANITIZER_COMMON_DEFINITIONS)
 
+include(FindPkgConfig)
+pkg_check_modules(TIRPC libtirpc)
+if (TIRPC_FOUND)
+  include_directories(${TIRPC_INCLUDE_DIRS})
+  set(CMAKE_REQUIRED_INCLUDES ${TIRPC_INCLUDE_DIRS})
+endif()
+
 include(CheckIncludeFile)
+cmake_push_check_state()
+string(REPLACE "-nodefaultlibs" "" CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
 append_have_file_definition(rpc/xdr.h HAVE_RPC_XDR_H SANITIZER_COMMON_DEFINITIONS)
-append_have_file_definition(tirpc/rpc/xdr.h HAVE_TIRPC_RPC_XDR_H SANITIZER_COMMON_DEFINITIONS)
+cmake_pop_check_state()
 
 set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SANITIZER_CFLAGS)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53125: Detect Clear Linux and apply Clear's default linker options

2018-10-30 Thread Michał Górny via Phabricator via cfe-commits
mgorny accepted this revision.
mgorny added a comment.
This revision is now accepted and ready to land.

LGTM, presuming the tests pass for you.


https://reviews.llvm.org/D53125



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


[PATCH] D49486: [cfe][CMake] Export the clang resource directory

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

@philip.pfaffe, did you establish whether this is still necessary or can be 
abandoned?


https://reviews.llvm.org/D49486



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


[PATCH] D56554: [ELF] Add '-z nognustack' opt to suppress emitting PT_GNU_STACK

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

@ruiu, what if one of the systems changes defaults (e.g. due to Hardening) and 
starts defaulting to noexecstack? In that case we'd want `-z execstack' to 
actually emit PT_GNU_STACK, and I don't think we really are able to 100% detect 
the default in clang. I'd really see this as a trinary option: emit RW, emit 
RWX or not emit at all. I don't think it's a good idea to make linker rely on 
implicit assumptions or hidden guesses that could easily confuse user as to 
what's happening and why.


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D56554



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


[PATCH] D56554: [ELF] Add '-z nognustack' opt to suppress emitting PT_GNU_STACK

2019-01-11 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Actually, I've just researched a bit and default stack permissions depend on 
arch in glibc, so assuming it's RWX by default is wrong.


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D56554



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


[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-11 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 181268.
mgorny added a comment.

Implemented checking the triple against target registry. Also made `--version` 
output the detected target.


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

https://reviews.llvm.org/D56215

Files:
  ELF/Config.h
  ELF/Driver.cpp
  ELF/Driver.h

Index: ELF/Driver.h
===
--- ELF/Driver.h
+++ ELF/Driver.h
@@ -31,7 +31,9 @@
   void addLibrary(StringRef Name);
 
 private:
+  void setDefaultTargetTriple(StringRef argv0);
   void readConfigs(llvm::opt::InputArgList &Args);
+  void appendDefaultSearchPaths();
   void createFiles(llvm::opt::InputArgList &Args);
   void inferMachineType();
   template  void link(llvm::opt::InputArgList &Args);
Index: ELF/Driver.cpp
===
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -54,6 +54,7 @@
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/TarWriter.h"
+#include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -365,6 +366,23 @@
   error("unknown -z value: " + StringRef(Arg->getValue()));
 }
 
+void LinkerDriver::appendDefaultSearchPaths() {
+  if (Config->TargetTriple.isOSNetBSD()) {
+// NetBSD driver relies on the linker knowing the default search paths.
+// Please keep this in sync with clang/lib/Driver/ToolChains/NetBSD.cpp
+// (NetBSD::NetBSD constructor)
+switch (Config->EMachine) {
+  case EM_386:
+Config->SearchPaths.push_back("=/usr/lib/i386");
+break;
+  case EM_X86_64:
+break;
+  // TODO: support non-x86 architectures
+}
+Config->SearchPaths.push_back("=/usr/lib");
+  }
+}
+
 void LinkerDriver::main(ArrayRef ArgsArr) {
   ELFOptTable Parser;
   opt::InputArgList Args = Parser.parse(ArgsArr.slice(1));
@@ -378,6 +396,26 @@
 return;
   }
 
+  if (const char *Path = getReproduceOption(Args)) {
+// Note that --reproduce is a debug option so you can ignore it
+// if you are trying to understand the whole picture of the code.
+Expected> ErrOrWriter =
+TarWriter::create(Path, path::stem(Path));
+if (ErrOrWriter) {
+  Tar = std::move(*ErrOrWriter);
+  Tar->append("response.txt", createResponseFile(Args));
+  Tar->append("version.txt", getLLDVersion() + "\n");
+} else {
+  error("--reproduce: " + toString(ErrOrWriter.takeError()));
+}
+  }
+
+  initLLVM();
+  setDefaultTargetTriple(ArgsArr[0]);
+  readConfigs(Args);
+  checkZOptions(Args);
+  appendDefaultSearchPaths();
+
   // Handle -v or -version.
   //
   // A note about "compatible with GNU linkers" message: this is a hack for
@@ -393,26 +431,11 @@
   // lot of "configure" scripts out there that are generated by old version
   // of Libtool. We cannot convince every software developer to migrate to
   // the latest version and re-generate scripts. So we have this hack.
-  if (Args.hasArg(OPT_v) || Args.hasArg(OPT_version))
+  if (Args.hasArg(OPT_v) || Args.hasArg(OPT_version)) {
 message(getLLDVersion() + " (compatible with GNU linkers)");
-
-  if (const char *Path = getReproduceOption(Args)) {
-// Note that --reproduce is a debug option so you can ignore it
-// if you are trying to understand the whole picture of the code.
-Expected> ErrOrWriter =
-TarWriter::create(Path, path::stem(Path));
-if (ErrOrWriter) {
-  Tar = std::move(*ErrOrWriter);
-  Tar->append("response.txt", createResponseFile(Args));
-  Tar->append("version.txt", getLLDVersion() + "\n");
-} else {
-  error("--reproduce: " + toString(ErrOrWriter.takeError()));
-}
+message("Target: " + Config->TargetTriple.str());
   }
 
-  readConfigs(Args);
-  checkZOptions(Args);
-
   // The behavior of -v or --version is a bit strange, but this is
   // needed for compatibility with GNU linkers.
   if (Args.hasArg(OPT_v) && !Args.hasArg(OPT_INPUT))
@@ -420,7 +443,6 @@
   if (Args.hasArg(OPT_version))
 return;
 
-  initLLVM();
   createFiles(Args);
   if (errorCount())
 return;
@@ -746,6 +768,21 @@
   error(Msg + ": " + StringRef(Err).trim());
 }
 
+void LinkerDriver::setDefaultTargetTriple(StringRef argv0) {
+  // Start with a default initial triple
+  Config->TargetTriple = llvm::Triple(getDefaultTargetTriple());
+
+  // Try to override triple with program name prefix
+  std::string ProgName = llvm::sys::path::stem(argv0);
+  size_t LastComponent = ProgName.rfind('-');
+  if (LastComponent != std::string::npos) {
+std::string Prefix = ProgName.substr(0, LastComponent);
+std::string IgnoredError;
+if (llvm::TargetRegistry::lookupTarget(Prefix, IgnoredError))
+  Config->TargetTriple = llvm::Triple(Prefix);
+  }
+}
+
 // Initializes Config members by the command line options.
 void LinkerDriver::readConfigs(opt::InputArgList &Args) {
   errorHandler().Verbose

[PATCH] D56607: [clang] [NetBSD] Enable additional sanitizer types

2019-01-11 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added a reviewer: krytarowski.

Repository:
  rC Clang

https://reviews.llvm.org/D56607

Files:
  lib/Driver/ToolChains/NetBSD.cpp


Index: lib/Driver/ToolChains/NetBSD.cpp
===
--- lib/Driver/ToolChains/NetBSD.cpp
+++ lib/Driver/ToolChains/NetBSD.cpp
@@ -432,10 +432,15 @@
 Res |= SanitizerKind::Vptr;
   }
   if (IsX86_64) {
+Res |= SanitizerKind::DataFlow;
 Res |= SanitizerKind::Efficiency;
+Res |= SanitizerKind::Function;
 Res |= SanitizerKind::Fuzzer;
 Res |= SanitizerKind::FuzzerNoLink;
+Res |= SanitizerKind::HWAddress;
 Res |= SanitizerKind::KernelAddress;
+Res |= SanitizerKind::KernelHWAddress;
+Res |= SanitizerKind::KernelMemory;
 Res |= SanitizerKind::Memory;
 Res |= SanitizerKind::Thread;
   }


Index: lib/Driver/ToolChains/NetBSD.cpp
===
--- lib/Driver/ToolChains/NetBSD.cpp
+++ lib/Driver/ToolChains/NetBSD.cpp
@@ -432,10 +432,15 @@
 Res |= SanitizerKind::Vptr;
   }
   if (IsX86_64) {
+Res |= SanitizerKind::DataFlow;
 Res |= SanitizerKind::Efficiency;
+Res |= SanitizerKind::Function;
 Res |= SanitizerKind::Fuzzer;
 Res |= SanitizerKind::FuzzerNoLink;
+Res |= SanitizerKind::HWAddress;
 Res |= SanitizerKind::KernelAddress;
+Res |= SanitizerKind::KernelHWAddress;
+Res |= SanitizerKind::KernelMemory;
 Res |= SanitizerKind::Memory;
 Res |= SanitizerKind::Thread;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56607: [clang] [NetBSD] Enable additional sanitizer types

2019-01-11 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 181356.
mgorny added a comment.
Herald added a subscriber: cryptoad.

Updated the tests to account for most of the known sanitizer types.

Notes/TODO:

1. I wasn't able to get a sane match for `-fsanitize=undefined`, so I just 
check if it enables anything.
2. `-fsanitize=efficiency-all` is reported as unsupported even though it's in 
SanitizerKinds.


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

https://reviews.llvm.org/D56607

Files:
  lib/Driver/ToolChains/NetBSD.cpp
  test/Driver/fsanitize.c


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -709,28 +709,67 @@
 // RUN: %clang -target x86_64-unknown-cloudabi -fsanitize=safe-stack %s -### 
2>&1 | FileCheck %s -check-prefix=SAFESTACK-CLOUDABI
 // SAFESTACK-CLOUDABI: "-fsanitize=safe-stack"
 
+
+
+// * NetBSD; please keep ordered as in Sanitizers.def *
+
 // RUN: %clang -target i386--netbsd -fsanitize=address %s -### 2>&1 | 
FileCheck %s -check-prefix=ADDRESS-NETBSD
 // RUN: %clang -target x86_64--netbsd -fsanitize=address %s -### 2>&1 | 
FileCheck %s -check-prefix=ADDRESS-NETBSD
 // ADDRESS-NETBSD: "-fsanitize=address"
 
+// RUN: %clang -target x86_64--netbsd -fsanitize=kernel-address %s -### 2>&1 | 
FileCheck %s -check-prefix=KERNEL-ADDRESS-NETBSD
+// KERNEL-ADDRESS-NETBSD: "-fsanitize=kernel-address"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=hwaddress %s -### 2>&1 | 
FileCheck %s -check-prefix=HWADDRESS-NETBSD
+// HWADDRESS-NETBSD: "-fsanitize=hwaddress"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=kernel-hwaddress %s -### 2>&1 
| FileCheck %s -check-prefix=KERNEL-HWADDRESS-NETBSD
+// KERNEL-HWADDRESS-NETBSD: "-fsanitize=kernel-hwaddress"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=memory %s -### 2>&1 | 
FileCheck %s -check-prefix=MEMORY-NETBSD
+// MEMORY-NETBSD: "-fsanitize=memory"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=kernel-memory %s -### 2>&1 | 
FileCheck %s -check-prefix=KERNEL-MEMORY-NETBSD
+// KERNEL-MEMORY-NETBSD: "-fsanitize=kernel-memory"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=thread %s -### 2>&1 | 
FileCheck %s -check-prefix=THREAD-NETBSD
+// THREAD-NETBSD: "-fsanitize=thread"
+
+// RUN: %clang -target i386--netbsd -fsanitize=leak %s -### 2>&1 | FileCheck 
%s -check-prefix=LEAK-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=leak %s -### 2>&1 | FileCheck 
%s -check-prefix=LEAK-NETBSD
+// LEAK-NETBSD: "-fsanitize=leak"
+
+// RUN: %clang -target i386--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
+// FUNCTION-NETBSD: "-fsanitize=function"
+
 // RUN: %clang -target i386--netbsd -fsanitize=vptr %s -### 2>&1 | FileCheck 
%s -check-prefix=VPTR-NETBSD
 // RUN: %clang -target x86_64--netbsd -fsanitize=vptr %s -### 2>&1 | FileCheck 
%s -check-prefix=VPTR-NETBSD
 // VPTR-NETBSD: "-fsanitize=vptr"
 
+// RUN: %clang -target x86_64--netbsd -fsanitize=dataflow %s -### 2>&1 | 
FileCheck %s -check-prefix=DATAFLOW-NETBSD
+// DATAFLOW-NETBSD: "-fsanitize=dataflow"
+
+// RUN: %clang -target i386--netbsd -fsanitize=cfi %s -### 2>&1 | FileCheck %s 
-check-prefix=CFI-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=cfi %s -### 2>&1 | FileCheck 
%s -check-prefix=CFI-NETBSD
+// CFI-NETBSD: 
"-fsanitize=cfi-derived-cast,cfi-icall,cfi-mfcall,cfi-unrelated-cast,cfi-nvcall,cfi-vcall"
+
 // RUN: %clang -target i386--netbsd -fsanitize=safe-stack %s -### 2>&1 | 
FileCheck %s -check-prefix=SAFESTACK-NETBSD
 // RUN: %clang -target x86_64--netbsd -fsanitize=safe-stack %s -### 2>&1 | 
FileCheck %s -check-prefix=SAFESTACK-NETBSD
 // SAFESTACK-NETBSD: "-fsanitize=safe-stack"
 
-// RUN: %clang -target i386--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
-// RUN: %clang -target x86_64--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
-// FUNCTION-NETBSD: "-fsanitize=function"
+// RUN: %clang -target x86_64--netbsd -fsanitize=shadow-call-stack %s -### 
2>&1 | FileCheck %s -check-prefix=SHADOW-CALL-STACK-NETBSD
+// SHADOW-CALL-STACK-NETBSD: "-fsanitize=shadow-call-stack"
+
+// RUN: %clang -target i386--netbsd -fsanitize=undefined %s -### 2>&1 | 
FileCheck %s -check-prefix=UNDEFINED-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=undefined %s -### 2>&1 | 
FileCheck %s -check-prefix=UNDEFINED-NETBSD
+// UNDEFINED-NETBSD: "-fsanitize={{.*}}
+
+// RUN: %clang -target i386--netbsd -fsanitize=scudo %s -### 2>&1 | FileCheck 
%s -check-prefix=SCUDO-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=scudo %s -### 2>&1 | 
FileCheck %s -check-prefix=SCUDO-NETBSD
+// SCUDO-NETBSD: "-fsanitize=scudo"
 
-// RUN: %clang -target i386--netbsd -fsanitize=leak %s -### 2>&1 | FileCheck 
%s -check-prefix=LEAK-NETBSD
-// RUN: %c

[PATCH] D56607: [clang] [NetBSD] Enable additional sanitizer types

2019-01-12 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL351002: [NetBSD] Enable additional sanitizer types (authored 
by mgorny, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56607?vs=181356&id=181433#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56607

Files:
  cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp
  cfe/trunk/test/Driver/fsanitize.c


Index: cfe/trunk/test/Driver/fsanitize.c
===
--- cfe/trunk/test/Driver/fsanitize.c
+++ cfe/trunk/test/Driver/fsanitize.c
@@ -709,28 +709,67 @@
 // RUN: %clang -target x86_64-unknown-cloudabi -fsanitize=safe-stack %s -### 
2>&1 | FileCheck %s -check-prefix=SAFESTACK-CLOUDABI
 // SAFESTACK-CLOUDABI: "-fsanitize=safe-stack"
 
+
+
+// * NetBSD; please keep ordered as in Sanitizers.def *
+
 // RUN: %clang -target i386--netbsd -fsanitize=address %s -### 2>&1 | 
FileCheck %s -check-prefix=ADDRESS-NETBSD
 // RUN: %clang -target x86_64--netbsd -fsanitize=address %s -### 2>&1 | 
FileCheck %s -check-prefix=ADDRESS-NETBSD
 // ADDRESS-NETBSD: "-fsanitize=address"
 
+// RUN: %clang -target x86_64--netbsd -fsanitize=kernel-address %s -### 2>&1 | 
FileCheck %s -check-prefix=KERNEL-ADDRESS-NETBSD
+// KERNEL-ADDRESS-NETBSD: "-fsanitize=kernel-address"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=hwaddress %s -### 2>&1 | 
FileCheck %s -check-prefix=HWADDRESS-NETBSD
+// HWADDRESS-NETBSD: "-fsanitize=hwaddress"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=kernel-hwaddress %s -### 2>&1 
| FileCheck %s -check-prefix=KERNEL-HWADDRESS-NETBSD
+// KERNEL-HWADDRESS-NETBSD: "-fsanitize=kernel-hwaddress"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=memory %s -### 2>&1 | 
FileCheck %s -check-prefix=MEMORY-NETBSD
+// MEMORY-NETBSD: "-fsanitize=memory"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=kernel-memory %s -### 2>&1 | 
FileCheck %s -check-prefix=KERNEL-MEMORY-NETBSD
+// KERNEL-MEMORY-NETBSD: "-fsanitize=kernel-memory"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=thread %s -### 2>&1 | 
FileCheck %s -check-prefix=THREAD-NETBSD
+// THREAD-NETBSD: "-fsanitize=thread"
+
+// RUN: %clang -target i386--netbsd -fsanitize=leak %s -### 2>&1 | FileCheck 
%s -check-prefix=LEAK-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=leak %s -### 2>&1 | FileCheck 
%s -check-prefix=LEAK-NETBSD
+// LEAK-NETBSD: "-fsanitize=leak"
+
+// RUN: %clang -target i386--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
+// FUNCTION-NETBSD: "-fsanitize=function"
+
 // RUN: %clang -target i386--netbsd -fsanitize=vptr %s -### 2>&1 | FileCheck 
%s -check-prefix=VPTR-NETBSD
 // RUN: %clang -target x86_64--netbsd -fsanitize=vptr %s -### 2>&1 | FileCheck 
%s -check-prefix=VPTR-NETBSD
 // VPTR-NETBSD: "-fsanitize=vptr"
 
+// RUN: %clang -target x86_64--netbsd -fsanitize=dataflow %s -### 2>&1 | 
FileCheck %s -check-prefix=DATAFLOW-NETBSD
+// DATAFLOW-NETBSD: "-fsanitize=dataflow"
+
+// RUN: %clang -target i386--netbsd -fsanitize=cfi %s -### 2>&1 | FileCheck %s 
-check-prefix=CFI-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=cfi %s -### 2>&1 | FileCheck 
%s -check-prefix=CFI-NETBSD
+// CFI-NETBSD: 
"-fsanitize=cfi-derived-cast,cfi-icall,cfi-mfcall,cfi-unrelated-cast,cfi-nvcall,cfi-vcall"
+
 // RUN: %clang -target i386--netbsd -fsanitize=safe-stack %s -### 2>&1 | 
FileCheck %s -check-prefix=SAFESTACK-NETBSD
 // RUN: %clang -target x86_64--netbsd -fsanitize=safe-stack %s -### 2>&1 | 
FileCheck %s -check-prefix=SAFESTACK-NETBSD
 // SAFESTACK-NETBSD: "-fsanitize=safe-stack"
 
-// RUN: %clang -target i386--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
-// RUN: %clang -target x86_64--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
-// FUNCTION-NETBSD: "-fsanitize=function"
+// RUN: %clang -target x86_64--netbsd -fsanitize=shadow-call-stack %s -### 
2>&1 | FileCheck %s -check-prefix=SHADOW-CALL-STACK-NETBSD
+// SHADOW-CALL-STACK-NETBSD: "-fsanitize=shadow-call-stack"
+
+// RUN: %clang -target i386--netbsd -fsanitize=undefined %s -### 2>&1 | 
FileCheck %s -check-prefix=UNDEFINED-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=undefined %s -### 2>&1 | 
FileCheck %s -check-prefix=UNDEFINED-NETBSD
+// UNDEFINED-NETBSD: "-fsanitize={{.*}}
+
+// RUN: %clang -target i386--netbsd -fsanitize=scudo %s -### 2>&1 | FileCheck 
%s -check-prefix=SCUDO-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=scudo %s -### 2>&1 | 
FileCheck %s -check-prefix=SCUDO-NETBSD
+// SCUDO-NETBSD: "-fsanitize=scudo"
 
-// RUN: %clang -target i386--netbsd -fsanitize=leak %s -### 2>&1 | FileCheck 
%s -check-prefix=LEAK-NETBSD
-// RUN: %clang -targe

[PATCH] D56647: [WIP] [ELF] Implement --copy-dt-needed-entries

2019-01-13 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: ruiu, krytarowski.
Herald added subscribers: llvm-commits, jfb, arichardson, emaste.
Herald added a reviewer: espindola.

This is my proof-of-concept on making `--copy-dt-needed-entries` work. 
Apparently, i've been able to hack on it hard enough to make it actually emit 
DT_NEEDED for all symbols, recursively:

  $ clang -fuse-ld=lld  -Wl,--copy-dt-needed-entries test.c  -lgit2
  $ readelf -d a.out 
  
  Dynamic section at offset 0x3010 contains 40 entries:
TagType Name/Value
   0x0001 (NEEDED) Shared library: [libgit2.so.27]
   0x0001 (NEEDED) Shared library: [librt.so.1]
   0x0001 (NEEDED) Shared library: [libpthread.so.0]
   0x0001 (NEEDED) Shared library: [libc.so.6]
   0x0001 (NEEDED) Shared library: 
[ld-linux-x86-64.so.2]
   0x0001 (NEEDED) Shared library: [libcurl.so.4]
   0x0001 (NEEDED) Shared library: [libcares.so.2]
   0x0001 (NEEDED) Shared library: [libnghttp2.so.14]
   0x0001 (NEEDED) Shared library: [libidn2.so.4]
   0x0001 (NEEDED) Shared library: [libunistring.so.2]
   0x0001 (NEEDED) Shared library: [libssl.so.1.1]
   0x0001 (NEEDED) Shared library: [libcrypto.so.1.1]
   0x0001 (NEEDED) Shared library: [libz.so.1]
   0x0001 (NEEDED) Shared library: [libdl.so.2]
   0x0001 (NEEDED) Shared library: 
[libhttp_parser.so.2.9]
   0x0001 (NEEDED) Shared library: [libssh2.so.1]
   0x0015 (DEBUG)  0x0
   0x0007 (RELA)   0x200620
   0x0008 (RELASZ) 48 (bytes)
   0x0009 (RELAENT)24 (bytes)
   0x0017 (JMPREL) 0x200650
   0x0002 (PLTRELSZ)   72 (bytes)
   0x0003 (PLTGOT) 0x202010
   0x0014 (PLTREL) RELA
   0x0006 (SYMTAB) 0x2002b0
   0x000b (SYMENT) 24 (bytes)
   0x0005 (STRTAB) 0x200488
   0x000a (STRSZ)  404 (bytes)
   0x6ef5 (GNU_HASH)   0x200400
   0x0004 (HASH)   0x200428
   0x0019 (INIT_ARRAY) 0x203008
   0x001b (INIT_ARRAYSZ)   8 (bytes)
   0x001a (FINI_ARRAY) 0x203000
   0x001c (FINI_ARRAYSZ)   8 (bytes)
   0x000c (INIT)   0x201200
   0x000d (FINI)   0x201218
   0x6ff0 (VERSYM) 0x2003b8
   0x6ffe (VERNEED)0x2003d0
   0x6fff (VERNEEDNUM) 1
   0x (NULL)   0x0

Can't say the code is nice but before I try to make it cleanly, I'd appreciate 
some tips on whether I'm even starting in the right direction.

FWICS, GNU ld's `--copy-dt-needed-entries` adds lot less libraries — it seems 
as if it implicitly forced `--as-needed`, and `--no-as-needed` doesn't seem to 
make a difference.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D56647

Files:
  ELF/Config.h
  ELF/Driver.cpp
  ELF/InputFiles.cpp
  ELF/InputFiles.h
  ELF/Options.td
  ELF/SymbolTable.cpp

Index: ELF/SymbolTable.cpp
===
--- ELF/SymbolTable.cpp
+++ ELF/SymbolTable.cpp
@@ -16,6 +16,7 @@
 
 #include "SymbolTable.h"
 #include "Config.h"
+#include "Driver.h"
 #include "LinkerScript.h"
 #include "Symbols.h"
 #include "SyntheticSections.h"
@@ -109,6 +110,17 @@
   return;
 
 SharedFiles.push_back(F);
+if (F->CopyDtNeeded) {
+  for (std::string& DtNeeded : F->parseDtNeeded()) {
+if (Optional Path = searchLibrary(":" + DtNeeded)) {
+  // TODO: how does memory management work here?
+  if (Optional Buffer = readFile(*Path))
+addFile(make>(*Buffer, DtNeeded));
+} else {
+  // TODO: error out?
+}
+  }
+}
 F->parseRest();
 return;
   }
Index: ELF/Options.td
===
--- ELF/Options.td
+++ ELF/Options.td
@@ -88,6 +88,10 @@
   HelpText<"Use colors in diagnostics">,
   MetaVarName<"[auto,always,never]">;
 
+defm copy_dt_needed_entries: B<"copy-dt-needed-entries",
+"Recursively include all dependencies (DT_NEEDED) of linked libraries in the executable",
+"Include only DT_NEEDED entries for libraries explicity listed (default)">;
+
 defm cref: B<"cref",
 "Output cross reference table",
 "Do not output cross reference table">;
@@ -495,7 +499,6 @@
 def: F<"long-plt">;
 def: F<"no-add-needed">;
 def: F<"no-allow-shlib-undef

[PATCH] D56650: [lld] [ELF] Support inferring target triple from filename

2019-01-13 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: ruiu, joerg, krytarowski, arichardson.
Herald added subscribers: llvm-commits, emaste.
Herald added a reviewer: espindola.

Support inferring the target triple from linker filename (e.g.
${triple}-ld.lld), and customizing the linker behavior based on it.
If the filename does not match any known target, lld defaults
to the default target configured in LLVM.

// NB: I understand this patch isn't going to be accepted upstream. However, 
since we're probably end up living with it in NetBSD, I'd appreciate any 
suggestions if the code could be improved.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D56650

Files:
  ELF/Config.h
  ELF/Driver.cpp
  ELF/Driver.h
  ELF/Options.td

Index: ELF/Options.td
===
--- ELF/Options.td
+++ ELF/Options.td
@@ -313,6 +313,8 @@
 
 defm sysroot: Eq<"sysroot", "Set the system root">;
 
+defm target: Eq<"target", "Apply configuration defaults for a given target">;
+
 def target1_rel: F<"target1-rel">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_REL32">;
 
 def target1_abs: F<"target1-abs">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_ABS32 (default)">;
Index: ELF/Driver.h
===
--- ELF/Driver.h
+++ ELF/Driver.h
@@ -31,6 +31,7 @@
   void addLibrary(StringRef Name);
 
 private:
+  void setTargetTriple(StringRef argv0, llvm::opt::InputArgList &Args);
   void readConfigs(llvm::opt::InputArgList &Args);
   void createFiles(llvm::opt::InputArgList &Args);
   void inferMachineType();
Index: ELF/Driver.cpp
===
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -54,6 +54,7 @@
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/TarWriter.h"
+#include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -378,6 +379,25 @@
 return;
   }
 
+  if (const char *Path = getReproduceOption(Args)) {
+// Note that --reproduce is a debug option so you can ignore it
+// if you are trying to understand the whole picture of the code.
+Expected> ErrOrWriter =
+TarWriter::create(Path, path::stem(Path));
+if (ErrOrWriter) {
+  Tar = std::move(*ErrOrWriter);
+  Tar->append("response.txt", createResponseFile(Args));
+  Tar->append("version.txt", getLLDVersion() + "\n");
+} else {
+  error("--reproduce: " + toString(ErrOrWriter.takeError()));
+}
+  }
+
+  initLLVM();
+  setTargetTriple(ArgsArr[0], Args);
+  readConfigs(Args);
+  checkZOptions(Args);
+
   // Handle -v or -version.
   //
   // A note about "compatible with GNU linkers" message: this is a hack for
@@ -393,26 +413,11 @@
   // lot of "configure" scripts out there that are generated by old version
   // of Libtool. We cannot convince every software developer to migrate to
   // the latest version and re-generate scripts. So we have this hack.
-  if (Args.hasArg(OPT_v) || Args.hasArg(OPT_version))
+  if (Args.hasArg(OPT_v) || Args.hasArg(OPT_version)) {
 message(getLLDVersion() + " (compatible with GNU linkers)");
-
-  if (const char *Path = getReproduceOption(Args)) {
-// Note that --reproduce is a debug option so you can ignore it
-// if you are trying to understand the whole picture of the code.
-Expected> ErrOrWriter =
-TarWriter::create(Path, path::stem(Path));
-if (ErrOrWriter) {
-  Tar = std::move(*ErrOrWriter);
-  Tar->append("response.txt", createResponseFile(Args));
-  Tar->append("version.txt", getLLDVersion() + "\n");
-} else {
-  error("--reproduce: " + toString(ErrOrWriter.takeError()));
-}
+message("Target: " + Config->TargetTriple.str());
   }
 
-  readConfigs(Args);
-  checkZOptions(Args);
-
   // The behavior of -v or --version is a bit strange, but this is
   // needed for compatibility with GNU linkers.
   if (Args.hasArg(OPT_v) && !Args.hasArg(OPT_INPUT))
@@ -420,7 +425,6 @@
   if (Args.hasArg(OPT_version))
 return;
 
-  initLLVM();
   createFiles(Args);
   if (errorCount())
 return;
@@ -746,6 +750,31 @@
   error(Msg + ": " + StringRef(Err).trim());
 }
 
+void LinkerDriver::setTargetTriple(StringRef argv0, opt::InputArgList &Args) {
+  // Firstly, see if user specified explicit --target
+  StringRef TargetOpt = Args.getLastArgValue(OPT_target);
+  if (!TargetOpt.empty()) {
+// TODO: do we want to verify it and fail on unsupported?
+Config->TargetTriple = llvm::Triple(TargetOpt);
+return;
+  }
+
+  // Secondly, try to get it from program name prefix
+  std::string ProgName = llvm::sys::path::stem(argv0);
+  size_t LastComponent = ProgName.rfind('-');
+  if (LastComponent != std::string::npos) {
+std::string Prefix = ProgName.substr(0, LastComponent);
+std::string IgnoredError;
+if (llvm::TargetRegistry::lookupTarget(Prefix, IgnoredError)) {
+  C

[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-13 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: ELF/Driver.cpp:770
+  // Start with a default initial triple
+  Config->TargetTriple = llvm::Triple(getDefaultTargetTriple());
+

krytarowski wrote:
> krytarowski wrote:
> > arichardson wrote:
> > > arichardson wrote:
> > > > If I invoke an unprefixed ld.lld on NetBSD but want to target a 
> > > > different operating system, this will cause all the NetBSD defaults to 
> > > > apply to that binary and will possibly cause it to crash at runtime.
> > > > 
> > > > I think any config changes based on a triple would need to use an 
> > > > explicit --target= flag instead. As @ruiu says, LLD's behaviour should 
> > > > not change depending on the host OS/default LLVM triple. Given the same 
> > > > input files and command line options the resulting binary should be 
> > > > identical on any host.
> > > There needs to be a way to override the target triple that is not 
> > > creating prefixed a symlink to ld.lld. Otherwise I can't use NetBSD 
> > > ld.lld to build a non-NetBSD target without giving a value for every 
> > > config option that lld supports.
> > > 
> > > I think there should be a command line option to override the triple 
> > > (e.g. --triple= or --target=).
> > > Also how will the default this interact with input files that have the 
> > > OSABI field set? I feel like the options based on the target OSABI should 
> > > be used instead of the default triple.
> > OSABI field is not reliable way to detect OS/ABI. Everybody except FreeBSD 
> > sets UNIX SystemV.
> Actually there is a FreeBSD specific hack to detect emulation name, and it 
> has suffix `fbsd`.. if it is detected it sets FreeBSD OSABI.
> 
> We don't have a chance to use a similar hack for NetBSD in other 
> configuration options.
I've addressed `--target` option in D56650.


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D56215



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


[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-13 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 181484.
mgorny marked 7 inline comments as done.
mgorny set the repository for this revision to rLLD LLVM Linker.
mgorny added a comment.
Herald added a subscriber: fedor.sergeev.

Split target logic into D56650 , switched to 
using target to determine which paths to apply. While at it, copied the code 
from clang since it now can match exactly.


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D56215

Files:
  ELF/Driver.cpp
  ELF/Driver.h


Index: ELF/Driver.h
===
--- ELF/Driver.h
+++ ELF/Driver.h
@@ -33,6 +33,7 @@
 private:
   void setTargetTriple(StringRef argv0, llvm::opt::InputArgList &Args);
   void readConfigs(llvm::opt::InputArgList &Args);
+  void appendDefaultSearchPaths();
   void createFiles(llvm::opt::InputArgList &Args);
   void inferMachineType();
   template  void link(llvm::opt::InputArgList &Args);
Index: ELF/Driver.cpp
===
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -366,6 +366,56 @@
   error("unknown -z value: " + StringRef(Arg->getValue()));
 }
 
+void LinkerDriver::appendDefaultSearchPaths() {
+  if (Config->TargetTriple.isOSNetBSD()) {
+// NetBSD driver relies on the linker knowing the default search paths.
+// Please keep this in sync with clang/lib/Driver/ToolChains/NetBSD.cpp
+// (NetBSD::NetBSD constructor)
+switch (Config->TargetTriple.getArch()) {
+case llvm::Triple::x86:
+  Config->SearchPaths.push_back("=/usr/lib/i386");
+  break;
+case llvm::Triple::arm:
+case llvm::Triple::armeb:
+case llvm::Triple::thumb:
+case llvm::Triple::thumbeb:
+  switch (Config->TargetTriple.getEnvironment()) {
+  case llvm::Triple::EABI:
+  case llvm::Triple::GNUEABI:
+Config->SearchPaths.push_back("=/usr/lib/eabi");
+break;
+  case llvm::Triple::EABIHF:
+  case llvm::Triple::GNUEABIHF:
+Config->SearchPaths.push_back("=/usr/lib/eabihf");
+break;
+  default:
+Config->SearchPaths.push_back("=/usr/lib/oabi");
+break;
+  }
+  break;
+#if 0 // TODO
+case llvm::Triple::mips64:
+case llvm::Triple::mips64el:
+  if (tools::mips::hasMipsAbiArg(Args, "o32"))
+Config->SearchPaths.push_back("=/usr/lib/o32");
+  else if (tools::mips::hasMipsAbiArg(Args, "64"))
+Config->SearchPaths.push_back("=/usr/lib/64");
+  break;
+#endif
+case llvm::Triple::ppc:
+  Config->SearchPaths.push_back("=/usr/lib/powerpc");
+  break;
+case llvm::Triple::sparc:
+  Config->SearchPaths.push_back("=/usr/lib/sparc");
+  break;
+default:
+  break;
+}
+
+Config->SearchPaths.push_back("=/usr/lib");
+  }
+}
+
 void LinkerDriver::main(ArrayRef ArgsArr) {
   ELFOptTable Parser;
   opt::InputArgList Args = Parser.parse(ArgsArr.slice(1));
@@ -397,6 +447,7 @@
   setTargetTriple(ArgsArr[0], Args);
   readConfigs(Args);
   checkZOptions(Args);
+  appendDefaultSearchPaths();
 
   // Handle -v or -version.
   //


Index: ELF/Driver.h
===
--- ELF/Driver.h
+++ ELF/Driver.h
@@ -33,6 +33,7 @@
 private:
   void setTargetTriple(StringRef argv0, llvm::opt::InputArgList &Args);
   void readConfigs(llvm::opt::InputArgList &Args);
+  void appendDefaultSearchPaths();
   void createFiles(llvm::opt::InputArgList &Args);
   void inferMachineType();
   template  void link(llvm::opt::InputArgList &Args);
Index: ELF/Driver.cpp
===
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -366,6 +366,56 @@
   error("unknown -z value: " + StringRef(Arg->getValue()));
 }
 
+void LinkerDriver::appendDefaultSearchPaths() {
+  if (Config->TargetTriple.isOSNetBSD()) {
+// NetBSD driver relies on the linker knowing the default search paths.
+// Please keep this in sync with clang/lib/Driver/ToolChains/NetBSD.cpp
+// (NetBSD::NetBSD constructor)
+switch (Config->TargetTriple.getArch()) {
+case llvm::Triple::x86:
+  Config->SearchPaths.push_back("=/usr/lib/i386");
+  break;
+case llvm::Triple::arm:
+case llvm::Triple::armeb:
+case llvm::Triple::thumb:
+case llvm::Triple::thumbeb:
+  switch (Config->TargetTriple.getEnvironment()) {
+  case llvm::Triple::EABI:
+  case llvm::Triple::GNUEABI:
+Config->SearchPaths.push_back("=/usr/lib/eabi");
+break;
+  case llvm::Triple::EABIHF:
+  case llvm::Triple::GNUEABIHF:
+Config->SearchPaths.push_back("=/usr/lib/eabihf");
+break;
+  default:
+Config->SearchPaths.push_back("=/usr/lib/oabi");
+break;
+  }
+  break;
+#if 0 // TODO
+case llvm::Triple::mips64:
+case llvm::Triple::mips64el:
+  if (tools::mips::hasMipsAbiArg(Args, "o32

[PATCH] D47819: [compiler-rt] [test] Disable sunrpc tests when rpc/xdr.h is missing

2019-01-14 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Ping. I'd really like to merge this before the branch.


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

https://reviews.llvm.org/D47819



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


[PATCH] D56650: [lld] [ELF] Support customizing behavior on target triple

2019-01-14 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 181552.
mgorny retitled this revision from "[lld] [ELF] Support inferring target triple 
from filename" to "[lld] [ELF] Support customizing behavior on target triple".
mgorny edited the summary of this revision.

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

https://reviews.llvm.org/D56650

Files:
  ELF/Config.h
  ELF/Driver.cpp
  ELF/Driver.h
  ELF/Options.td

Index: ELF/Options.td
===
--- ELF/Options.td
+++ ELF/Options.td
@@ -313,6 +313,8 @@
 
 defm sysroot: Eq<"sysroot", "Set the system root">;
 
+defm target: Eq<"target", "Apply configuration defaults for a given target">;
+
 def target1_rel: F<"target1-rel">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_REL32">;
 
 def target1_abs: F<"target1-abs">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_ABS32 (default)">;
Index: ELF/Driver.h
===
--- ELF/Driver.h
+++ ELF/Driver.h
@@ -31,6 +31,7 @@
   void addLibrary(StringRef Name);
 
 private:
+  void setTargetTriple(StringRef argv0, llvm::opt::InputArgList &Args);
   void readConfigs(llvm::opt::InputArgList &Args);
   void createFiles(llvm::opt::InputArgList &Args);
   void inferMachineType();
Index: ELF/Driver.cpp
===
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -54,6 +54,7 @@
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/TarWriter.h"
+#include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -378,6 +379,25 @@
 return;
   }
 
+  if (const char *Path = getReproduceOption(Args)) {
+// Note that --reproduce is a debug option so you can ignore it
+// if you are trying to understand the whole picture of the code.
+Expected> ErrOrWriter =
+TarWriter::create(Path, path::stem(Path));
+if (ErrOrWriter) {
+  Tar = std::move(*ErrOrWriter);
+  Tar->append("response.txt", createResponseFile(Args));
+  Tar->append("version.txt", getLLDVersion() + "\n");
+} else {
+  error("--reproduce: " + toString(ErrOrWriter.takeError()));
+}
+  }
+
+  initLLVM();
+  setTargetTriple(ArgsArr[0], Args);
+  readConfigs(Args);
+  checkZOptions(Args);
+
   // Handle -v or -version.
   //
   // A note about "compatible with GNU linkers" message: this is a hack for
@@ -393,26 +413,11 @@
   // lot of "configure" scripts out there that are generated by old version
   // of Libtool. We cannot convince every software developer to migrate to
   // the latest version and re-generate scripts. So we have this hack.
-  if (Args.hasArg(OPT_v) || Args.hasArg(OPT_version))
+  if (Args.hasArg(OPT_v) || Args.hasArg(OPT_version)) {
 message(getLLDVersion() + " (compatible with GNU linkers)");
-
-  if (const char *Path = getReproduceOption(Args)) {
-// Note that --reproduce is a debug option so you can ignore it
-// if you are trying to understand the whole picture of the code.
-Expected> ErrOrWriter =
-TarWriter::create(Path, path::stem(Path));
-if (ErrOrWriter) {
-  Tar = std::move(*ErrOrWriter);
-  Tar->append("response.txt", createResponseFile(Args));
-  Tar->append("version.txt", getLLDVersion() + "\n");
-} else {
-  error("--reproduce: " + toString(ErrOrWriter.takeError()));
-}
+message("Target: " + Config->TargetTriple.str());
   }
 
-  readConfigs(Args);
-  checkZOptions(Args);
-
   // The behavior of -v or --version is a bit strange, but this is
   // needed for compatibility with GNU linkers.
   if (Args.hasArg(OPT_v) && !Args.hasArg(OPT_INPUT))
@@ -420,7 +425,6 @@
   if (Args.hasArg(OPT_version))
 return;
 
-  initLLVM();
   createFiles(Args);
   if (errorCount())
 return;
@@ -746,6 +750,34 @@
   error(Msg + ": " + StringRef(Err).trim());
 }
 
+void LinkerDriver::setTargetTriple(StringRef argv0, opt::InputArgList &Args) {
+  std::string TargetError;
+
+  // Firstly, see if user specified explicit --target
+  StringRef TargetOpt = Args.getLastArgValue(OPT_target);
+  if (!TargetOpt.empty()) {
+if (llvm::TargetRegistry::lookupTarget(TargetOpt, TargetError))
+  Config->TargetTriple = llvm::Triple(TargetOpt);
+else
+  error("Unsupported --target=" + TargetOpt + ": " + TargetError);
+return;
+  }
+
+  // Secondly, try to get it from program name prefix
+  std::string ProgName = llvm::sys::path::stem(argv0);
+  size_t LastComponent = ProgName.rfind('-');
+  if (LastComponent != std::string::npos) {
+std::string Prefix = ProgName.substr(0, LastComponent);
+if (llvm::TargetRegistry::lookupTarget(Prefix, TargetError)) {
+  Config->TargetTriple = llvm::Triple(Prefix);
+  return;
+}
+  }
+
+  // Finally, use the default target triple
+  Config->TargetTriple = llvm::Triple(getDefaultTargetTriple());
+}
+
 // Initializes Config members by the command line

[PATCH] D56650: [lld] [ELF] Support customizing behavior on target triple

2019-01-14 Thread Michał Górny via Phabricator via cfe-commits
mgorny marked 2 inline comments as done.
mgorny added inline comments.



Comment at: ELF/Driver.cpp:757
+  if (!TargetOpt.empty()) {
+// TODO: do we want to verify it and fail on unsupported?
+Config->TargetTriple = llvm::Triple(TargetOpt);

arichardson wrote:
> I think failing on an unknown triple would be good since it can avoid user 
> error where the wrong defaults are chosen just because of a small typo.
Somewhat done. Note that LLD apparently doesn't fail on errors immediately, so 
it behaves a bit weird.


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

https://reviews.llvm.org/D56650



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


[PATCH] D56650: [lld] [ELF] Support customizing behavior on target triple

2019-01-14 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 181554.
mgorny marked an inline comment as done.
mgorny added a comment.

Fixed leaving triple unset on invalid `--target`.


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

https://reviews.llvm.org/D56650

Files:
  ELF/Config.h
  ELF/Driver.cpp
  ELF/Driver.h
  ELF/Options.td

Index: ELF/Options.td
===
--- ELF/Options.td
+++ ELF/Options.td
@@ -313,6 +313,8 @@
 
 defm sysroot: Eq<"sysroot", "Set the system root">;
 
+defm target: Eq<"target", "Apply configuration defaults for a given target">;
+
 def target1_rel: F<"target1-rel">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_REL32">;
 
 def target1_abs: F<"target1-abs">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_ABS32 (default)">;
Index: ELF/Driver.h
===
--- ELF/Driver.h
+++ ELF/Driver.h
@@ -31,6 +31,7 @@
   void addLibrary(StringRef Name);
 
 private:
+  void setTargetTriple(StringRef argv0, llvm::opt::InputArgList &Args);
   void readConfigs(llvm::opt::InputArgList &Args);
   void createFiles(llvm::opt::InputArgList &Args);
   void inferMachineType();
Index: ELF/Driver.cpp
===
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -54,6 +54,7 @@
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/TarWriter.h"
+#include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -378,6 +379,25 @@
 return;
   }
 
+  if (const char *Path = getReproduceOption(Args)) {
+// Note that --reproduce is a debug option so you can ignore it
+// if you are trying to understand the whole picture of the code.
+Expected> ErrOrWriter =
+TarWriter::create(Path, path::stem(Path));
+if (ErrOrWriter) {
+  Tar = std::move(*ErrOrWriter);
+  Tar->append("response.txt", createResponseFile(Args));
+  Tar->append("version.txt", getLLDVersion() + "\n");
+} else {
+  error("--reproduce: " + toString(ErrOrWriter.takeError()));
+}
+  }
+
+  initLLVM();
+  setTargetTriple(ArgsArr[0], Args);
+  readConfigs(Args);
+  checkZOptions(Args);
+
   // Handle -v or -version.
   //
   // A note about "compatible with GNU linkers" message: this is a hack for
@@ -393,26 +413,11 @@
   // lot of "configure" scripts out there that are generated by old version
   // of Libtool. We cannot convince every software developer to migrate to
   // the latest version and re-generate scripts. So we have this hack.
-  if (Args.hasArg(OPT_v) || Args.hasArg(OPT_version))
+  if (Args.hasArg(OPT_v) || Args.hasArg(OPT_version)) {
 message(getLLDVersion() + " (compatible with GNU linkers)");
-
-  if (const char *Path = getReproduceOption(Args)) {
-// Note that --reproduce is a debug option so you can ignore it
-// if you are trying to understand the whole picture of the code.
-Expected> ErrOrWriter =
-TarWriter::create(Path, path::stem(Path));
-if (ErrOrWriter) {
-  Tar = std::move(*ErrOrWriter);
-  Tar->append("response.txt", createResponseFile(Args));
-  Tar->append("version.txt", getLLDVersion() + "\n");
-} else {
-  error("--reproduce: " + toString(ErrOrWriter.takeError()));
-}
+message("Target: " + Config->TargetTriple.str());
   }
 
-  readConfigs(Args);
-  checkZOptions(Args);
-
   // The behavior of -v or --version is a bit strange, but this is
   // needed for compatibility with GNU linkers.
   if (Args.hasArg(OPT_v) && !Args.hasArg(OPT_INPUT))
@@ -420,7 +425,6 @@
   if (Args.hasArg(OPT_version))
 return;
 
-  initLLVM();
   createFiles(Args);
   if (errorCount())
 return;
@@ -746,6 +750,34 @@
   error(Msg + ": " + StringRef(Err).trim());
 }
 
+void LinkerDriver::setTargetTriple(StringRef argv0, opt::InputArgList &Args) {
+  std::string TargetError;
+
+  // Firstly, see if user specified explicit --target
+  StringRef TargetOpt = Args.getLastArgValue(OPT_target);
+  if (!TargetOpt.empty()) {
+if (llvm::TargetRegistry::lookupTarget(TargetOpt, TargetError)) {
+  Config->TargetTriple = llvm::Triple(TargetOpt);
+  return;
+} else
+  error("Unsupported --target=" + TargetOpt + ": " + TargetError);
+  }
+
+  // Secondly, try to get it from program name prefix
+  std::string ProgName = llvm::sys::path::stem(argv0);
+  size_t LastComponent = ProgName.rfind('-');
+  if (LastComponent != std::string::npos) {
+std::string Prefix = ProgName.substr(0, LastComponent);
+if (llvm::TargetRegistry::lookupTarget(Prefix, TargetError)) {
+  Config->TargetTriple = llvm::Triple(Prefix);
+  return;
+}
+  }
+
+  // Finally, use the default target triple
+  Config->TargetTriple = llvm::Triple(getDefaultTargetTriple());
+}
+
 // Initializes Config members by the command line options.
 void LinkerDriver::readConfigs(opt::InputArgList &Args) {
   errorHand

[PATCH] D47819: [compiler-rt] [test] Disable sunrpc tests when rpc/xdr.h is missing

2019-01-14 Thread Michał Górny via Phabricator via cfe-commits
mgorny marked 2 inline comments as done.
mgorny added a comment.

In D47819#1356347 , @Lekensteyn wrote:

> The direction of this patch looks reasonable to me. Is it worth mentioning 
> the issue (https://github.com/google/sanitizers/issues/974) in the commit 
> message?


Yes, makes sense. I'll add it when committing.

> What environment have you tested this in, could you verify that the tests are 
> indeed skipped on a system without these headers, and passed otherwise?

I have only tests without those headers. I'll try to rebuild glibc with them 
enabled if it's still supported but it'd be preferable if somebody else tested 
it on 'natural' environment.




Comment at: lib/sanitizer_common/CMakeLists.txt:195
+set(SANITIZER_COMMON_DEFINITIONS
+  HAVE_RPC_XDR_H=${HAVE_RPC_XDR_H})
 

Lekensteyn wrote:
> The old code defined HAVE_xxx to 0 or 1, but in general wouldn't it be 
> preferable to define it to 1 if available, and not define it at all if 
> unavailable? This would match most other HAVE_xxx checks.
> 
> In order to make the lit config work in this case, you have to use something 
> like `pythonize_bool(HAVE_RPC_XDR_H)`.
Well, I suppose I could do that but given that the old code did it like this, 
the 0/1 definition seems to be a common practice in compiler-rt, and there is 
no apparent benefit from doing it the other way, I don't think it a good thing 
to do.



Comment at: test/lit.common.configured.in:39
 set_default("android", @ANDROID_PYBOOL@)
+set_default("have_rpc_xdr_h", @HAVE_RPC_XDR_H@)
 config.available_features.add('target-is-%s' % config.target_arch)

Lekensteyn wrote:
> This becomes 0 or 1 instead of True or False, not sure if that will cause 
> issues later.
It shouldn't. 0/1 evaluates the same in boolean context, and other LLVM tests 
are relying on 0/1 being passed to lit already.


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

https://reviews.llvm.org/D47819



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


[PATCH] D47819: [compiler-rt] [test] Disable sunrpc tests when rpc/xdr.h is missing

2019-01-14 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

  PASS: MemorySanitizer-X86_64 :: Linux/sunrpc_bytes.cc (2932 of 6195)
  PASS: MemorySanitizer-X86_64 :: Linux/sunrpc_string.cc (2935 of 6195)
  PASS: MemorySanitizer-X86_64 :: Linux/sunrpc.cc (2974 of 6195)
  PASS: ThreadSanitizer-x86_64 :: sunrpc.cc (5110 of 6195)

So yep, it works. Tested both ways now.


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

https://reviews.llvm.org/D47819



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


[PATCH] D47819: [compiler-rt] [test] Disable sunrpc tests when rpc/xdr.h is missing

2019-01-14 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCRT351109: [test] Disable sunrpc tests when rpc/xdr.h is 
missing (authored by mgorny, committed by ).

Repository:
  rCRT Compiler Runtime

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

https://reviews.llvm.org/D47819

Files:
  cmake/Modules/CompilerRTUtils.cmake
  cmake/base-config-ix.cmake
  lib/sanitizer_common/CMakeLists.txt
  test/lit.common.cfg
  test/lit.common.configured.in
  test/msan/Linux/sunrpc.cc
  test/msan/Linux/sunrpc_bytes.cc
  test/msan/Linux/sunrpc_string.cc
  test/tsan/sunrpc.cc

Index: cmake/base-config-ix.cmake
===
--- cmake/base-config-ix.cmake
+++ cmake/base-config-ix.cmake
@@ -8,6 +8,12 @@
 
 check_include_file(unwind.h HAVE_UNWIND_H)
 
+# Used by sanitizer_common and tests.
+check_include_file(rpc/xdr.h HAVE_RPC_XDR_H)
+if (NOT HAVE_RPC_XDR_H)
+  set(HAVE_RPC_XDR_H 0)
+endif()
+
 # Top level target used to build all compiler-rt libraries.
 add_custom_target(compiler-rt ALL)
 add_custom_target(install-compiler-rt)
Index: cmake/Modules/CompilerRTUtils.cmake
===
--- cmake/Modules/CompilerRTUtils.cmake
+++ cmake/Modules/CompilerRTUtils.cmake
@@ -58,14 +58,6 @@
   endif()
 endmacro()
 
-macro(append_have_file_definition filename varname list)
-  check_include_file("${filename}" "${varname}")
-  if (NOT ${varname})
-set("${varname}" 0)
-  endif()
-  list(APPEND ${list} "${varname}=${${varname}}")
-endmacro()
-
 macro(list_intersect output input1 input2)
   set(${output})
   foreach(it ${${input1}})
Index: test/lit.common.configured.in
===
--- test/lit.common.configured.in
+++ test/lit.common.configured.in
@@ -36,6 +36,7 @@
 set_default("use_lto", config.use_thinlto)
 set_default("use_newpm", False)
 set_default("android", @ANDROID_PYBOOL@)
+set_default("have_rpc_xdr_h", @HAVE_RPC_XDR_H@)
 config.available_features.add('target-is-%s' % config.target_arch)
 
 if config.enable_per_target_runtime_dir:
Index: test/tsan/sunrpc.cc
===
--- test/tsan/sunrpc.cc
+++ test/tsan/sunrpc.cc
@@ -1,3 +1,5 @@
+// REQUIRES: sunrpc
+
 // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
 
 #include 
Index: test/msan/Linux/sunrpc_bytes.cc
===
--- test/msan/Linux/sunrpc_bytes.cc
+++ test/msan/Linux/sunrpc_bytes.cc
@@ -1,3 +1,5 @@
+// REQUIRES: sunrpc
+
 // RUN: %clangxx_msan -g -O0 %s -o %t && \
 // RUN: %run %t 2>&1
 // RUN: %clangxx_msan -g -O0 -DUNINIT=1 %s -o %t && \
Index: test/msan/Linux/sunrpc.cc
===
--- test/msan/Linux/sunrpc.cc
+++ test/msan/Linux/sunrpc.cc
@@ -1,3 +1,5 @@
+// REQUIRES: sunrpc
+
 // RUN: %clangxx_msan -g -O0 -DTYPE=int -DFN=xdr_int %s -o %t && \
 // RUN: %run %t 2>&1
 // RUN: %clangxx_msan -g -O0 -DTYPE=int -DFN=xdr_int -DUNINIT=1 %s -o %t && \
Index: test/msan/Linux/sunrpc_string.cc
===
--- test/msan/Linux/sunrpc_string.cc
+++ test/msan/Linux/sunrpc_string.cc
@@ -1,3 +1,5 @@
+// REQUIRES: sunrpc
+
 // RUN: %clangxx_msan -g -O0 %s -o %t && \
 // RUN: %run %t 2>&1
 // RUN: %clangxx_msan -g -O0 -DUNINIT=1 %s -o %t && \
Index: test/lit.common.cfg
===
--- test/lit.common.cfg
+++ test/lit.common.cfg
@@ -359,6 +359,9 @@
   if config.use_newpm:
 config.lto_flags += ["-fexperimental-new-pass-manager"]
 
+if config.have_rpc_xdr_h:
+  config.available_features.add('sunrpc')
+
 # Ask llvm-config about assertion mode.
 try:
   llvm_config_cmd = subprocess.Popen(
Index: lib/sanitizer_common/CMakeLists.txt
===
--- lib/sanitizer_common/CMakeLists.txt
+++ lib/sanitizer_common/CMakeLists.txt
@@ -192,10 +192,8 @@
 
 include_directories(..)
 
-set(SANITIZER_COMMON_DEFINITIONS)
-
-include(CheckIncludeFile)
-append_have_file_definition(rpc/xdr.h HAVE_RPC_XDR_H SANITIZER_COMMON_DEFINITIONS)
+set(SANITIZER_COMMON_DEFINITIONS
+  HAVE_RPC_XDR_H=${HAVE_RPC_XDR_H})
 
 set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SANITIZER_CFLAGS)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56554: [ELF] Add '-z nognustack' opt to suppress emitting PT_GNU_STACK

2019-01-14 Thread Michał Górny via Phabricator via cfe-commits
mgorny marked 2 inline comments as done.
mgorny added a comment.

@ruiu, what do you think? The current logic forces some precedence, i.e. if you 
pass `-z nognustack`, further `-z {no,}execstack` are ignored. I suppose we 
could just force passing `-z nognustack` as last option clang-wise.


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D56554



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


[PATCH] D56732: [clang] [test] Disable Python binding tests w/ LLVM_ENABLE_PIC=OFF

2019-01-15 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added a reviewer: thakis.

Disable Python binding tests when LLVM_ENABLE_PIC is disabled,
as libclang.so is not being built in that case.  Reported by Nico Weber.

@thakis, could you test it, please?


Repository:
  rC Clang

https://reviews.llvm.org/D56732

Files:
  bindings/python/tests/CMakeLists.txt


Index: bindings/python/tests/CMakeLists.txt
===
--- bindings/python/tests/CMakeLists.txt
+++ bindings/python/tests/CMakeLists.txt
@@ -10,6 +10,11 @@
 set(RUN_PYTHON_TESTS TRUE)
 set_target_properties(check-clang-python PROPERTIES FOLDER "Clang tests")
 
+# Tests require libclang.so which is only built with LLVM_ENABLE_PIC=ON
+if(NOT LLVM_ENABLE_PIC)
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
 # Do not try to run if libclang was built with ASan because
 # the sanitizer library will likely be loaded too late to perform
 # interception and will then fail.


Index: bindings/python/tests/CMakeLists.txt
===
--- bindings/python/tests/CMakeLists.txt
+++ bindings/python/tests/CMakeLists.txt
@@ -10,6 +10,11 @@
 set(RUN_PYTHON_TESTS TRUE)
 set_target_properties(check-clang-python PROPERTIES FOLDER "Clang tests")
 
+# Tests require libclang.so which is only built with LLVM_ENABLE_PIC=ON
+if(NOT LLVM_ENABLE_PIC)
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
 # Do not try to run if libclang was built with ASan because
 # the sanitizer library will likely be loaded too late to perform
 # interception and will then fail.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56732: [clang] [test] Disable Python binding tests w/ LLVM_ENABLE_PIC=OFF

2019-01-16 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC351304: [test] Disable Python binding tests w/ 
LLVM_ENABLE_PIC=OFF (authored by mgorny, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D56732

Files:
  bindings/python/tests/CMakeLists.txt


Index: bindings/python/tests/CMakeLists.txt
===
--- bindings/python/tests/CMakeLists.txt
+++ bindings/python/tests/CMakeLists.txt
@@ -10,6 +10,11 @@
 set(RUN_PYTHON_TESTS TRUE)
 set_target_properties(check-clang-python PROPERTIES FOLDER "Clang tests")
 
+# Tests require libclang.so which is only built with LLVM_ENABLE_PIC=ON
+if(NOT LLVM_ENABLE_PIC)
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
 # Do not try to run if libclang was built with ASan because
 # the sanitizer library will likely be loaded too late to perform
 # interception and will then fail.


Index: bindings/python/tests/CMakeLists.txt
===
--- bindings/python/tests/CMakeLists.txt
+++ bindings/python/tests/CMakeLists.txt
@@ -10,6 +10,11 @@
 set(RUN_PYTHON_TESTS TRUE)
 set_target_properties(check-clang-python PROPERTIES FOLDER "Clang tests")
 
+# Tests require libclang.so which is only built with LLVM_ENABLE_PIC=ON
+if(NOT LLVM_ENABLE_PIC)
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
 # Do not try to run if libclang was built with ASan because
 # the sanitizer library will likely be loaded too late to perform
 # interception and will then fail.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56932: [Driver] [NetBSD] Pass default library search paths to linker

2019-01-18 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: krytarowski, joerg, ruiu, chandlerc, rsmith.

Pass library search paths to linker as -L options, similarly to how
other toolchain drivers do it.  This fixes compatibility with vanilla
LLD.

Bug report: https://bugs.llvm.org/show_bug.cgi?id=33155

// This is simplified version of D33726 


Repository:
  rC Clang

https://reviews.llvm.org/D56932

Files:
  lib/Driver/ToolChains/NetBSD.cpp


Index: lib/Driver/ToolChains/NetBSD.cpp
===
--- lib/Driver/ToolChains/NetBSD.cpp
+++ lib/Driver/ToolChains/NetBSD.cpp
@@ -245,6 +245,7 @@
   }
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
+  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
   Args.AddAllArgs(CmdArgs, options::OPT_e);
   Args.AddAllArgs(CmdArgs, options::OPT_s);


Index: lib/Driver/ToolChains/NetBSD.cpp
===
--- lib/Driver/ToolChains/NetBSD.cpp
+++ lib/Driver/ToolChains/NetBSD.cpp
@@ -245,6 +245,7 @@
   }
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
+  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
   Args.AddAllArgs(CmdArgs, options::OPT_e);
   Args.AddAllArgs(CmdArgs, options::OPT_s);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56976: [clang] [test] Pass -ccc-install-dir in mac compilation db test

2019-01-20 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: krytarowski, sammccall, hokein, ilya-biryukov, rnk.

Pass -ccc-install-dir explicitly as the compilation database code does
not pass argv[0] to getMainExecutable(), while some systems require it
to return the correct path.  Since the relevant code is apparently only
applicable to Darwin, just pass correct -ccc-install-dir to make
the tests pass on *BSD systems.


Repository:
  rC Clang

https://reviews.llvm.org/D56976

Files:
  test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp


Index: test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
===
--- test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
+++ test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
@@ -10,6 +10,8 @@
 //
 // RUN: cp clang-check %t/mock-libcxx/bin/
 // RUN: cp %s %t/test.cpp
-// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- -stdlib=libc++ 
-target x86_64-apple-darwin
+// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- \
+// RUN: -stdlib=libc++ -target x86_64-apple-darwin \
+// RUN: -ccc-install-dir %t/mock-libcxx/bin
 #include 
 vector v;


Index: test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
===
--- test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
+++ test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
@@ -10,6 +10,8 @@
 //
 // RUN: cp clang-check %t/mock-libcxx/bin/
 // RUN: cp %s %t/test.cpp
-// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- -stdlib=libc++ -target x86_64-apple-darwin
+// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- \
+// RUN: -stdlib=libc++ -target x86_64-apple-darwin \
+// RUN: -ccc-install-dir %t/mock-libcxx/bin
 #include 
 vector v;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56976: [clang] [test] Pass -ccc-install-dir in mac compilation db test

2019-01-21 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In D56976#1365001 , @ilya-biryukov 
wrote:

> LGTM to unbreak the tests on *BSD, but could you please leave a comment?
>  It would probably be best to take `argv[0]` into account on *BSD systems as 
> well (possibly only if `clang` could not be found).
>
> At least if that's the behaviour on **all** other systems.


Actually, it works on other systems because they don't use `argv[0]`. The 
problem is in compilation db code using getMainExecutable() in ctor without 
passing the real argv to it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56976



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


[PATCH] D56976: [clang] [test] Pass -ccc-install-dir in mac compilation db test

2019-01-21 Thread Michał Górny via Phabricator via cfe-commits
mgorny marked an inline comment as done.
mgorny added a comment.

In D56976#1365190 , @ilya-biryukov 
wrote:

> Was confused about your comment, so it works on other systems because they 
> don't rely on `argv[0]` to get the path to main executable. Got you.


Exactly.


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

https://reviews.llvm.org/D56976



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


[PATCH] D56976: [clang] [test] Pass -ccc-install-dir in mac compilation db test

2019-01-21 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 182785.
mgorny added a comment.

Added a comment as requested.


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

https://reviews.llvm.org/D56976

Files:
  test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp


Index: test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
===
--- test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
+++ test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
@@ -10,6 +10,11 @@
 //
 // RUN: cp clang-check %t/mock-libcxx/bin/
 // RUN: cp %s %t/test.cpp
-// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- -stdlib=libc++ 
-target x86_64-apple-darwin
+// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- \
+// RUN: -stdlib=libc++ -target x86_64-apple-darwin \
+// RUN: -ccc-install-dir %t/mock-libcxx/bin
+//
+// ^ -ccc-install-dir passed to unbreak tests on *BSD where
+//   getMainExecutable() relies on real argv[0] being passed
 #include 
 vector v;


Index: test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
===
--- test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
+++ test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
@@ -10,6 +10,11 @@
 //
 // RUN: cp clang-check %t/mock-libcxx/bin/
 // RUN: cp %s %t/test.cpp
-// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- -stdlib=libc++ -target x86_64-apple-darwin
+// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- \
+// RUN: -stdlib=libc++ -target x86_64-apple-darwin \
+// RUN: -ccc-install-dir %t/mock-libcxx/bin
+//
+// ^ -ccc-install-dir passed to unbreak tests on *BSD where
+//   getMainExecutable() relies on real argv[0] being passed
 #include 
 vector v;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56976: [clang] [test] Pass -ccc-install-dir in mac compilation db test

2019-01-21 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL351752: [test] Pass -ccc-install-dir in mac compilation db 
test (authored by mgorny, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56976?vs=182785&id=182803#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56976

Files:
  cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp


Index: cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
===
--- cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
+++ cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
@@ -10,6 +10,11 @@
 //
 // RUN: cp clang-check %t/mock-libcxx/bin/
 // RUN: cp %s %t/test.cpp
-// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- -stdlib=libc++ 
-target x86_64-apple-darwin
+// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- \
+// RUN: -stdlib=libc++ -target x86_64-apple-darwin \
+// RUN: -ccc-install-dir %t/mock-libcxx/bin
+//
+// ^ -ccc-install-dir passed to unbreak tests on *BSD where
+//   getMainExecutable() relies on real argv[0] being passed
 #include 
 vector v;


Index: cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
===
--- cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
+++ cfe/trunk/test/Tooling/clang-check-mac-libcxx-fixed-compilation-db.cpp
@@ -10,6 +10,11 @@
 //
 // RUN: cp clang-check %t/mock-libcxx/bin/
 // RUN: cp %s %t/test.cpp
-// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- -stdlib=libc++ -target x86_64-apple-darwin
+// RUN: "%t/mock-libcxx/bin/clang-check" -p %t %t/test.cpp -- \
+// RUN: -stdlib=libc++ -target x86_64-apple-darwin \
+// RUN: -ccc-install-dir %t/mock-libcxx/bin
+//
+// ^ -ccc-install-dir passed to unbreak tests on *BSD where
+//   getMainExecutable() relies on real argv[0] being passed
 #include 
 vector v;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56554: [ELF] Add '-z nognustack' opt to suppress emitting PT_GNU_STACK

2019-01-24 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Just to be clear, are you suggesting that I add `-z gnustack` as well?


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D56554



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


[PATCH] D56554: [ELF] Add '-z nognustack' opt to suppress emitting PT_GNU_STACK

2019-01-24 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In D56554#1369592 , @ruiu wrote:

> No, I'm suggesting you add execstack, noexecstack and nognustack as a 
> tri-state -z flag. Does this sound good?


Do you mean that of those three options, the last one specified should take 
precedence?


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D56554



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


[PATCH] D56932: [Driver] [NetBSD] Pass default library search paths to linker

2019-01-26 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Gentle ping.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56932



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


[PATCH] D56554: [ELF] Add '-z nognustack' opt to suppress emitting PT_GNU_STACK

2019-01-26 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In D56554#1369606 , @mgorny wrote:

> In D56554#1369592 , @ruiu wrote:
>
> > No, I'm suggesting you add execstack, noexecstack and nognustack as a 
> > tri-state -z flag. Does this sound good?
>
>
> Do you mean that of those three options, the last one specified should take 
> precedence?


(and, if yes, could you suggest how to implement it? `getZOption()` doesn't 
seem suitable.


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D56554



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


[PATCH] D56554: [ELF] Add '-z nognustack' opt to suppress emitting PT_GNU_STACK

2019-01-26 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 183729.
mgorny added a comment.

Ok, here's my proposition of using trinary enum.


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

https://reviews.llvm.org/D56554

Files:
  ELF/Config.h
  ELF/Driver.cpp
  ELF/Writer.cpp
  docs/ld.lld.1
  test/ELF/gnustack.s

Index: test/ELF/gnustack.s
===
--- test/ELF/gnustack.s
+++ test/ELF/gnustack.s
@@ -10,6 +10,9 @@
 # RUN: ld.lld %t1 -o %t -z noexecstack
 # RUN: llvm-readobj --program-headers -s %t | FileCheck --check-prefix=RW %s
 
+# RUN: ld.lld %t1 -o %t -z nognustack
+# RUN: llvm-readobj --program-headers -s %t | FileCheck --check-prefix=NOGNUSTACK %s
+
 # RW:  Type: PT_GNU_STACK
 # RW-NEXT: Offset: 0x0
 # RW-NEXT: VirtualAddress: 0x0
@@ -35,5 +38,7 @@
 # RWX-NEXT: ]
 # RWX-NEXT: Alignment: 0
 
+# NOGNUSTACK-NOT: Type: PT_GNU_STACK
+
 .globl _start
 _start:
Index: docs/ld.lld.1
===
--- docs/ld.lld.1
+++ docs/ld.lld.1
@@ -509,6 +509,10 @@
 .Dv DF_1_NOOPEN
 flag to indicate that the object may not be opened by
 .Xr dlopen 3 .
+.It Cm nognustack
+Do not emit the
+.Dv PT_GNU_STACK
+segment.
 .It Cm norelro
 Do not indicate that portions of the object shold be mapped read-only
 after initial relocation processing.
Index: ELF/Writer.cpp
===
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -1976,14 +1976,16 @@
   if (OutputSection *Cmd = findSection(".openbsd.randomdata"))
 AddHdr(PT_OPENBSD_RANDOMIZE, Cmd->getPhdrFlags())->add(Cmd);
 
-  // PT_GNU_STACK is a special section to tell the loader to make the
-  // pages for the stack non-executable. If you really want an executable
-  // stack, you can pass -z execstack, but that's not recommended for
-  // security reasons.
-  unsigned Perm = PF_R | PF_W;
-  if (Config->ZExecstack)
-Perm |= PF_X;
-  AddHdr(PT_GNU_STACK, Perm)->p_memsz = Config->ZStackSize;
+  if (Config->ZGnustack != GnuStackKind::None) {
+// PT_GNU_STACK is a special section to tell the loader to make the
+// pages for the stack non-executable. If you really want an executable
+// stack, you can pass -z execstack, but that's not recommended for
+// security reasons.
+unsigned Perm = PF_R | PF_W;
+if (Config->ZGnustack == GnuStackKind::Exec)
+  Perm |= PF_X;
+AddHdr(PT_GNU_STACK, Perm)->p_memsz = Config->ZStackSize;
+  }
 
   // PT_OPENBSD_WXNEEDED is a OpenBSD-specific header to mark the executable
   // is expected to perform W^X violations, such as calling mprotect(2) or
Index: ELF/Driver.cpp
===
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -345,6 +345,20 @@
   return Default;
 }
 
+static GnuStackKind getZGnuStack(opt::InputArgList &Args) {
+  for (auto *Arg : Args.filtered_reverse(OPT_z)) {
+if (StringRef("execstack") == Arg->getValue())
+  return GnuStackKind::Exec;
+else if (StringRef("noexecstack") == Arg->getValue())
+  return GnuStackKind::NoExec;
+else if (StringRef("nognustack") == Arg->getValue())
+  return GnuStackKind::None;
+  }
+
+  // default
+  return GnuStackKind::NoExec;
+}
+
 static bool isKnownZFlag(StringRef S) {
   return S == "combreloc" || S == "copyreloc" || S == "defs" ||
  S == "execstack" || S == "global" || S == "hazardplt" ||
@@ -352,6 +366,7 @@
  S == "keep-text-section-prefix" || S == "lazy" || S == "muldefs" ||
  S == "nocombreloc" || S == "nocopyreloc" || S == "nodefaultlib" ||
  S == "nodelete" || S == "nodlopen" || S == "noexecstack" ||
+ S == "nognustack" ||
  S == "nokeep-text-section-prefix" || S == "norelro" || S == "notext" ||
  S == "now" || S == "origin" || S == "relro" || S == "retpolineplt" ||
  S == "rodynamic" || S == "text" || S == "wxneeded" ||
@@ -868,8 +883,8 @@
   Args.hasFlag(OPT_warn_symbol_ordering, OPT_no_warn_symbol_ordering, true);
   Config->ZCombreloc = getZFlag(Args, "combreloc", "nocombreloc", true);
   Config->ZCopyreloc = getZFlag(Args, "copyreloc", "nocopyreloc", true);
-  Config->ZExecstack = getZFlag(Args, "execstack", "noexecstack", false);
   Config->ZGlobal = hasZOption(Args, "global");
+  Config->ZGnustack = getZGnuStack(Args);
   Config->ZHazardplt = hasZOption(Args, "hazardplt");
   Config->ZInitfirst = hasZOption(Args, "initfirst");
   Config->ZInterpose = hasZOption(Args, "interpose");
Index: ELF/Config.h
===
--- ELF/Config.h
+++ ELF/Config.h
@@ -61,6 +61,9 @@
 // For tracking ARM Float Argument PCS
 enum class ARMVFPArgKind { Default, Base, VFP, ToolChain };
 
+// For -z *stack
+enum class GnuStackKind { None, Exec, NoExec };
+
 struct SymbolVersion {
   llvm::StringRef Name;
   bool IsExternCpp;
@@ -184,8 +187,8 @@
   bool WriteAddends;
   bool ZCombreloc;
   bool ZCopyreloc;
-  bool ZEx

[PATCH] D57303: [ToolChains] [NetBSD] Append -rpath for shared compiler-rt runtimes

2019-01-27 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: krytarowski, joerg, phosek, dlj.
Herald added a subscriber: dberris.

Append appropriate -rpath when using shared compiler-rt runtimes,
e.g. '-fsanitize=address -shared-libasan'.  There's already a similar
logic in CommonArgs.cpp but it uses non-standard arch-suffixed
installation directory while we want our driver to work with standard
installation paths.


Repository:
  rC Clang

https://reviews.llvm.org/D57303

Files:
  lib/Driver/ToolChains/NetBSD.cpp


Index: lib/Driver/ToolChains/NetBSD.cpp
===
--- lib/Driver/ToolChains/NetBSD.cpp
+++ lib/Driver/ToolChains/NetBSD.cpp
@@ -255,6 +255,13 @@
   bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
 
+  const SanitizerArgs &SanArgs = ToolChain.getSanitizerArgs();
+  if (SanArgs.needsSharedRt()) {
+CmdArgs.push_back("-rpath");
+CmdArgs.push_back(Args.MakeArgString(
+ToolChain.getCompilerRTPath().c_str()));
+  }
+
   unsigned Major, Minor, Micro;
   ToolChain.getTriple().getOSVersion(Major, Minor, Micro);
   bool useLibgcc = true;


Index: lib/Driver/ToolChains/NetBSD.cpp
===
--- lib/Driver/ToolChains/NetBSD.cpp
+++ lib/Driver/ToolChains/NetBSD.cpp
@@ -255,6 +255,13 @@
   bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
 
+  const SanitizerArgs &SanArgs = ToolChain.getSanitizerArgs();
+  if (SanArgs.needsSharedRt()) {
+CmdArgs.push_back("-rpath");
+CmdArgs.push_back(Args.MakeArgString(
+ToolChain.getCompilerRTPath().c_str()));
+  }
+
   unsigned Major, Minor, Micro;
   ToolChain.getTriple().getOSVersion(Major, Minor, Micro);
   bool useLibgcc = true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   5   6   7   8   9   >