Opened 5 months ago

Closed 2 months ago

Last modified 6 weeks ago

#69867 closed defect (fixed)

legacy-support headers should work with later SDK versions

Reported by: fhgwright (Fred Wright) Owned by: fhgwright (Fred Wright)
Priority: Low Milestone:
Component: ports Version: 2.9.3
Keywords: Cc: ryandesign (Ryan Carsten Schmidt), mascguy (Christopher Nielsen), barracuda156
Port: legacy-support

Description

It's ordinarily legal (with some limitations) to build for a given OS target while using an SDK for a later OS version. In some cases, the legacy-support headers may not work properly in this situation. One known case is #69838.

It would be desirable (though not high priority) to fix this.

Change History (22)

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

In df195e0aea5b49d03c149970ddb303bcada0f7d7/macports-legacy-support (master):

stpncpy: Fix potential header collision with "later" SDK

This is one case of the general problem in:

#69867

This should fix the only known case specifically related to collisions
with "secure" wrappers. Whether there are other types of SDK
collisions is TBD.

TESTED:
Builds and passes tests on 10.4-10.5 ppc, 10.4-10.6 i386, 10.5-10.6
ppc (i386 Rosetta), 10.5-12.x x86_64, 11.x-14.x arm64.
Builds test_stpncpy successfully on 10.6 with 10.7 SDK.

comment:2 Changed 5 months ago by Christopher Nielsen <mascguy@…>

In badcd63f0127ac3034d9522fb7445f9a873f899b/macports-ports (master):

legacy-support-devel: update to latest master

  • stpncpy: Fix potential header collision with "later" SDK

See: https://github.com/macports/macports-legacy-support/pull/85
See: #69867

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

One thing that would help in testing this issue would be to teach the build procedure to honor SDKROOT. Currently it doesn't.

comment:4 Changed 5 months ago by ryandesign (Ryan Carsten Schmidt)

The build procedure of what? If you mean you are setting the SDKROOT environment variable in your shell and MacPorts is not passing it through to the builds, that's intentional; most environment variables are deliberately not passed through. You can override configure.sdk_version or configure.sdkroot on the command line if you want to test a different SDK, e.g. sudo port configure configure.sdk_version=11 (this assumes you have the macOS 11 SDK in the standard location) or sudo port configure configure.sdkroot=/path/to/MacOSX11.sdk (for an SDK located anywhre).

comment:5 in reply to:  4 Changed 5 months ago by fhgwright (Fred Wright)

Replying to ryandesign:

The build procedure of what? If you mean you are setting the SDKROOT environment variable in your shell and MacPorts is not passing it through to the builds, that's intentional; most environment variables are deliberately not passed through. You can override configure.sdk_version or configure.sdkroot on the command line if you want to test a different SDK, e.g. sudo port configure configure.sdk_version=11 (this assumes you have the macOS 11 SDK in the standard location) or sudo port configure configure.sdkroot=/path/to/MacOSX11.sdk (for an SDK located anywhre).

No, I mean the project's build procedure. Testing it as a port would add unnecessary friction.

An example of why legacy-support should have its own ticket component, since this isn't a ports issue. :-)

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

Another case where this would fail is building on 10.4 with a 10.5+ SDK. The headers provided by 10.4 legacy-support to correct the omissions in the 10.4 SDK would override the non-omitted versions in the 10.5+ SDK, with a variety of potential problems. The decision to incorporate the "missing" headers needs to be made at the time the headers are used, not the time they're installed.

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

In 4405385bb024205da873fb3b4aabf9099b1cd5be/macports-legacy-support (master):

Move renameat() to the proper header.

Commit e9cf5ab3 moved the renameat() declaration from sys/stdio.h to
stdio.h, but this is incompatible with the normal header setup.
This moves it back to restore compatibility, but requires knowledge
of the SDK version to cope with the absence of sys/stdio.h in
pre-10.10 SDKs. This is handled via the new sdkversion.h.

Re: #69867

TESTED:
Builds and passes tests on all platforms, including the new test for
this issue.

comment:8 Changed 3 months ago by fhgwright (Fred Wright)

In f53c6a567a3acc9d4d073ac0c84e6d9c70ce6f62/macports-legacy-support (master):

Rework Tiger headers for better compatibility.

Prior to this, missing and deficient Tiger headers were handled by
installing extra headers on 10.4. This was incompatible with builds
using any non-Tiger SDK. The new approach uses wrapper headers with
appropriate SDK-based conditionals, and is compatible with all SDKs.
Special handling of header installs on 10.4 is no longer required.

This also avoids the need for an extra include path when building
the legacy-support components themselves on 10.4.

Re: #69867

TESTED:
Tested on 10.4-10.5 ppc, 10.5-10.6 ppc (i386 Rosetta), 10.4-10.6 i386,
10.5-12.x x86_64, and 11.x-14.x arm64. Tested against all 10.4-14.x
SDKs, using the headerinfo manual test (from a subsequent commit).
All target/SDK combinations where the SDK supports the CPU
architecture work correctly, including all SDKs on Intel
architectures. Only 10.4-10.6 SDKs support ppc, and only 11.x+ SDKs
support arm64.

comment:9 Changed 3 months ago by fhgwright (Fred Wright)

In ac9791553b8b96e9a8011e773bf25b7004758c22/macports-legacy-support (master):

Fix stpncpy() security wrapper for 10.5 with 10.7+ SDK.

The previous fix for the 10.5 compiler issue only applied when the
wrapper is being provided by the legacy-support headers. But the
problem also exists when the wrapper is applied by a 10.7+ SDK when
building for 10.5. This moves the hack outside the check for the
prefdefined wrapper.

In the 10.7+ SDK case, the inline was defined before the macro hack,
so we use a different name for the inline here. To make this
effective, we unconditionally define the macro here, overriding the
SDK.

Re: #69867

TESTED:
Tested on 10.4-10.5 ppc, 10.5-10.6 ppc (i386 Rosetta), 10.4-10.6 i386,
10.5-12.x x86_64, and 11.x-14.x arm64. Tested against all 10.4-14.x
SDKs, using the headerinfo manual test (from a subsequent commit).
All target/SDK combinations where the SDK supports the CPU
architecture work correctly, including all SDKs on Intel
architectures. Only 10.4-10.6 SDKs support ppc, and only 11.x+ SDKs
support arm64.

comment:10 Changed 3 months ago by fhgwright (Fred Wright)

In fa92ff2aa5577853edb56ba7898c6f7103beee52/macports-legacy-support (master):

sincos: Implement sincos[f]_stret

Builds with 10.9+ SDKs expect these functions as part of an improved
internal interface, but they don't become available until 10.9.
Builds targeting 10.6 or earlier don't use them, but we don't worry
about that.

We don't try to do anything fancy - this just creates a compatible
interface to the two-call approach.

Re: #69867

TESTED:
Tested on 10.4-10.5 ppc, 10.5-10.6 ppc (i386 Rosetta), 10.4-10.6 i386,
10.5-12.x x86_64, and 11.x-14.x arm64. Tested against all 10.4-14.x
SDKs, using the headerinfo manual test (from a subsequent commit).
All target/SDK combinations where the SDK supports the CPU
architecture work correctly, including all SDKs on Intel
architectures. Only 10.4-10.6 SDKs support ppc, and only 11.x+ SDKs
support arm64.

comment:11 Changed 3 months ago by fhgwright (Fred Wright)

In e0a0fafdf81f12959a29cdd834a449c1827f96c9/macports-legacy-support (master):

Add secure/_common.h to avoid security wrappers on 10.4.

Security wrappers are unsupported on 10.4. They're never enabled when
using the 10.4 SDK, but builds with later SDKs and the enable on
(default in 10.6+, allowable in 10.5) result in build failures. This
is not limited to legacy-support's stpncpy(), but affects native
functions (e.g. strncpy()) as well. We avoid this by #undefing
_FORTIFY_SOURCE in any 10.4 build.

Re: #69867

TESTED:
Tested on 10.4-10.5 ppc, 10.5-10.6 ppc (i386 Rosetta), 10.4-10.6 i386,
10.5-12.x x86_64, and 11.x-14.x arm64. Tested against all 10.4-14.x
SDKs, using the headerinfo manual test (from a subsequent commit).
All target/SDK combinations where the SDK supports the CPU
architecture work correctly, including all SDKs on Intel
architectures. Only 10.4-10.6 SDKs support ppc, and only 11.x+ SDKs
support arm64.

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

In 3b29576cd0eda9d9c45ca241cb806c616ff19df1/macports-legacy-support (master):

Fix 10.6- builds with 10.14+ SDKs.

Beginning with the 10.14 SDK, AvailabilityInternal.h uses the
has_include() feature without checking whether it's available. So
we add the usual default definition when it's not.

Re: #69867

TESTED:
Tested on 10.4-10.5 ppc, 10.5-10.6 ppc (i386 Rosetta), 10.4-10.6 i386,
10.5-12.x x86_64, and 11.x-14.x arm64. Tested against all 10.4-14.x
SDKs, using the headerinfo manual test (from a subsequent commit).
All target/SDK combinations where the SDK supports the CPU
architecture work correctly, including all SDKs on Intel
architectures. Only 10.4-10.6 SDKs support ppc, and only 11.x+ SDKs
support arm64.

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

In 0e7c7718033057d410fbd09bc22297e0a1f69300/macports-legacy-support (master):

Fix 10.6- builds with 14.x+ SDKs.

Beginning with the 14.x SDK, AvailabilityInternal.h uses the
has_builtin() operator. Although it includes a defined() condition,
that doesn't actually work because the operator needs to be parseable
before evaluating the boolean. So we provide a default (always false)
definition when the compiler doesn't have it.

Re: #69867

TESTED:
Tested on 10.4-10.5 ppc, 10.5-10.6 ppc (i386 Rosetta), 10.4-10.6 i386,
10.5-12.x x86_64, and 11.x-14.x arm64. Tested against all 10.4-14.x
SDKs, using the headerinfo manual test (from a subsequent commit).
All target/SDK combinations where the SDK supports the CPU
architecture work correctly, including all SDKs on Intel
architectures. Only 10.4-10.6 SDKs support ppc, and only 11.x+ SDKs
support arm64.

comment:14 Changed 3 months ago by fhgwright (Fred Wright)

In 6f0ee43a1e662308527bd0c8cd85031d9a6553d9/macports-ports (master):

legacy-support-devel: update to latest master

  • Adds optional security wrapper for stpncpy().

Re: #69878

  • Fixes most issues with mismatched SDKs.

Re: #69867

  • Moves renameat() prototype to the proper header location.

Simplifies Tiger-only handling in the Portfile, though only for the
devel subport until the next release. In the interim, two different
versions of this code are present.

TESTED:
Tested both normal and -devel versions 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-14.x arm64.
Builds on all tested platforms except 10.4 ppc +universal.
Passes all tests in all buildable cases.

comment:15 Changed 3 months ago by fhgwright (Fred Wright)

In 5b06d58603710b847be0ad5adcf0d287ade64626/macports-ports (master):

legacy-support: Update to latest master

  • Fixes incorrect CLOCK_UPTIME_RAW_APPROX definition
  • Fixes Makefile flag handling (for non-port builds)

Re: #69782

  • Eliminates spurious fmemopen() in OSes that don't need it
  • Much internal rework of feature flags (WIP)

Re: #69867

TESTED:
Tested both normal and -devel versions 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-14.x arm64.
Builds on all tested platforms except 10.4 ppc +universal.
Passes all tests in all buildable cases.

comment:16 Changed 2 months ago by fhgwright (Fred Wright)

In 042b096f96bf4ade801b8bf1c734f812c202173c/macports-legacy-support (master):

Convert some feature flags to the new scheme.

This reworks the flags that interact with DARWIN_C_LEVEL
conditionals, to allow proper testing with different SDKs.

Re: #69867

Also fixes a warning and cleans up some whitespace in sys/stat.h.

TESTED:
Builds and passes tests on all platforms, including with allowable
mismatched SDK cases.

comment:17 Changed 2 months ago by fhgwright (Fred Wright)

In b6f68a5633ce1b124d98d54056af589909c60c6e/macports-legacy-support (master):

Convert most remaining feature flags to new scheme.

Also corrects misnamed feature flag for lchmod().

Also removes unnecessary feature flags for AI_NUMERICSERV and
PTHREAD_RWLOCK_*.

Also removes unnecessary #includes where not needed for unnecessary
feature flags.

Also renames guard macro in dirfuncs_compat.h to avoid confusion with
feature flags.

Re: #69867

TESTED:
Builds and passes tests on all platforms, including with allowable
mismatched SDK cases.

comment:18 Changed 2 months ago by fhgwright (Fred Wright)

In 1103ed6849918d9604b6095b6d53a6a44f3f68b0/macports-legacy-support (master):

Rework sysconf flags to fit new scheme.

The old method of deriving sysconf wrapper needs from ifndefs was
incompatible with SDK flexibility. This sets up the usual SDK/lib
flags, referenced to the appropriate OS versions (and the i386 fix).

See: #69867

TESTED:
Builds and passes tests on all platforms.

comment:19 Changed 2 months ago by fhgwright (Fred Wright)

Resolution: fixed
Status: assignedclosed

In 22d4b01ae9263880c47cd578a937d31f6f723a40/macports-legacy-support (master):

sdkversion.h: Respect SDK 11.x+ version non-definitions.

Also adds a tool to extract the macro list from an SDK.

Closes: #69867

TESTED:
Builds and passes tests on all platforms.
Version macros are absent where appropriate in the darwin_c tests.

comment:20 Changed 2 months ago by fhgwright (Fred Wright)

In bd4acde3ef5abb100c78e3ffe9df7c73a01f63e3/macports-ports (master):

legacy-support-devel: Update to latest master

  • Adds appropriate DARWIN_C_LEVEL conditionals, as in SDK headers. Re: #69688
  • Completes rework for "mismatched" SDK compatibility. Re: #69867
  • Makes clockid_t an enum, matching SDK behavior.
  • Makes mildly invasive support for "earlier" SDKs a non-default option.

TESTED:
Tested both normal and -devel versions 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-14.x arm64.
Builds on all tested platforms except 10.4 ppc +universal.
Passes all tests in all buildable cases.

comment:21 Changed 2 months ago by fhgwright (Fred Wright)

In a16240162b34f3a69eab8c529bd6bef7d25d51df/macports-ports (master):

legacy-support-devel: Update to latest master.

Since the previous legacy-support-devel:

  • Adds SLIST_REMOVE_AFTER, SLIST_HEAD_INITIALIZER Re: #69890
  • Adds fgetattrlist()

In the previous legacy-support-devel, since v1.2.4:

  • Adds optional security wrapper for stpncpy(). Re: #69878
  • Moves renameat() prototype to the proper header location.
  • Fixes incorrect CLOCK_UPTIME_RAW_APPROX definition
  • Eliminates spurious fmemopen() in OSes that don't need it
  • Adds appropriate DARWIN_C_LEVEL conditionals, as in SDK headers. Re: #69688
  • Reworks headers for "mismatched" SDK compatibility. Re: #69867
  • Makes clockid_t an enum, matching SDK behavior.

TESTED:
Tested both normal and -devel versions 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-14.x arm64.
Builds on all tested platforms except 10.4 ppc +universal.
Passes all tests in all buildable cases.

comment:22 Changed 6 weeks ago by fhgwright (Fred Wright)

In ceccb8bb27da3987f9c191f0ad8181998af1831c/macports-ports (master):

legacy-support: Update to v1.3.0.

  • Adds optional security wrapper for stpncpy(). Re: #69878
  • Moves renameat() prototype to the proper header location.
  • Fixes incorrect CLOCK_UPTIME_RAW_APPROX definition.
  • Eliminates spurious fmemopen() in OSes that don't need it.
  • Adds appropriate DARWIN_C_LEVEL conditionals, as in SDK headers. Re: #69688
  • Reworks headers for "mismatched" SDK compatibility. Re: #69867
  • Makes clockid_t an enum, matching SDK behavior.
  • Adds SLIST_REMOVE_AFTER, SLIST_HEAD_INITIALIZER. Re: #69890
  • Adds fgetattrlist(). Closes: #70350

Portfile changes:

  • Removes obsolete portion of Tiger-specific additions.
  • Moves atexit removal from post-extract to pre-patch, to respect expected phase behavior.

TESTED:
Tested both normal and -devel versions (currently identical) 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-14.x arm64.
Builds on all tested platforms except 10.4 ppc +universal.
Passes all tests in all buildable cases.

Note: See TracTickets for help on using tickets.