Skip to content
Snippets Groups Projects
  1. Nov 24, 2024
    • Fred Wright's avatar
      test_fdopendir: Add non-POSIX variant. · 3fc18563
      Fred Wright authored
      This provides coverage for the non-UNIX2003 variant on 32-bit
      platforms.
      
      TESTED:
      Passes on all platforms.  Generates expected references.
      3fc18563
    • Fred Wright's avatar
      Makefile: Rip out splitandfilterandmergemultiarch, etc. · cf1a237e
      Fred Wright authored
      Now that splitandfilterandmergemultiarch and its callers are no longer
      used (solely to build fdopendir), they can be removed.  This also
      removed the only references to LDX (formerly LD), LIPO, and PLATFORM,
      so their default definitions are removed as well.
      
      TESTED:
      Build still works (and tests pass) on all platforms.
      cf1a237e
    • Fred Wright's avatar
      fdopendir: Rework to handle variants directly in source. · d43551c9
      Fred Wright authored
      This reworks the fdopendir code to directly build all the needed
      variants, instead of the horrible splitandfilterandmergemultiarch
      kludge in the Makefile.  Not only does it reduce code duplication, but
      it also drastically improves readability.  It does not change the
      underlying logic in the "guts", but merely changes the interfacing to
      the different variants.
      
      This was the only use of splitandfilterandmergemultiarch, which will
      be excised in a subsequent commit.
      
      A subtle problem that this introduced is that the empty object filter
      for the static library was previously failing to filter fdopendir.o
      due to the way it was constructed, but fixing that resulted in a truly
      empty static library on 10.15+ platforms.  This is actually illegal,
      so there's now a hack to put one dummy object into the archive in this
      case.  The dummy object defines a single global symbol, thereby
      avoiding the "has no symbols" warning from 'ar' and other tools.
      
      TESTED:
      Builds and passes all tests (including the new one in a subsequent
      commit), on all platforms.
      d43551c9
    • Fred Wright's avatar
      Makefile: Use system tools. · 2aad6bae
      Fred Wright authored
      Referencing the "bare" ar, ld, lipo, and install_name_tool
      opportunistically uses the MacPorts cctools and ld64 versions, without
      explicit dependencies.  This adds the explicit /usr/bin/ prefix to all
      but lipo to avoid that.  These are still overridable defaults.
      
      Since LD and AR are standard make defaults, defaulting them doesn't
      work.  We switch to LDX and ARX to avoid that.
      
      The lipo reference is left as is (since the system lipo is
      inadequate), but is expected to go away in the near future.
      
      TESTED:
      Builds (including tests) on all platforms, with all applicable SDKs.
      2aad6bae
    • Fred Wright's avatar
      test_fdopendir: Add fstatat() buffer overrun defense. · e8d226b2
      Fred Wright authored
      At the time of this writing, fstatat() may choose the wrong variant of
      stat to return, possibly overflowing the provided buffer.  To defend
      against this, we make the buffer the larger of the two possible sizes,
      and also move it off the stack for less verbosity when debugging.  See
      the comment in the code.
      
      TESTED:
      All versions pass, including previously crashing ino32 cases.
      e8d226b2
    • Fred Wright's avatar
      test_fdopendir: Add verbose mode. · 3662d5f8
      Fred Wright authored
      This simply turns the old 'FEEDBACK' compile-time option into a
      runtime option.
      
      Also adds a one-line message on success.
      3662d5f8
    • Fred Wright's avatar
      test_fdopendir: Add versions with 32/64-bit inodes. · 61e9d6ed
      Fred Wright authored
      This ensures that both 32- and 64-bit inode cases are tested,
      regardless of the platform default.
      
      TESTED:
      Pass (except known ino32 bug) on all platforms, with all applicable
      SDKs.
      61e9d6ed
    • Fred Wright's avatar
      test_scandir: Add version with 64-bit inodes. · 13d13438
      Fred Wright authored
      Also fixes 32-bit wrapper to use proper config flag, and to disable it
      on arm64, where it doesn't work.
      
      TESTED:
      Passes on all platforms with all applicable SDKs.
      13d13438
    • Fred Wright's avatar
      Makefile: Add DEBUG and OPT options. · b622f1db
      Fred Wright authored
      The OPT value (default -Os) is included in compile commands, and the
      DEBUG value is included in both compile and link commands.
      
      TESTED:
      Both default and debug settings work.
      b622f1db
  2. Nov 16, 2024
    • Fred Wright's avatar
    • Fred Wright's avatar
      Remove obsolete replacement which. · a3c9731c
      Fred Wright authored
      This patched csh script has been replaced by a build of the C version.
      a3c9731c
    • Fred Wright's avatar
      Makefile: Use C-based 'which' on Tiger. · 4defe287
      Fred Wright authored
      Unlike the 10.5+ 'which' command, which is a C program, the
      OS-supplied 10.4 version is a csh script, with some deficiencies.
      Since 2019, legacy-support has been supplying a patched version
      of the csh script correcting some, but not all, deficiencies.  In
      particular, the replacement version doesn't implement the '-a'
      option, without providing an informative error message.
      
      This change replaces the patched csh script with a build of the
      10.5 version.  For consistency, it has the same universality as
      the Apple-supplied programs, regardless of whether legacy-support
      is being built universal in general.  Specifically, it uses the
      new binarchs tool to copy the architectures from /usr/bin/true,
      since full universal builds don't work on 10.4 ppc.
      
      TESTED:
      Built and tested with all option combinations.
      Tested the updated install target.
      4defe287
    • Fred Wright's avatar
      Add tool to obtain architectures of a program. · 3cb2d812
      Fred Wright authored
      This is used to build a program with the same architecture(s) as
      a specified program (default /usr/bin/true).
      3cb2d812
    • Fred Wright's avatar
      which.c: Fix buildability. · 7ab30e4d
      Fred Wright authored
      Provides a dummy definition of __FBSDID to avoid compile errors,
      without deleting the ID string inherited from FreeBSD.
      
      TESTED:
      Builds now work on 10.4, including universal builds where applicable.
      7ab30e4d
    • Fred Wright's avatar
      Import 10.5 which.c and which.1. · 13181f61
      Fred Wright authored
      This brings in the sources for Apple's 10.5 C-based 'which' (from
      FreeBSD), verbatim @shell_cmds-116.  A future commit will use them.
      13181f61
    • Fred Wright's avatar
      Add tool to create temporary tool Makefile. · 1010bab0
      Fred Wright authored
      This creates a simple Makefile for C programs, with architecture(s)
      derived from macports.conf.
      
      TESTED:
      Makefile has proper architectures with all options on all platforms.
      1010bab0
    • Fred Wright's avatar
      test_pthread_get_stacksize_np: Fix incorrect message. · 42932b8d
      Fred Wright authored
      TESTED:
      Message is now correct.
      42932b8d
    • Fred Wright's avatar
      pthread_get_stacksize_np: Cache dlsym() result. · f1488bae
      Fred Wright authored
      This avoids repeatedly looking up the symbol for the OS call.
      
      Also cleans up indentation.
      
      TESTED:
      Passes tests on all platforms.
      f1488bae
    • Fred Wright's avatar
      sysconf: Speed up _SC_PHYS_PAGES. · 8292b6c1
      Fred Wright authored
      It's a silly waste of time to use the string-lookup version of
      sysconf() rather than using the numeric version, even though that's
      what Apple's code does.
      
      Also adds comment explaining 32-bit issues.
      
      Also, since the "i386" bug in Apple's code is really a 32-bit bug, the
      feature-flag condition is adjusted to be more honest.  This has no
      actual effect, since i386 is the only supported 32-bit processor in
      the relevant OS versions.  This removes the only reference to
      __MPLS_APPLE_I386__, but the definition is retained in case it's
      useful in the future.
      
      TESTED:
      Passes tests on all platforms.
      8292b6c1
    • Fred Wright's avatar
      sysconf: Cache dlsym() result. · 616bb9fc
      Fred Wright authored
      This avoids repeating the symbol lookup on every call.
      
      TESTED:
      Passes tests on all platforms.
      616bb9fc
    • Fred Wright's avatar
      README-CPP.txt: Remove trailing space. · 077f08b2
      Fred Wright authored
      077f08b2
  3. Nov 14, 2024
    • Fred Wright's avatar
      test_realpath: Add nonexistent path case. · 42c54ff9
      Fred Wright authored
      Although more thorough testing of various path cases would be useful,
      this one, which just tests a simple nonexistent relative path, is
      sufficient to demonstrate a bug in the 10.6 non-POSIX realpath(),
      which returns "success" via an unsafe pointer to an internal buffer.
      
      TESTED:
      Fails in known bad case without the fix; passes in all cases with the
      fix.
      42c54ff9
    • Fred Wright's avatar
      realpath: Fix 10.6 non-POSIX version. · 46a30685
      Fred Wright authored
      This adds our allocating wrapper to the 10.6 non-POSIX case, which
      returns an unsafe buffer pointer when supplied with a nonexistent path
      and no buffer.  Providing our own malloc()ed buffer avoids the
      problem.  This only affects 32-bit builds, since 64-bit non-POSIX is
      nonexistent.
      
      The original flag is renamed in the process, with the original name
      now reflecting the combined need for the wrapper.
      
      Some whitespace cleanup is also applied to the other composite flag
      definitions.
      
      Updates README to reflect the fix.
      
      TESTED:
      Tests pass on all platforms, including newly added test case (next
      commit).
      46a30685
    • Fred Wright's avatar
      Makefile: Include ARCHFLAGS for xtests/mantests. · 301c8575
      Fred Wright authored
      The rework of the Makefile recipes dropped this, which impacts
      those test builds for non-default architectures.
      
      TESTED:
      ARCHFLAGS is now honored as intended.
      301c8575
  4. Nov 07, 2024
    • Fred Wright's avatar
      Fix build on 10.4 x86_64 · 8dfd6277
      Fred Wright authored
      The special treatment for 10.4 in splitandfilterandmergemultiarch was
      not being applied appropriately to x86_64, causing a build failure
      for fdopendir.
      
      Fixing this bug prior to fixing the realpath() wrapper resulted in
      successfully building code that didn't work correctly, though the
      realpath() bug wasn't limited to this one configuration.
      
      Note that at the time of this writing, when this case is built as a
      port, the architecture is coerced to i386.  Until that is fixed, this
      fix won't affect the actual port.
      
      TESTED:
      With the realpath() fix, builds successfully on all platforms,
      including 10.4 x86_64.
      8dfd6277
    • Fred Wright's avatar
      test_realpath: Add test for legacy compatibility entry. · b70895d1
      Fred Wright authored
      This tests the macports_legacy_realpath() entry point, which is no
      longer used by new builds but possibly referenced by old builds.
      
      TESTED:
      Passes on all platforms; fails when the legacy entry is disabled.
      b70895d1
    • Fred Wright's avatar
      Fix realpath_nonext for 10.15. · 833254fb
      Fred Wright authored
      This excludes testing the non-POSIX version on 10.15, which has a bug
      (Apple's).
      
      Also reverses order of nonposix cases, for consistency, and expands
      the comment.
      
      TESTED:
      Now passes on all platforms.
      833254fb
    • Fred Wright's avatar
      Add tests for alternate realpath() versions. · ca62f3ea
      Fred Wright authored
      This ensures that all three versions of realpath() (two in 64-bit
      builds) have test coverage.  The test for the impossible 64-bit
      non-POSIX case is a dummy.
      
      The 10.15 non-POSIX realpath() has a bug (unrelated to
      legacy-support) causing the relevant test to fail.  A subsequent
      commit excludes that case from the test.
      
      This test uncovered real bugs in the former wrapper implementation.
      
      TESTED:
      Without the realpath() fix, fails on 10.5 and on 10.4 with later SDK.
      With the fix, passes on all platforms (except as noted above).
      ca62f3ea
    • Fred Wright's avatar
      Rewrite realpath() wrapper. · b3de412f
      Fred Wright authored
      The former implementation didn't necessarily provide all versions of
      realpath() that might be invoked, and didn't necessarily invoke the
      proper version.  That led to possible crashes and possible unnecessary
      semantic differences.  This fixes all that, though it doesn't retrofit
      the 10.5+ semantic changes to 10.4 (and neither did the earlier
      implementation).
      
      The former implementation also failed to return any internally
      allocated buffer on failures, causing a memory leak.  That is now
      fixed as well.
      
      TESTED:
      Builds and passes all tests (including expanded tests) on all
      platforms, with all applicable SDKs.
      b3de412f
    • Fred Wright's avatar
      Add convenience flag for 64-bit checks. · 49ebada0
      Fred Wright authored
      49ebada0
    • Fred Wright's avatar
      Improve test_realpath. · 02a51528
      Fred Wright authored
      Makes failures more informative, and minimizes output in success
      case unless -v option is given.  Also includes a test for the
      "traditional" realpath().
      
      TESTED:
      Provides better information, while still demonstrating the failure on
      10.4 x86_64.
      02a51528
    • Fred Wright's avatar
      Add realpath_test tool. · 88f2d1b7
      Fred Wright authored
      This provides a tool for investigating the behavior of the different
      versions of realpath() with specified paths.
      88f2d1b7
    • Fred Wright's avatar
      Makefile: Fix test_clean. · e0b2f96f
      Fred Wright authored
      The recently added test_clean target was initially misisng a couple
      of items, and became much more deficient with the addition of
      the new test targets.  This fixes all that, as well as removing
      some redundant entries from the main clean target.
      
      TESTED:
      All build products from test_all are now removed by test_clean.
      e0b2f96f
  5. Nov 04, 2024
    • Fred Wright's avatar
      Makefile: Fix superfluous library rebuilds. · f1becf12
      Fred Wright authored
      The fix for parallel builds made directories separate targets, but
      directory dependencies need to be order-only, since their mtimes are
      updated whenever files are added, removed, or renamed.  Failure to do
      this resulted in intermittent unnecessary rebuilds of libraries when
      building tests.  When building directly in the repo, this is a
      harmless waste of time, but when building in the MacPorts context,
      such rebuilds fail due to ownership and permission issues.  This
      change makes directories order-only dependencies, thereby ignoring
      their mtimes.
      
      This also removes unnecessary directory dependencies from the tests
      that don't use the library.
      
      TESTED:
      Ran tests on all platforms.  Intermittent test failures are now gone.
      f1becf12
    • Fred Wright's avatar
      Hide atexit.c until it's fixed. · 295b94ae
      Fred Wright authored
      This has the same effect as what the Portfile has been doing all along,
      but in a less kludgy manner.
      
      TESTED:
      Has the desired effect on the sources.
      295b94ae
    • Fred Wright's avatar
      Makefile: Add syslib and 'all' test targets. · 56c09343
      Fred Wright authored
      The syslib targets run versions of the tests linked against the
      "system" version of the library, substituting for the normal OS system
      library.  This provides a check that the syslib was built correctly.
      
      Targets for all syslib tests and all versions of all tests are added.
      
      TESTED:
      Tests build and pass on all platforms.
      New targets run all expected tests.
      56c09343
    • Fred Wright's avatar
      Rename sources with overly verbose names. · 56efe80a
      Fred Wright authored
      Six source files contained "macports_legacy_" prefixes in their
      filenames, which is redundant and overly verbose.  This removes those
      prefixes.
      
      No Makefile adjustment is needed, since it relies on wildcards.
      
      TESTED:
      Build succeeds and tests pass.
      56efe80a
    • Fred Wright's avatar
      test_arc4random: Fix warning. · 8c9e4f68
      Fred Wright authored
      The result of a function being tested is discarded, which produces a
      "set but not used" warning from some compilers.  We add a void cast to
      avoid this.
      
      TESTED:
      Previously present warnings are now gone.
      8c9e4f68
    • Fred Wright's avatar
      Makefile: Fix parallel builds. · c8612c60
      Fred Wright authored
      Creating directories with "install -d" suffers from a race condition,
      because, although it first-order avoids creating directories that
      already exist, if multiple instances attempt to create a given
      directory at the same time, the error due to a collision is not
      correctly handled.  To get around this, we make separate recipes for
      directory creation, with dependencies on them in the rules that
      populate them.
      
      Unfortunately, this makes the automatic variables useless for some of
      the populating commands, since they include the directories.  In such
      cases, we need to use explicit variables for the input files.
      
      Maintaining the unused ability to put static and dynamic libraries in
      separate directories (while not actually being separate) would have
      complicated things, so that capability has been dropped.
      
      This special treatment of directories is not applied to the
      installation of headers, since that's a complicated multi-directory
      target only used in a single recipe, and hence not vulnerable to
      parallelism.
      
      TESTED:
      All builds now succeed with parallelism, including those that
      previously exhibited a failure.
      c8612c60
    • Fred Wright's avatar
      Rewrite symbol aliases test. · 33e1b3f8
      Fred Wright authored
      The old symbol aliases test relied on looking up symbols with dlsym(),
      which doesn't work with a statically-linked library.  This rewrites it
      to use ordinary external references, which will fail if the referenced
      symbols are missing.
      
      This means that any errors are build-time errors rather than runtime
      errors.  As noted in the comment, there's theoretically a way to avoid
      that by using weak references, but we don't bother to wrestle with the
      added complications of that approach.
      
      TESTED:
      This version passes with both static and dynamic libraries.
      33e1b3f8
Loading