[cfe-dev] Running LLVMHello Pass from Clang(-cl)

Alexandre Ganea via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 11 05:50:13 PST 2020


cc the proper mailing list.

De : Alexandre Ganea
Envoyé : November 11, 2020 8:49 AM
À : Eric Astor <eric.astor at gmail.com>; Gaier, Bjoern <Bjoern.Gaier at horiba.com>
Cc : llvm-dev <llvm-dev at lists.llvm.org>
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 <cfe-dev-bounces at lists.llvm.org<mailto:cfe-dev-bounces at lists.llvm.org>> De la part de Eric Astor via cfe-dev
Envoyé : November 11, 2020 8:39 AM
À : Gaier, Bjoern <Bjoern.Gaier at horiba.com<mailto:Bjoern.Gaier at horiba.com>>
Cc : Clang Dev <cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>>
Objet : Re: [cfe-dev] Running LLVMHello Pass from Clang(-cl)

The "Error generating preprocessed source(s)" message here is from a generic error trap:
https://github.com/llvm/llvm-project/blob/ba71a0746f31a2f5f9af992f569a9418133a9a38/clang/lib/Driver/Driver.cpp#L1385

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 <cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>> 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 <cfe-dev-bounces at lists.llvm.org<mailto:cfe-dev-bounces at lists.llvm.org>> On Behalf Of Andrzej Warzynski via cfe-dev
Sent: 11 November 2020 12:56
To: cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>
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<file://Microsoft> Visual
> Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.27.29110\\include"
> -internal-isystem "D:\\Program Files (x86)\\Microsoft<file://Microsoft> Visual
> Studio\\2019\\Professional\\VC\\Tools\\MSVC\\14.27.29110\\atlmfc\\include"
> -internal-isystem "C:\\Program Files (x86)\\Windows<file://Windows>
> Kits\\10\\Include\\10.0.18362.0\\ucrt" -internal-isystem "C:\\Program
> Files (x86)\\Windows<file://Windows> Kits\\10\\include\\10.0.18362.0\\shared"
> -internal-isystem "C:
>
> \\Program<file://Program> Files (x86)\\Windows<file://Windows> Kits\\10\\include\\10.0.18362.0\\um"
> -internal-isystem "C:\\Program Files
> (x86)\\WindowsKits\\10\\include\\10.0.18362.0\\winrt<file://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 <eric.astor at gmail.com<mailto:eric.astor at gmail.com>>
> *Sent:* 10 November 2020 14:50
> *To:* Gaier, Bjoern <Bjoern.Gaier at horiba.com<mailto:Bjoern.Gaier at horiba.com>>
> *Cc:* Clang Dev <cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>>
> *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
> <cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org> <mailto:cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>>> 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
>     cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org> <mailto:cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>>
>     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
> cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>
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
cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20201111/2a524108/attachment-0001.html>


More information about the cfe-dev mailing list