You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tsfile.apache.org by co...@apache.org on 2026/09/17 07:36:36 UTC

(tsfile) 21/22: fix(ci): resolve native package portability failures

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

ColinLeeo pushed a commit to branch feat/native-package-artifacts
in repository https://gitbox.apache.org/repos/asf/tsfile.git

commit ba4fb6f6858cffeee77ecba9c2d04e2230715e19
Author: ColinLee <sh...@163.com>
AuthorDate: Thu Sep 10 23:55:27 2026 +0800

    fix(ci): resolve native package portability failures
---
 .github/workflows/native-packages.yml    |  1 +
 cpp/src/utils/util_define.h              |  4 +-
 packaging/tests/check_native_workflow.rb |  5 +++
 packaging/tests/test_native_install.py   | 76 +++++++++++++++++++++++++++++++-
 4 files changed, 83 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/native-packages.yml b/.github/workflows/native-packages.yml
index 99bf2d8bb..187bb91fd 100644
--- a/.github/workflows/native-packages.yml
+++ b/.github/workflows/native-packages.yml
@@ -581,6 +581,7 @@ jobs:
       - name: Merge both bottle tags into the Formula
         shell: bash
         run: |
+          brew trust apache/tsfile-dev
           brew bottle --merge --write --no-commit homebrew/bottles/*.json
           tap_path="$(brew --repository apache/tsfile-dev)"
           cp "$tap_path/Formula/tsfile-dev.rb" homebrew/Formula/tsfile-dev.rb
diff --git a/cpp/src/utils/util_define.h b/cpp/src/utils/util_define.h
index f7f638e5b..33784e152 100644
--- a/cpp/src/utils/util_define.h
+++ b/cpp/src/utils/util_define.h
@@ -120,14 +120,14 @@ typedef int mode_t;
 #endif  // __GNUC__ >= 4
 
 /* ======== nullptr ======== */
-#if __cplusplus < 201103L
+#if __cplusplus < 201103L && !defined(_MSC_VER)
 #ifndef nullptr
 #define nullptr NULL
 #endif
 #define OVERRIDE
 #else
 #define OVERRIDE override
-#endif  // __cplusplus < 201103L
+#endif  // __cplusplus < 201103L && !defined(_MSC_VER)
 
 /* ======== cache line ======== */
 #ifndef CACHE_LINE_SIZE
diff --git a/packaging/tests/check_native_workflow.rb b/packaging/tests/check_native_workflow.rb
index 053e25174..828c6630a 100644
--- a/packaging/tests/check_native_workflow.rb
+++ b/packaging/tests/check_native_workflow.rb
@@ -41,6 +41,11 @@ raise "Windows ZIP needs a consistent static CRT" unless windows.include?("-DTSF
 raise "All native target runtimes must be checked" unless windows.include?("CheckStaticMSVCRuntime.cmake")
 raise "Both staged and extracted PE imports must be checked" unless windows.scan("python packaging/scripts/verify_windows_runtime.py").size == 2
 
+homebrew_merge = jobs.fetch("merge-homebrew").fetch("steps").filter_map { |step| step["run"] }.join("\n")
+trust = homebrew_merge.index("brew trust apache/tsfile-dev")
+merge = homebrew_merge.index("brew bottle --merge")
+raise "Homebrew merge must trust its temporary tap before loading the Formula" unless trust && merge && trust < merge
+
 %w[test-deb test-rpm build-windows].each do |name|
   steps = jobs.fetch(name).fetch("steps")
   raise "#{name} must check out the consumer fixture" unless steps.any? { |step| step["uses"].to_s.start_with?("actions/checkout@") }
diff --git a/packaging/tests/test_native_install.py b/packaging/tests/test_native_install.py
index ed3eb5a10..0ce6d8b42 100644
--- a/packaging/tests/test_native_install.py
+++ b/packaging/tests/test_native_install.py
@@ -32,10 +32,44 @@ FIXTURES = ROOT / "cpp/cmake/tests/projects"
 
 
 class PublicHeaderCompatibilityTest(unittest.TestCase):
-    def test_static_assert_uses_the_native_keyword_for_msvc(self):
+    def test_simd_int64_reduction_normalizes_lane_types(self):
+        statistic = (ROOT / "cpp/src/common/statistic.h").read_text()
+        self.assertIn("std::min<int64_t>(simde_mm_cvtsi128_si64(vmin)", statistic)
+        self.assertIn("std::max<int64_t>(simde_mm_cvtsi128_si64(vmax)", statistic)
+        source = textwrap.dedent("""\
+            #include <algorithm>
+            #include <cstdint>
+
+            long simde_mm_cvtsi128_si64(int);
+            long long simde_mm_extract_epi64(int, int);
+
+            std::int64_t reduce_min(int value) {
+              return std::min<std::int64_t>(simde_mm_cvtsi128_si64(value),
+                                            simde_mm_extract_epi64(value, 1));
+            }
+            """)
+        result = subprocess.run(
+            [
+                *shlex.split(os.environ.get("CXX", "c++")),
+                "-fsyntax-only",
+                "-x",
+                "c++",
+                "-std=c++11",
+                "-",
+            ],
+            input=source,
+            text=True,
+            stdout=subprocess.PIPE,
+            stderr=subprocess.STDOUT,
+        )
+        self.assertEqual(result.returncode, 0, result.stdout)
+
+    def test_msvc_old_cplusplus_uses_native_cxx11_features(self):
         source = textwrap.dedent("""\
             #include "utils/util_define.h"
             class Probe { STATIC_ASSERT(true, MSVC_old_cplusplus); };
+            class Base { virtual void reset(); };
+            class Derived : public Base { void reset() OVERRIDE; };
             """)
         result = subprocess.run(
             [
@@ -59,6 +93,46 @@ class PublicHeaderCompatibilityTest(unittest.TestCase):
         self.assertEqual(result.returncode, 0, result.stdout[-4000:])
         self.assertRegex(result.stdout, r"class Probe \{\s*(?:static_assert|_Static_assert)")
         self.assertNotIn("static_assertion_MSVC_old_cplusplus", result.stdout)
+        self.assertIn("void reset() override", result.stdout)
+
+    def test_msvc_old_cplusplus_does_not_define_nullptr(self):
+        compatibility = (ROOT / "cpp/src/utils/util_define.h").read_text()
+        section = re.search(
+            r"/\* ======== nullptr ======== \*/\n(.*?)\n/\* ======== cache line",
+            compatibility,
+            re.S,
+        )
+        self.assertIsNotNone(section)
+        source = section.group(1) + textwrap.dedent("""\
+
+            #ifdef nullptr
+            #error nullptr must remain a native MSVC keyword
+            #endif
+            class Base { virtual void reset(); };
+            class Derived : public Base { void reset() OVERRIDE; };
+            int* pointer = nullptr;
+            """)
+        result = subprocess.run(
+            [
+                *shlex.split(os.environ.get("CXX", "c++")),
+                "-E",
+                "-P",
+                "-nostdinc",
+                "-x",
+                "c++",
+                "-std=c++11",
+                "-D_MSC_VER=1930",
+                "-D__cplusplus=199711L",
+                "-",
+            ],
+            input=source,
+            text=True,
+            stdout=subprocess.PIPE,
+            stderr=subprocess.STDOUT,
+        )
+        self.assertEqual(result.returncode, 0, result.stdout)
+        self.assertIn("void reset() override", result.stdout)
+        self.assertRegex(result.stdout, r"int\s*\*\s*pointer\s*=\s*nullptr")
 
 
 class StaticANTLRPackageTest(unittest.TestCase):