[flang] [clang] [Flang, Clang] Enable and test 'rdynamic' flag (PR #75598)
Radu Salavat via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 20 05:29:38 PST 2023
https://github.com/Radu2k updated https://github.com/llvm/llvm-project/pull/75598
>From 6180787f9bc9449ce90999c3c5f9c96cfd057a50 Mon Sep 17 00:00:00 2001
From: Radu2k <radu.salavat at arm.com>
Date: Fri, 15 Dec 2023 12:11:04 +0000
Subject: [PATCH 1/3] Enable and test 'rdynamic' flag
---
clang/include/clang/Driver/Options.td | 3 ++-
flang/test/Driver/rdynamic-check.f90 | 10 ++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
create mode 100644 flang/test/Driver/rdynamic-check.f90
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 1b02087425b751..9678165bfd98e8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5308,7 +5308,8 @@ def rewrite_objc : Flag<["-"], "rewrite-objc">, Flags<[NoXarchOption]>,
def rewrite_legacy_objc : Flag<["-"], "rewrite-legacy-objc">,
Flags<[NoXarchOption]>,
HelpText<"Rewrite Legacy Objective-C source to C++">;
-def rdynamic : Flag<["-"], "rdynamic">, Group<Link_Group>;
+def rdynamic : Flag<["-"], "rdynamic">, Group<Link_Group>,
+ Visibility<[ClangOption, FlangOption]>;
def resource_dir : Separate<["-"], "resource-dir">,
Flags<[NoXarchOption, HelpHidden]>,
Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>,
diff --git a/flang/test/Driver/rdynamic-check.f90 b/flang/test/Driver/rdynamic-check.f90
new file mode 100644
index 00000000000000..6892d8ac67f212
--- /dev/null
+++ b/flang/test/Driver/rdynamic-check.f90
@@ -0,0 +1,10 @@
+! Verify that rdynamic flag adds -export-dynamic flag and passes it on to the linker.
+
+! RUN: %flang -### --target=x86_64-linux-gnu -rdynamic %s 2>&1 | FileCheck --check-prefixes=GNU-LINKER-OPTIONS %s
+! RUN: %flang -### --target=aarch64-linux-none -rdynamic %s 2>&1 | FileCheck --check-prefixes=AARCH-LINKER-OPTIONS %s
+
+! GNU-LINKER-OPTIONS: "{{.*}}ld"
+! GNU-LINKER-OPTIONS-SAME: "-export-dynamic"
+
+! AARCH-LINKER-OPTIONS: "{{.*}}ld"
+! AARCH-LINKER-OPTIONS-SAME: "-export-dynamic"
>From e2990df14e2432f9e607d0431e2bb4e97dba24b8 Mon Sep 17 00:00:00 2001
From: Radu2k <radu.salavat at arm.com>
Date: Tue, 19 Dec 2023 09:00:40 +0000
Subject: [PATCH 2/3] Remove dedicated test file
---
flang/test/Driver/dynamic-linker.f90 | 4 ++++
flang/test/Driver/rdynamic-check.f90 | 10 ----------
2 files changed, 4 insertions(+), 10 deletions(-)
delete mode 100644 flang/test/Driver/rdynamic-check.f90
diff --git a/flang/test/Driver/dynamic-linker.f90 b/flang/test/Driver/dynamic-linker.f90
index df119c22a2ea51..5958ee624f836f 100644
--- a/flang/test/Driver/dynamic-linker.f90
+++ b/flang/test/Driver/dynamic-linker.f90
@@ -7,6 +7,7 @@
! RUN: %flang -### --target=x86_64-windows-msvc -rpath /path/to/dir -shared \
! RUN: -static %s 2>&1 | FileCheck \
! RUN: --check-prefixes=MSVC-LINKER-OPTIONS %s
+! RUN: %flang -### --target=aarch64-linux-none -rdynamic %s 2>&1 | FileCheck --check-prefixes=AARCH-LINKER-OPTIONS %s
! TODO: Could the linker have an extension or a suffix?
! GNU-LINKER-OPTIONS: "{{.*}}ld{{(.exe)?}}"
@@ -14,6 +15,9 @@
! GNU-LINKER-OPTIONS-SAME: "-static"
! GNU-LINKER-OPTIONS-SAME: "-rpath" "/path/to/dir"
+! AARCH-LINKER-OPTIONS: "{{.*}}ld"
+! AARCH-LINKER-OPTIONS-SAME: "-export-dynamic"
+
! For MSVC, adding -static does not add any additional linker options.
! MSVC-LINKER-OPTIONS: "{{.*}}link{{(.exe)?}}"
! MSVC-LINKER-OPTIONS-SAME: "-dll"
diff --git a/flang/test/Driver/rdynamic-check.f90 b/flang/test/Driver/rdynamic-check.f90
deleted file mode 100644
index 6892d8ac67f212..00000000000000
--- a/flang/test/Driver/rdynamic-check.f90
+++ /dev/null
@@ -1,10 +0,0 @@
-! Verify that rdynamic flag adds -export-dynamic flag and passes it on to the linker.
-
-! RUN: %flang -### --target=x86_64-linux-gnu -rdynamic %s 2>&1 | FileCheck --check-prefixes=GNU-LINKER-OPTIONS %s
-! RUN: %flang -### --target=aarch64-linux-none -rdynamic %s 2>&1 | FileCheck --check-prefixes=AARCH-LINKER-OPTIONS %s
-
-! GNU-LINKER-OPTIONS: "{{.*}}ld"
-! GNU-LINKER-OPTIONS-SAME: "-export-dynamic"
-
-! AARCH-LINKER-OPTIONS: "{{.*}}ld"
-! AARCH-LINKER-OPTIONS-SAME: "-export-dynamic"
>From 524e92b5fdfee329ada30cdb2adabf7b088ffaa8 Mon Sep 17 00:00:00 2001
From: Radu2k <radu.salavat at arm.com>
Date: Wed, 20 Dec 2023 13:26:03 +0000
Subject: [PATCH 3/3] Change test prefix to 'RDYNAMIC'
---
flang/test/Driver/dynamic-linker.f90 | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/flang/test/Driver/dynamic-linker.f90 b/flang/test/Driver/dynamic-linker.f90
index 5958ee624f836f..1cbd407d21ce09 100644
--- a/flang/test/Driver/dynamic-linker.f90
+++ b/flang/test/Driver/dynamic-linker.f90
@@ -7,7 +7,7 @@
! RUN: %flang -### --target=x86_64-windows-msvc -rpath /path/to/dir -shared \
! RUN: -static %s 2>&1 | FileCheck \
! RUN: --check-prefixes=MSVC-LINKER-OPTIONS %s
-! RUN: %flang -### --target=aarch64-linux-none -rdynamic %s 2>&1 | FileCheck --check-prefixes=AARCH-LINKER-OPTIONS %s
+! RUN: %flang -### --target=aarch64-linux-none -rdynamic %s 2>&1 | FileCheck --check-prefixes=RDYNAMIC-LINKER-OPTION %s
! TODO: Could the linker have an extension or a suffix?
! GNU-LINKER-OPTIONS: "{{.*}}ld{{(.exe)?}}"
@@ -15,8 +15,8 @@
! GNU-LINKER-OPTIONS-SAME: "-static"
! GNU-LINKER-OPTIONS-SAME: "-rpath" "/path/to/dir"
-! AARCH-LINKER-OPTIONS: "{{.*}}ld"
-! AARCH-LINKER-OPTIONS-SAME: "-export-dynamic"
+! RDYNAMIC-LINKER-OPTION: "{{.*}}ld"
+! RDYNAMIC-LINKER-OPTION-SAME: "-export-dynamic"
! For MSVC, adding -static does not add any additional linker options.
! MSVC-LINKER-OPTIONS: "{{.*}}link{{(.exe)?}}"
More information about the cfe-commits
mailing list