[flang-commits] [clang] [flang] [Flang, Clang] Enable and test 'rdynamic' flag (PR #75598)

Radu Salavat via flang-commits flang-commits at lists.llvm.org
Fri Dec 15 04:37:02 PST 2023


https://github.com/Radu2k created https://github.com/llvm/llvm-project/pull/75598

Enable and test 'rdynamic' flag

>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] 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"



More information about the flang-commits mailing list