Skip to content

Commit 81802aa

Browse files
committed
[flang][Driver] Enable -pie and -no-pie in flang's driver
Passing -pie to flang will pass the flag on to the linker. Passing -no-pie will ensure that -pie is *not* passed to the linker. This behavior is consistent with both clang and gfortran. Fixes #159970
1 parent 22a10c8 commit 81802aa

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5999,7 +5999,6 @@ def nofixprebinding : Flag<["-"], "nofixprebinding">;
59995999
def nolibc : Flag<["-"], "nolibc">;
60006000
def nomultidefs : Flag<["-"], "nomultidefs">;
60016001
def nopie : Flag<["-"], "nopie">, Visibility<[ClangOption, FlangOption]>, Flags<[TargetSpecific]>; // OpenBSD
6002-
def no_pie : Flag<["-"], "no-pie">, Visibility<[ClangOption, FlangOption]>;
60036002
def noprebind : Flag<["-"], "noprebind">;
60046003
def noprofilelib : Flag<["-"], "noprofilelib">;
60056004
def noseglinkedit : Flag<["-"], "noseglinkedit">;
@@ -6113,7 +6112,6 @@ defm pthread : BoolOption<"", "pthread",
61136112
PosFlag<SetTrue, [], [ClangOption], "Support POSIX threads in generated code">,
61146113
NegFlag<SetFalse>,
61156114
BothFlags<[], [ClangOption, CC1Option, FlangOption, FC1Option]>>;
6116-
def pie : Flag<["-"], "pie">, Group<Link_Group>;
61176115
def static_pie : Flag<["-"], "static-pie">, Group<Link_Group>;
61186116
def read__only__relocs : Separate<["-"], "read_only_relocs">;
61196117
def remap : Flag<["-"], "remap">;
@@ -6508,6 +6506,8 @@ def fpic : Flag<["-"], "fpic">, Group<f_Group>;
65086506
def fno_pic : Flag<["-"], "fno-pic">, Group<f_Group>;
65096507
def fpie : Flag<["-"], "fpie">, Group<f_Group>;
65106508
def fno_pie : Flag<["-"], "fno-pie">, Group<f_Group>;
6509+
def pie : Flag<["-"], "pie">, Group<Link_Group>;
6510+
def no_pie : Flag<["-"], "no-pie">;
65116511

65126512
} // let Vis = [Default, FlangOption]
65136513

flang/test/Driver/misc-flags.f90

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010
! Make sure that `-L' is "visible" to Flang's driver
1111
! RUN: %flang -L/ -### %s
1212

13+
! Check that '-pie' is "visible" to Flang's driver and is passed on to the
14+
! linker.
15+
! RUN: %flang -pie -### %s 2>&1 | FileCheck %s --check-prefix=PIE
16+
! PIE: "-pie"
17+
18+
! Check that '-no-pie' is "visible" to Flang's driver and that "-pie" is *not*
19+
! passed to the linker.
20+
! RUN: %flang -no-pie -### %s 2>&1 | FileCheck %s --check-prefix=NO-PIE
21+
! NO-PIE-NOT: "-pie"
22+
1323
program hello
1424
write(*,*), "Hello world!"
1525
end program hello

0 commit comments

Comments
 (0)