[PATCH] D128333: [clang][flang] Disable defaulting to `-fpie` for LLVM Flang

Andrzej Warzynski via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 22 04:47:07 PDT 2022


awarzynski added a comment.

In D128333#3601299 <https://reviews.llvm.org/D128333#3601299>, @kiranchandramohan wrote:

> Is the longer-term plan to support this in Flang as well?

I don't see why not. AFAIK, the switch in Clang took a while and happened gradually - so we probably shouldn't rush this in Flang. We'd also need to check the behavior in `gfortran` (so that we maintain consistency).

> Does this affect building object files too or is it just the executable?

Just the executable.

AFAIK, `isPIEDefault` is only used in tools::ParsePICArgs <https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/CommonArgs.cpp#L1208> . In Flang, we don't support any of `-fpic/-fPIC/-fpie/-fPIE`. And `CLANG_DEFAULT_PIE_ON_LINUX` leads to `-fpie` being added by default to the final linker invocation (when generating the executable). But that doesn't make sense if the object files were generated with `-fpic`. Hence the change.

> How would this affect mixed C++/Fortran programs if the Clang and Flang settings are different?

Good question! We've not experimented with mixed C++/Fortran programs enough, so I don't have an answer. But we should probably create a GitHub ticket to restore consistency between Clang and Flang.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128333



More information about the cfe-commits mailing list