From: Jeff King <peff@peff.net>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Nikhil Gupta <nikhilgupta2102@gmail.com>,
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 10:51:38 -0400 [thread overview]
Message-ID: <YMIm+hqqeY2IjEW3@coredump.intra.peff.net> (raw)
In-Reply-To: <YMIjaytMYslKjK6z@coredump.intra.peff.net>
On Thu, Jun 10, 2021 at 10:36:27AM -0400, Jeff King wrote:
> Most compilers put the directory of the source file at the start of the
> search path. E.g., gcc says under -I:
>
> 1. For the quote form of the include directive, the directory of the
> current file is searched first.
>
> Which is why we need "-I." at all; we are finding "archive.h" from
> "builtin/*.c". I'm not sure what "current file" there means, or how
> portable it is. Is it the source file being filed, or the file
> containing the #include directive?
>
> I'd hope it's consistently the latter. Otherwise "foo.h" which includes
> "bar.h" cannot be included as "../foo.h" (from builtin/foo.c) and as
> "foo.h" (from top-level foo.c).
>
> If so, then yeah, using "../archive.h" (and dropping -I. entirely) would
> be an option. Which is nice, because it makes things less magical and
> more predictable (think what confusion we'd see if we introduced
> "archive.h" into builtin/ ourselves).
There's a related case, which is that within trace2/foo.c, we'd include
trace2/foo.h. Without "-I.", the correct include there is just "foo.h".
So what was explicit actually becomes implicit. Here's a real example to
make this file work without -I:
diff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c
index a8018f18cc..592c194ab4 100644
--- a/trace2/tr2_tgt_perf.c
+++ b/trace2/tr2_tgt_perf.c
@@ -1,15 +1,15 @@
-#include "cache.h"
-#include "config.h"
-#include "run-command.h"
-#include "quote.h"
-#include "version.h"
-#include "json-writer.h"
-#include "trace2/tr2_dst.h"
-#include "trace2/tr2_sid.h"
-#include "trace2/tr2_sysenv.h"
-#include "trace2/tr2_tbuf.h"
-#include "trace2/tr2_tgt.h"
-#include "trace2/tr2_tls.h"
+#include "../cache.h"
+#include "../config.h"
+#include "../run-command.h"
+#include "../quote.h"
+#include "../version.h"
+#include "../json-writer.h"
+#include "tr2_dst.h"
+#include "tr2_sid.h"
+#include "tr2_sysenv.h"
+#include "tr2_tbuf.h"
+#include "tr2_tgt.h"
+#include "tr2_tls.h"
So I dunno. I had hoped it would be a strict readability improvement,
but now I'm not so sure.
-Peff
prev parent reply other threads:[~2021-06-10 14:51 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 ` Build errors when building git on MacOS 11 (x86-64) and for M1 macs Ævar Arnfjörð Bjarmason
2021-06-10 14:24 ` Felipe Contreras
2021-06-10 14:36 ` Jeff King
2021-06-10 14:51 ` Jeff King [this message]
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=YMIm+hqqeY2IjEW3@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=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).