Add support for -weak_framework linking on Darwin
Sebastian Dröge <[email protected]>
| Newsgroups | gmane.comp.gnu.libtool.patches |
|---|---|
| Message-ID | <[email protected]> |
Hi, please see attached patch to add support for -weak-framework linking on Darwin. It replicates the logic that is already there for -framework. -weak_framework allows linking to a Framework without having a strong dependency on it at runtime. If the Framework is not there at runtime, all its symbols are going to be NULL. I'm not sure if the patch is 100% correct, please review. It works for me in a project which fails to link otherwise as the dependency_libs / inherited linker flags are not containing the -weak_frameworks but only the -frameworks. Best regards, -- Sebastian Dröge, Centricular Ltd · http://www.centricular.com
0001-Add-support-for-weak_framework-linking-on-Darwin.patch
(text/x-patch, 4.3 KB)
From d359712db85c74a5d63f9da0e2de21e07c2b4a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <[email protected]> Date: Wed, 22 Oct 2014 12:51:52 +0200 Subject: [PATCH] Add support for -weak_framework linking on Darwin --- build-aux/ltmain.in | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in index 65b5a2d..7740a38 100644 --- a/build-aux/ltmain.in +++ b/build-aux/ltmain.in @@ -4749,6 +4749,19 @@ func_mode_link () prev= continue ;; + weak_framework) + case $host in + *-*-darwin*) + case "$deplibs " in + *" $qarg.ltweak_framework "*) ;; + *) func_append deplibs " $qarg.ltweak_framework" # this is fixed later + ;; + esac + ;; + esac + prev= + continue + ;; inst_prefix) inst_prefix_dir=$arg prev= @@ -4988,6 +5001,11 @@ func_mode_link () continue ;; + -weak_framework) + prev=weak_framework + continue + ;; + -inst-prefix-dir) prev=inst_prefix continue @@ -5712,7 +5730,7 @@ func_mode_link () continue fi ;; # -l - *.ltframework) + *.ltframework | *.ltweak_framework) if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" @@ -5727,6 +5745,7 @@ func_mode_link () fi continue ;; + -L*) case $linkmode in lib) @@ -5882,7 +5901,7 @@ func_mode_link () # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then - tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` + tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g' | $SED 's/-weak_framework \([^ $]*\)/\1.ltweak_framework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; @@ -5890,7 +5909,7 @@ func_mode_link () esac done fi - dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g' | $SED 's% \([^ $]*\).ltweak_framework% -weak_framework \1%g'` if test lib,link = "$linkmode,$pass" || test prog,scan = "$linkmode,$pass" || { test prog != "$linkmode" && test lib != "$linkmode"; }; then @@ -6564,7 +6583,7 @@ func_mode_link () compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else - compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g' | $SED 's% \([^ $]*\).ltweak_framework% -weak_framework \1%g'` fi fi dependency_libs=$newdependency_libs @@ -7472,8 +7491,8 @@ EOF case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g' | $SED 's% \([^ $]*\).ltweak_framework% -weak_framework \1%g'` + deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g' | $SED 's% \([^ $]*\).ltweak_framework% -weak_framework \1%g'` ;; esac @@ -8203,8 +8222,8 @@ EOF esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" - compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` - finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` + compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g' | $SED 's% \([^ $]*\).ltweak_framework% -weak_framework \1%g'` + finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g' | $SED 's% \([^ $]*\).ltweak_framework% -weak_framework \1%g'` ;; esac -- 2.1.1
signature.asc
(application/pgp-signature, 949 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQJ8BAABCgBmBQJUR49LXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ3RjRCQzdDQzNDQTA2Rjk3MzM2QkJGRUIw NjY4Q0MxNDg2QzJEN0I1AAoJEAZozBSGwte16PUQANYnMpdhWq/8QRvhQbjrNZ16 XzK3AcEFYqVdXKXsinfDUGCNP+j1Ei2BhwBv3OO3JGJ/Gi162wCiXWOTzSBLKiq0 WGtxLW0JIhMhbRUpN6NI3c4m76tEUsRHEWoMvZmQnfYMV9Iq37AIKRXqHzkzyP9d zdYjJG52k98RU0Io5x0NWpW1pnFhbyVEMFlTpOct/hAl1dCjYH9eS3D06GC+v2fJ 3+VucLLmHxltkJWKKvxD359/u8cBM5wJXUYf3ldXIkHAPluKqEEsYXa18hsvrBXI Pm2P8UFa8GhSWuaR0+ElEkLEzoM+9GWw5LCJMeXXGSgosgua8ESxiaXDQkwCLlr2 rwjwK/sHVdlhXwfhecRD3BGtGwABVYyMNd83S9gZ+F5j1TO0K+UpQRMl3qNTYxXQ d+rJkIskE9A+237AV9YvgEakeGfZF4F1lgMw6R+eMP1/g3FqZITI/ZAgddqEnh19 iEI6q+10dLF9aPRWP7HofcMd4Ri7fgJnYgJh4TdhyIsDY5l+dA9ZJenXwsGooFc5 V6BBfVVKuwUTUjEFwbH/eriK3rHCq6MVhclXWIrvw9dQiz/DZKVEo/o3kRkzUF3r 6hOPl0llopsVsiho6QtYH49+qovOdeQAe3QuBogzljzAfwOmB/urz1cGXfcGm10R DzD3508UWGQVpcL4UNZw =BdWB -----END PGP SIGNATURE-----