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

Re: [PATCH 1/1] do not add common-main to lib

From
Jeff King <peff@peff.net>
Date
Aug 15, 2016, 12:02 UTC
Message-ID
<20160815120223.4lr23aiqmqzjprch@sigill.intra.peff.net>
In-Reply-To
<20160815075207.31280-1-list@eworm.de>
On Mon, Aug 15, 2016 at 09:52:07AM +0200, Christian Hesse wrote:
Show 7 quoted lines
> From: Christian Hesse <mail@eworm.de>
> 
> Commit 08aade70 (mingw: declare main()'s argv as const) changed
> declaration of main function. This breaks linking external projects
> (e.g. cgit) to libgit.a with:
> 
> error: Multiple definition of `main'

I'd expect the culprit is actually 3f2e229 (add an extra level of indirection to main(), 2016-07-01).

> So do not add common-main to lib and let projects have their own
> main function.

That is certainly an option, but I think it means that those projects are potentially buggy in the same way that some git commands were prior to the common-main series. Namely, the common main() may do some run-time setup that parts of libgit.a assume has been done.

I would not be surprised if cgit crashes on Windows, for instance, for the reasons detailed in 650c449 (common-main: call git_extract_argv0_path(), 2016-07-01). I would also not be surprised if nobody actually builds cgit on Windows. :)

The "right" way to do it (according to the way libgit.a views the world) is for cgit's main to become cmd_main(), and let libgit.a do its run-time startup before getting there.

-Peff
Previous: Christian HesseNext: Christian Hesse
Message 2 of 5 in “do not add common-main to lib”
  1. 1/1 do not add common-main to libChristian Hesse, Aug 15, 2016
  2. Jeff KingAug 15, 2016
  3. Christian HesseAug 15, 2016
  4. Johannes SchindelinAug 15, 2016
  5. Christian HesseAug 15, 2016

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.