Skip to content

Commit 114325b

Browse files
committed
Kaleidoscope-Ch8: use Reloc::PIC_
which has better portability across different OSes. In addition, on many ELF OSes, this output relocatable file can be linked without -no-pie.
1 parent 7ca94a8 commit 114325b

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl08.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,16 @@ To see which features and CPUs that LLVM knows about, we can use
105105
3dnowa - Enable 3DNow! Athlon instructions.
106106
...
107107

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

111111
.. code-block:: c++
112112

113113
auto CPU = "generic";
114114
auto Features = "";
115115

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

120119

121120
Configuring the Module

llvm/examples/Kaleidoscope/Chapter8/toy.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,9 +1242,8 @@ int main() {
12421242
auto Features = "";
12431243

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

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

0 commit comments

Comments
 (0)