[docs][tutorial] Chapter 4 - JIT Initialization listing gives compilation error
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Considering the listing in Chapter 4 of the Kaleidoscope tutorial that initializes the `static std::unique_ptr theJIT;`:
https://github.com/llvm/llvm-project/blob/0c94a978df783bd67535350eac84088fc482716a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl04.md?plain=1#L280-L282
assuming the `KaleidoscopeJIT.h` header is [this version](https://github.com/llvm/llvm-project/blob/release/22.x/llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h), there is no default constructor, yielding (redacted):
```
[build] FAILED: [code=1] CMakeFiles/Kaleidoscope.dir/main.cpp.o
[build] clang++ -I/home/user/kaleidoscope/include -g -std=gnu++17 -D_GNU_SOURCE -D_GLIBCXX_USE_CXX11_ABI=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -MD -MT CMakeFiles/Kaleidoscope.dir/main.cpp.o -MF CMakeFiles/Kaleidoscope.dir/main.cpp.o.d -o CMakeFiles/Kaleidoscope.dir/main.cpp.o -c /home/user/kaleidoscope/main.cpp
[build] In file included from /home/user/kaleidoscope/main.cpp:6:
[build] In file included from /include/c++/15.3.0/memory:80:
[build] /include/c++/15.3.0/bits/unique_ptr.h:1103:34: error: no matching constructor for initialization of 'llvm::orc::KaleidoscopeJIT'
[build] 1103 | { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
[build] | ^
[build] /home/user/kaleidoscope/main.cpp:666:19: note: in instantiation of function template specialization 'std::make_unique' requested here
[build] 666 | theJIT = std::make_unique();
[build] | ^
[build] /home/user/kaleidoscope/include/KaleidoscopeJIT.h:39:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided
[build] 39 | class KaleidoscopeJIT {
[build] | ^~~~~~~~~~~~~~~
[build] /home/user/kaleidoscope/include/KaleidoscopeJIT.h:52:5: note: candidate constructor not viable: requires 3 arguments, but 0 were provided
[build] 52 | KaleidoscopeJIT(std::unique_ptr ES,
[build] | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] 53 | JITTargetMachineBuilder JTMB, DataLayout DL)
[build] | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] 1 error generated.
[build] ninja: build stopped: subcommand failed.
[proc] The command: cmake --build /home/user/kaleidoscope/build --config Debug --target all -- exited with code: 1
[driver] Build completed: 00:00:07.677
[build] Build finished with exit code 1
```
While it's clear further down that this should be done with `KaleidoscopeJIT::Create()`, in the full implementation:
https://github.com/llvm/llvm-project/blob/0c94a978df783bd67535350eac84088fc482716a/llvm/examples/Kaleidoscope/Chapter4/toy.cpp#L722-L724
the text implies that code compiles at this point, showing expected output, and the listing should reflect the compiling code.
> With just these two changes, let’s see how Kaleidoscope works now!
Contributor guide
Research direction
Start with the Chapter 4 listing in llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl04.md and compare its JIT initialization with llvm/examples/Kaleidoscope/Chapter4/toy.cpp and KaleidoscopeJIT.h. Update the tutorial listing so it uses the compiling initialization shown by the implementation, then verify the Chapter 4 example builds successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100