[clang] [flang] [flang][Driver] Enable -pie and -no-pie in flang's driver (PR #164890)

Daniel Chen via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 27 11:27:56 PDT 2025


DanielCChen wrote:

> Following investigation of the failure of pre-merge CI, I found that the tests were likely to fail on certain platforms. A number of tests have been added that check the behavior of -pie on various platforms.
> 
> @DavidTruby, could you take a look at the Windows tests and see if they look reasonable? They pass for me, but I want to be certain that I have not made any bad assumptions.
> 
> @DanielCChen, @kkwli, could you do the same for AIX?

I got error when applying the patch as
```
> git apply ~/temp/164890.patch
error: patch failed: flang/test/Driver/linker-options.f90:10
error: flang/test/Driver/linker-options.f90: patch does not apply
error: patch failed: flang/test/Driver/linker-options.f90:10
error: flang/test/Driver/linker-options.f90: patch does not apply
```

Even though `flang/test/Driver/misc-flags.f90` is deleted, it still showed up in the patch.
```diff --git a/flang/test/Driver/misc-flags.f90 b/flang/test/Driver/misc-flags.f90
index 61d763c5b64dd..e594c9cb50517 100644
--- a/flang/test/Driver/misc-flags.f90
+++ b/flang/test/Driver/misc-flags.f90
@@ -10,6 +10,16 @@
 ! Make sure that `-L' is "visible" to Flang's driver
 ! RUN: %flang -L/ -### %s

+! Check that '-pie' is "visible" to Flang's driver and is passed on to the
+! linker.
+! RUN: %flang -pie -### %s 2>&1 | FileCheck %s --check-prefix=PIE
+! PIE: "-pie"
+
+! Check that '-no-pie' is "visible" to Flang's driver and that "-pie" is *not*
+! passed to the linker.
+! RUN: %flang -no-pie -### %s 2>&1 | FileCheck %s --check-prefix=NO-PIE
+! NO-PIE-NOT: "-pie"
+
 program hello
   write(*,*), "Hello world!"

```

https://github.com/llvm/llvm-project/pull/164890


More information about the cfe-commits mailing list