git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] build: get rid of the notion of a git library

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 10, 2013, 23:41 UTC
Message-ID
<7v8v2hedou.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vk3m1efda.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 25 quoted lines
> Jeff King <peff@peff.net> writes:
>
>> My general impression of the goal of our current code organization is:
>>
>>   1. builtin/*.c should each contain a single builtin command and its
>>      supporting static functions. Each file gets linked into git.o to
>>      make the "main" git executable.
>
> Correct; that is what we aimed for when we made builtin-*.c (later
> moved to builtin/*.c).  Some builtin/*.c files can contain more than
> one cmd_foo implementations, so "single" is not a solid rule, and it
> does not have to be, because all of them are expected to be linked
> into the main binary together with git.c to be called from main().
>
> And as you hinted, if some global data or functions in it turns out
> to be useful for standalone binaries, their definitions must migrate
> out of buitlin/*.c to ./*.c files, because standalone binaries with
> their own main() definition cannot be linked with builtin/*.o, the
> latter of which requires to be linked with git.o with its own main().
> ...
> The rationale behind libgit.a was so that make targets for the
> standalone binaries (note: all of them were standalone in the
> beginning) do not have to list *.o files that each of them needs to
> be linked with.  It was primary done as a convenient way to have the
> linker figure out the dependency and link only what was needed.

For the particular case of trying to make sequencer.o, which does not currently have dependencies on builtin/*.o, depend on something that is in builtin/notes.o, the link phase of standalone that wants anything from revision.o (which is pretty much everything ;-) goes like this:

        upload-pack.c   wants handle_revision_opt etc.
        revision.c      provides handle_revision_opt
                        wants name_decoration etc.
        log-tree.c      provides name_decoration
                        wants append_signoff
        sequencer.c     provides append_signoff

So sequencer.o _is_ meant to be usable from standalone and belongs to libgit.a

If sequencer.o wants to call init_copy_notes_for_rewrite() and its friends [*1*] that are currently in builtin/notes.o, first the called function(s) should be moved outside builtin/notes.o to notes.o or somewhere more library-ish place to be included in libgit.a, which is meant to be usable from standalone.

[Footnote]
*1* ... which is a very reasonable thing to do.  But moving
    sequencer.o to builtin/sequencer.o is *not* the way to do this.
Previous: Junio C HamanoNext: Felipe Contreras
Message 23 of 59 in “build: get rid of the notion of a git library”
  1. build: get rid of the notion of a git libraryFelipe Contreras, Jun 8, 2013
  2. Ramkumar RamachandraJun 8, 2013
  3. Felipe ContrerasJun 8, 2013
  4. Ramkumar RamachandraJun 9, 2013
  5. John KeepingJun 9, 2013
  6. Felipe ContrerasJun 9, 2013
  7. John KeepingJun 9, 2013
  8. Felipe ContrerasJun 9, 2013
  9. John KeepingJun 9, 2013
  10. Ramkumar RamachandraJun 9, 2013
  11. Ramkumar RamachandraJun 9, 2013
  12. Felipe ContrerasJun 9, 2013
  13. John KeepingJun 9, 2013
  14. Felipe ContrerasJun 9, 2013
  15. Ramkumar RamachandraJun 9, 2013
  16. Vincent van RavesteijnJun 9, 2013
  17. Felipe ContrerasJun 9, 2013
  18. Jeff KingJun 10, 2013
  19. Felipe ContrerasJun 10, 2013
  20. Jeff KingJun 10, 2013
  21. Felipe ContrerasJun 10, 2013
  22. Junio C HamanoJun 10, 2013
  23. Junio C HamanoJun 10, 2013
  24. Felipe ContrerasJun 10, 2013
  25. Junio C HamanoJun 11, 2013
  26. Junio C HamanoJun 11, 2013
  27. Felipe ContrerasJun 11, 2013
  28. Junio C HamanoJun 11, 2013
  29. Felipe ContrerasJun 11, 2013
  30. Junio C HamanoJun 11, 2013
  31. Felipe ContrerasJun 11, 2013
  32. Linus TorvaldsJun 11, 2013
  33. Felipe ContrerasJun 11, 2013
  34. Junio C HamanoJun 11, 2013
  35. Felipe ContrerasJun 11, 2013
  36. 0/3 Refactor useful notes functions into notes-utils.[ch]Johan Herland, Jun 12, 2013
  37. 1/3 finish_copy_notes_for_rewrite(): Let caller provide commit messageJohan Herland, Jun 12, 2013
  38. Junio C HamanoJun 12, 2013
  39. 2/3 Move copy_note_for_rewrite + friends from builtin/notes.c to notes-utils.cJohan Herland, Jun 12, 2013
  40. Felipe ContrerasJun 12, 2013
  41. Johan HerlandJun 12, 2013
  42. Felipe ContrerasJun 12, 2013
  43. Johan HerlandJun 12, 2013
  44. Felipe ContrerasJun 12, 2013
  45. Andreas KreyJun 13, 2013
  46. Felipe ContrerasJun 13, 2013
  47. Junio C HamanoJun 12, 2013
  48. 3/3 Move create_notes_commit() from notes-merge.c into notes-utils.cJohan Herland, Jun 12, 2013
  49. Junio C HamanoJun 12, 2013
  50. Felipe ContrerasJun 12, 2013
  51. Junio C HamanoJun 13, 2013
  52. Felipe ContrerasJun 13, 2013
  53. Felipe ContrerasJun 13, 2013
  54. Junio C HamanoJun 11, 2013
  55. Felipe ContrerasJun 11, 2013
  56. Junio C HamanoJun 11, 2013
  57. Felipe ContrerasJun 11, 2013
  58. Felipe ContrerasJun 11, 2013
  59. Felipe ContrerasJun 9, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.