Skip to content

Commit 7d8c2e1

Browse files
authored
Merge pull request #13162 from ggouaillardet/topic/v5.0.x/flang_darwin
2 parents 9536ec4 + b633b4e commit 7d8c2e1

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

autogen.pl

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,10 @@ sub patch_autotools_output {
867867
verbose "$indent_str"."Patching \"-pthread\" option for NAG compiler in ltmain.sh\n";
868868
system("$patch_prog -N -p0 < $topdir/config/ltmain_nag_pthread.diff >/dev/null 2>&1");
869869
unlink("config/ltmain.sh.rej");
870+
871+
verbose "$indent_str"."Patching \"-framework\" option for flang compiler in ltmain.sh\n";
872+
system("$patch_prog -N -p0 < $topdir/config/ltmain_flang_darwin.diff >/dev/null 2>&1");
873+
unlink("config/ltmain.sh.rej");
870874
}
871875

872876
# If there's no configure script, there's nothing else to do.
@@ -1053,8 +1057,14 @@ sub patch_autotools_output {
10531057
lt_prog_compiler_static_FC=\'-Bstatic\'
10541058
;;';
10551059
$replace_string = "case \$cc_basename in
1060+
flang*)
1061+
# flang compiler
1062+
lt_prog_compiler_wl_FC='-Wl,'
1063+
lt_prog_compiler_pic_FC='-fPIC'
1064+
lt_prog_compiler_static_FC='-static'
1065+
;;
10561066
icc* | ifort*)
1057-
#Intel Fortran compiler
1067+
# Intel Fortran compiler
10581068
lt_prog_compiler_wl_FC='-Wl,'
10591069
lt_prog_compiler_pic_FC='-fno-common -PIC'
10601070
lt_prog_compiler_static_FC=''
@@ -1091,6 +1101,23 @@ sub patch_autotools_output {
10911101
$c =~ s/$search_string/$replace_string/g;
10921102
}
10931103

1104+
$search_string = 'case \$cc_basename in
1105+
ifort\*\|nagfor\*\) _lt_dar_can_shared=yes ;;
1106+
\*\) _lt_dar_can_shared=\$GCC ;;
1107+
esac';
1108+
$replace_string = "case \$cc_basename in
1109+
flang*|ifort*|nagfor*) _lt_dar_can_shared=yes ;;
1110+
*) _lt_dar_can_shared=\$GCC ;;
1111+
esac";
1112+
push(@verbose_out, $indent_str . "Patching configure for flang compiler on Darwin (FC)\n");
1113+
$c =~ s/$search_string/$replace_string/g;
1114+
1115+
$search_string = 'archive_cmds_FC="\\\\\\$CC -dynamiclib';
1116+
$replace_string = 'archive_cmds_FC="\$CC --shared';
1117+
push(@verbose_out, $indent_str . "Patching configure for flang compiler on Darwin (FC)\n");
1118+
$c =~ s/$search_string/$replace_string/g;
1119+
$c =~ s/(archive_cmds_FC.*)-install_name \\\$rpath/$1-Wl,-install_name,\\\`echo \\\$rpath | sed \'s%^[ ]*%%\'\\\`/g;
1120+
10941121
# Only write out verbose statements and a new configure if the
10951122
# configure content actually changed
10961123
return

config/ltmain_flang_darwin.diff

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--- config/ltmain.sh 2025-03-25 11:32:01
2+
+++ config/ltmain.sh 2025-03-25 11:36:23
3+
@@ -9023,7 +9023,14 @@
4+
compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
5+
finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
6+
else
7+
- compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8+
+ case $host in
9+
+ *-*-darwin*)
10+
+ case $CC in
11+
+ flang*) compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -Wl,-framework,\1%g'`;;
12+
+ *) compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`;;
13+
+ esac;;
14+
+ *) compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`;;
15+
+ esac
16+
fi
17+
fi
18+
dependency_libs=$newdependency_libs
19+
@@ -9367,7 +9374,7 @@
20+
verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
21+
# On Darwin other compilers
22+
case $CC in
23+
- nagfor*)
24+
+ flang*|nagfor*)
25+
verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
26+
;;
27+
*)
28+
@@ -9867,7 +9874,10 @@
29+
# Time to change all our "foo.ltframework" stuff back to "-framework foo"
30+
case $host in
31+
*-*-darwin*)
32+
- newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
33+
+ case $CC in
34+
+ flang*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -Wl,-framework,\1%g'`;;
35+
+ *) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`;;
36+
+ esac
37+
new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
38+
deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
39+
;;

0 commit comments

Comments
 (0)