Skip to content

Commit

Permalink
Kaleidoscope-Ch8: use Reloc::PIC_
Browse files Browse the repository at this point in the history
which has better portability across different OSes.
In addition, on many ELF OSes, this output relocatable file can be
linked without -no-pie.
  • Loading branch information
MaskRay committed Dec 6, 2023
1 parent 7ca94a8 commit 114325b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 3 additions & 4 deletions llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl08.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,16 @@ To see which features and CPUs that LLVM knows about, we can use
3dnowa - Enable 3DNow! Athlon instructions.
...

For our example, we'll use the generic CPU without any additional
features, options or relocation model.
For our example, we'll use the generic CPU without any additional feature or
target option.

.. code-block:: c++

auto CPU = "generic";
auto Features = "";

TargetOptions opt;
auto RM = std::optional<Reloc::Model>();
auto TargetMachine = Target->createTargetMachine(TargetTriple, CPU, Features, opt, RM);
auto TargetMachine = Target->createTargetMachine(TargetTriple, CPU, Features, opt, Reloc::PIC_);


Configuring the Module
Expand Down
5 changes: 2 additions & 3 deletions llvm/examples/Kaleidoscope/Chapter8/toy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1242,9 +1242,8 @@ int main() {
auto Features = "";

TargetOptions opt;
auto RM = std::optional<Reloc::Model>();
auto TheTargetMachine =
Target->createTargetMachine(TargetTriple, CPU, Features, opt, RM);
auto TheTargetMachine = Target->createTargetMachine(
TargetTriple, CPU, Features, opt, Reloc::PIC_);

TheModule->setDataLayout(TheTargetMachine->createDataLayout());

Expand Down

0 comments on commit 114325b

Please sign in to comment.