Opened 13 months ago

Closed 13 months ago

Last modified 10 months ago

#71842 closed defect (fixed)

legacy-support: include sys/stdio.h from stdio.h

Reported by: barracuda156 Owned by: fhgwright (Fred Wright)
Priority: Normal Milestone:
Component: legacy-support Version: 2.10.5
Keywords: Cc: fhgwright (Fred Wright), mascguy (Christopher Nielsen), macportsraf
Port: legacy-support

Description

Apple headers from 10.10+ include sys/stdio.h from stdio.h, which makes renameat available: https://github.com/alexey-lysiuk/macos-sdk/blob/69ddec41e6224afebd5f19bb24764305ac3e828a/MacOSX10.10.sdk/usr/include/stdio.h#L75

legacy-support provides renameat in sys/stdio.h, however does not include that header from stdio.h: https://github.com/macports/macports-legacy-support/blob/f109400eccefe2f735bcd9a068dad7a53407d548/include/stdio.h

Obviously, Apple header does not do that either when sys/stdio.h does not exist in the OS: https://github.com/alexey-lysiuk/macos-sdk/blob/0efb06490f664d335a4fdff9198df7d03e87deda/MacOSX10.8.sdk/usr/include/stdio.h (or any other SDK before that header appears).

In result, we get failures when compiling software which expects renameat to be available via stdio.h (which should work in fact, as it seems, but fails with legacy-support.

Examples: https://github.com/capnproto/capnproto/pull/2212 https://github.com/leo-arch/clifm/issues/298

Change History (8)

comment:1 in reply to:  description Changed 13 months ago by fhgwright (Fred Wright)

Replying to barracuda156:

Apple headers from 10.10+ include sys/stdio.h from stdio.h, which makes renameat available: https://github.com/alexey-lysiuk/macos-sdk/blob/69ddec41e6224afebd5f19bb24764305ac3e828a/MacOSX10.10.sdk/usr/include/stdio.h#L75

Not exactly. In the 10.10-10.12 SDKs, it's indeed included by stdio.h, but in the 10.13+ SDKs it's included by _stdio.h and not by stdio.h. So there's some question about what the "correct" behavior should be considered to be, and how the software in question decides what header to use.

Copying the later behavior would probably make more sense.

comment:2 Changed 13 months ago by barracuda156

But is _stdio.h included in turn via stdio.h? Internal headers should not be included directly by third-party software.

comment:3 in reply to:  2 ; Changed 13 months ago by fhgwright (Fred Wright)

Replying to barracuda156:

But is _stdio.h included in turn via stdio.h? Internal headers should not be included directly by third-party software.

Ah, yes, it is. Though in any case, legacy-support won't change anything related to renameat in 10.10+, anyway.

IMO, *stdio.h was a dumb place to put the renameat prototype, but that ship has already sailed.

I'll fix this soon, since it's easy (even including the test). :-)

comment:4 in reply to:  3 Changed 13 months ago by barracuda156

Replying to fhgwright:

Replying to barracuda156:

But is _stdio.h included in turn via stdio.h? Internal headers should not be included directly by third-party software.

Ah, yes, it is. Though in any case, legacy-support won't change anything related to renameat in 10.10+, anyway.

IMO, *stdio.h was a dumb place to put the renameat prototype, but that ship has already sailed.

I'll fix this soon, since it's easy (even including the test). :-)

Great, thanks.

comment:5 Changed 13 months ago by fhgwright (Fred Wright)

Owner: set to fhgwright
Resolution: fixed
Status: newclosed

In 1146902f9226e3e0bc80aa1a3e710ce8148700e1/macports-legacy-support (master):

Make stdio.h include sys/stdio.h for renameat().

The declaration of renameat() is in sys/stdio.h, to match Apple's
arrangement (when it exists) in 10.10+, but Apple also includes
(directly or indirectly) sys/stdio.h from stdio.h, so we need to
duplicate that behavior to ensure that stdio.h provides renameat() as
expected.

Closes: #71842

TESTED:
Passes all tests, including updated renameat test.

comment:6 Changed 13 months ago by fhgwright (Fred Wright)

In e5cdc7ae6e22afebb2a5df15e7588dfdc2662fd9/macports-ports (master):

legacy-support-devel: Update to latest master.

Notable changes since last -devel version:

  • Fixes 10.4 Rosetta bug in fstatx_np()
  • Makes renameat() available via stdio.h See: #71842
  • Implements interim clock_gettime_nsec_np() See: #61691
  • Implements clock_settime() See: #71399
  • Adds net/if_tun.h for <10.6 See: #70231
  • Provides pthread_[f]chdir_np() for 10.5+ See: #71265
  • Adds CPU_TYPE_ARM definition for 10.4 See: #71621

Also adds Portfile comments regarding suggested github.tarball_from
change.

Also, the prior addition of vdprintf() in v20241026 neglected to close
the related tickets:

Closes: #67598
Closes: #70118

TESTED:
Tested both normal and -devel versions -/+universal on 10.4-10.5 ppc,
10.5-10.6 ppc (i386 Rosetta), 10.4-10.6 i386, 10.4-12.x x86_64, and
11.x-15.x arm64.
Builds and passes all tests on all tested platforms.

comment:7 Changed 12 months ago by fhgwright (Fred Wright)

In a784d15ced04e75724ee259cec1f7a3d1ab696d3/macports-ports (master):

legacy-support: update to v1.4.0.

Notable changes since v1.3.0:

  • Works around Apple's broken versioning in the macOS 15 SDK
  • Implements scandir() compatibility feature
  • Fixes dprintf() bug and implements vdprintf() See: #67598 See: #70118
  • Mismatched SDK compatibility is extended to include 15.x SDK.
  • Broken 10.4 CLOCK_MONOTONIC is fixed.
  • Fixes stat inconsistency in some 32-bit 10.4 builds.
  • Adds stat64 header support for 10.4 SDK.
  • Adds INODE64 support for *stat*() on 10.4.
  • Reworks fstatat*() support, similar to previous item, fixing buffer overrun in some cases.
  • Backports 10.5 'which' to 10.4.
  • Adds support for code that can't tolerate the normal scandir() compatibility feature.
  • Replaces broken 10.4/10.5 copyfile wrapper with full 10.6 copyfile.
  • Extends 10.4 INODE64 support to *statx_np() functions.
  • Expands TARGET_* defaults. See: #70824
  • Fixes 10.4 Rosetta bug in fstatx_np()
  • Makes renameat() available via stdio.h See: #71842
  • Implements interim clock_gettime_nsec_np() See: #61691
  • Implements clock_settime() See: #71399
  • Adds net/if_tun.h for <10.6 See: #70231
  • Provides pthread_[f]chdir_np() for 10.5+ See: #71265
  • Adds CPU_TYPE_ARM definition for 10.4 See: #71621

TESTED:
Tested both normal and -devel versions -/+universal on 10.4-10.5 ppc,
10.5-10.6 ppc (i386 Rosetta), 10.4-10.6 i386, 10.4-12.x x86_64, and
11.x-15.x arm64.
Builds and passes all tests on all tested platforms.

comment:8 Changed 10 months ago by mascguy (Christopher Nielsen)

Component: portslegacy-support

Recategorize existing legacy-support lib tickets, to use new component definition.

Note: See TracTickets for help on using tickets.