Opened 6 months ago

Last modified 6 months ago

#73214 assigned defect

influxdb @2.7.10: error: elided lifetime has a name

Reported by: amadeus24 Owned by: herbygillot (Herby Gillot)
Priority: Normal Milestone:
Component: ports Version: 2.11.6
Keywords: arm64 Cc:
Port: influxdb

Description

The InfluxDB 2.7.10 Port currently fails at the Rust libflux build step, reporting:

error: elided lifetime has a name
error: could not compile `flux-core` (lib) due to 2 previous errors

This is caused by #![cfg_attr(feature = "strict", deny(warnings, missing_docs))] in flux-core/src/lib.rs, which triggers the elided_named_lifetimes lint on modern Rust (>=1.77).
Without meaning I know it better, my proposal would be:

  • Remove "strict" from Cargo’s default features in libflux.
  • Add #![allow(elided_named_lifetimes)] to suppress the lint.
  • Pass RUSTFLAGS=-Aelided_named_lifetimes in build.env-append.
  • Pin Go’s stringer tool to v0.38.0 to ensure reproducible code generation.

A patch which worked for me:

--- Portfile	2025-11-08 11:40:00
+++ Portfile	2025-11-08 12:15:00
@@ -1,6 +1,7 @@
 # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
 
 PortSystem                  1.0
 PortGroup                   golang 1.0
+<<<<<<< PATCH: influxdb libflux/lifetimes + stringer pin
 
 go.setup                    github.com/influxdata/influxdb 2.7.10 v
 # Delete this on next update to use golang PortGroup's default ('archive')
@@ -36,12 +37,17 @@
 fetch.type                  git
 
-# Add local gopath/bin to PATH and allow Go to write its module cache
-build.env-append            PATH=${gopath}/bin:$env(PATH) \
-                            GOFLAGS=-modcacherw \
-							RUSTFLAGS=-Aelided_named_lifetimes
-                           # RUSTFLAGS=-Ccap-lints=allow\ -Aelided_named_lifetimes
+# Add local gopath/bin to PATH and allow Go to write its module cache
+# Also: relax Rust lifetime lint that breaks libflux on modern toolchains.
+build.env-append            PATH=${gopath}/bin:$env(PATH) \
+                            GOFLAGS=-modcacherw \
+                            RUSTFLAGS=-Aelided_named_lifetimes
 
@@ -108,6 +114,74 @@
     }
 }
 
-# After 'go mod download', Cargo vendored deps exist. Patch libflux there.
-post-configure {
-    # Look for the vendored libflux under the Go module cache.
-    set libflux_roots [glob -nocomplain -types d ${gopath}/pkg/mod/github.com/influxdata/flux@*/libflux]
-    if {[llength $libflux_roots] == 0} {
-        ui_msg "Note: no libflux path found under ${gopath}/pkg/mod yet (nothing to patch)."
-    }
-    foreach root $libflux_roots {
-        ui_msg "Adjusting libflux under $root"
-
-        # 1) Drop 'strict' from default features so deny(warnings) isn't auto-enabled.
-        set cargotoml "${root}/Cargo.toml"
-        if {[file exists $cargotoml]} {
-            # remove 'strict' token from default = [ ... ]
-            reinplace -E {s/^(default\s*=\s*\[[^]]*)\bstrict\b\s*,?/\1/} $cargotoml
-            # tidy possible trailing comma before closing bracket
-            reinplace -E {s/,\s*\]/]/} $cargotoml
-            ui_msg "Removed 'strict' from default features in $cargotoml"
-        }
-
-        # 2) Relax crate-level deny if still present (extra safety).
-        set corelib "${root}/flux-core/src/lib.rs"
-        if {[file exists $corelib]} {
-            reinplace -E {s/deny\s*\(\s*warnings\s*,\s*missing_docs\s*\)/deny(missing_docs)/} $corelib
-            ui_msg "Relaxed crate-level 'deny(warnings,missing_docs)' in $corelib"
-        }
-    }
-}
+# NOTE: Keep post-configure minimal; we’ll patch in pre-build when the module cache is surely present.
+
+# --- BEGIN: build-time tweaks (pin Go stringer; patch libflux lifetime/strict) ---
+pre-build {
+    # 0) Pin stringer everywhere to avoid upstream module drift
+    set needle "golang.org/x/tools/cmd/stringer"
+    set replacement "golang.org/x/tools/cmd/stringer@v0.38.0"
+
+    ui_msg "Pre-build: scanning tree to pin stringer to v0.38.0…"
+    fs-traverse f ${worksrcpath} {
+        if {[file isfile $f]} {
+            if {![catch {exec /usr/bin/grep -q -- $needle $f}]} {
+                catch {file attributes $f -permissions u+w}
+                reinplace "s|${needle}|${replacement}|g" $f
+                ui_msg "  pinned in: $f"
+            }
+        }
+    }
+    ui_msg "Pre-build: go install ${replacement}"
+    system -W ${worksrcpath} "env GO111MODULE=on GOPATH=${gopath} ${prefix}/bin/go install ${replacement}"
+    build.env-append PATH=${gopath}/bin:$env(PATH)
+
+    # 1) Ensure libflux is in the module cache; then patch it
+    set flux_roots_1 [glob -nocomplain -types d ${gopath}/pkg/mod/github.com/influxdata/flux@*/libflux]
+    if {[llength $flux_roots_1] == 0} {
+        ui_msg "Pre-build: libflux not found yet; fetching github.com/influxdata/flux@v0.195.2…"
+        system -W ${worksrcpath} "env GO111MODULE=on GOPATH=${gopath} ${prefix}/bin/go mod download github.com/influxdata/flux@v0.195.2"
+        set flux_roots_1 [glob -nocomplain -types d ${gopath}/pkg/mod/github.com/influxdata/flux@*/libflux]
+    }
+
+    # Also patch the path pkg-config helper sometimes builds under:
+    set flux_roots_2 [glob -nocomplain -types d ${workpath}/.home/Library/Caches/go-build/pkgconfig/github.com/influxdata/flux@*/libflux]
+    set fluxlib_roots [concat $flux_roots_1 $flux_roots_2]
+
+    foreach root $fluxlib_roots {
+        ui_msg "Pre-build: adjusting libflux under $root"
+        catch {system "chmod -R u+w $root"}
+
+        # A) Insert allow for elided_named_lifetimes at the very top of lib.rs
+        set corelib    "${root}/flux-core/src/lib.rs"
+        if {[file exists $corelib]} {
+            # Insert as line 1 (portable BSD sed form via reinplace)
+            reinplace -E "1i\\
+#![allow(elided_named_lifetimes)]
+" $corelib
+        }
+
+        # B) Remove 'strict' from the default features in Cargo.toml (avoids deny(warnings))
+        set cargotoml  "${root}/Cargo.toml"
+        if {[file exists $cargotoml]} {
+            reinplace -E {s/^(default\s*=\s*\[[^]]*)\bstrict\b\s*,?/\1/} $cargotoml
+            reinplace -E {s/,\s*\]/]/} $cargotoml
+        }
+    }
+}
+# --- END: build-time tweaks ---
 
 use_parallel_build          no
 use_xcode                   yes
+>>>>>>> PATCH: influxdb libflux/lifetimes + stringer pin

Attachments (1)

Portfile.diff (4.8 KB) - added by amadeus24 6 months ago.

Download all attachments as: .zip

Change History (4)

comment:1 Changed 6 months ago by ryandesign (Ryan Carsten Schmidt)

Cc: herbygillot removed
Keywords: InfluxDB 2.7.10 fails to build on removed
Owner: set to herbygillot
Port: influxdb added; InfluxDB removed
Status: newassigned
Summary: InfluxDB 2.7.10 fails to build on arm64 due to Rust lifetime lint in libfluxinfluxdb @2.7.10: error: elided lifetime has a name

comment:2 in reply to:  description Changed 6 months ago by ryandesign (Ryan Carsten Schmidt)

Replying to amadeus24:

+<<<<<<< PATCH: influxdb libflux/lifetimes + stringer pin
+>>>>>>> PATCH: influxdb libflux/lifetimes + stringer pin

Surely at least the addition of these lines is erroneous as it would cause a syntax error. I have not evaluated the other proposed changes.

Changed 6 months ago by amadeus24

Attachment: Portfile.diff added

comment:3 Changed 6 months ago by amadeus24

Yes, you are right. I had several tries. Portfile-orig is the original Portfile, Portfile-new the one I have changed. Below the content of the Portfile.diff (also attached).

--- Portfile-orig	2025-11-09 19:00:26
+++ Portfile-new	2025-11-09 18:59:56
@@ -29,8 +29,10 @@
 # Build script (build.py) requires a git checkout
 fetch.type                  git
 
-# Add local gopath/bin to PATH
-build.env-append            PATH=$env(PATH):${gopath}/bin
+# Ensure our GOPATH/bin comes first and allow Go to write its module cache.
+build.env-append            PATH=${gopath}/bin:$env(PATH) \
+                            GOFLAGS=-modcacherw \
+                            RUSTFLAGS=-Aelided_named_lifetimes
 
 depends_build-append        bin:node:nodejs22 \
                             bin:npm:npm10 \
@@ -63,7 +65,6 @@
 
 post-extract {
     copy ${filespath}/org.macports.influxdb.plist ${influxdb_plist_src}
-
     copy ${filespath}/config.toml.example ${workpath}/
 }
 
@@ -87,8 +88,72 @@
     }
 }
 
-destroot {
+# --- BEGIN: build-time tweaks (stringer pin + libflux lint relax) ---
+pre-build {
+    # Pin stringer to v0.38.0 wherever it's referenced and install that exact version.
+    set needle      "golang.org/x/tools/cmd/stringer"
+    set replacement "golang.org/x/tools/cmd/stringer@v0.38.0"
 
+    ui_msg "Pre-build: scanning tree to pin stringer to v0.38.0…"
+    fs-traverse f ${worksrcpath} {
+        if {[file isfile $f]} {
+            if {![catch {exec /usr/bin/grep -q -- $needle $f}]} {
+                catch {file attributes $f -permissions u+w}
+                reinplace "s|${needle}|${replacement}|g" $f
+                ui_msg "  pinned in: $f"
+            }
+        }
+    }
+    ui_msg "Pre-build: go install ${replacement}"
+    system -W ${worksrcpath} "env GO111MODULE=on GOPATH=${gopath} ${prefix}/bin/go install ${replacement}"
+
+    # Find libflux in both possible trees.
+    set flux_roots_1 [glob -nocomplain -types d ${gopath}/pkg/mod/github.com/influxdata/flux@*/libflux]
+    set flux_roots_2 [glob -nocomplain -types d ${workpath}/.home/Library/Caches/go-build/pkgconfig/github.com/influxdata/flux@*/libflux]
+    set fluxlib_roots [concat $flux_roots_1 $flux_roots_2]
+
+    if {[llength $fluxlib_roots] == 0} {
+        ui_msg "Pre-build: libflux not found yet; fetching github.com/influxdata/flux@v0.195.2…"
+        system -W ${worksrcpath} "env GO111MODULE=on GOPATH=${gopath} ${prefix}/bin/go mod download github.com/influxdata/flux@v0.195.2"
+        set fluxlib_roots [concat \
+            [glob -nocomplain -types d ${gopath}/pkg/mod/github.com/influxdata/flux@*/libflux] \
+            [glob -nocomplain -types d ${workpath}/.home/Library/Caches/go-build/pkgconfig/github.com/influxdata/flux@*/libflux] \
+        ]
+    }
+
+    foreach root $fluxlib_roots {
+        ui_msg "Pre-build: adjusting libflux under $root"
+        catch {system "chmod -R u+w $root"}
+
+        set corelib   "${root}/flux-core/src/lib.rs"
+        set cargotoml "${root}/Cargo.toml"
+
+        # 1) Stop strict-deny builds from failing on warnings, and allow the lifetime lint.
+        if {[file exists $corelib]} {
+            catch {file attributes $corelib -permissions u+w}
+
+            # Turn 'deny(warnings' into 'allow(warnings'
+            reinplace -E {s/#!\[\s*deny\s*\(\s*warnings\b/#![allow(warnings/g} $corelib
+            # Replace cfg_attr(strict, deny(...)) with allow(...)
+            reinplace -E {s/^\s*#!\[\s*cfg_attr\([^]]*strict[^]]*\)\s*,\s*deny\([^]]*\)\s*\)\s*\]/#![allow(warnings, missing_docs)]/} $corelib
+
+            # Insert the lifetime allow at the very top iff missing (Tcl-safe; BSD sed-safe).
+            if {[catch {exec /usr/bin/grep -q -- {#![allow(elided_named_lifetimes)]} $corelib}]} {
+                reinplace -E {1s;^;#![allow(elided_named_lifetimes)]\n;} $corelib
+				ui_msg "Inserted \#\!\[allow(elided_named_lifetimes)\] at top of $corelib"
+            }
+        }
+
+        # 2) If 'strict' is in default features, drop it.
+        if {[file exists $cargotoml]} {
+            reinplace -E {s/(default\s*=\s*\[[^]]*)\bstrict\b\s*,?/\1/} $cargotoml
+            reinplace -E {s/,\s*\]/]/} $cargotoml
+        }
+    }
+}
+# --- END: build-time tweaks ---
+
+destroot {
     copy {*}[glob ${worksrcpath}/bin/${goos}/*] ${destroot}${prefix}/bin/
 
     xinstall  -d -m 0755 ${destroot}${influxdb_conf_dir}
@@ -118,7 +183,6 @@
                           ${destroot}${influxdb_data_dir}
 
 post-activate {
-
     if {![file exists ${influxdb_conf_file}]} {
         copy ${influxdb_example_conf} ${influxdb_conf_file}
     }
@@ -128,12 +192,12 @@
 ATTENTION: the InfluxDB CLI is no longer packaged as part of InfluxDB.
 Please install the influx-cli port.
 
-To start the InfluxDB service, use `port load`:
+To start the InfluxDB service, use \`port load\`:
 
     \$ sudo port load ${name}
     \$ influx # if you installed the CLI via the influx-cli port
 
-`port unload` will stop and remove the service:
+\`port unload\` will stop and remove the service:
 
     \$ sudo port unload ${name}

Sorry for any inconvenience.

Note: See TracTickets for help on using tickets.