[PATCH] D128333: [clang][flang] Disable defaulting to `-fpie` for LLVM Flang
Andrzej Warzynski via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 28 07:47:07 PDT 2022
awarzynski added a comment.
In D128333#3613696 <https://reviews.llvm.org/D128333#3613696>, @MaskRay wrote:
> True. If it is difficult to override the -pie default from flang side, I am fine with the code change.
Thanks! The proper/long-term fix will require extending Flang's frontend driver so that it supports `-mrelocation-model`, `-fpic` and `-fpic-level` (and probably a few more). But I don't want to rush that.
>>> (Why does flang use clang/lib/Driver? For clang developers, it seems that `check-clang check-clang-tools` is not sufficient. `check-flang` needs to be used as well.)
>> Otherwise, we'd have to re-implement clang/lib/Driver for LLVM Flang. This design was proposed and discussed here <https://lists.llvm.org/pipermail/cfe-dev/2019-June/062669.html>.
> OK, so you did bring this up. I guess I'll have to accept...
With clangDriver <https://github.com/llvm/llvm-project/blob/be4b40d5bc6c1449090ff102e5f23254fd535cd4/clang/lib/Driver/CMakeLists.txt#L15-L96> being effectively shared between Clang and Flang, it would make a lot of sense to lift `clangDriver` out of Clang so that it's an independent sub-project. We've proposed that and folks have been mostly in favor. Relevant RFCs:
- RFC: refactoring libclangDriver/libclangFrontend to share with Flang <https://lists.llvm.org/pipermail/cfe-dev/2020-July/066393.html>
- RFC: refactoring clangDriver - diagnostics classes <https://lists.llvm.org/pipermail/cfe-dev/2020-November/067263.html>
Not much is really happening in this area ATM, but I'm hoping that https://discourse.llvm.org/t/rfc-improving-clang-s-diagnostics could unblock some progress.
Comment at: flang/test/Driver/no-pie.f90:3
+! RUN COMMANDS
> The `! RUN COMMANDS` and `EXPECTED OUTPUT` comments seem rather redundant. I'd remove them.
This style is quite common in this directory, see e.g. https://github.com/llvm/llvm-project/blob/main/flang/test/Driver/emit-asm-aarch64.f90. I'm hoping that this makes these tests easier to follow for folks less familiar with LIT in general.
If that's OK, I'll leave this here (but I don't expect others to follow similar approach, IMO it's a matter of personal preference).
Comment at: flang/test/Driver/no-pie.f90:11
+! CHECK-NOT: fpie
+! CHECK-NOT: fpic
> This NOT pattern can easily get stale. You need a test that driver `-pie` forwards `-pie` to the linker and by default `-pie` does not pass the the linker.
Good point, will update!
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
More information about the cfe-commits