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

Gaier, Bjoern via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 11 00:16:36 PST 2020


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 <eric.astor at gmail.com>
Sent: 10 November 2020 14:50
To: Gaier, Bjoern <Bjoern.Gaier at horiba.com>
Cc: Clang Dev <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>> 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>
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20201111/abb77c08/attachment-0001.html>


More information about the cfe-dev mailing list