Skip to content

Commit 3f79259

Browse files
committed
Add more tests for the defaults and expected behavior on a range of platforms
1 parent 94722a3 commit 3f79259

File tree

1 file changed

+86
-6
lines changed

1 file changed

+86
-6
lines changed

flang/test/Driver/linker-options.f90

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

13+
! ------------------------------------------------------------------------------
1314
! Check that '-pie' and '-no-pie' are "visible" to Flang's driver. Check that
14-
! the correct option is added to the link line. The default is '-pie'.
15-
! RUN: %flang -### %s 2>&1 | FileCheck %s --check-prefix=PIE
16-
! RUN: %flang -pie -### %s 2>&1 | FileCheck %s --check-prefix=PIE
17-
! RUN: %flang -no-pie -### %s 2>&1 | FileCheck %s --check-prefix=NO-PIE
18-
! RUN: %flang -pie -no-pie -### %s 2>&1 | FileCheck %s --check-prefix=NO-PIE
19-
! RUN: %flang -no-pie -pie -### %s 2>&1 | FileCheck %s --check-prefix=PIE
15+
! the correct option is added to the link line.
16+
!
17+
! Last match "wins"
18+
! RUN: %flang -target x86_64-pc-linux-gnu -pie -no-pie -### %s 2>&1 \
19+
! RUN: | FileCheck %s --check-prefix=NO-PIE
20+
! RUN: %flang -target x86_64-pc-linux-gnu -no-pie -pie -### %s 2>&1 \
21+
! RUN: | FileCheck %s --check-prefix=PIE
22+
! RUN: %flang -target x86_64-pc-linux-gnu -pie -### %s 2>&1 \
23+
! RUN: | FileCheck %s --check-prefix=PIE
24+
! RUN: %flang -target x86_64-pc-linux-gnu -no-pie -### %s 2>&1 \
25+
! RUN: | FileCheck %s --check-prefix=NO-PIE
26+
!
27+
! Ensure that "-pie" is passed to the linker.
28+
! RUN: %flang -target i386-unknown-freebsd -pie -### %s 2>&1 \
29+
! RUN: | FileCheck %s --check-prefix=PIE
30+
! RUN: %flang -target aarch64-pc-linux-gnu -pie -### %s 2>&1 \
31+
! RUN: | FileCheck %s --check-prefix=PIE
32+
!
33+
! On Musl Linux, PIE is enabled by default, but can be disabled.
34+
! RUN: %flang -target x86_64-linux-musl -### %s 2>&1 \
35+
! RUN: | FileCheck %s --check-prefix=PIE
36+
! RUN: %flang -target i686-linux-musl -### %s 2>&1 \
37+
! RUN: | FileCheck %s --check-prefix=PIE
38+
! RUN: %flang -target armv6-linux-musleabihf %s -### 2>&1 \
39+
! RUN: | FileCheck %s --check-prefix=PIE
40+
! RUN: %flang -target armv7-linux-musleabihf %s -### 2>&1 \
41+
! RUN: | FileCheck %s --check-prefix=PIE
42+
! RUN: %flang --target=x86_64-linux-musl -no-pie -### 2>&1 \
43+
! RUN: | FileCheck %s --check-prefix=NO-PIE
44+
!
45+
! On OpenBSD, -pie is not passed to the linker, but can be forced.
46+
! RUN: %flang -target amd64-pc-openbsd -### %s 2>&1 \
47+
! RUN: | FileCheck %s --check-prefix=NO-PIE
48+
! RUN: %flang -target i386-pc-openbsd -### %s 2>&1 \
49+
! RUN: | FileCheck %s --check-prefix=NO-PIE
50+
! RUN: %flang -target aarch64-unknown-openbsd -### %s 2>&1 \
51+
! RUN: | FileCheck %s --check-prefix=NO-PIE
52+
! RUN: %flang -target arm-unknown-openbsd -### %s 2>&1 \
53+
! RUN: | FileCheck %s --check-prefix=NO-PIE
54+
! RUN: %flang -target powerpc-unknown-openbsd -### %s 2>&1 \
55+
! RUN: | FileCheck %s --check-prefix=NO-PIE
56+
! RUN: %flang -target sparc64-unknown-openbsd -### %s 2>&1 \
57+
! RUN: | FileCheck %s --check-prefix=NO-PIE
58+
! RUN: %flang -target i386-pc-openbsd -pie -### %s 2>&1 \
59+
! RUN: | FileCheck %s --check-prefix=PIE
60+
!
61+
! On FreeBSD, -pie is not passed to the linker, but can be forced.
62+
! RUN: %flang -target amd64-pc-freebsd -### %s 2>&1 \
63+
! RUN: | FileCheck %s --check-prefix=NO-PIE
64+
! RUN: %flang -target i386-pc-freebsd -### %s 2>&1 \
65+
! RUN: | FileCheck %s --check-prefix=NO-PIE
66+
! RUN: %flang -target aarch64-unknown-freebsd -### %s 2>&1 \
67+
! RUN: | FileCheck %s --check-prefix=NO-PIE
68+
! RUN: %flang -target arm-unknown-freebsd -### %s 2>&1 \
69+
! RUN: | FileCheck %s --check-prefix=NO-PIE
70+
! RUN: %flang -target powerpc-unknown-freebsd -### %s 2>&1 \
71+
! RUN: | FileCheck %s --check-prefix=NO-PIE
72+
! RUN: %flang -target sparc64-unknown-freebsd -### %s 2>&1 \
73+
! RUN: | FileCheck %s --check-prefix=NO-PIE
74+
! RUN: %flang -target i386-pc-freebsd -pie -### %s 2>&1 \
75+
! RUN: | FileCheck %s --check-prefix=PIE
76+
!
77+
! On AIX, -pie is never passed to the linker.
78+
! RUN: %flang -target powerpc64-unknown-aix -### %s 2>&1 \
79+
! RUN: | FileCheck %s --check-prefix=NO-PIE
80+
! RUN: %flang -target powerpc64-unknown-aix -pie -### %s 2>&1 \
81+
! RUN: | FileCheck %s --check-prefix=NO-PIE
82+
! RUN: %flang -target powerpc64-unknown-aix -no-pie -### %s 2>&1 \
83+
! RUN: | FileCheck %s --check-prefix=NO-PIE
84+
!
85+
! On MinGW and Windows, -pie may be specified, but it is ignored.
86+
! RUN: %flang -target aarch64-pc-windows-gnu -### %s 2>&1 \
87+
! RUN: | FileCheck %s --check-prefix=NO-PIE
88+
! RUN: %flang -target x86_64-pc-windows-gnu -pie -### %s 2>&1 \
89+
! RUN: | FileCheck %s --check-prefix=NO-PIE
90+
! RUN: %flang -target i686-pc-windows-gnu -no-pie -### %s 2>&1 \
91+
! RUN: | FileCheck %s --check-prefix=NO-PIE
92+
! RUN: %flang -target aarch64-windows-msvc -### %s 2>&1 \
93+
! RUN: | FileCheck %s --check-prefix=NO-PIE
94+
! RUN: %flang -target aarch64-windows-msvc -pie -### %s 2>&1 \
95+
! RUN: | FileCheck %s --check-prefix=NO-PIE
96+
! RUN: %flang -target aarch64-windows-msvc -no-pie -### %s 2>&1 \
97+
! RUN: | FileCheck %s --check-prefix=NO-PIE
98+
!
2099
! PIE: "-pie"
21100
! NO-PIE-NOT: "-pie"
101+
! ------------------------------------------------------------------------------
22102

23103
program hello
24104
write(*,*), "Hello world!"

0 commit comments

Comments
 (0)