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

Re: Minor portability issues + fixes

From
Jeff King <peff@peff.net>
Date
May 20, 2020, 04:28 UTC
Message-ID
<20200520042838.GA102274@coredump.intra.peff.net>
In-Reply-To
<40a42f1d-61bd-46fb-8946-5588df7b044b@www.fastmail.com>
On Tue, May 19, 2020 at 12:22:00AM -0400, Daniel Richard G. wrote:
Show 7 quoted lines
> > If so, then perhaps it should be added to the AIX defines in
> > config.mak.uname.
> 
> I've confirmed that this works. But would it not be safe to #include
> both inttypes.h and stdint.h explicitly if both are present, rather than
> cater to AIX specifically? I could see this similarly arising in, say,
> an old version of Solaris.

Yes, as long as we check that both are present, I think that would do the right thing. And the autoconf check could cover that. I don't think there's an easy way to have a general Makefile knob that can check which files are present, though (and we generally consider the Makefile and its knobs to be the primary mechanism; autoconf to turn those knobs is generally implemented on top).

So probably we'd want something like (in this order):
  - NEEDS_EXPLICIT_STDINT gets passed from the Makefile into the
    compiler via -D, which then triggers stdint.h being included
    unconditionally in git-compat-util.h
  - optionally set that in config.mak.uname for AIX (checking uname_R
    since it sounds like only old versions need it)
  - add an autoconf rule that sets it, either strictly (when a
    test-program decides it's needed) or loosely (when we see that it's
    available at all)

Even just the first one would let you build by setting the knob manually; the rest is gravy on top, if you or somebody else chooses to do it.

Show 10 quoted lines
> > I do wonder, though, if configure.ac could be extended for AIX to
> > support whatever syntax the system linker uses for setting the run-path.
> > I understand that you don't care either way about this feature, but this
> > might be a good opportunity to fix it.
> 
> This could be a bit complicated, I'm afraid.
> 
> The applicable value for CC_LD_DYNPATH on AIX is "-Wl,-blibpath:".
> However, have a look at the description for this option in the
> ld(1) man page:

OK, gross. :) I agree it's not worth going too far into this rabbit hole. I do wonder if you could just be using GNU ld along with gcc, but maybe that's not practical.

You should be able to build with:
  make CC_LD_DYNPATH=-L

as a workaround, but it would be nice if the Makefile handled this correctly. It looks like CC_LD_DYNPATH gets used in a lot of places, so I suspect we'd want a Makefile function to help out. Something like:

  # usage: $(call linker_lib,PATH)
  # Create linker args for looking for libraries in PATH at both link-time
  # and run-time.
  linker_lib = -L$1 $(if $(CC_LD_DYNPATH),$(CC_LD_DYNPATH)$1)
which would allow:
  EXTLIBS += $(call linker_lib,$(LIBPCREDIR)/$(lib))

etc. This would be our first foray into Makefile functions, but I think we've determined that most platforms have a recent enough GNU make for it to be OK (and we already require GNU make).

-Peff
Previous: Daniel Richard G.Next: Daniel Richard G.
Message 4 of 8 in “Minor portability issues + fixes”
  1. Daniel Richard G.May 19, 2020
  2. Jeff KingMay 19, 2020
  3. Daniel Richard G.May 19, 2020
  4. Jeff KingMay 20, 2020
  5. Daniel Richard G.May 21, 2020
  6. Jeff KingMay 22, 2020
  7. Carlo Marcelo Arenas BelónMay 19, 2020
  8. Daniel Richard G.May 19, 2020

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.