From 3107f313f19a921469776ca498b6aaa0984feda0 Mon Sep 17 00:00:00 2001 From: Radu Salavat Date: Thu, 21 Dec 2023 16:37:51 +0200 Subject: [PATCH] [Flang, Clang] Enable and test 'rdynamic' flag (#75598) Enable and test 'rdynamic' flag --- clang/include/clang/Driver/Options.td | 3 ++- flang/test/Driver/dynamic-linker.f90 | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 965d402af2d7b3..2b93ddf033499c 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; +def rdynamic : Flag<["-"], "rdynamic">, Group, + Visibility<[ClangOption, FlangOption]>; def resource_dir : Separate<["-"], "resource-dir">, Flags<[NoXarchOption, HelpHidden]>, Visibility<[ClangOption, CC1Option, CLOption, DXCOption]>, diff --git a/flang/test/Driver/dynamic-linker.f90 b/flang/test/Driver/dynamic-linker.f90 index df119c22a2ea51..1cbd407d21ce09 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=RDYNAMIC-LINKER-OPTION %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" +! 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)?}}" ! MSVC-LINKER-OPTIONS-SAME: "-dll"