#319 incorrect linking order

closed-fixed
nobody
None
5
2012-09-21
2012-08-04
Mike Frysinger
No

the recent change due to bug 3542572 [1] misses an important nuances:
- all linked libraries must come after all source objects
- linker flags must come before all source objects and linked libraries

by moving LDFLAGS after the objects and the local ELF_LIBS before the objects, both those aspects are broken.

to make the original bug report (which i can't comment on let alone re-open) work, you'd have to split the local -L flags into a dedicated variable which would then show up before ldflags.

... -o $(ELF_LIB) $(ELF_OTHER_LDFLAGS) $(LDFLAGS) -Wl,-h,$(ELF_SONAME) $(OBJS) $(ELF_OTHER_LIBS) ...

(tangentally related, if you used libtool to create your shared libraries, it would handle these nuances for you)

1: https://sourceforge.net/tracker/?func=detail&aid=3542572&group_id=2406&atid=102406

Discussion

  • Theodore Ts'o
    Theodore Ts'o
    2012-08-04

    Oops, you're quite right.

    It's unfortunate that we have to close comments on bugs once they are resolved, but that's the default on SF these days due to the very high spam rate. :-(

    I've included the fix which I've plan to use. Please sanity check; I'll leave this bug open for a day or two before closing it out.

    Thanks!!

     
  • Theodore Ts'o
    Theodore Ts'o
    2012-08-04

    Proposed fix for this issue.

     
    Attachments
  • Mike Frysinger
    Mike Frysinger
    2012-08-06

    looks sane to me. thanks!

     
  • Theodore Ts'o
    Theodore Ts'o
    2012-08-06

    Oops, I screwed up the proposed fix. I'm updating it with a fixed version.

     
  • Theodore Ts'o
    Theodore Ts'o
    2012-08-06

    Proposed fix for this issue (v2).

     
    Attachments
  • The v2 patch is similar to what I came up myself as well, after noticing that 1.42.5 FTBFS on ubuntu (due to --as-needed). Looks good to me, using it in the upload to ubuntu.

     
  • Theodore Ts'o
    Theodore Ts'o
    2012-09-21

    • status: open --> closed-fixed