Running LLVMHello Pass from Clang(-cl)

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Running LLVMHello Pass from Clang(-cl)

Manas via cfe-dev

Hello everyone,

 

I build and run the LLVM (and clang) under Windows. I wanted to dive into the LLVM passes because I see a huge benefit in them for our project. So I made sure to configurate CMAKE with “CLANG_PLUGIN_SUPPORT”, “LLVM_ENABLE_PLUGINS” and “LLVM_EXPORT_SYMBOLS_FOR_PLUGINS”.

Except one project, everything build fine and I was able to execute “opt.exe” with the LLVMHello.dll – everything worked as expected!

 

However, then I tried using the DLL with Clang-Cl because this would be the way how to integrate it to our system. So I used:

clang-cl.exe -Xclang -load -Xclang LLVMHello.dll Test.cpp

 

However, this failed with:

clang-cl: error: clang frontend command failed due to signal (use -v to see invocation)

clang version 12.0.0

Target: x86_64-pc-windows-msvc

Thread model: posix

InstalledDir: D:\Program Files\LLVM_orc_removal\bin

clang-cl: note: diagnostic msg: Error generating preprocessed source(s).

 

If I remove the loading of LLVMHello.dll it works correctly again. I feel like, that LLVMHello.dll is not finding all the symbols needed. So I linked LLVMHello.dll with “clang.lib” instead of “opt.lib” - but with no success.

 

I also read that there are ways to include those passes directly into the source code of Clang, but I hoped to use this dynamic approach instead.

 

Any comments, ideas or something about this?

 

Kind greetings

Björn

 

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Running LLVMHello Pass from Clang(-cl)

Manas via cfe-dev
This line seems critical:
clang-cl: error: clang frontend command failed due to signal (use -v to see invocation)
 
Have you tried rerunning with -v? The full invocation might be informative.

Best,
- Eric

On Tue, Nov 10, 2020 at 4:13 AM Gaier, Bjoern via cfe-dev <[hidden email]> wrote:

Hello everyone,

 

I build and run the LLVM (and clang) under Windows. I wanted to dive into the LLVM passes because I see a huge benefit in them for our project. So I made sure to configurate CMAKE with “CLANG_PLUGIN_SUPPORT”, “LLVM_ENABLE_PLUGINS” and “LLVM_EXPORT_SYMBOLS_FOR_PLUGINS”.

Except one project, everything build fine and I was able to execute “opt.exe” with the LLVMHello.dll – everything worked as expected!

 

However, then I tried using the DLL with Clang-Cl because this would be the way how to integrate it to our system. So I used:

clang-cl.exe -Xclang -load -Xclang LLVMHello.dll Test.cpp

 

However, this failed with:

clang-cl: error: clang frontend command failed due to signal (use -v to see invocation)

clang version 12.0.0

Target: x86_64-pc-windows-msvc

Thread model: posix

InstalledDir: D:\Program Files\LLVM_orc_removal\bin

clang-cl: note: diagnostic msg: Error generating preprocessed source(s).

 

If I remove the loading of LLVMHello.dll it works correctly again. I feel like, that LLVMHello.dll is not finding all the symbols needed. So I linked LLVMHello.dll with “clang.lib” instead of “opt.lib” - but with no success.

 

I also read that there are ways to include those passes directly into the source code of Clang, but I hoped to use this dynamic approach instead.

 

Any comments, ideas or something about this?

 

Kind greetings

Björn

 

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Running LLVMHello Pass from Clang(-cl)

Manas via cfe-dev

Hello Eric,

 

I got this now:

D:\Program Files\LLVM_orc_removal\bin>clang-cl.exe -v -Xclang -load -Xclang LLVMHello.dll Test.cpp

clang version 12.0.0

Target: x86_64-pc-windows-msvc

Thread model: posix

InstalledDir: D:\Program Files\LLVM_orc_removal\bin

"D:\\Program Files\\LLVM_orc_removal\\bin\\clang-cl.exe" -cc1 -triple x86_64-pc-windows-msvc19.27.29111 -emit-obj -mrelax-all -mincremental-linker-compatible --mrelax-relocations -disable-free -main-file-name Test.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -relaxed-aliasing -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -mllvm -x86-asm-syntax=intel -tune-cpu generic -D_MT -flto-visibility-public-std --dependent-lib=libcmt --dependent-lib=oldnames -stack-protector 2 -fms-volatile -fdiagnostics-format msvc -v -resource-dir "D:\\Program  Files\\LLVM_orc_removal\\lib\\clang\\12.0.0" -internal-isystem "D:\\Program Files\\LLVM_orc_removal\\lib\\clang\\12.0.0\\include" -internal-isystem "D:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.27.29110\\include" -internal-isystem "D:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.27.29110\\atlmfc\\include" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\shared" -internal-isystem "C:

\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\um" -internal-isystem "C:\\Program Files (x86)\\WindowsKits\\10\\include\\10.0.18362.0\\winrt" -fdeprecated-macro -fdebug-compilation-dir "D:\\Program Files\\LLVM_orc_removal\\bin" -ferror-limit 19 -fmessage-length=120 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.27.29111 -std=c++14 -fdelayed-template-parsing -fcolor-diagnostics -load LLVMHello.dll -faddrsig -o "C:\\Users\\h16020\\AppData\\Local\\Temp\\Test-f1a523.obj" -x c++ Test.cpp

clang-cl: error: clang frontend command failed due to signal (use -v to see invocation)

clang version 12.0.0

Target: x86_64-pc-windows-msvc

Thread model: posix

InstalledDir: D:\Program Files\LLVM_orc_removal\bin

clang-cl: note: diagnostic msg: Error generating preprocessed source(s).

 

And here with -Xclang

D:\Program Files\LLVM_orc_removal\bin>clang-cl.exe -Xclang -v -Xclang -load -Xclang LLVMHello.dll Test.cpp

clang-cl: error: clang frontend command failed due to signal (use -v to see invocation)

clang version 12.0.0

Target: x86_64-pc-windows-msvc

Thread model: posix

InstalledDir: D:\Program Files\LLVM_orc_removal\bin

clang-cl: note: diagnostic msg: Error generating preprocessed source(s).

 

Didn’t told me much óò

Kind greetings

Björn

 

From: Eric Astor <[hidden email]>
Sent: 10 November 2020 14:50
To: Gaier, Bjoern <[hidden email]>
Cc: Clang Dev <[hidden email]>
Subject: Re: [cfe-dev] Running LLVMHello Pass from Clang(-cl)

 

This line seems critical:

clang-cl: error: clang frontend command failed due to signal (use -v to see invocation)

 

Have you tried rerunning with -v? The full invocation might be informative.

 

Best,

- Eric

 

On Tue, Nov 10, 2020 at 4:13 AM Gaier, Bjoern via cfe-dev <[hidden email]> wrote:

Hello everyone,

 

I build and run the LLVM (and clang) under Windows. I wanted to dive into the LLVM passes because I see a huge benefit in them for our project. So I made sure to configurate CMAKE with “CLANG_PLUGIN_SUPPORT”, “LLVM_ENABLE_PLUGINS” and “LLVM_EXPORT_SYMBOLS_FOR_PLUGINS”.

Except one project, everything build fine and I was able to execute “opt.exe” with the LLVMHello.dll – everything worked as expected!

 

However, then I tried using the DLL with Clang-Cl because this would be the way how to integrate it to our system. So I used:

clang-cl.exe -Xclang -load -Xclang LLVMHello.dll Test.cpp

 

However, this failed with:

clang-cl: error: clang frontend command failed due to signal (use -v to see invocation)

clang version 12.0.0

Target: x86_64-pc-windows-msvc

Thread model: posix

InstalledDir: D:\Program Files\LLVM_orc_removal\bin

clang-cl: note: diagnostic msg: Error generating preprocessed source(s).

 

If I remove the loading of LLVMHello.dll it works correctly again. I feel like, that LLVMHello.dll is not finding all the symbols needed. So I linked LLVMHello.dll with “clang.lib” instead of “opt.lib” - but with no success.

 

I also read that there are ways to include those passes directly into the source code of Clang, but I hoped to use this dynamic approach instead.

 

Any comments, ideas or something about this?

 

Kind greetings

Björn

 

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Running LLVMHello Pass from Clang(-cl)

Manas via cfe-dev
Hello Gaier,

This might indicate the root cause:

```
clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
```

However, I have no better suggestion other than investigating with a
debugger :/

Btw, have you tried on Linux? Dynamically loaded plugins are not really
supported on Windows. Yes, sometimes stuff works, but your mileage will
vary. If you test this on Linux and it still fails then at least you
will be confident that it's not related to Windows-specific limitations.

-Andrzej

On 11/11/2020 08:16, Gaier, Bjoern via cfe-dev wrote:

> Hello Eric,
>
> I got this now:
>
> D:\Program Files\LLVM_orc_removal\bin>clang-cl.exe -v -Xclang -load
> -Xclang LLVMHello.dll Test.cpp
>
> clang version 12.0.0
>
> Target: x86_64-pc-windows-msvc
>
> Thread model: posix
>
> InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
> "D:\\Program Files\\LLVM_orc_removal\\bin\\clang-cl.exe" -cc1 -triple
> x86_64-pc-windows-msvc19.27.29111 -emit-obj -mrelax-all
> -mincremental-linker-compatible --mrelax-relocations -disable-free
> -main-file-name Test.cpp -mrelocation-model pic -pic-level 2
> -mframe-pointer=none -relaxed-aliasing -fmath-errno -fno-rounding-math
> -mconstructor-aliases -munwind-tables -target-cpu x86-64 -mllvm
> -x86-asm-syntax=intel -tune-cpu generic -D_MT
> -flto-visibility-public-std --dependent-lib=libcmt
> --dependent-lib=oldnames -stack-protector 2 -fms-volatile
> -fdiagnostics-format msvc -v -resource-dir "D:\\Program
>   Files\\LLVM_orc_removal\\lib\\clang\\12.0.0" -internal-isystem
> "D:\\Program Files\\LLVM_orc_removal\\lib\\clang\\12.0.0\\include"
> -internal-isystem "D:\\Program Files (x86)\\Microsoft Visual
> Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.27.29110\\include"
> -internal-isystem "D:\\Program Files (x86)\\Microsoft Visual
> Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.27.29110\\atlmfc\\include"
> -internal-isystem "C:\\Program Files (x86)\\Windows
> Kits\\10\\Include\\10.0.18362.0\\ucrt" -internal-isystem "C:\\Program
> Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\shared"
> -internal-isystem "C:
>
> \\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\um"
> -internal-isystem "C:\\Program Files
> (x86)\\WindowsKits\\10\\include\\10.0.18362.0\\winrt" -fdeprecated-macro
> -fdebug-compilation-dir "D:\\Program Files\\LLVM_orc_removal\\bin"
> -ferror-limit 19 -fmessage-length=120 -fno-use-cxa-atexit
> -fms-extensions -fms-compatibility
> -fms-compatibility-version=19.27.29111 -std=c++14
> -fdelayed-template-parsing -fcolor-diagnostics -load LLVMHello.dll
> -faddrsig -o "C:\\Users\\h16020\\AppData\\Local\\Temp\\Test-f1a523.obj"
> -x c++ Test.cpp
>
> clang-cl: error: clang frontend command failed due to signal (use -v to
> see invocation)
>
> clang version 12.0.0
>
> Target: x86_64-pc-windows-msvc
>
> Thread model: posix
>
> InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
> clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
>
> And here with -Xclang
>
> D:\Program Files\LLVM_orc_removal\bin>clang-cl.exe -Xclang -v -Xclang
> -load -Xclang LLVMHello.dll Test.cpp
>
> clang-cl: error: clang frontend command failed due to signal (use -v to
> see invocation)
>
> clang version 12.0.0
>
> Target: x86_64-pc-windows-msvc
>
> Thread model: posix
>
> InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
> clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
>
> Didn’t told me much óò
>
> Kind greetings
>
> Björn
>
> *From:*Eric Astor <[hidden email]>
> *Sent:* 10 November 2020 14:50
> *To:* Gaier, Bjoern <[hidden email]>
> *Cc:* Clang Dev <[hidden email]>
> *Subject:* Re: [cfe-dev] Running LLVMHello Pass from Clang(-cl)
>
> This line seems critical:
>
>     clang-cl: error: clang frontend command failed due to signal (use -v
>     to see invocation)
>
> Have you tried rerunning with -v? The full invocation might be informative.
>
> Best,
>
> - Eric
>
> On Tue, Nov 10, 2020 at 4:13 AM Gaier, Bjoern via cfe-dev
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Hello everyone,
>
>     I build and run the LLVM (and clang) under Windows. I wanted to dive
>     into the LLVM passes because I see a huge benefit in them for our
>     project. So I made sure to configurate CMAKE with
>     “CLANG_PLUGIN_SUPPORT”, “LLVM_ENABLE_PLUGINS” and
>     “LLVM_EXPORT_SYMBOLS_FOR_PLUGINS”.
>
>     Except one project, everything build fine and I was able to execute
>     “opt.exe” with the LLVMHello.dll – everything worked as expected!
>
>     However, then I tried using the DLL with Clang-Cl because this would
>     be the way how to integrate it to our system. So I used:
>
>     clang-cl.exe -Xclang -load -Xclang LLVMHello.dll Test.cpp
>
>     However, this failed with:
>
>     clang-cl: error: clang frontend command failed due to signal (use -v
>     to see invocation)
>
>     clang version 12.0.0
>
>     Target: x86_64-pc-windows-msvc
>
>     Thread model: posix
>
>     InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
>     clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
>
>     If I remove the loading of LLVMHello.dll it works correctly again. I
>     feel like, that LLVMHello.dll is not finding all the symbols needed.
>     So I linked LLVMHello.dll with “clang.lib” instead of “opt.lib” -
>     but with no success.
>
>     I also read that there are ways to include those passes directly
>     into the source code of Clang, but I hoped to use this dynamic
>     approach instead.
>
>     Any comments, ideas or something about this?
>
>     Kind greetings
>
>     Björn
>
>     Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816,
>     USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr.
>     Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin
>     Cansiz.
>
>     _______________________________________________
>     cfe-dev mailing list
>     [hidden email] <mailto:[hidden email]>
>     https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>     <https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
>
> Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816,
> USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr.
> Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Running LLVMHello Pass from Clang(-cl)

Manas via cfe-dev
Hey Andrzej,

Sadly I can not run it under Linux and also don't have debug symbols enabled (because of disk space issues...)

I'm really confused by this, because the plugin works with opt causing no issues. So.... what is opt doing differently then Clang? >o<

- Björn

-----Original Message-----
From: cfe-dev <[hidden email]> On Behalf Of Andrzej Warzynski via cfe-dev
Sent: 11 November 2020 12:56
To: [hidden email]
Subject: Re: [cfe-dev] Running LLVMHello Pass from Clang(-cl)

Hello Gaier,

This might indicate the root cause:

```
clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
```

However, I have no better suggestion other than investigating with a debugger :/

Btw, have you tried on Linux? Dynamically loaded plugins are not really supported on Windows. Yes, sometimes stuff works, but your mileage will vary. If you test this on Linux and it still fails then at least you will be confident that it's not related to Windows-specific limitations.

-Andrzej

On 11/11/2020 08:16, Gaier, Bjoern via cfe-dev wrote:

> Hello Eric,
>
> I got this now:
>
> D:\Program Files\LLVM_orc_removal\bin>clang-cl.exe -v -Xclang -load
> -Xclang LLVMHello.dll Test.cpp
>
> clang version 12.0.0
>
> Target: x86_64-pc-windows-msvc
>
> Thread model: posix
>
> InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
> "D:\\Program Files\\LLVM_orc_removal\\bin\\clang-cl.exe" -cc1 -triple
> x86_64-pc-windows-msvc19.27.29111 -emit-obj -mrelax-all
> -mincremental-linker-compatible --mrelax-relocations -disable-free
> -main-file-name Test.cpp -mrelocation-model pic -pic-level 2
> -mframe-pointer=none -relaxed-aliasing -fmath-errno -fno-rounding-math
> -mconstructor-aliases -munwind-tables -target-cpu x86-64 -mllvm
> -x86-asm-syntax=intel -tune-cpu generic -D_MT
> -flto-visibility-public-std --dependent-lib=libcmt
> --dependent-lib=oldnames -stack-protector 2 -fms-volatile
> -fdiagnostics-format msvc -v -resource-dir "D:\\Program
>   Files\\LLVM_orc_removal\\lib\\clang\\12.0.0" -internal-isystem
> "D:\\Program Files\\LLVM_orc_removal\\lib\\clang\\12.0.0\\include"
> -internal-isystem "D:\\Program Files (x86)\\Microsoft Visual
> Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.27.29110\\include"
> -internal-isystem "D:\\Program Files (x86)\\Microsoft Visual
> Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.27.29110\\atlmfc\\include"
> -internal-isystem "C:\\Program Files (x86)\\Windows
> Kits\\10\\Include\\10.0.18362.0\\ucrt" -internal-isystem "C:\\Program
> Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\shared"
> -internal-isystem "C:
>
> \\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\um"
> -internal-isystem "C:\\Program Files
> (x86)\\WindowsKits\\10\\include\\10.0.18362.0\\winrt"
> -fdeprecated-macro -fdebug-compilation-dir "D:\\Program Files\\LLVM_orc_removal\\bin"
> -ferror-limit 19 -fmessage-length=120 -fno-use-cxa-atexit
> -fms-extensions -fms-compatibility
> -fms-compatibility-version=19.27.29111 -std=c++14
> -fdelayed-template-parsing -fcolor-diagnostics -load LLVMHello.dll
> -faddrsig -o "C:\\Users\\h16020\\AppData\\Local\\Temp\\Test-f1a523.obj"
> -x c++ Test.cpp
>
> clang-cl: error: clang frontend command failed due to signal (use -v
> to see invocation)
>
> clang version 12.0.0
>
> Target: x86_64-pc-windows-msvc
>
> Thread model: posix
>
> InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
> clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
>
> And here with -Xclang
>
> D:\Program Files\LLVM_orc_removal\bin>clang-cl.exe -Xclang -v -Xclang
> -load -Xclang LLVMHello.dll Test.cpp
>
> clang-cl: error: clang frontend command failed due to signal (use -v
> to see invocation)
>
> clang version 12.0.0
>
> Target: x86_64-pc-windows-msvc
>
> Thread model: posix
>
> InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
> clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
>
> Didn’t told me much óò
>
> Kind greetings
>
> Björn
>
> *From:*Eric Astor <[hidden email]>
> *Sent:* 10 November 2020 14:50
> *To:* Gaier, Bjoern <[hidden email]>
> *Cc:* Clang Dev <[hidden email]>
> *Subject:* Re: [cfe-dev] Running LLVMHello Pass from Clang(-cl)
>
> This line seems critical:
>
>     clang-cl: error: clang frontend command failed due to signal (use -v
>     to see invocation)
>
> Have you tried rerunning with -v? The full invocation might be informative.
>
> Best,
>
> - Eric
>
> On Tue, Nov 10, 2020 at 4:13 AM Gaier, Bjoern via cfe-dev
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Hello everyone,
>
>     I build and run the LLVM (and clang) under Windows. I wanted to dive
>     into the LLVM passes because I see a huge benefit in them for our
>     project. So I made sure to configurate CMAKE with
>     “CLANG_PLUGIN_SUPPORT”, “LLVM_ENABLE_PLUGINS” and
>     “LLVM_EXPORT_SYMBOLS_FOR_PLUGINS”.
>
>     Except one project, everything build fine and I was able to execute
>     “opt.exe” with the LLVMHello.dll – everything worked as expected!
>
>     However, then I tried using the DLL with Clang-Cl because this would
>     be the way how to integrate it to our system. So I used:
>
>     clang-cl.exe -Xclang -load -Xclang LLVMHello.dll Test.cpp
>
>     However, this failed with:
>
>     clang-cl: error: clang frontend command failed due to signal (use -v
>     to see invocation)
>
>     clang version 12.0.0
>
>     Target: x86_64-pc-windows-msvc
>
>     Thread model: posix
>
>     InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
>     clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
>
>     If I remove the loading of LLVMHello.dll it works correctly again. I
>     feel like, that LLVMHello.dll is not finding all the symbols needed.
>     So I linked LLVMHello.dll with “clang.lib” instead of “opt.lib” -
>     but with no success.
>
>     I also read that there are ways to include those passes directly
>     into the source code of Clang, but I hoped to use this dynamic
>     approach instead.
>
>     Any comments, ideas or something about this?
>
>     Kind greetings
>
>     Björn
>
>     Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816,
>     USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr.
>     Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin
>     Cansiz.
>
>     _______________________________________________
>     cfe-dev mailing list
>     [hidden email] <mailto:[hidden email]>
>     https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>     <https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
>
> Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816,
> USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr.
> Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Running LLVMHello Pass from Clang(-cl)

Manas via cfe-dev
The "Error generating preprocessed source(s)" message here is from a generic error trap:

I've found instances of this online that were resolved by increasing the heap size, so it can be caused by just about anything. The underlying command line doesn't include a smoking gun for me either.

As Andrzej mentioned, I don't know that dynamic plugins are actually well-supported on Windows, so this might be hard to track down without the ability to run a debugger. If you can't build with debug symbols, can you write a step-by-step reproduction procedure so someone else can try, including all the code necessary?

- Eric

On Wed, Nov 11, 2020 at 8:16 AM Gaier, Bjoern via cfe-dev <[hidden email]> wrote:
Hey Andrzej,

Sadly I can not run it under Linux and also don't have debug symbols enabled (because of disk space issues...)

I'm really confused by this, because the plugin works with opt causing no issues. So.... what is opt doing differently then Clang? >o<

- Björn

-----Original Message-----
From: cfe-dev <[hidden email]> On Behalf Of Andrzej Warzynski via cfe-dev
Sent: 11 November 2020 12:56
To: [hidden email]
Subject: Re: [cfe-dev] Running LLVMHello Pass from Clang(-cl)

Hello Gaier,

This might indicate the root cause:

```
clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
```

However, I have no better suggestion other than investigating with a debugger :/

Btw, have you tried on Linux? Dynamically loaded plugins are not really supported on Windows. Yes, sometimes stuff works, but your mileage will vary. If you test this on Linux and it still fails then at least you will be confident that it's not related to Windows-specific limitations.

-Andrzej

On 11/11/2020 08:16, Gaier, Bjoern via cfe-dev wrote:
> Hello Eric,
>
> I got this now:
>
> D:\Program Files\LLVM_orc_removal\bin>clang-cl.exe -v -Xclang -load
> -Xclang LLVMHello.dll Test.cpp
>
> clang version 12.0.0
>
> Target: x86_64-pc-windows-msvc
>
> Thread model: posix
>
> InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
> "D:\\Program Files\\LLVM_orc_removal\\bin\\clang-cl.exe" -cc1 -triple
> x86_64-pc-windows-msvc19.27.29111 -emit-obj -mrelax-all
> -mincremental-linker-compatible --mrelax-relocations -disable-free
> -main-file-name Test.cpp -mrelocation-model pic -pic-level 2
> -mframe-pointer=none -relaxed-aliasing -fmath-errno -fno-rounding-math
> -mconstructor-aliases -munwind-tables -target-cpu x86-64 -mllvm
> -x86-asm-syntax=intel -tune-cpu generic -D_MT
> -flto-visibility-public-std --dependent-lib=libcmt
> --dependent-lib=oldnames -stack-protector 2 -fms-volatile
> -fdiagnostics-format msvc -v -resource-dir "D:\\Program
>   Files\\LLVM_orc_removal\\lib\\clang\\12.0.0" -internal-isystem
> "D:\\Program Files\\LLVM_orc_removal\\lib\\clang\\12.0.0\\include"
> -internal-isystem "D:\\Program Files (x86)\\Microsoft Visual
> Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.27.29110\\include"
> -internal-isystem "D:\\Program Files (x86)\\Microsoft Visual
> Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.27.29110\\atlmfc\\include"
> -internal-isystem "C:\\Program Files (x86)\\Windows
> Kits\\10\\Include\\10.0.18362.0\\ucrt" -internal-isystem "C:\\Program
> Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\shared"
> -internal-isystem "C:
>
> \\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\um"
> -internal-isystem "C:\\Program Files
> (x86)\\WindowsKits\\10\\include\\10.0.18362.0\\winrt"
> -fdeprecated-macro -fdebug-compilation-dir "D:\\Program Files\\LLVM_orc_removal\\bin"
> -ferror-limit 19 -fmessage-length=120 -fno-use-cxa-atexit
> -fms-extensions -fms-compatibility
> -fms-compatibility-version=19.27.29111 -std=c++14
> -fdelayed-template-parsing -fcolor-diagnostics -load LLVMHello.dll
> -faddrsig -o "C:\\Users\\h16020\\AppData\\Local\\Temp\\Test-f1a523.obj"
> -x c++ Test.cpp
>
> clang-cl: error: clang frontend command failed due to signal (use -v
> to see invocation)
>
> clang version 12.0.0
>
> Target: x86_64-pc-windows-msvc
>
> Thread model: posix
>
> InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
> clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
>
> And here with -Xclang
>
> D:\Program Files\LLVM_orc_removal\bin>clang-cl.exe -Xclang -v -Xclang
> -load -Xclang LLVMHello.dll Test.cpp
>
> clang-cl: error: clang frontend command failed due to signal (use -v
> to see invocation)
>
> clang version 12.0.0
>
> Target: x86_64-pc-windows-msvc
>
> Thread model: posix
>
> InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
> clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
>
> Didn’t told me much óò
>
> Kind greetings
>
> Björn
>
> *From:*Eric Astor <[hidden email]>
> *Sent:* 10 November 2020 14:50
> *To:* Gaier, Bjoern <[hidden email]>
> *Cc:* Clang Dev <[hidden email]>
> *Subject:* Re: [cfe-dev] Running LLVMHello Pass from Clang(-cl)
>
> This line seems critical:
>
>     clang-cl: error: clang frontend command failed due to signal (use -v
>     to see invocation)
>
> Have you tried rerunning with -v? The full invocation might be informative.
>
> Best,
>
> - Eric
>
> On Tue, Nov 10, 2020 at 4:13 AM Gaier, Bjoern via cfe-dev
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Hello everyone,
>
>     I build and run the LLVM (and clang) under Windows. I wanted to dive
>     into the LLVM passes because I see a huge benefit in them for our
>     project. So I made sure to configurate CMAKE with
>     “CLANG_PLUGIN_SUPPORT”, “LLVM_ENABLE_PLUGINS” and
>     “LLVM_EXPORT_SYMBOLS_FOR_PLUGINS”.
>
>     Except one project, everything build fine and I was able to execute
>     “opt.exe” with the LLVMHello.dll – everything worked as expected!
>
>     However, then I tried using the DLL with Clang-Cl because this would
>     be the way how to integrate it to our system. So I used:
>
>     clang-cl.exe -Xclang -load -Xclang LLVMHello.dll Test.cpp
>
>     However, this failed with:
>
>     clang-cl: error: clang frontend command failed due to signal (use -v
>     to see invocation)
>
>     clang version 12.0.0
>
>     Target: x86_64-pc-windows-msvc
>
>     Thread model: posix
>
>     InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
>     clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
>
>     If I remove the loading of LLVMHello.dll it works correctly again. I
>     feel like, that LLVMHello.dll is not finding all the symbols needed.
>     So I linked LLVMHello.dll with “clang.lib” instead of “opt.lib” -
>     but with no success.
>
>     I also read that there are ways to include those passes directly
>     into the source code of Clang, but I hoped to use this dynamic
>     approach instead.
>
>     Any comments, ideas or something about this?
>
>     Kind greetings
>
>     Björn
>
>     Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816,
>     USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr.
>     Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin
>     Cansiz.
>
>     _______________________________________________
>     cfe-dev mailing list
>     [hidden email] <mailto:[hidden email]>
>     https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>     <https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
>
> Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816,
> USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr.
> Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Running LLVMHello Pass from Clang(-cl)

Manas via cfe-dev

cc the proper mailing list.

 

De : Alexandre Ganea
Envoyé : November 11, 2020 8:49 AM
À : Eric Astor <[hidden email]>; Gaier, Bjoern <[hidden email]>
Cc : llvm-dev <[hidden email]>
Objet : RE: [cfe-dev] Running LLVMHello Pass from Clang(-cl)

 

Björn,

Can you try adding -fno-integrated-cc1 to the command-line, see if you get more infos?

 

De : cfe-dev <[hidden email]> De la part de Eric Astor via cfe-dev
Envoyé : November 11, 2020 8:39 AM
À : Gaier, Bjoern <[hidden email]>
Cc : Clang Dev <[hidden email]>
Objet : Re: [cfe-dev] Running LLVMHello Pass from Clang(-cl)

 

The "Error generating preprocessed source(s)" message here is from a generic error trap:

 

I've found instances of this online that were resolved by increasing the heap size, so it can be caused by just about anything. The underlying command line doesn't include a smoking gun for me either.

 

As Andrzej mentioned, I don't know that dynamic plugins are actually well-supported on Windows, so this might be hard to track down without the ability to run a debugger. If you can't build with debug symbols, can you write a step-by-step reproduction procedure so someone else can try, including all the code necessary?

 

- Eric

 

On Wed, Nov 11, 2020 at 8:16 AM Gaier, Bjoern via cfe-dev <[hidden email]> wrote:

Hey Andrzej,

Sadly I can not run it under Linux and also don't have debug symbols enabled (because of disk space issues...)

I'm really confused by this, because the plugin works with opt causing no issues. So.... what is opt doing differently then Clang? >o<

- Björn

-----Original Message-----
From: cfe-dev <[hidden email]> On Behalf Of Andrzej Warzynski via cfe-dev
Sent: 11 November 2020 12:56
To: [hidden email]
Subject: Re: [cfe-dev] Running LLVMHello Pass from Clang(-cl)

Hello Gaier,

This might indicate the root cause:

```
clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
```

However, I have no better suggestion other than investigating with a debugger :/

Btw, have you tried on Linux? Dynamically loaded plugins are not really supported on Windows. Yes, sometimes stuff works, but your mileage will vary. If you test this on Linux and it still fails then at least you will be confident that it's not related to Windows-specific limitations.

-Andrzej

On 11/11/2020 08:16, Gaier, Bjoern via cfe-dev wrote:
> Hello Eric,
>
> I got this now:
>
> D:\Program Files\LLVM_orc_removal\bin>clang-cl.exe -v -Xclang -load
> -Xclang LLVMHello.dll Test.cpp
>
> clang version 12.0.0
>
> Target: x86_64-pc-windows-msvc
>
> Thread model: posix
>
> InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
> "D:\\Program Files\\LLVM_orc_removal\\bin\\clang-cl.exe" -cc1 -triple
> x86_64-pc-windows-msvc19.27.29111 -emit-obj -mrelax-all
> -mincremental-linker-compatible --mrelax-relocations -disable-free
> -main-file-name Test.cpp -mrelocation-model pic -pic-level 2
> -mframe-pointer=none -relaxed-aliasing -fmath-errno -fno-rounding-math
> -mconstructor-aliases -munwind-tables -target-cpu x86-64 -mllvm
> -x86-asm-syntax=intel -tune-cpu generic -D_MT
> -flto-visibility-public-std --dependent-lib=libcmt
> --dependent-lib=oldnames -stack-protector 2 -fms-volatile
> -fdiagnostics-format msvc -v -resource-dir "D:\\Program
>   Files\\LLVM_orc_removal\\lib\\clang\\12.0.0" -internal-isystem
> "D:\\Program Files\\LLVM_orc_removal\\lib\\clang\\12.0.0\\include"
> -internal-isystem "D:\\Program Files (x86)\\Microsoft Visual
> Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.27.29110\\include"
> -internal-isystem "D:\\Program Files (x86)\\Microsoft Visual
> Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.27.29110\\atlmfc\\include"
> -internal-isystem "C:\\Program Files (x86)\\Windows
> Kits\\10\\Include\\10.0.18362.0\\ucrt" -internal-isystem "C:\\Program
> Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\shared"
> -internal-isystem "C:
>
> \\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\um"
> -internal-isystem "C:\\Program Files
> (x86)\\WindowsKits\\10\\include\\10.0.18362.0\\winrt"
> -fdeprecated-macro -fdebug-compilation-dir "D:\\Program Files\\LLVM_orc_removal\\bin"
> -ferror-limit 19 -fmessage-length=120 -fno-use-cxa-atexit
> -fms-extensions -fms-compatibility
> -fms-compatibility-version=19.27.29111 -std=c++14
> -fdelayed-template-parsing -fcolor-diagnostics -load LLVMHello.dll
> -faddrsig -o "C:\\Users\\h16020\\AppData\\Local\\Temp\\Test-f1a523.obj"
> -x c++ Test.cpp
>
> clang-cl: error: clang frontend command failed due to signal (use -v
> to see invocation)
>
> clang version 12.0.0
>
> Target: x86_64-pc-windows-msvc
>
> Thread model: posix
>
> InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
> clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
>
> And here with -Xclang
>
> D:\Program Files\LLVM_orc_removal\bin>clang-cl.exe -Xclang -v -Xclang
> -load -Xclang LLVMHello.dll Test.cpp
>
> clang-cl: error: clang frontend command failed due to signal (use -v
> to see invocation)
>
> clang version 12.0.0
>
> Target: x86_64-pc-windows-msvc
>
> Thread model: posix
>
> InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
> clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
>
> Didn’t told me much óò
>
> Kind greetings
>
> Björn
>
> *From:*Eric Astor <[hidden email]>
> *Sent:* 10 November 2020 14:50
> *To:* Gaier, Bjoern <[hidden email]>
> *Cc:* Clang Dev <[hidden email]>
> *Subject:* Re: [cfe-dev] Running LLVMHello Pass from Clang(-cl)
>
> This line seems critical:
>
>     clang-cl: error: clang frontend command failed due to signal (use -v
>     to see invocation)
>
> Have you tried rerunning with -v? The full invocation might be informative.
>
> Best,
>
> - Eric
>
> On Tue, Nov 10, 2020 at 4:13 AM Gaier, Bjoern via cfe-dev
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Hello everyone,
>
>     I build and run the LLVM (and clang) under Windows. I wanted to dive
>     into the LLVM passes because I see a huge benefit in them for our
>     project. So I made sure to configurate CMAKE with
>     “CLANG_PLUGIN_SUPPORT”, “LLVM_ENABLE_PLUGINS” and
>     “LLVM_EXPORT_SYMBOLS_FOR_PLUGINS”.
>
>     Except one project, everything build fine and I was able to execute
>     “opt.exe” with the LLVMHello.dll – everything worked as expected!
>
>     However, then I tried using the DLL with Clang-Cl because this would
>     be the way how to integrate it to our system. So I used:
>
>     clang-cl.exe -Xclang -load -Xclang LLVMHello.dll Test.cpp
>
>     However, this failed with:
>
>     clang-cl: error: clang frontend command failed due to signal (use -v
>     to see invocation)
>
>     clang version 12.0.0
>
>     Target: x86_64-pc-windows-msvc
>
>     Thread model: posix
>
>     InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
>     clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
>
>     If I remove the loading of LLVMHello.dll it works correctly again. I
>     feel like, that LLVMHello.dll is not finding all the symbols needed.
>     So I linked LLVMHello.dll with “clang.lib” instead of “opt.lib” -
>     but with no success.
>
>     I also read that there are ways to include those passes directly
>     into the source code of Clang, but I hoped to use this dynamic
>     approach instead.
>
>     Any comments, ideas or something about this?
>
>     Kind greetings
>
>     Björn
>
>     Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816,
>     USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr.
>     Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin
>     Cansiz.
>
>     _______________________________________________
>     cfe-dev mailing list
>     [hidden email] <mailto:[hidden email]>
>     https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>     <https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
>
> Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816,
> USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr.
> Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Running LLVMHello Pass from Clang(-cl)

Manas via cfe-dev
In reply to this post by Manas via cfe-dev
Hi Björn

On 11/11/2020 13:15, Gaier, Bjoern wrote:
>
> I'm really confused by this, because the plugin works with opt causing no issues. So.... what is opt doing differently then Clang? >o<
>

Short answer - a lot :)

Long answer: Clang is a complete compiler. It will normally run the
preprocessor, code-gen, middlend, backend/assembler. It consumes a lot
of various input file types (C, C++, Objective-C, Objective-C++,
assembly files, LLVM IR files ...) and can generate almost as many. It
has its own, very complex compiler driver.

Opt is just the middlend. It consumes LLVM IR and generates LLVM IR.
It's much _much_ more basic than Clang. It has it's own basic driver
(i.e. main entry point, command-line options definitions and
processing). It's stand-alone tool independent of Clang.

In terms of the middlend, both Clang and Opt will use similar LLVM
libraries, but will drive them differently. In theory they should behave
similarly, but reality is a bit more complex and nuanced :)

In particular, from your error message it's clear that something goes
wrong within the frontend. However, when using `opt` you completely
bypass the frontend.

I hope that this helps. Sadly this doesn't solve our problem.

-Andrzej

P.S. Apologies for addressing you with your surname earlier. That was
before my morning coffee :)

> - Björn
>
> -----Original Message-----
> From: cfe-dev <[hidden email]> On Behalf Of Andrzej Warzynski via cfe-dev
> Sent: 11 November 2020 12:56
> To: [hidden email]
> Subject: Re: [cfe-dev] Running LLVMHello Pass from Clang(-cl)
>
> Hello Gaier,
>
> This might indicate the root cause:
>
> ```
> clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
> ```
>
> However, I have no better suggestion other than investigating with a debugger :/
>
> Btw, have you tried on Linux? Dynamically loaded plugins are not really supported on Windows. Yes, sometimes stuff works, but your mileage will vary. If you test this on Linux and it still fails then at least you will be confident that it's not related to Windows-specific limitations.
>
> -Andrzej
>
> On 11/11/2020 08:16, Gaier, Bjoern via cfe-dev wrote:
>> Hello Eric,
>>
>> I got this now:
>>
>> D:\Program Files\LLVM_orc_removal\bin>clang-cl.exe -v -Xclang -load
>> -Xclang LLVMHello.dll Test.cpp
>>
>> clang version 12.0.0
>>
>> Target: x86_64-pc-windows-msvc
>>
>> Thread model: posix
>>
>> InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>>
>> "D:\\Program Files\\LLVM_orc_removal\\bin\\clang-cl.exe" -cc1 -triple
>> x86_64-pc-windows-msvc19.27.29111 -emit-obj -mrelax-all
>> -mincremental-linker-compatible --mrelax-relocations -disable-free
>> -main-file-name Test.cpp -mrelocation-model pic -pic-level 2
>> -mframe-pointer=none -relaxed-aliasing -fmath-errno -fno-rounding-math
>> -mconstructor-aliases -munwind-tables -target-cpu x86-64 -mllvm
>> -x86-asm-syntax=intel -tune-cpu generic -D_MT
>> -flto-visibility-public-std --dependent-lib=libcmt
>> --dependent-lib=oldnames -stack-protector 2 -fms-volatile
>> -fdiagnostics-format msvc -v -resource-dir "D:\\Program
>>    Files\\LLVM_orc_removal\\lib\\clang\\12.0.0" -internal-isystem
>> "D:\\Program Files\\LLVM_orc_removal\\lib\\clang\\12.0.0\\include"
>> -internal-isystem "D:\\Program Files (x86)\\Microsoft Visual
>> Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.27.29110\\include"
>> -internal-isystem "D:\\Program Files (x86)\\Microsoft Visual
>> Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.27.29110\\atlmfc\\include"
>> -internal-isystem "C:\\Program Files (x86)\\Windows
>> Kits\\10\\Include\\10.0.18362.0\\ucrt" -internal-isystem "C:\\Program
>> Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\shared"
>> -internal-isystem "C:
>>
>> \\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\um"
>> -internal-isystem "C:\\Program Files
>> (x86)\\WindowsKits\\10\\include\\10.0.18362.0\\winrt"
>> -fdeprecated-macro -fdebug-compilation-dir "D:\\Program Files\\LLVM_orc_removal\\bin"
>> -ferror-limit 19 -fmessage-length=120 -fno-use-cxa-atexit
>> -fms-extensions -fms-compatibility
>> -fms-compatibility-version=19.27.29111 -std=c++14
>> -fdelayed-template-parsing -fcolor-diagnostics -load LLVMHello.dll
>> -faddrsig -o "C:\\Users\\h16020\\AppData\\Local\\Temp\\Test-f1a523.obj"
>> -x c++ Test.cpp
>>
>> clang-cl: error: clang frontend command failed due to signal (use -v
>> to see invocation)
>>
>> clang version 12.0.0
>>
>> Target: x86_64-pc-windows-msvc
>>
>> Thread model: posix
>>
>> InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>>
>> clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
>>
>> And here with -Xclang
>>
>> D:\Program Files\LLVM_orc_removal\bin>clang-cl.exe -Xclang -v -Xclang
>> -load -Xclang LLVMHello.dll Test.cpp
>>
>> clang-cl: error: clang frontend command failed due to signal (use -v
>> to see invocation)
>>
>> clang version 12.0.0
>>
>> Target: x86_64-pc-windows-msvc
>>
>> Thread model: posix
>>
>> InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>>
>> clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
>>
>> Didn’t told me much óò
>>
>> Kind greetings
>>
>> Björn
>>
>> *From:*Eric Astor <[hidden email]>
>> *Sent:* 10 November 2020 14:50
>> *To:* Gaier, Bjoern <[hidden email]>
>> *Cc:* Clang Dev <[hidden email]>
>> *Subject:* Re: [cfe-dev] Running LLVMHello Pass from Clang(-cl)
>>
>> This line seems critical:
>>
>>      clang-cl: error: clang frontend command failed due to signal (use -v
>>      to see invocation)
>>
>> Have you tried rerunning with -v? The full invocation might be informative.
>>
>> Best,
>>
>> - Eric
>>
>> On Tue, Nov 10, 2020 at 4:13 AM Gaier, Bjoern via cfe-dev
>> <[hidden email] <mailto:[hidden email]>> wrote:
>>
>>      Hello everyone,
>>
>>      I build and run the LLVM (and clang) under Windows. I wanted to dive
>>      into the LLVM passes because I see a huge benefit in them for our
>>      project. So I made sure to configurate CMAKE with
>>      “CLANG_PLUGIN_SUPPORT”, “LLVM_ENABLE_PLUGINS” and
>>      “LLVM_EXPORT_SYMBOLS_FOR_PLUGINS”.
>>
>>      Except one project, everything build fine and I was able to execute
>>      “opt.exe” with the LLVMHello.dll – everything worked as expected!
>>
>>      However, then I tried using the DLL with Clang-Cl because this would
>>      be the way how to integrate it to our system. So I used:
>>
>>      clang-cl.exe -Xclang -load -Xclang LLVMHello.dll Test.cpp
>>
>>      However, this failed with:
>>
>>      clang-cl: error: clang frontend command failed due to signal (use -v
>>      to see invocation)
>>
>>      clang version 12.0.0
>>
>>      Target: x86_64-pc-windows-msvc
>>
>>      Thread model: posix
>>
>>      InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>>
>>      clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
>>
>>      If I remove the loading of LLVMHello.dll it works correctly again. I
>>      feel like, that LLVMHello.dll is not finding all the symbols needed.
>>      So I linked LLVMHello.dll with “clang.lib” instead of “opt.lib” -
>>      but with no success.
>>
>>      I also read that there are ways to include those passes directly
>>      into the source code of Clang, but I hoped to use this dynamic
>>      approach instead.
>>
>>      Any comments, ideas or something about this?
>>
>>      Kind greetings
>>
>>      Björn
>>
>>      Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816,
>>      USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr.
>>      Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin
>>      Cansiz.
>>
>>      _______________________________________________
>>      cfe-dev mailing list
>>      [hidden email] <mailto:[hidden email]>
>>      https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>      <https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
>>
>> Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816,
>> USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr.
>> Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
>>
>> _______________________________________________
>> cfe-dev mailing list
>> [hidden email]
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
>
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Running LLVMHello Pass from Clang(-cl)

Manas via cfe-dev
In reply to this post by Manas via cfe-dev

Hey guys,

 

Thank you all for your answers – I try to answer you all in this mail. Big sorry if this causes spam…

 

@Eric:

Luckily there is no code from me involved to reproduce it, because I was starting to learn it. So to reproduce:

  1. Configurate CMAKE with:
  • “CLANG_PLUGIN_SUPPORT”
  • “LLVM_ENABLE_PLUGINS”
  •  “LLVM_EXPORT_SYMBOLS_FOR_PLUGINS”
  • Targeting Windows x64 (VS2019 with the latest Win10 SDK)

 

  1. Build it
  2. Copy the LLVMHello.dll from where it was build to the ‘bin’ directory of the llvm installation. Create a file called “Test.cpp” there and add a simple, empty main there.
  3. Now execute “clang-cl.exe -Xclang -load -Xclang LLVMHello.dll Test.cpp”

 

@Alexandre

Adding -fno-integrated-cc1 Didn’t changed output – when using “-Xclang” it was even unknown

 

@Andrzej 

No worries about my name :’D

Thank you for the explanation! I was so happy having it run with opt that I thought everything would be good now :c

 

Thank you all again ^o^

 

Björn

 

From: Eric Astor <[hidden email]>
Sent: 11 November 2020 14:39
To: Gaier, Bjoern <[hidden email]>
Cc: Andrzej Warzynski <[hidden email]>; Clang Dev <[hidden email]>
Subject: Re: [cfe-dev] Running LLVMHello Pass from Clang(-cl)

 

The "Error generating preprocessed source(s)" message here is from a generic error trap:

 

I've found instances of this online that were resolved by increasing the heap size, so it can be caused by just about anything. The underlying command line doesn't include a smoking gun for me either.

 

As Andrzej mentioned, I don't know that dynamic plugins are actually well-supported on Windows, so this might be hard to track down without the ability to run a debugger. If you can't build with debug symbols, can you write a step-by-step reproduction procedure so someone else can try, including all the code necessary?

 

- Eric

 

On Wed, Nov 11, 2020 at 8:16 AM Gaier, Bjoern via cfe-dev <[hidden email]> wrote:

Hey Andrzej,

Sadly I can not run it under Linux and also don't have debug symbols enabled (because of disk space issues...)

I'm really confused by this, because the plugin works with opt causing no issues. So.... what is opt doing differently then Clang? >o<

- Björn

-----Original Message-----
From: cfe-dev <[hidden email]> On Behalf Of Andrzej Warzynski via cfe-dev
Sent: 11 November 2020 12:56
To: [hidden email]
Subject: Re: [cfe-dev] Running LLVMHello Pass from Clang(-cl)

Hello Gaier,

This might indicate the root cause:

```
clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
```

However, I have no better suggestion other than investigating with a debugger :/

Btw, have you tried on Linux? Dynamically loaded plugins are not really supported on Windows. Yes, sometimes stuff works, but your mileage will vary. If you test this on Linux and it still fails then at least you will be confident that it's not related to Windows-specific limitations.

-Andrzej

On 11/11/2020 08:16, Gaier, Bjoern via cfe-dev wrote:
> Hello Eric,
>
> I got this now:
>
> D:\Program Files\LLVM_orc_removal\bin>clang-cl.exe -v -Xclang -load
> -Xclang LLVMHello.dll Test.cpp
>
> clang version 12.0.0
>
> Target: x86_64-pc-windows-msvc
>
> Thread model: posix
>
> InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
> "D:\\Program Files\\LLVM_orc_removal\\bin\\clang-cl.exe" -cc1 -triple
> x86_64-pc-windows-msvc19.27.29111 -emit-obj -mrelax-all
> -mincremental-linker-compatible --mrelax-relocations -disable-free
> -main-file-name Test.cpp -mrelocation-model pic -pic-level 2
> -mframe-pointer=none -relaxed-aliasing -fmath-errno -fno-rounding-math
> -mconstructor-aliases -munwind-tables -target-cpu x86-64 -mllvm
> -x86-asm-syntax=intel -tune-cpu generic -D_MT
> -flto-visibility-public-std --dependent-lib=libcmt
> --dependent-lib=oldnames -stack-protector 2 -fms-volatile
> -fdiagnostics-format msvc -v -resource-dir "D:\\Program
>   Files\\LLVM_orc_removal\\lib\\clang\\12.0.0" -internal-isystem
> "D:\\Program Files\\LLVM_orc_removal\\lib\\clang\\12.0.0\\include"
> -internal-isystem "D:\\Program Files (x86)\\Microsoft Visual
> Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.27.29110\\include"
> -internal-isystem "D:\\Program Files (x86)\\Microsoft Visual
> Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.27.29110\\atlmfc\\include"
> -internal-isystem "C:\\Program Files (x86)\\Windows
> Kits\\10\\Include\\10.0.18362.0\\ucrt" -internal-isystem "C:\\Program
> Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\shared"
> -internal-isystem "C:
>
> \\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\um"
> -internal-isystem "C:\\Program Files
> (x86)\\WindowsKits\\10\\include\\10.0.18362.0\\winrt"
> -fdeprecated-macro -fdebug-compilation-dir "D:\\Program Files\\LLVM_orc_removal\\bin"
> -ferror-limit 19 -fmessage-length=120 -fno-use-cxa-atexit
> -fms-extensions -fms-compatibility
> -fms-compatibility-version=19.27.29111 -std=c++14
> -fdelayed-template-parsing -fcolor-diagnostics -load LLVMHello.dll
> -faddrsig -o "C:\\Users\\h16020\\AppData\\Local\\Temp\\Test-f1a523.obj"
> -x c++ Test.cpp
>
> clang-cl: error: clang frontend command failed due to signal (use -v
> to see invocation)
>
> clang version 12.0.0
>
> Target: x86_64-pc-windows-msvc
>
> Thread model: posix
>
> InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
> clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
>
> And here with -Xclang
>
> D:\Program Files\LLVM_orc_removal\bin>clang-cl.exe -Xclang -v -Xclang
> -load -Xclang LLVMHello.dll Test.cpp
>
> clang-cl: error: clang frontend command failed due to signal (use -v
> to see invocation)
>
> clang version 12.0.0
>
> Target: x86_64-pc-windows-msvc
>
> Thread model: posix
>
> InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
> clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
>
> Didn’t told me much óò
>
> Kind greetings
>
> Björn
>
> *From:*Eric Astor <[hidden email]>
> *Sent:* 10 November 2020 14:50
> *To:* Gaier, Bjoern <[hidden email]>
> *Cc:* Clang Dev <[hidden email]>
> *Subject:* Re: [cfe-dev] Running LLVMHello Pass from Clang(-cl)
>
> This line seems critical:
>
>     clang-cl: error: clang frontend command failed due to signal (use -v
>     to see invocation)
>
> Have you tried rerunning with -v? The full invocation might be informative.
>
> Best,
>
> - Eric
>
> On Tue, Nov 10, 2020 at 4:13 AM Gaier, Bjoern via cfe-dev
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Hello everyone,
>
>     I build and run the LLVM (and clang) under Windows. I wanted to dive
>     into the LLVM passes because I see a huge benefit in them for our
>     project. So I made sure to configurate CMAKE with
>     “CLANG_PLUGIN_SUPPORT”, “LLVM_ENABLE_PLUGINS” and
>     “LLVM_EXPORT_SYMBOLS_FOR_PLUGINS”.
>
>     Except one project, everything build fine and I was able to execute
>     “opt.exe” with the LLVMHello.dll – everything worked as expected!
>
>     However, then I tried using the DLL with Clang-Cl because this would
>     be the way how to integrate it to our system. So I used:
>
>     clang-cl.exe -Xclang -load -Xclang LLVMHello.dll Test.cpp
>
>     However, this failed with:
>
>     clang-cl: error: clang frontend command failed due to signal (use -v
>     to see invocation)
>
>     clang version 12.0.0
>
>     Target: x86_64-pc-windows-msvc
>
>     Thread model: posix
>
>     InstalledDir: D:\Program Files\LLVM_orc_removal\bin
>
>     clang-cl: note: diagnostic msg: Error generating preprocessed source(s).
>
>     If I remove the loading of LLVMHello.dll it works correctly again. I
>     feel like, that LLVMHello.dll is not finding all the symbols needed.
>     So I linked LLVMHello.dll with “clang.lib” instead of “opt.lib” -
>     but with no success.
>
>     I also read that there are ways to include those passes directly
>     into the source code of Clang, but I hoped to use this dynamic
>     approach instead.
>
>     Any comments, ideas or something about this?
>
>     Kind greetings
>
>     Björn
>
>     Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816,
>     USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr.
>     Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin
>     Cansiz.
>
>     _______________________________________________
>     cfe-dev mailing list
>     [hidden email] <mailto:[hidden email]>
>     https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>     <https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
>
> Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816,
> USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr.
> Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Takashi Nagano, Junichi Tajika, Ergin Cansiz.
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev