3

opt command not working for CLANG compiler, installed CLANG and LLVM, after I ran

clang++ -emit-llvm -S test.cpp -o prog.ll

it is working well and good but once I tried running the 'opt'

opt --dot-cfg prog.ll

I am getting the error as

'opt' is not recognized as an internal or external command,
operable program or batch file.'
pinkfloydx33
  • 11,863
  • 3
  • 46
  • 63
Anand
  • 37
  • 3
  • What platform are you on? What's your `clang` version? – Zoso May 04 '21 at 08:19
  • check if opt is indeed installed then check if its path is in `PATH` – bolov May 04 '21 at 08:51
  • Clang version is 10.0.0, LLVM version is 12 and platform is Windows – Anand May 04 '21 at 09:44
  • Whatever you installed provided clang, but not opt, or provided opt in a location that's not in your PATH. You didn't specify either precisely what you installed, where you installed it or what your PATH is, so reproducing this would be tricky indeed. – arnt May 04 '21 at 10:16
  • I don't quite understand what you mean by LLVM version is 12 but Clang is 10. Could you add what/how you installed the LLVM toolchain and how are you obtaining those versions? Also, if you installed the toolchain from [here](https://github.com/llvm/llvm-project/releases/tag/llvmorg-12.0.0)(`LLVM-12.0.0-win64.exe`), surprisingly it doesn't ship with an `opt` tool. – Zoso May 04 '21 at 11:21
  • a. We have to install LLVM from LLVM Download Page. b. ‘Pre-Built Binaries’ and download Windows (64-bit) .sig and install it. c. To compile the Open x64 Native tools Command prompt for VS … d. Under CMD we have to “cd” to project folder. f. To create new file we have to type in ‘echo > file name .c’ g. Open the file in any editor and write the code. h. To check code from MS CL compiler ‘cl file_name .c’ if it runs without any error i. To build the same code in CLANG type in the following command clang -std=c17 -Wall -pedantic test.c – Anand May 04 '21 at 11:25
  • LLVM version means I had downloaded the LLVM of certain version from the website, Kindly refer the link from which I have downloaded https://releases.llvm.org/download.html#12.0.0 – Anand May 04 '21 at 12:12
  • Please don't add details in comments. Instead [edit] the question to include that information. – cigien May 04 '21 at 23:41

0 Answers0