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

[BUG] Compilation failure with Clang on Windows #1294

Open
MatthieuHernandez opened this issue Oct 3, 2024 · 6 comments
Open

[BUG] Compilation failure with Clang on Windows #1294

MatthieuHernandez opened this issue Oct 3, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@MatthieuHernandez
Copy link
Contributor

I get a compiler error when I compile the sources.

  • compiler: clang version 18.1.6
  • standard library: MSVC version 14.35.32215
  • OS: Windows 11 version 23H2

This is the error I get:

PS C:\Programming\Git\cppfront\source> clang++ -v cppfront.cpp -std=c++20 -o cppfront
clang version 18.1.6
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
 "C:\\Program Files\\LLVM\\bin\\clang++.exe" -cc1 -triple x86_64-pc-windows-msvc19.35.32217 -emit-obj -mrelax-all -mincremental-linker-compatible -dumpdir cppfront- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name cppfront.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic "-fdebug-compilation-dir=C:\\Programming\\Git\\cppfront\\source" -v "-fcoverage-compilation-dir=C:\\Programming\\Git\\cppfront\\source" -resource-dir "C:\\Program Files\\LLVM\\lib\\clang\\18" -internal-isystem "C:\\Program Files\\LLVM\\lib\\clang\\18\\include" -internal-isystem "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.35.32215\\include" -internal-isystem "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.35.32215\\atlmfc\\include" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\shared" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\winrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\cppwinrt" -std=c++20 -fdeprecated-macro -ferror-limit 19 -fmessage-length=280 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.35.32217 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -o "C:\\Users\\matth\\AppData\\Local\\Temp\\cppfront-eabda8.o" -x c++ cppfront.cpp
clang -cc1 version 18.1.6 based upon LLVM 18.1.6 default target x86_64-pc-windows-msvc
#include "..." search starts here:
#include <...> search starts here:
 C:\Program Files\LLVM\lib\clang\18\include
 C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include
 C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\atlmfc\include
 C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt
 C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared
 C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um
 C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\winrt
 C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\cppwinrt
End of search list.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: "C:\\Program Files\\LLVM\\bin\\clang++.exe" -cc1 -triple x86_64-pc-windows-msvc19.35.32217 -emit-obj -mrelax-all -mincremental-linker-compatible -dumpdir cppfront- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name cppfront.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -fdebug-compilation-dir=C:\\Programming\\Git\\cppfront\\source -v -fcoverage-compilation-dir=C:\\Programming\\Git\\cppfront\\source -resource-dir "C:\\Program Files\\LLVM\\lib\\clang\\18" -internal-isystem "C:\\Program Files\\LLVM\\lib\\clang\\18\\include" -internal-isystem "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.35.32215\\include" -internal-isystem "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.35.32215\\atlmfc\\include" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\shared" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\winrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\cppwinrt" -std=c++20 -fdeprecated-macro -ferror-limit 19 -fmessage-length=280 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.35.32217 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -o C:\\Users\\matth\\AppData\\Local\\Temp\\cppfront-eabda8.o -x c++ cppfront.cpp
1.      reflect.h2:250:140: current parser token ')'
2.      reflect.h2:22:1: parsing namespace 'cpp2'
3.      reflect.h2:24:1: parsing namespace 'cpp2::meta'
4.      reflect.h2:250:78: parsing function body 'cpp2::meta::declaration_base::position'
5.      reflect.h2:250:78: in compound statement ('{}')
Exception Code: 0xC0000005
 #0 0x00007ff676efbc28 (C:\Program Files\LLVM\bin\clang++.exe+0x1c7bc28)
 #1 0x00007ff676efbbe3 (C:\Program Files\LLVM\bin\clang++.exe+0x1c7bbe3)
 #2 0x00007ff676efb011 (C:\Program Files\LLVM\bin\clang++.exe+0x1c7b011)
 #3 0x00007ff676d552b8 (C:\Program Files\LLVM\bin\clang++.exe+0x1ad52b8)
 #4 0x00007ff676d541d7 (C:\Program Files\LLVM\bin\clang++.exe+0x1ad41d7)
 #5 0x00007ff676d6fe6a (C:\Program Files\LLVM\bin\clang++.exe+0x1aefe6a)
 #6 0x00007ff676d5420e (C:\Program Files\LLVM\bin\clang++.exe+0x1ad420e)
 #7 0x00007ff676d531d1 (C:\Program Files\LLVM\bin\clang++.exe+0x1ad31d1)
 #8 0x00007ff676d5417c (C:\Program Files\LLVM\bin\clang++.exe+0x1ad417c)
 #9 0x00007ff6786d65c9 (C:\Program Files\LLVM\bin\clang++.exe+0x34565c9)
#10 0x00007ff6786cfb2e (C:\Program Files\LLVM\bin\clang++.exe+0x344fb2e)
#11 0x00007ff676d54b84 (C:\Program Files\LLVM\bin\clang++.exe+0x1ad4b84)
#12 0x00007ff676d568af (C:\Program Files\LLVM\bin\clang++.exe+0x1ad68af)
#13 0x00007ff676d5419d (C:\Program Files\LLVM\bin\clang++.exe+0x1ad419d)
#14 0x00007ff676dc3129 (C:\Program Files\LLVM\bin\clang++.exe+0x1b43129)
#15 0x00007ff67734f3dd (C:\Program Files\LLVM\bin\clang++.exe+0x20cf3dd)
#16 0x00007ff67734b45a (C:\Program Files\LLVM\bin\clang++.exe+0x20cb45a)
#17 0x00007ff67734aedc (C:\Program Files\LLVM\bin\clang++.exe+0x20caedc)
#18 0x00007ff6770a3e0d (C:\Program Files\LLVM\bin\clang++.exe+0x1e23e0d)
#19 0x00007ff676f49853 (C:\Program Files\LLVM\bin\clang++.exe+0x1cc9853)
#20 0x00007ff676f7d543 (C:\Program Files\LLVM\bin\clang++.exe+0x1cfd543)
#21 0x00007ff675903936 (C:\Program Files\LLVM\bin\clang++.exe+0x683936)
#22 0x00007ff676ecfc56 (C:\Program Files\LLVM\bin\clang++.exe+0x1c4fc56)
#23 0x00007ff676ec91a9 (C:\Program Files\LLVM\bin\clang++.exe+0x1c491a9)
#24 0x00007ff676ec4bad (C:\Program Files\LLVM\bin\clang++.exe+0x1c44bad)
#25 0x00007ff676ec2181 (C:\Program Files\LLVM\bin\clang++.exe+0x1c42181)
#26 0x00007ff676ebf2eb (C:\Program Files\LLVM\bin\clang++.exe+0x1c3f2eb)
#27 0x00007ff676eb46c5 (C:\Program Files\LLVM\bin\clang++.exe+0x1c346c5)
#28 0x00007ff676d1b949 (C:\Program Files\LLVM\bin\clang++.exe+0x1a9b949)
#29 0x00007ff676d0fed4 (C:\Program Files\LLVM\bin\clang++.exe+0x1a8fed4)
#30 0x00007ff676d0ecd7 (C:\Program Files\LLVM\bin\clang++.exe+0x1a8ecd7)
#31 0x00007ff676d0c975 (C:\Program Files\LLVM\bin\clang++.exe+0x1a8c975)
#32 0x00007ff676d0c5cc (C:\Program Files\LLVM\bin\clang++.exe+0x1a8c5cc)
#33 0x00007ff67536d43e (C:\Program Files\LLVM\bin\clang++.exe+0xed43e)
#34 0x00007ff676d0dd47 (C:\Program Files\LLVM\bin\clang++.exe+0x1a8dd47)
#35 0x00007ff676d0c820 (C:\Program Files\LLVM\bin\clang++.exe+0x1a8c820)
#36 0x00007ff676d0c5cc (C:\Program Files\LLVM\bin\clang++.exe+0x1a8c5cc)
#37 0x00007ff67536d43e (C:\Program Files\LLVM\bin\clang++.exe+0xed43e)
#38 0x00007ff676d0dd47 (C:\Program Files\LLVM\bin\clang++.exe+0x1a8dd47)
#39 0x00007ff676d0c820 (C:\Program Files\LLVM\bin\clang++.exe+0x1a8c820)
#40 0x00007ff6776ff53f (C:\Program Files\LLVM\bin\clang++.exe+0x247f53f)
#41 0x00007ff6776ff1d1 (C:\Program Files\LLVM\bin\clang++.exe+0x247f1d1)
#42 0x00007ff67582dd31 (C:\Program Files\LLVM\bin\clang++.exe+0x5add31)
#43 0x00007ff67582d7d2 (C:\Program Files\LLVM\bin\clang++.exe+0x5ad7d2)
#44 0x00007ff67582a504 (C:\Program Files\LLVM\bin\clang++.exe+0x5aa504)
#45 0x00007ff675828080 (C:\Program Files\LLVM\bin\clang++.exe+0x5a8080)
#46 0x00007ff675826a4e (C:\Program Files\LLVM\bin\clang++.exe+0x5a6a4e)
#47 0x00007ff675666f7c (C:\Program Files\LLVM\bin\clang++.exe+0x3e6f7c)
#48 0x00007ff675662bc3 (C:\Program Files\LLVM\bin\clang++.exe+0x3e2bc3)
#49 0x00007ff677784bb0 (C:\Program Files\LLVM\bin\clang++.exe+0x2504bb0)
#50 0x00007ffdc945257d (C:\WINDOWS\System32\KERNEL32.DLL+0x1257d)
#51 0x00007ffdcb12af28 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x5af28)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 18.1.6
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
clang++: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: C:\Users\matth\AppData\Local\Temp\cppfront-6291c4.cpp
clang++: note: diagnostic msg: C:\Users\matth\AppData\Local\Temp\cppfront-6291c4.sh
clang++: note: diagnostic msg:

********************
@MatthieuHernandez MatthieuHernandez added the bug Something isn't working label Oct 3, 2024
@MatthieuHernandez MatthieuHernandez changed the title [BUG] Cannot compile with Clang under Windowds [BUG] Compilation failure with Clang on Windows Oct 3, 2024
@MatthieuHernandez
Copy link
Contributor Author

I also get a error when trying to compile with MSVC.

PS C:\Programming\Git\cppfront\source> cl cppfront.cpp -std:c++20 -EHsc
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.50727.762 for x64
Copyright (C) Microsoft Corporation. All rights reserved.

cppfront.cpp
C:\Programming\Git\cppfront\source\../include/cpp2util.h(51): fatal error C1034: version: no include path set

@vanceism7
Copy link
Contributor

vanceism7 commented Oct 3, 2024

Interesting, I was seeing a similar error to your clang++ compilation when invoking cl - mentioned here: #1293

Its weird that your cl is having a hard time seeing the includes though. I thought it would pick those up automatically. Are you running cl from the Developer Powershell for VS 2022 shell?

@MatthieuHernandez
Copy link
Contributor Author

I was running the command from Powershell but using Developer Command Prompt it works with cl. It seems that the error was on my side, sorry 😅
I guess I'm missing some paths in my environment variables, even though I do have the path to MSVC includes.
However, this doesn't solve my problem with the Clang compiler.

@vanceism7
Copy link
Contributor

vanceism7 commented Oct 3, 2024

Yea, so I just tested this with a fresh install of MingW and also Clang the same as you; nothing is compiling for me on any of them either.

On clang, I'm getting exactly the same errors you're getting. Using MingW g++, I'm getting the issue mentioned in the guide

Note: On Windows (including MinGW), if you get a "too many sections" message, specify the switch /bigobj (MSVC) or /Wa,-mbig-obj (GCC).

But using the /Wa,-mbig-obj isn't fixing it. When I ran g++ inside of a linux vm, it compiled perfectly in just a couple of seconds - so it seems like building in windows is just problematic at the moment

@vanceism7
Copy link
Contributor

vanceism7 commented Oct 7, 2024

Hey so I'm not sure why clang isn't compiling properly, but your msvc version looks old. I was running into this same issue with cl version 14, update it to 19 and it should start working for msvc compiler

@MatthieuHernandez
Copy link
Contributor Author

For now, I'm compiling completely with MSVC and it's working properly, I haven't retried compiling with Clang.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants