[PATCH] D131533: [Flang][Driver] Enable PIC in the frontend

Usman Nadeem via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 17 16:42:34 PDT 2022


mnadeem marked 9 inline comments as done.
mnadeem added inline comments.


================
Comment at: flang/lib/Frontend/CompilerInvocation.cpp:151
+static llvm::Reloc::Model getRelocationFromName(llvm::StringRef model) {
+  if (model.equals("static"))
+    return llvm::Reloc::Static;
----------------
MaskRay wrote:
> awarzynski wrote:
> > Only `-fpic` and `-fpie` are tested/supported right? Please, could you trim this accordingly? Or, alternatively, expand the test.
> Prefer `==` to `equals`
Using llvm::StringSwitch now


================
Comment at: flang/lib/Frontend/CompilerInvocation.cpp:151-162
+  if (model.equals("static"))
+    return llvm::Reloc::Static;
+  if (model.equals("pic"))
+    return llvm::Reloc::PIC_;
+  if (model.equals("dynamic-no-pic"))
+    return llvm::Reloc::DynamicNoPIC;
+  if (model.equals("ropi"))
----------------
mnadeem wrote:
> MaskRay wrote:
> > awarzynski wrote:
> > > Only `-fpic` and `-fpie` are tested/supported right? Please, could you trim this accordingly? Or, alternatively, expand the test.
> > Prefer `==` to `equals`
> Using llvm::StringSwitch now
Added more tests.


================
Comment at: flang/lib/Frontend/FrontendActions.cpp:532
+  // Set PIC/PIE level LLVM module flags.
+  if (auto PICLevel = ci.getInvocation().getFrontendOpts().PICLevel)
+    llvmModule->setPICLevel(*PICLevel);
----------------
MaskRay wrote:
> expand `auto`
Changed the data type and logic.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131533/new/

https://reviews.llvm.org/D131533



More information about the cfe-commits mailing list