This is an automated email from the ASF dual-hosted git repository.

zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git


The following commit(s) were added to refs/heads/main by this push:
     new 5fc8ca615 fix(c/driver_manager,rust/driver_manager): establish 
standard platform tuples (#3313)
5fc8ca615 is described below

commit 5fc8ca615fe7cf8e1324cebc97c3ca43776db8cc
Author: Matt Topol <[email protected]>
AuthorDate: Wed Aug 20 15:50:41 2025 -0400

    fix(c/driver_manager,rust/driver_manager): establish standard platform 
tuples (#3313)
    
    Add to the docs an authoritative definition of the platform tuples we'll
    use for the driver manager (for OS, Arch, env). Update the C and Rust
    driver managers to use these authoritative platform tuple strings.
    
    This should unify everything to a specific way of identifying platform
    tuples with Driver manifests.
    
    ---------
    
    Co-authored-by: Bryce Mecum <[email protected]>
---
 c/driver_manager/current_arch.h         | 53 ++++++++++++++++++++++-
 docs/source/format/driver_manifests.rst | 77 +++++++++++++++++++++++++++++++++
 go/adbc/drivermgr/current_arch.h        | 55 ++++++++++++++++++++++-
 rust/driver_manager/src/lib.rs          | 20 ++++++---
 4 files changed, 197 insertions(+), 8 deletions(-)

diff --git a/c/driver_manager/current_arch.h b/c/driver_manager/current_arch.h
index ab0444f41..fc7167c20 100644
--- a/c/driver_manager/current_arch.h
+++ b/c/driver_manager/current_arch.h
@@ -19,15 +19,38 @@
 
 #include <string>
 
+#if defined(_WIN32)
+#define ADBC_LITTLE_ENDIAN 1
+#else
+#if defined(__APPLE__) || defined(__FreeBSD__)
+#include <machine/endian.h>
+#elif defined(sun) || defined(__sun)
+#include <sys/byteorder.h>
+#elif !defined(_AIX)
+#include <endian.h>
+#endif
+#if !defined(__BYTE_ORDER__) || !defined(__ORDER_LITTLE_ENDIAN__)
+#define ADBC_LITTLE_ENDIAN 1
+#else
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#define ADBC_LITTLE_ENDIAN 1
+#else
+#define ADBC_LITTLE_ENDIAN 0
+#endif
+#endif
+#endif
+
 namespace adbc {
 
 const std::string& CurrentArch() {
 #if defined(_WIN32)
   static const std::string platform = "windows";
 #elif defined(__APPLE__)
-  static const std::string platform = "osx";
+  static const std::string platform = "macos";
 #elif defined(__FreeBSD__)
   static const std::string platform = "freebsd";
+#elif defined(__OpenBSD__)
+  static const std::string platform = "openbsd";
 #elif defined(__linux__)
   static const std::string platform = "linux";
 #else
@@ -37,17 +60,45 @@ const std::string& CurrentArch() {
 #if defined(__x86_64__) || defined(__amd64__) || defined(_M_X64) || 
defined(_M_AMD64)
   static const std::string arch = "amd64";
 #elif defined(__aarch64__) || defined(_M_ARM64) || defined(__ARM_ARCH_ISA_A64)
+#ifdef ADBC_LITTLE_ENDIAN
   static const std::string arch = "arm64";
+#else
+  static const std::string arch = "arm64be";
+#endif
 #elif defined(__i386__) || defined(_M_IX86) || defined(_M_X86)
   static const std::string arch = "x86";
 #elif defined(__arm__) || defined(_M_ARM)
+#ifdef ADBC_LITTLE_ENDIAN
   static const std::string arch = "arm";
+#else
+  static const std::string arch = "armbe";
+#endif
 #elif defined(__riscv) || defined(_M_RISCV)
+#if defined(__riscv_xlen) && __riscv_xlen == 64
+  static const std::string arch = "riscv64";
+#else
   static const std::string arch = "riscv";
+#endif
+#elif defined(__ppc64__) || defined(__powerpc64__)
+#ifdef ADBC_LITTLE_ENDIAN
+  static const std::string arch = "powerpc64le";
+#else
+  static const std::string arch = "powerpc64";
+#endif
 #elif defined(__powerpc__) || defined(__ppc__) || defined(_M_PPC)
   static const std::string arch = "powerpc";
 #elif defined(__s390x__) || defined(_M_S390)
   static const std::string arch = "s390x";
+#elif defined(__sparc__) || defined(__sparc)
+#if defined(_LP64) || defined(__LP64__)
+  static const std::string arch = "sparc64";
+#else
+  static const std::string arch = "sparc";
+#endif
+#elif defined(__wasm32__)
+  static const std::string arch = "wasm32";
+#elif defined(__wasm64__)
+  static const std::string arch = "wasm64";
 #else
   static const std::string arch = "unknown";
 #endif
diff --git a/docs/source/format/driver_manifests.rst 
b/docs/source/format/driver_manifests.rst
index 5b9996cfc..9dcdfcbf2 100644
--- a/docs/source/format/driver_manifests.rst
+++ b/docs/source/format/driver_manifests.rst
@@ -239,6 +239,83 @@ a string (single path) or a table of platform-specific 
paths.  The ``Driver.shar
 needed to successfully load a driver manifest.  The other keys are optional, 
but provide useful metadata
 about the driver.
 
+Platform Tuples
+^^^^^^^^^^^^^^^
+
+Since the manifests use platform tuples to specify the different systems that
+drivers might be built for, it is important to create a consistent way to name
+these tuples. Specifically, consistent naming for operating system (OS) and
+architecture combinations that can be used by all systems that read and/or 
write
+manifest files.
+
+As such, the following table should be considered the authoritative list:
+
++---------------+---------------+
+| OS            | Tuple Name    |
++===============+===============+
+| Linux         | ``linux``     |
++---------------+---------------+
+| macOS         | ``macos``     |
++---------------+---------------+
+| Windows       | ``windows``   |
++---------------+---------------+
+| FreeBSD       | ``freebsd``   |
++---------------+---------------+
+| OpenBSD       | ``openbsd``   |
++---------------+---------------+
+
++---------------+-----------------+
+| Architecture  | Tuple Name      |
++===============+=================+
+| i386          | ``x86``         |
++---------------+-----------------+
+| x86           | ``x86``         |
++---------------+-----------------+
+| x86-64        | ``amd64``       |
++---------------+-----------------+
+| x64           | ``amd64``       |
++---------------+-----------------+
+| amd64         | ``amd64``       |
++---------------+-----------------+
+| arm (32-bit)  | ``arm``         |
++---------------+-----------------+
+| armbe (32-bit)| ``armbe``       |
++---------------+-----------------+
+| arm64be       | ``arm64be``     |
++---------------+-----------------+
+| aarch64       | ``arm64``       |
++---------------+-----------------+
+| arm64         | ``arm64``       |
++---------------+-----------------+
+| s390x         | ``s390x``       |
++---------------+-----------------+
+| ppc           | ``powerpc``     |
++---------------+-----------------+
+| ppc64         | ``powerpc64``   |
++---------------+-----------------+
+| ppc64le       | ``powerpc64le`` |
++---------------+-----------------+
+| riscv         | ``riscv``       |
++---------------+-----------------+
+| riscv64       | ``riscv64``     |
++---------------+-----------------+
+| sparc         | ``sparc``       |
++---------------+-----------------+
+| sparc64       | ``sparc64``     |
++---------------+-----------------+
+| Wasm (32-bit) | ``wasm32``      |
++---------------+-----------------+
+| Wasm (64-bit) | ``wasm64``      |
++---------------+-----------------+
+
+The construction of the platform tuple is: ``<OS>_<Architecture>``, for 
example:
+``linux_amd64``.
+
+.. note::
+   For alternative scenarios such as using musl instead of the GNU C Library
+   (glibc) or MinGW, the tuple should have the appropriate suffix for that
+   environment. i.e. ``linux_amd64_musl`` or ``windows_amd64_mingw``.
+
 Manifest Location and Discovery
 -------------------------------
 
diff --git a/go/adbc/drivermgr/current_arch.h b/go/adbc/drivermgr/current_arch.h
index 15ab2774e..fc7167c20 100644
--- a/go/adbc/drivermgr/current_arch.h
+++ b/go/adbc/drivermgr/current_arch.h
@@ -19,15 +19,38 @@
 
 #include <string>
 
+#if defined(_WIN32)
+#define ADBC_LITTLE_ENDIAN 1
+#else
+#if defined(__APPLE__) || defined(__FreeBSD__)
+#include <machine/endian.h>
+#elif defined(sun) || defined(__sun)
+#include <sys/byteorder.h>
+#elif !defined(_AIX)
+#include <endian.h>
+#endif
+#if !defined(__BYTE_ORDER__) || !defined(__ORDER_LITTLE_ENDIAN__)
+#define ADBC_LITTLE_ENDIAN 1
+#else
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#define ADBC_LITTLE_ENDIAN 1
+#else
+#define ADBC_LITTLE_ENDIAN 0
+#endif
+#endif
+#endif
+
 namespace adbc {
 
 const std::string& CurrentArch() {
 #if defined(_WIN32)
   static const std::string platform = "windows";
 #elif defined(__APPLE__)
-  static const std::string platform = "osx";
+  static const std::string platform = "macos";
 #elif defined(__FreeBSD__)
   static const std::string platform = "freebsd";
+#elif defined(__OpenBSD__)
+  static const std::string platform = "openbsd";
 #elif defined(__linux__)
   static const std::string platform = "linux";
 #else
@@ -37,17 +60,45 @@ const std::string& CurrentArch() {
 #if defined(__x86_64__) || defined(__amd64__) || defined(_M_X64) || 
defined(_M_AMD64)
   static const std::string arch = "amd64";
 #elif defined(__aarch64__) || defined(_M_ARM64) || defined(__ARM_ARCH_ISA_A64)
+#ifdef ADBC_LITTLE_ENDIAN
   static const std::string arch = "arm64";
+#else
+  static const std::string arch = "arm64be";
+#endif
 #elif defined(__i386__) || defined(_M_IX86) || defined(_M_X86)
   static const std::string arch = "x86";
 #elif defined(__arm__) || defined(_M_ARM)
+#ifdef ADBC_LITTLE_ENDIAN
   static const std::string arch = "arm";
+#else
+  static const std::string arch = "armbe";
+#endif
 #elif defined(__riscv) || defined(_M_RISCV)
+#if defined(__riscv_xlen) && __riscv_xlen == 64
+  static const std::string arch = "riscv64";
+#else
   static const std::string arch = "riscv";
+#endif
+#elif defined(__ppc64__) || defined(__powerpc64__)
+#ifdef ADBC_LITTLE_ENDIAN
+  static const std::string arch = "powerpc64le";
+#else
+  static const std::string arch = "powerpc64";
+#endif
 #elif defined(__powerpc__) || defined(__ppc__) || defined(_M_PPC)
   static const std::string arch = "powerpc";
 #elif defined(__s390x__) || defined(_M_S390)
   static const std::string arch = "s390x";
+#elif defined(__sparc__) || defined(__sparc)
+#if defined(_LP64) || defined(__LP64__)
+  static const std::string arch = "sparc64";
+#else
+  static const std::string arch = "sparc";
+#endif
+#elif defined(__wasm32__)
+  static const std::string arch = "wasm32";
+#elif defined(__wasm64__)
+  static const std::string arch = "wasm64";
 #else
   static const std::string arch = "unknown";
 #endif
@@ -76,7 +127,7 @@ const std::string& CurrentArch() {
 #if defined(__MINGW32__) || defined(__MINGW64__)
   static const std::string target = "_mingw";
 #elif defined(__MUSL__)
-  static const std::string target = "_musl"
+  static const std::string target = "_musl";
 #else
   static const std::string target = "";
 #endif
diff --git a/rust/driver_manager/src/lib.rs b/rust/driver_manager/src/lib.rs
index d583996da..21f08251a 100644
--- a/rust/driver_manager/src/lib.rs
+++ b/rust/driver_manager/src/lib.rs
@@ -1804,14 +1804,24 @@ fn get_search_paths(lvls: LoadFlags) -> Vec<PathBuf> {
 const fn arch_triplet() -> (&'static str, &'static str, &'static str) {
     #[cfg(target_arch = "x86_64")]
     const ARCH: &str = "amd64";
-    #[cfg(target_arch = "aarch64")]
+    #[cfg(all(target_arch = "aarch64", target_endian = "big"))]
+    const ARCH: &str = "arm64be";
+    #[cfg(all(target_arch = "aarch64", target_endian = "little"))]
     const ARCH: &str = "arm64";
-    #[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
+    #[cfg(all(target_arch = "powerpc64", target_endian = "little"))]
+    const ARCH: &str = "powerpc64le";
+    #[cfg(all(target_arch = "powerpc64", target_endian = "big"))]
+    const ARCH: &str = "powerpc64";
+    #[cfg(target_arch = "riscv32")]
+    const ARCH: &str = "riscv";
+    #[cfg(not(any(
+        target_arch = "x86_64",
+        target_arch = "aarch64",
+        target_arch = "powerpc64",
+        target_arch = "riscv32",
+    )))]
     const ARCH: &str = std::env::consts::ARCH;
 
-    #[cfg(target_os = "macos")]
-    const OS: &str = "osx";
-    #[cfg(not(target_os = "macos"))]
     const OS: &str = std::env::consts::OS;
 
     #[cfg(target_env = "musl")]

Reply via email to