ExportXMLWordPrintableJSON

    • DevProd Build
    • Fully Compatible
    • ALL
    • Build OnDeck
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Problem

      Cross-compiled release archives use the build host architecture in their top-level extraction directory. Dylan Richardson reported this when downloading the s390x enterprise RHEL 9 binaries for MongoDB 9.0.7: the archive extracts into an aarch64-named directory even though mongod correctly reports s390x.

      Observed directory:

      mongodb-linux-aarch64-enterprise-rhel9-9.0.7/
      

      Expected directory:

      mongodb-linux-s390x-enterprise-rhel9-9.0.7/
      

      The supplied mongod --version output reports:

      {
        "version": "9.0.7",
        "gitVersion": "490348b4bbbf1bceb434baa206d7857e3ec1ec8a",
        "environment": {
          "distmod": "rhel9",
          "distarch": "s390x",
          "target_arch": "s390x"
        }
      }
      

      Root Cause

      Source inspection on master at b7ea0b259e4 shows:

      • bazel/wrapper_hook/write_wrapper_hook_bazelrc.py:get_mongo_arch() derives MONGO_ARCH from platform.machine() and ignores its arguments.
      • The dist definition in BUILD.bazel uses {MONGO_ARCH} in package_extract_name.
      • bazel/install_rules/install_rules.bzl passes that name to pkg_tar and pkg_zip as package_dir.
      • The enterprise RHEL 9 s390x variant cross-compiles on ARM64 using --config=linux-s390x-rhel9-cross-rbe-arm64, so the host-derived value is aarch64.
      • Binary buildInfo already resolves its architecture from the target platform; the remaining defect is in archive naming.

      Proposed Fix

      Resolve the archive directory architecture from Bazel's target CPU constraints, preserving the established distribution spellings (x86_64, aarch64, ppc64le, s390x). Apply consistently to the stripped and debug distribution archives and supported archive formats, including native and cross builds.
      A narrowly scoped mitigation is to pass --define=MONGO_ARCH=s390x in the affected variant's compile flags (and ppc64le for PPC variants), overriding the host-derived default.

      Acceptance Criteria

      • An ARM64-hosted s390x build produces an s390x-named top-level directory matching the binary target architecture.
      • Cross-built PPC archives use ppc64le rather than the host architecture.
      • Native distribution directory naming remains consistent with existing release conventions.
      • Add regression coverage for host/target architecture mismatches and validate the produced archive member paths.
      • Track backport requests for v9.0, v8.3, v8.2, v8.0, and v7.0. Adapt the fix to each branch's packaging implementation and verify applicability on older branches.

      Related Work

      SERVER-136923 fixed target architecture in cross-compiled server buildInfo.
      SERVER-136176 tracks the zseries cross-compilation backports.

      Evidence and Impact

      The 9.0.7 observation and version output are from Dylan Richardson's report supplied by the requester. Source inspection confirms the naming path; an archive has not been rebuilt during this investigation. This produces misleading extraction paths and can break scripts that expect the target architecture in the distribution directory name.

            Assignee:
            Daniel Moody
            Reporter:
            Daniel Moody
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: