Re: [clang-tools-extra] r291446 - [include-fixer] Load symbol index asynchronously.
Committed r291892. Should also resolve the bogus MSVC warnings. On Fri, Jan 13, 2017 at 12:00 AM, Bill Seurer via cfe-commits wrote: > On 01/10/2017 01:53 PM, Benjamin Kramer wrote: >> >> I didn't manage to reproduce this. Does adding ${PTHREAD_LIB} to >> LINK_LIBS of tools/clang/tools/extra/include-fixer/plugin/CMakeLists.txt >> help? > > > That does seem to make it work. > > >> On Tue, Jan 10, 2017 at 8:31 PM, Bill Seurer >> wrote: >>> >>> On 01/09/2017 09:18 AM, Benjamin Kramer via cfe-commits wrote: Author: d0k Date: Mon Jan 9 09:18:28 2017 New Revision: 291446 URL: http://llvm.org/viewvc/llvm-project?rev=291446&view=rev Log: [include-fixer] Load symbol index asynchronously. We don't actually need the index until parse time, so fetch it in the background and start parsing. By the time it is actually needed it's likely that the loading phase has completed in the background. >>> >>> >>> >>> This update causes a linker error on ppc64le on a Release+Asserts+Shared >>> build. >>> >>> cmake with -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON >>> -DBUILD_SHARED_LIBS=ON >>> >>> >>> http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/754 >>> >>> >>> Details: >>> >>> [117/123] Linking CXX shared library >>> lib/libclangIncludeFixerPlugin.so.40.0svn >>> FAILED: : && /home/seurer/gcc/install/gcc-5.4.0/bin/g++ -fPIC -fPIC >>> -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter >>> -Wwrite-strings >>> -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long >>> -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment >>> -Werror=date-time -std=c++11 -ffunction-sections -fdata-sections >>> -fno-common >>> -Woverloaded-virtual -fno-strict-aliasing -O3 >>> -L/home/seurer/gcc/install/gcc-5.4.0/lib64 -Wl,-z,defs >>> -Wl,-rpath-link,/home/seurer/llvm/build/llvm-test2/./lib -Wl,-O3 >>> -Wl,--gc-sections -shared -Wl,-soname,libclangIncludeFixerPlugin.so.40 -o >>> lib/libclangIncludeFixerPlugin.so.40.0svn >>> >>> tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o >>> lib/libclangAST.so.40.0svn lib/libclangBasic.so.40.0svn >>> lib/libclangFrontend.so.40.0svn lib/libclangIncludeFixer.so.40.0svn >>> lib/libclangParse.so.40.0svn lib/libclangSema.so.40.0svn >>> lib/libclangTooling.so.40.0svn lib/libLLVMSupport.so.40.0svn >>> -Wl,-rpath,"\$ORIGIN/../lib" && : >>> >>> tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o:(.toc+0xb0): >>> undefined reference to `pthread_create' >>> collect2: error: ld returned 1 exit status >>> [117/123] Building CXX object >>> >>> tools/clang/tools/extra/include-fixer/tool/CMakeFiles/clang-include-fixer.dir/ClangIncludeFixer.cpp.o >>> ninja: build stopped: subcommand failed. >>> [1/7] Linking CXX shared library >>> lib/libclangIncludeFixerPlugin.so.40.0svn >>> FAILED: : && /home/seurer/gcc/install/gcc-5.4.0/bin/g++ -fPIC -fPIC >>> -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter >>> -Wwrite-strings >>> -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long >>> -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment >>> -Werror=date-time -std=c++11 -ffunction-sections -fdata-sections >>> -fno-common >>> -Woverloaded-virtual -fno-strict-aliasing -O3 >>> -L/home/seurer/gcc/install/gcc-5.4.0/lib64 -Wl,-z,defs >>> -Wl,-rpath-link,/home/seurer/llvm/build/llvm-test2/./lib -Wl,-O3 >>> -Wl,--gc-sections -shared -Wl,-soname,libclangIncludeFixerPlugin.so.40 -o >>> lib/libclangIncludeFixerPlugin.so.40.0svn >>> >>> tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o >>> lib/libclangAST.so.40.0svn lib/libclangBasic.so.40.0svn >>> lib/libclangFrontend.so.40.0svn lib/libclangIncludeFixer.so.40.0svn >>> lib/libclangParse.so.40.0svn lib/libclangSema.so.40.0svn >>> lib/libclangTooling.so.40.0svn lib/libLLVMSupport.so.40.0svn >>> -Wl,-rpath,"\$ORIGIN/../lib" && : >>> >>> tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o:(.toc+0xb0): >>> undefined reference to `pthread_create' >>> collect2: error: ld returned 1 exit status >>> >>> >>> >>> >>> Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h clang-tools-extra/trunk/include-fixer/plugin/IncludeFixerPlugin.cpp clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp?rev=291446&r1=291445&r2=291446&view=diff =
Re: [clang-tools-extra] r291446 - [include-fixer] Load symbol index asynchronously.
On 01/10/2017 01:53 PM, Benjamin Kramer wrote: I didn't manage to reproduce this. Does adding ${PTHREAD_LIB} to LINK_LIBS of tools/clang/tools/extra/include-fixer/plugin/CMakeLists.txt help? That does seem to make it work. On Tue, Jan 10, 2017 at 8:31 PM, Bill Seurer wrote: On 01/09/2017 09:18 AM, Benjamin Kramer via cfe-commits wrote: Author: d0k Date: Mon Jan 9 09:18:28 2017 New Revision: 291446 URL: http://llvm.org/viewvc/llvm-project?rev=291446&view=rev Log: [include-fixer] Load symbol index asynchronously. We don't actually need the index until parse time, so fetch it in the background and start parsing. By the time it is actually needed it's likely that the loading phase has completed in the background. This update causes a linker error on ppc64le on a Release+Asserts+Shared build. cmake with -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DBUILD_SHARED_LIBS=ON http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/754 Details: [117/123] Linking CXX shared library lib/libclangIncludeFixerPlugin.so.40.0svn FAILED: : && /home/seurer/gcc/install/gcc-5.4.0/bin/g++ -fPIC -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -Werror=date-time -std=c++11 -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3 -L/home/seurer/gcc/install/gcc-5.4.0/lib64 -Wl,-z,defs -Wl,-rpath-link,/home/seurer/llvm/build/llvm-test2/./lib -Wl,-O3 -Wl,--gc-sections -shared -Wl,-soname,libclangIncludeFixerPlugin.so.40 -o lib/libclangIncludeFixerPlugin.so.40.0svn tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o lib/libclangAST.so.40.0svn lib/libclangBasic.so.40.0svn lib/libclangFrontend.so.40.0svn lib/libclangIncludeFixer.so.40.0svn lib/libclangParse.so.40.0svn lib/libclangSema.so.40.0svn lib/libclangTooling.so.40.0svn lib/libLLVMSupport.so.40.0svn -Wl,-rpath,"\$ORIGIN/../lib" && : tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o:(.toc+0xb0): undefined reference to `pthread_create' collect2: error: ld returned 1 exit status [117/123] Building CXX object tools/clang/tools/extra/include-fixer/tool/CMakeFiles/clang-include-fixer.dir/ClangIncludeFixer.cpp.o ninja: build stopped: subcommand failed. [1/7] Linking CXX shared library lib/libclangIncludeFixerPlugin.so.40.0svn FAILED: : && /home/seurer/gcc/install/gcc-5.4.0/bin/g++ -fPIC -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -Werror=date-time -std=c++11 -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3 -L/home/seurer/gcc/install/gcc-5.4.0/lib64 -Wl,-z,defs -Wl,-rpath-link,/home/seurer/llvm/build/llvm-test2/./lib -Wl,-O3 -Wl,--gc-sections -shared -Wl,-soname,libclangIncludeFixerPlugin.so.40 -o lib/libclangIncludeFixerPlugin.so.40.0svn tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o lib/libclangAST.so.40.0svn lib/libclangBasic.so.40.0svn lib/libclangFrontend.so.40.0svn lib/libclangIncludeFixer.so.40.0svn lib/libclangParse.so.40.0svn lib/libclangSema.so.40.0svn lib/libclangTooling.so.40.0svn lib/libLLVMSupport.so.40.0svn -Wl,-rpath,"\$ORIGIN/../lib" && : tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o:(.toc+0xb0): undefined reference to `pthread_create' collect2: error: ld returned 1 exit status Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h clang-tools-extra/trunk/include-fixer/plugin/IncludeFixerPlugin.cpp clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp?rev=291446&r1=291445&r2=291446&view=diff == --- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp (original) +++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp Mon Jan 9 09:18:28 2017 @@ -64,7 +64,7 @@ SymbolIndexManager::search(llvm::StringR do { std::vector Symbols; for (const auto &DB : SymbolIndices) { - auto Res = DB->search(Names.back().str()); + auto Res = DB.get()->search(Names.back()); Symbols.insert(Symbols.end(), Res.begin(), Res.end()); } Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h URL: http://llvm.org/viewvc/l
Re: [clang-tools-extra] r291446 - [include-fixer] Load symbol index asynchronously.
Hello Benjamin, It looks like this commit added warnings to the builder: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/3596 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\ppltasks.h(1531): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\ppltasks.h(1531): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\ppltasks.h(1531): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\ppltasks.h(1531): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\ppltasks.h(1531): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc Please have a look at this? Thanks Galina On Mon, Jan 9, 2017 at 7:18 AM, Benjamin Kramer via cfe-commits < cfe-commits@lists.llvm.org> wrote: > Author: d0k > Date: Mon Jan 9 09:18:28 2017 > New Revision: 291446 > > URL: http://llvm.org/viewvc/llvm-project?rev=291446&view=rev > Log: > [include-fixer] Load symbol index asynchronously. > > We don't actually need the index until parse time, so fetch it in the > background and start parsing. By the time it is actually needed it's > likely that the loading phase has completed in the background. > > Modified: > clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp > clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h > clang-tools-extra/trunk/include-fixer/plugin/IncludeFixerPlugin.cpp > clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp > clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp > > Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/ > trunk/include-fixer/SymbolIndexManager.cpp?rev=291446&r1=291445&r2=291446& > view=diff > > == > --- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp > (original) > +++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp Mon Jan > 9 09:18:28 2017 > @@ -64,7 +64,7 @@ SymbolIndexManager::search(llvm::StringR >do { > std::vector Symbols; > for (const auto &DB : SymbolIndices) { > - auto Res = DB->search(Names.back().str()); > + auto Res = DB.get()->search(Names.back()); >Symbols.insert(Symbols.end(), Res.begin(), Res.end()); > } > > > Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/ > trunk/include-fixer/SymbolIndexManager.h?rev=291446&r1=291445&r2=291446& > view=diff > > == > --- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h (original) > +++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h Mon Jan 9 > 09:18:28 2017 > @@ -13,6 +13,7 @@ > #include "SymbolIndex.h" > #include "find-all-symbols/SymbolInfo.h" > #include "llvm/ADT/StringRef.h" > +#include > > namespace clang { > namespace include_fixer { > @@ -21,8 +22,8 @@ namespace include_fixer { > /// to an indentifier in the source code from multiple symbol databases. > class SymbolIndexManager { > public: > - void addSymbolIndex(std::unique_ptr DB) { > -SymbolIndices.push_back(std::move(DB)); > + void addSymbolIndex(std::function()> F) { > +SymbolIndices.push_back(std::async(std::launch::async, F)); >} > >/// Search for header files to be included for an identifier. > @@ -39,7 +40,7 @@ public: >search(llvm::StringRef Identifier, bool IsNestedSearch = true) const; > > private: > - std::vector> SymbolIndices; > + std::vector>> > SymbolIndices; > }; > > } // namespace include_fixer > > Modified: clang-tools-extra/trunk/include-fixer/plugin/ > IncludeFixerPlugin.cpp > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/ > trunk/include-fixer/plugin/IncludeFixerPlugin.cpp?rev= > 291446&r1=291445&r2=291446&view=diff > > == > --- clang-tools-extra/trunk/include-fixer/plugin/IncludeFixerPlugin.cpp > (original) > +++ clang-tools-extra/trunk/include-fixer/plugin/IncludeFixerPlugin.cpp > Mon Jan 9 09:18:28 2017 > @@ -61,23 +61,26 @@ public: > Input = Arg.substr(strlen("-input=")); > } > > -llvm::ErrorOr> > SymbolIdx( > -nullptr); > -if (DB == "yaml") { > - if (!Input.empty()) { > -SymbolIdx = include_fixer::YamlSymbolIndex:: > createFromFile(Input); > - } else { > -// If we don't have any input file, look in the direct
Re: [clang-tools-extra] r291446 - [include-fixer] Load symbol index asynchronously.
I didn't manage to reproduce this. Does adding ${PTHREAD_LIB} to LINK_LIBS of tools/clang/tools/extra/include-fixer/plugin/CMakeLists.txt help? On Tue, Jan 10, 2017 at 8:31 PM, Bill Seurer wrote: > On 01/09/2017 09:18 AM, Benjamin Kramer via cfe-commits wrote: >> >> Author: d0k >> Date: Mon Jan 9 09:18:28 2017 >> New Revision: 291446 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=291446&view=rev >> Log: >> [include-fixer] Load symbol index asynchronously. >> >> We don't actually need the index until parse time, so fetch it in the >> background and start parsing. By the time it is actually needed it's >> likely that the loading phase has completed in the background. > > > This update causes a linker error on ppc64le on a Release+Asserts+Shared > build. > > cmake with -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON > -DBUILD_SHARED_LIBS=ON > > http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/754 > > > Details: > > [117/123] Linking CXX shared library > lib/libclangIncludeFixerPlugin.so.40.0svn > FAILED: : && /home/seurer/gcc/install/gcc-5.4.0/bin/g++ -fPIC -fPIC > -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings > -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long > -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment > -Werror=date-time -std=c++11 -ffunction-sections -fdata-sections -fno-common > -Woverloaded-virtual -fno-strict-aliasing -O3 > -L/home/seurer/gcc/install/gcc-5.4.0/lib64 -Wl,-z,defs > -Wl,-rpath-link,/home/seurer/llvm/build/llvm-test2/./lib -Wl,-O3 > -Wl,--gc-sections -shared -Wl,-soname,libclangIncludeFixerPlugin.so.40 -o > lib/libclangIncludeFixerPlugin.so.40.0svn > tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o > lib/libclangAST.so.40.0svn lib/libclangBasic.so.40.0svn > lib/libclangFrontend.so.40.0svn lib/libclangIncludeFixer.so.40.0svn > lib/libclangParse.so.40.0svn lib/libclangSema.so.40.0svn > lib/libclangTooling.so.40.0svn lib/libLLVMSupport.so.40.0svn > -Wl,-rpath,"\$ORIGIN/../lib" && : > tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o:(.toc+0xb0): > undefined reference to `pthread_create' > collect2: error: ld returned 1 exit status > [117/123] Building CXX object > tools/clang/tools/extra/include-fixer/tool/CMakeFiles/clang-include-fixer.dir/ClangIncludeFixer.cpp.o > ninja: build stopped: subcommand failed. > [1/7] Linking CXX shared library lib/libclangIncludeFixerPlugin.so.40.0svn > FAILED: : && /home/seurer/gcc/install/gcc-5.4.0/bin/g++ -fPIC -fPIC > -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings > -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long > -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment > -Werror=date-time -std=c++11 -ffunction-sections -fdata-sections -fno-common > -Woverloaded-virtual -fno-strict-aliasing -O3 > -L/home/seurer/gcc/install/gcc-5.4.0/lib64 -Wl,-z,defs > -Wl,-rpath-link,/home/seurer/llvm/build/llvm-test2/./lib -Wl,-O3 > -Wl,--gc-sections -shared -Wl,-soname,libclangIncludeFixerPlugin.so.40 -o > lib/libclangIncludeFixerPlugin.so.40.0svn > tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o > lib/libclangAST.so.40.0svn lib/libclangBasic.so.40.0svn > lib/libclangFrontend.so.40.0svn lib/libclangIncludeFixer.so.40.0svn > lib/libclangParse.so.40.0svn lib/libclangSema.so.40.0svn > lib/libclangTooling.so.40.0svn lib/libLLVMSupport.so.40.0svn > -Wl,-rpath,"\$ORIGIN/../lib" && : > tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o:(.toc+0xb0): > undefined reference to `pthread_create' > collect2: error: ld returned 1 exit status > > > > > >> Modified: >> clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp >> clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h >> clang-tools-extra/trunk/include-fixer/plugin/IncludeFixerPlugin.cpp >> clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp >> clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp >> >> Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp?rev=291446&r1=291445&r2=291446&view=diff >> >> == >> --- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp >> (original) >> +++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp Mon Jan >> 9 09:18:28 2017 >> @@ -64,7 +64,7 @@ SymbolIndexManager::search(llvm::StringR >>do { >> std::vector Symbols; >> for (const auto &DB : SymbolIndices) { >> - auto Res = DB->search(Names.back().str()); >> + auto Res = DB.get()->search(Names.back()); >>Symbols.insert(Symbols.end(), Res.be
Re: [clang-tools-extra] r291446 - [include-fixer] Load symbol index asynchronously.
On 01/09/2017 09:18 AM, Benjamin Kramer via cfe-commits wrote: Author: d0k Date: Mon Jan 9 09:18:28 2017 New Revision: 291446 URL: http://llvm.org/viewvc/llvm-project?rev=291446&view=rev Log: [include-fixer] Load symbol index asynchronously. We don't actually need the index until parse time, so fetch it in the background and start parsing. By the time it is actually needed it's likely that the loading phase has completed in the background. This update causes a linker error on ppc64le on a Release+Asserts+Shared build. cmake with -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DBUILD_SHARED_LIBS=ON http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/754 Details: [117/123] Linking CXX shared library lib/libclangIncludeFixerPlugin.so.40.0svn FAILED: : && /home/seurer/gcc/install/gcc-5.4.0/bin/g++ -fPIC -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -Werror=date-time -std=c++11 -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3 -L/home/seurer/gcc/install/gcc-5.4.0/lib64 -Wl,-z,defs -Wl,-rpath-link,/home/seurer/llvm/build/llvm-test2/./lib -Wl,-O3 -Wl,--gc-sections -shared -Wl,-soname,libclangIncludeFixerPlugin.so.40 -o lib/libclangIncludeFixerPlugin.so.40.0svn tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o lib/libclangAST.so.40.0svn lib/libclangBasic.so.40.0svn lib/libclangFrontend.so.40.0svn lib/libclangIncludeFixer.so.40.0svn lib/libclangParse.so.40.0svn lib/libclangSema.so.40.0svn lib/libclangTooling.so.40.0svn lib/libLLVMSupport.so.40.0svn -Wl,-rpath,"\$ORIGIN/../lib" && : tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o:(.toc+0xb0): undefined reference to `pthread_create' collect2: error: ld returned 1 exit status [117/123] Building CXX object tools/clang/tools/extra/include-fixer/tool/CMakeFiles/clang-include-fixer.dir/ClangIncludeFixer.cpp.o ninja: build stopped: subcommand failed. [1/7] Linking CXX shared library lib/libclangIncludeFixerPlugin.so.40.0svn FAILED: : && /home/seurer/gcc/install/gcc-5.4.0/bin/g++ -fPIC -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -Werror=date-time -std=c++11 -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3 -L/home/seurer/gcc/install/gcc-5.4.0/lib64 -Wl,-z,defs -Wl,-rpath-link,/home/seurer/llvm/build/llvm-test2/./lib -Wl,-O3 -Wl,--gc-sections -shared -Wl,-soname,libclangIncludeFixerPlugin.so.40 -o lib/libclangIncludeFixerPlugin.so.40.0svn tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o lib/libclangAST.so.40.0svn lib/libclangBasic.so.40.0svn lib/libclangFrontend.so.40.0svn lib/libclangIncludeFixer.so.40.0svn lib/libclangParse.so.40.0svn lib/libclangSema.so.40.0svn lib/libclangTooling.so.40.0svn lib/libLLVMSupport.so.40.0svn -Wl,-rpath,"\$ORIGIN/../lib" && : tools/clang/tools/extra/include-fixer/plugin/CMakeFiles/clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o:(.toc+0xb0): undefined reference to `pthread_create' collect2: error: ld returned 1 exit status Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h clang-tools-extra/trunk/include-fixer/plugin/IncludeFixerPlugin.cpp clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp?rev=291446&r1=291445&r2=291446&view=diff == --- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp (original) +++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp Mon Jan 9 09:18:28 2017 @@ -64,7 +64,7 @@ SymbolIndexManager::search(llvm::StringR do { std::vector Symbols; for (const auto &DB : SymbolIndices) { - auto Res = DB->search(Names.back().str()); + auto Res = DB.get()->search(Names.back()); Symbols.insert(Symbols.end(), Res.begin(), Res.end()); } Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h?rev=291446&r1=291445&r2=291446&view=diff == --- clang-tools-extra/trunk/include-fixer/Symb
[clang-tools-extra] r291446 - [include-fixer] Load symbol index asynchronously.
Author: d0k Date: Mon Jan 9 09:18:28 2017 New Revision: 291446 URL: http://llvm.org/viewvc/llvm-project?rev=291446&view=rev Log: [include-fixer] Load symbol index asynchronously. We don't actually need the index until parse time, so fetch it in the background and start parsing. By the time it is actually needed it's likely that the loading phase has completed in the background. Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h clang-tools-extra/trunk/include-fixer/plugin/IncludeFixerPlugin.cpp clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp?rev=291446&r1=291445&r2=291446&view=diff == --- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp (original) +++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp Mon Jan 9 09:18:28 2017 @@ -64,7 +64,7 @@ SymbolIndexManager::search(llvm::StringR do { std::vector Symbols; for (const auto &DB : SymbolIndices) { - auto Res = DB->search(Names.back().str()); + auto Res = DB.get()->search(Names.back()); Symbols.insert(Symbols.end(), Res.begin(), Res.end()); } Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h?rev=291446&r1=291445&r2=291446&view=diff == --- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h (original) +++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h Mon Jan 9 09:18:28 2017 @@ -13,6 +13,7 @@ #include "SymbolIndex.h" #include "find-all-symbols/SymbolInfo.h" #include "llvm/ADT/StringRef.h" +#include namespace clang { namespace include_fixer { @@ -21,8 +22,8 @@ namespace include_fixer { /// to an indentifier in the source code from multiple symbol databases. class SymbolIndexManager { public: - void addSymbolIndex(std::unique_ptr DB) { -SymbolIndices.push_back(std::move(DB)); + void addSymbolIndex(std::function()> F) { +SymbolIndices.push_back(std::async(std::launch::async, F)); } /// Search for header files to be included for an identifier. @@ -39,7 +40,7 @@ public: search(llvm::StringRef Identifier, bool IsNestedSearch = true) const; private: - std::vector> SymbolIndices; + std::vector>> SymbolIndices; }; } // namespace include_fixer Modified: clang-tools-extra/trunk/include-fixer/plugin/IncludeFixerPlugin.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/plugin/IncludeFixerPlugin.cpp?rev=291446&r1=291445&r2=291446&view=diff == --- clang-tools-extra/trunk/include-fixer/plugin/IncludeFixerPlugin.cpp (original) +++ clang-tools-extra/trunk/include-fixer/plugin/IncludeFixerPlugin.cpp Mon Jan 9 09:18:28 2017 @@ -61,23 +61,26 @@ public: Input = Arg.substr(strlen("-input=")); } -llvm::ErrorOr> SymbolIdx( -nullptr); -if (DB == "yaml") { - if (!Input.empty()) { -SymbolIdx = include_fixer::YamlSymbolIndex::createFromFile(Input); - } else { -// If we don't have any input file, look in the directory of the first -// file and its parents. -const FrontendOptions &FO = CI.getFrontendOpts(); -SmallString<128> AbsolutePath( -tooling::getAbsolutePath(FO.Inputs[0].getFile())); -StringRef Directory = llvm::sys::path::parent_path(AbsolutePath); -SymbolIdx = include_fixer::YamlSymbolIndex::createFromDirectory( -Directory, "find_all_symbols_db.yaml"); +std::string InputFile = CI.getFrontendOpts().Inputs[0].getFile(); +auto CreateYamlIdx = [=]() -> std::unique_ptr { + llvm::ErrorOr> SymbolIdx( + nullptr); + if (DB == "yaml") { +if (!Input.empty()) { + SymbolIdx = include_fixer::YamlSymbolIndex::createFromFile(Input); +} else { + // If we don't have any input file, look in the directory of the first + // file and its parents. + SmallString<128> AbsolutePath(tooling::getAbsolutePath(InputFile)); + StringRef Directory = llvm::sys::path::parent_path(AbsolutePath); + SymbolIdx = include_fixer::YamlSymbolIndex::createFromDirectory( + Directory, "find_all_symbols_db.yaml"); +} } -} -SymbolIndexMgr->addSymbolIndex(std::move(*SymbolIdx)); + return std::move(*SymbolIdx); +}; + +SymbolIndexMgr->addSymbolIndex(std::move(CreateYamlIdx)); return true; } Modified: c