git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Nikhil Gupta <nikhilgupta2102@gmail.com>
Cc: git-packagers@googlegroups.com, Git List <git@vger.kernel.org>
Subject: Re: Build errors when building git on MacOS 11 (x86-64) and for M1 macs
Date: Thu, 10 Jun 2021 15:52:09 +0200	[thread overview]
Message-ID: <87sg1p24zc.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <f5487adb-b7dc-4f97-bca1-749701337759n@googlegroups.com>


[CC-ing the main git@ list for the "bug in git" aspect of this]

On Thu, Jun 10 2021, Nikhil Gupta wrote:

> &nbsp; | The following shell command exited with status 2:
> &nbsp; | &nbsp;
> &nbsp; | $ CFLAGS=-I/opt/chef-workstation/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector CPPFLAGS=-I/opt/chef-workstation/embedded/include -O3
> -D_FORTIFY_SOURCE=2 -fstack-protector CXXFLAGS=-I/opt/chef-workstation/embedded/include -O3 -D_FORTIFY_SOURCE=2 -fstack-protector
> LDFLAGS=-Wl,-rpath,/opt/chef-workstation/embedded/lib -L/opt/chef-workstation/embedded/lib LD_RUN_PATH=/opt/chef-workstation/embedded/lib MAKE=gmake
> OMNIBUS_INSTALL_DIR=/opt/chef-workstation
> PATH=/opt/chef-workstation/bin:/opt/chef-workstation/embedded/bin:/Users/administrator/.buildkite-agent/builds/MM009-local-1/chef/chef-chef-workstation-master-omnibus-adhoc/omnibus/vendor/bundle/ruby/2.7.0/bin:/opt/angry-omnibus-toolchain/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
> PKG_CONFIG_PATH=/opt/chef-workstation/embedded/lib/pkgconfig gmake prefix=/opt/chef-workstation/embedded bindir=/opt/chef-workstation/gitbin -j 10
> [...]
> &nbsp; | * new script parameters
> &nbsp; | builtin/archive.c:48:24: error: implicit declaration of function 'archive_format_from_filename' is invalid in C99
> [-Werror,-Wimplicit-function-declaration]
> &nbsp; | const char *format = archive_format_from_filename(name_hint);
> &nbsp; | ^
> &nbsp; | builtin/archive.c:48:24: note: did you mean 'archive_read_open_filename'?
> &nbsp; | /opt/chef-workstation/embedded/include/archive.h:527:15: note: 'archive_read_open_filename' declared here
> &nbsp; | __LA_DECL int archive_read_open_filename(struct archive *,
> &nbsp; | ^
> &nbsp; | builtin/archive.c:48:15: warning: incompatible integer to pointer conversion initializing 'const char *' with an expression of type 'int'
> [-Wint-conversion]
> &nbsp; | const char *format = archive_format_from_filename(name_hint);
> &nbsp; | ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> &nbsp; | builtin/archive.c:101:2: error: implicit declaration of function 'init_archivers' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
> &nbsp; | init_archivers();
> &nbsp; | ^
> &nbsp; | builtin/archive.c:111:9: error: implicit declaration of function 'write_archive' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
> &nbsp; | return write_archive(argc, argv, prefix, the_repository, output, 0);
> &nbsp; | ^
> &nbsp; | builtin/archive.c:111:9: note: did you mean 'write_or_die'?
> &nbsp; | ./cache.h:1737:6: note: 'write_or_die' declared here
> &nbsp; | void write_or_die(int fd, const void *buf, size_t count);
> &nbsp; | ^
> &nbsp; | 1 warning and 3 errors generated.
> &nbsp; | gmake: *** [Makefile:2431: builtin/archive.o] Error 1
> &nbsp; | gmake: *** Waiting for unfinished jobs....
> &nbsp; | &nbsp;
> &nbsp; | &nbsp;

I have no access to such a system, but I think think I see the problem
from what you've supplied here.

You supplied a CFLAGS=-I/opt/chef-workstation/embedded/include which has
an archive.h file that's unrelated to the archive.h file git expects.

Thus we include that and find things unrelated to git, and error when we
encounter a function we expected to have declared in our own archive.h.

The solution is something like defining a config.mak file where you add
flags with BASIC_CFLAGS +=, not =. See config.mak.uname for an
example. You'll then add new directories after our own -I.

This is arguably a bug in git's Makefile in that we should have that
"-I." in an ESSENTIAL_CFLAGS variable or something, I can't think of a
scenario where git would compile without it. That or things in builtin/
should include e.g. ../archive.h, perhaps such a thing isn't portable.

I think (but have not confirmed) that you probably got this far because
your compiler will stick -I. at the /end/ of the flags implicitly (or is
that standardized C behavior? I can't remember).

So it worked until we had a filename conflict, i.e. we'd find strbuf.h
in our own sources, but have an issue with a common name like archive.h.

       reply	other threads:[~2021-06-10 14:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <f5487adb-b7dc-4f97-bca1-749701337759n@googlegroups.com>
2021-06-10 13:52 ` Ævar Arnfjörð Bjarmason [this message]
2021-06-10 14:24   ` Build errors when building git on MacOS 11 (x86-64) and for M1 macs Felipe Contreras
2021-06-10 14:36   ` Jeff King
2021-06-10 14:51     ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sg1p24zc.fsf@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=git-packagers@googlegroups.com \
    --cc=git@vger.kernel.org \
    --cc=nikhilgupta2102@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).