After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 566994 - Safer passing of -framework flag
Safer passing of -framework flag
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: build
2.18.x
Other Mac OS
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2009-01-08 07:27 UTC by Daniel Macks
Modified: 2012-06-06 14:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Safer -framework usage (361 bytes, patch)
2009-01-08 07:30 UTC, Daniel Macks
none Details | Review
Safer -framework usage (1.17 KB, patch)
2012-06-05 18:19 UTC, Daniel Macks
none Details | Review
Safer -framework usage (against git HEAD) (1.70 KB, patch)
2012-06-05 23:31 UTC, Daniel Macks
committed Details | Review

Description Daniel Macks 2009-01-08 07:27:05 UTC
On OS X, glib-2.18.3 passes "-framework Carbon" as a linker flag, which gets written to the .la libtool files and propagated when linking against the libs. That syntax is risky: if there are several -framework flags ("-framework Carbon" inherited from glib, "-framework SomethingElse", etc), some flag-handling routines will strip out some of those "-framework" words as redundant because they don't realize that "-framework Foo" is a two-word pair (i.e., make that "-framework Carbon SomethingElse", which is totally broken). Safer to pass "-Wl,-framework,Carbon" so that the whole thing looks like a single word.
Comment 1 Daniel Macks 2009-01-08 07:30:09 UTC
Created attachment 126008 [details] [review]
Safer -framework usage
Comment 2 Daniel Macks 2009-01-08 08:12:58 UTC
Hrm, without the patch, "-framework Carbon" appears in *.la inherited_linker_flags; with the patch from Comment #1, nothing about Carbon appears anywhere in *.la (I --disable-static when ./configuring glib). I'll talk to some libtool folks to figure out just WTF is going on here...
Comment 3 Daniel Macks 2009-01-08 18:03:48 UTC
...who say that they *should* be passed if static lib and not necessary if shared lib (the -framework flag is passed to the linker for the shared lib so dyld makes sure it's loaded to resolve the symbols there). If static, flag *does* need to be propagated, and libtool's internal notes about inherited_linker_flags say that "Currently, these flags are not uniquified and thus accumulate." so probably best for now to leave the flag as-is unpatched and wait for evidence of it causing a symptom. I guess leave this bug open but ignore it...
Comment 4 Emmanuele Bassi (:ebassi) 2012-02-29 10:30:02 UTC
is this still relevant?
Comment 5 Tobias Mueller 2012-06-01 17:51:35 UTC
Daniel, Ping.
Comment 6 Daniel Macks 2012-06-02 21:13:05 UTC
My gnome sandbox is waaaaay out-of-date, will try it in the next few days and report back.
Comment 7 Daniel Macks 2012-06-05 17:58:12 UTC
There are now two places in configure.ac where a "-framework foo" is propagated as a two-word flag and that winds up being published. Fink's packaging dropped the static lib long ago and libtool may well be handling things cleanly for direct access there, so "still an issue, still don't care" at that point. However, fink's packaging handler alerts that the multiword is also going into the .pc files, which is a potential risk (it's used and later processed by tools other than a known-safe one). The standard pkg-config program has a special case to hold "-framework foo" as a single unit when uniquifying and collecting, but it's still fragile towards any other tool that doesn't know this special case (I've seen efforts to fork or reimplement pkg-config, not sure we should rely on them to know about and work around this situation) or somehow else rationally assumes that nonquoted whitespace is a word delimiter.
Comment 8 Daniel Macks 2012-06-05 18:19:43 UTC
Created attachment 215667 [details] [review]
Safer -framework usage

Now fixes both instances in configure.ac. For self-consistency, also makes same change in a makefile, but that one only appears to propagate to .la not .pc
Comment 9 Colin Walters 2012-06-05 18:31:19 UTC
(In reply to comment #8)
> Created an attachment (id=215667) [details] [review]
> Safer -framework usage
> 
> Now fixes both instances in configure.ac. For self-consistency, also makes same
> change in a makefile, but that one only appears to propagate to .la not .pc

Would you be willing to do a git checkout and write a commit message?  https://live.gnome.org/GnomeLove/SubmittingPatches
Comment 10 Daniel Macks 2012-06-05 23:31:07 UTC
Created attachment 215698 [details] [review]
Safer -framework usage (against git HEAD)

Per Comment #9 (I think...I'm still a novice at using git)
Comment 11 Colin Walters 2012-06-06 01:25:46 UTC
Review of attachment 215698 [details] [review]:

Perfect, thanks!  You're getting things closer to the point where I can be sitting on the beach with a drink in one hand, pressing the accepted-commit-now button with my phone on the other...
Comment 12 Colin Walters 2012-06-06 01:29:07 UTC
(In reply to comment #11)
> Review of attachment 215698 [details] [review]:

Although I do have one question; aren't we exacerbating the problem here by passing -framework twice inside the GLib build itself?  Shouldn't adding it exactly once to LDFLAGS in configure be sufficient?
Comment 13 Daniel Macks 2012-06-06 14:52:59 UTC
The flag-passing is indeed redundant in gio/Makefile.am. Here are the key extracted lines:

configure.ac:

AM_CONDITIONAL(OS_COCOA, [test "$glib_have_cocoa" = "yes"])

if test "x$glib_have_cocoa" = "xyes"; then
  AC_DEFINE(HAVE_COCOA, 1, [define to 1 if Cocoa is available])
  LDFLAGS="$LDFLAGS -Wl,-framework,Foundation"
fi

gio/Makefile.am:

if OS_COCOA
libgio_2_0_la_LDFLAGS += -Wl,-framework,Foundation
endif