Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fatal error: too many errors emitted, stopping now #313

Open
jensen82 opened this issue Aug 27, 2024 · 13 comments
Open

fatal error: too many errors emitted, stopping now #313

jensen82 opened this issue Aug 27, 2024 · 13 comments

Comments

@jensen82
Copy link

jensen82 commented Aug 27, 2024

I'm trying to generate a class diagram of my project and got the error in the caption. This is the uml-file

diagrams: class_diagram: type: class title: Basic class diagram example include: paths: ['lib/systemlink/include'] comment_parser: clang plantuml: after: - '{% set e=element("A") %} note left of {{ e.alias }} : {{ trim(e.comment.brief.0) }}' - '{% set e=element("clanguml::t00002::B") %} note top of {{ e.alias }} : {{ trim(e.comment.brief.0) }}' - | note right of {{ alias("D") }} {{ comment("D").text }} end note mermaid: after: - '{% set e=element("A") %} note for {{ e.alias }} "{{ trim(e.comment.brief.0) }}"' - '{% set e=element("clanguml::t00002::B") %} note for {{ e.alias }} "{{ trim(e.comment.brief.0) }}"' - 'note for {{ alias("D") }} "{{ comment("D").text }}"'

My compilation database looks like this:

{ "directory": "C:/dev/projects/myclientLib/myclientLib/source/build/lib/systemlink", "command": "C:\\msys64\\ucrt64\\bin\\g++.exe -DFILELOG -DLOG_ENABLED -IC:\\dev\\projects\\myclientLib\\myclientLib\\source\\lib\\myclientLiblib\\myclientLib.modules.3rdparty.plog\\1.1.10.69\\build\\native\\include -IC:\\dev\\projects\\myclientLib\\myclientLib\\source\\lib\\myclientLiblib\\myclientLib.modules.3rdparty.boost.headers\\1.85.0.124\\build\\native\\include -IC:\\dev\\projects\\myclientLib\\myclientLib\\source\\lib\\myclientLiblib\\modules.cpp.myclientLib.TransportLayer.Client.debug-windows-10-x86_64-gnu.13\\1.3.0\\build\\native\\include -IC:\\dev\\projects\\myclientLib\\myclientLib\\source\\lib\\myclientLiblib\\modules.cpp.googletest.debug-windows-10-x86_64-gnu.13\\1.14.0\\build\\native\\include -IC:\\dev\\projects\\myclientLib\\myclientLib\\source\\lib\\systemlink\\include -IC:\\dev\\projects\\myclientLib\\myclientLib\\source\\build\\lib\\systemlink -Wall -Wno-unused-parameter -pedantic --std=c++11 -fPIC -frtti -g3 -O0 -DDEBUG -std=c++11 -o CMakeFiles\\myclientLibstatic.dir\\src\\ApsThreatAlertData.cpp.obj -c C:\\dev\\projects\\myclientLib\\myclientLib\\source\\lib\\systemlink\\src\\ApsThreatAlertData.cpp", "file": "C:/dev/projects/myclientLib/myclientLib/source/lib/systemlink/src/ApsThreatAlertData.cpp", "output": "lib/systemlink/CMakeFiles/myclientLibstatic.dir/src/ApsThreatAlertData.cpp.obj" }, { "directory": "C:/dev/projects/myclientLib/myclientLib/source/build/lib/systemlink", "command": "C:\\msys64\\ucrt64\\bin\\g++.exe -DFILELOG -DLOG_ENABLED -IC:\\dev\\projects\\myclientLib\\myclientLib\\source\\lib\\myclientLiblib\\myclientLib.modules.3rdparty.plog\\1.1.10.69\\build\\native\\include -IC:\\dev\\projects\\myclientLib\\myclientLib\\source\\lib\\myclientLiblib\\myclientLib.modules.3rdparty.boost.headers\\1.85.0.124\\build\\native\\include -IC:\\dev\\projects\\myclientLib\\myclientLib\\source\\lib\\myclientLiblib\\modules.cpp.myclientLib.TransportLayer.Client.debug-windows-10-x86_64-gnu.13\\1.3.0\\build\\native\\include -IC:\\dev\\projects\\myclientLib\\myclientLib\\source\\lib\\myclientLiblib\\modules.cpp.googletest.debug-windows-10-x86_64-gnu.13\\1.14.0\\build\\native\\include -IC:\\dev\\projects\\myclientLib\\myclientLib\\source\\lib\\systemlink\\include -IC:\\dev\\projects\\myclientLib\\myclientLib\\source\\build\\lib\\systemlink -Wall -Wno-unused-parameter -pedantic --std=c++11 -fPIC -frtti -g3 -O0 -DDEBUG -std=c++11 -o CMakeFiles\\myclientLibstatic.dir\\src\\IDataManagementFeature.cpp.obj -c C:\\dev\\projects\\myclientLib\\myclientLib\\source\\lib\\systemlink\\src\\IDataManagementFeature.cpp", "file": "C:/dev/projects/myclientLib/myclientLib/source/lib/systemlink/src/IDataManagementFeature.cpp", "output": "lib/systemlink/CMakeFiles/myclientLibstatic.dir/src/IDataManagementFeature.cpp.obj" },

What could be the problem? Is the compilation database malformed?

@bkryza
Copy link
Owner

bkryza commented Aug 27, 2024

@jensen82 Can you see any specific errors reported by Clang in the log?
The error fatal error: too many errors emitted, stopping now is usually emitted by Clang when parsing the sources, for instance when it cannot find certain include files or your project uses features of C++ higher than version specified in the compilation database.

In general these errors can be resolved by adjusting the compilation database, which can be done through the clang-uml configuration file, for instance:

add_compile_flags:
  - -I/opt/my_toolchain/include
remove_compile_flags:
  - -I/usr/include
  - r: "-m.*"

Also see here

@jensen82
Copy link
Author

Hi,

i'm sorry. Did not work.

Here are some details:

[info] [tid 10504] [C:\dev\projects\clang-uml-tmp\clang-uml\src\common\generators\generators.h:367] Generating diagram t00002_class In file included from C:\dev\playground\cpp-cast\main.cpp:1: In file included from C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.40.33807\include\iostream:8: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.40.33807\include\yvals_core.h:898:1: error: static assertion failed: error STL1000: Unexpected compiler version, expected Clang 17.0.0 or newer. _EMIT_STL_ERROR(STL1000, "Unexpected compiler version, expected Clang 17.0.0 or newer."); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.40.33807\include\yvals_core.h:519:44: note: expanded from macro '_EMIT_STL_ERROR' #define _EMIT_STL_ERROR(NUMBER, MESSAGE) static_assert(false, "error " #NUMBER ": " MESSAGE) ^ ~~~~~ 1 error generated. Error while processing C:\dev\playground\cpp-cast\main.cpp. [error] [tid 10504] [C:\dev\projects\clang-uml-tmp\clang-uml\src\common\generators\generators.cc:289] ERROR: Failed to generate diagram t00002_class: Diagram t00002_class generation failed

@bkryza
Copy link
Owner

bkryza commented Aug 28, 2024

@jensen82 Ok, can you also paste the output of

clang-uml.exe --version

?

@jensen82
Copy link
Author

jensen82 commented Aug 29, 2024

Of course...

This is clang:
clang version 17.0.3
Target: i686-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\bin

This is clang-uml:
clang-uml 0.5.4-2-g43482c9
Copyright (C) 2021-2024 Bartek Kryza [email protected]
Windows, 32-bit
Built against LLVM/Clang libraries version: 15.0.6
Using LLVM/Clang libraries version: clang version 15.0.6 (https://github.com/llvm/llvm-project.git 088f33605d8a61ff519c580a71b1dd57d16a03f8)

The requirement is fulfilled....

@bkryza
Copy link
Owner

bkryza commented Aug 29, 2024

@jensen82 Ok, now I see that you've built clang-uml on Windows from source, and linked it against LLVM 15.

Your errors:

error STL1000: Unexpected compiler version, expected Clang 17.0.0 or newer. _EMIT_STL_ERROR(STL1000, "Unexpected compiler version, expected Clang 17.0.0 or newer.");

state that you need to link clang-uml with at least version 17 to be able to use with headers in VC Tools.

Or you can try the clang-uml installer for version 0.5.4 which is linked with LLVM 18...

@jensen82
Copy link
Author

@jensen82 Ok, now I see that you've built clang-uml on Windows from source, and linked it against LLVM 15.

Your errors:

error STL1000: Unexpected compiler version, expected Clang 17.0.0 or newer. _EMIT_STL_ERROR(STL1000, "Unexpected compiler version, expected Clang 17.0.0 or newer.");

state that you need to link clang-uml with at least version 17 to be able to use with headers in VC Tools.

Or you can try the clang-uml installer for version 0.5.4 which is linked with LLVM 18...

Sorry, i should have seen it. I thought clang 17 is used for runtime...

Thank you

@jensen82
Copy link
Author

Just for info. I followed your tutorial to build it. Did you ever try it with MinGw on Windows?

@bkryza
Copy link
Owner

bkryza commented Aug 29, 2024

@jensen82 I haven't although I definitely would like to check whether it's possible to use it.

Can you describe a little more your setup? What do you use to compile (MSVC or mingw) for each of the following:

  • your project from which you want to generate diagrams
  • LLVM
  • clang-uml

?

I don't think it's possible to mix so either all three have to be built using mingw or all using MSVC, but I might be wrong...

Also, in the end did get it to work or are you still getting some errors?

@jensen82
Copy link
Author

jensen82 commented Sep 2, 2024

Hi,

i tried the installer, still a problem. i attached the console output
errors.txt

@jensen82
Copy link
Author

jensen82 commented Sep 2, 2024

Seems like -fPIC is not supported

@jensen82
Copy link
Author

jensen82 commented Sep 9, 2024

Maybe you need more infos, is there an opportunity to log to a file?

@bkryza
Copy link
Owner

bkryza commented Sep 9, 2024

The problem is that Clang fails on the MSVC sources, in particular:

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.41.34120\include\ratio

for instance an error like:

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.41.34120\include\ratio:57:5: error: statement not allowed in constexpr function
   57 |     while (_Bx != 0) {
      |     ^

means that Clang version to which clang-uml is linked cannot parse this code? Could be that your compile_commands.json for instance does not have proper C++ flags (especially missing C++ version flag)...

Could you describe your setup in more detail so that I can try to reproduce it?

  • Is your project based in MSVC or Mingw?
  • How do you generate your compile_commands.json
  • How do you invoke clang-uml?
  • The contents of your .clang-uml config file

@bkryza
Copy link
Owner

bkryza commented Sep 9, 2024

@jensen82 You can also adjust the compilation database within the .clang-uml config file, by adding and removing specific flags:

remove_compile_flags:
  - '-Wall'
  - '-pedantic'
  - '--std=c++11'
  - '-std=c++11'
add_compile_flags:
  -  '-std=c++20'

You can try different C++ versions, but AFAIK c++11 does not allow loops in constexpr functions, so that's probably why the ratio header file is rejected by Clang, assuming you have c++11 in your compile_commands.json or no version flag...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants