Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure: cargo-pgrx #320131

Closed
anoadragon453 opened this issue Jun 15, 2024 · 4 comments · Fixed by #320302
Closed

Build failure: cargo-pgrx #320131

anoadragon453 opened this issue Jun 15, 2024 · 4 comments · Fixed by #320302
Labels
0.kind: build failure A package fails to build

Comments

@anoadragon453
Copy link
Member

anoadragon453 commented Jun 15, 2024

I was attempting to build pgvecto-rs 0.2.1 which relies on cargo-pgrx, and hit a build failure on e9ee548 (nixos-unstable via flakes). I add pgvecto-rs to my system flake in this line.

Steps To Reproduce

Steps to reproduce the behavior:

  1. build pgvectors-0.2.1
  2. Run into a rust compilation failure of the std_detect crate while building cargo-pgrx, which pgvectors-0.2.1 relies on.

Build log

Click to view logs
@nix { "action": "setPhase", "phase": "unpackPhase" }
Running phase: unpackPhase
unpacking source archive /nix/store/2jd1xa3isz1d74pq6if0zmh7lsi3zbx5-source
source root is source
Executing cargoSetupPostUnpackHook
Finished cargoSetupPostUnpackHook
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: patchPhase
applying patch /nix/store/l31pik55kdjixyfs7dad61hqgsqqmvj1-0001-read-clang-flags-from-environment.diff
patching file crates/c/build.rs
Hunk #1 succeeded at 1 with fuzz 1.
Executing cargoSetupPostPatchHook
Validating consistency between /build/source/Cargo.lock and /build/cargo-vendor-dir/Cargo.lock
Finished cargoSetupPostPatchHook
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
Running phase: configurePhase
@nix { "action": "setPhase", "phase": "buildPhase" }
Running phase: buildPhase
Executing cargo-pgrx buildPhase
   Validating /nix/store/7wy8v3sjqiqy6bw75rymgshrsp8cllqs-postgresql-14.12/bin/pg_config
 Initializing data directory at /build/tmp.poc6yAMXrY/data-14
waiting for server to start....2024-06-15 20:13:27.382 GMT [74] LOG:  starting PostgreSQL 14.12 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 13.3.0, 64-bit
2024-06-15 20:13:27.382 GMT [74] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2024-06-15 20:13:27.383 GMT [74] LOG:  listening on Unix socket "/build/tmp.S6BpGEK97x/.s.PGSQL.5432"
2024-06-15 20:13:27.385 GMT [75] LOG:  database system was shut down at 2024-06-15 20:13:27 GMT
2024-06-15 20:13:27.387 GMT [74] LOG:  database system is ready to accept connections
 done
server started
2024-06-15 20:13:27.482 GMT [83] ERROR:  role "nixbld" already exists
2024-06-15 20:13:27.482 GMT [83] STATEMENT:  CREATE ROLE nixbld SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN;
createuser: error: creation of new role failed: ERROR:  role "nixbld" already exists
waiting for server to shut down....2024-06-15 20:13:27.483 GMT [74] LOG:  received fast shutdown request
2024-06-15 20:13:27.486 GMT [74] LOG:  aborting any active transactions
2024-06-15 20:13:27.487 GMT [74] LOG:  background worker "logical replication launcher" (PID 81) exited with exit code 1
2024-06-15 20:13:27.487 GMT [76] LOG:  shutting down
2024-06-15 20:13:27.497 GMT [74] LOG:  database system is shut down
 done
server stopped
warning: `/build/.cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
warning: `/build/.cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
       Using PgConfig("pg14") and `pg_config` from /nix/store/7wy8v3sjqiqy6bw75rymgshrsp8cllqs-postgresql-14.12/bin/pg_config
    Building extension with features  pg14
     Running command "/nix/store/qyw7qc22j2ngf9wip8sxagaxb0387gnq-cargo-1.78.0/bin/.cargo-wrapped" "build" "--release" "--features" " pg14" "--no-default-features" "--message-format=json-render-diagnostics" "--frozen" "-j" "8"
warning: `/build/.cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
   Compiling proc-macro2 v1.0.71
   Compiling unicode-ident v1.0.12
   Compiling libc v0.2.151
   Compiling cfg-if v1.0.0
   Compiling serde v1.0.193
   Compiling autocfg v1.1.0
   Compiling memchr v2.7.1
   Compiling syn v1.0.109
   Compiling thiserror v1.0.52
   Compiling scopeguard v1.2.0
   Compiling serde_json v1.0.108
   Compiling hashbrown v0.14.3
   Compiling lock_api v0.4.11
   Compiling eyre v0.6.11
   Compiling equivalent v1.0.1
   Compiling regex-syntax v0.8.2
   Compiling aho-corasick v1.1.2
   Compiling crossbeam-utils v0.8.18
   Compiling quote v1.0.33
   Compiling cc v1.0.83
   Compiling syn v2.0.43
   Compiling getrandom v0.2.11
   Compiling indexmap v2.1.0
   Compiling version_check v0.9.4
   Compiling tinyvec_macros v0.1.1
   Compiling glob v0.3.1
   Compiling tinyvec v1.6.0
   Compiling clang-sys v1.6.1
   Compiling regex-automata v0.4.3
   Compiling ring v0.17.7
   Compiling spin v0.9.8
   Compiling lazy_static v1.4.0
   Compiling ucd-trie v0.1.6
   Compiling once_cell v1.19.0
   Compiling winnow v0.5.31
   Compiling indenter v0.3.3
   Compiling anyhow v1.0.77
   Compiling unicode-normalization v0.1.22
   Compiling unicode-bidi v0.3.14
   Compiling minimal-lexical v0.2.1
   Compiling regex v1.10.2
   Compiling option-ext v0.2.0
   Compiling target-features v0.1.5
   Compiling percent-encoding v2.3.1
   Compiling semver v1.0.20
   Compiling libloading v0.7.4
   Compiling form_urlencoded v1.2.1
   Compiling idna v0.5.0
   Compiling dirs-sys v0.4.1
   Compiling nom v7.1.3
   Compiling proc-macro-error-attr v1.0.4
   Compiling bitflags v2.4.1
   Compiling crc32fast v1.3.2
   Compiling itoa v1.0.10
   Compiling ryu v1.0.16
   Compiling untrusted v0.9.0
   Compiling rustix v0.38.28
   Compiling serde_derive v1.0.193
   Compiling thiserror-impl v1.0.52
   Compiling bindgen v0.68.1
   Compiling cexpr v0.6.0
   Compiling pathsearch v0.2.0
   Compiling url v2.5.0
   Compiling dirs v5.0.1
   Compiling pest v2.7.5
   Compiling crossbeam-epoch v0.9.17
   Compiling proc-macro-error v1.0.4
   Compiling memoffset v0.9.0
   Compiling linux-raw-sys v0.4.12
   Compiling semver-parser v0.10.2
   Compiling semver v0.11.0
   Compiling lazycell v1.3.0
   Compiling fixedbitset v0.4.2
   Compiling unicode-segmentation v1.10.1
   Compiling owo-colors v3.5.0
   Compiling libm v0.2.8
   Compiling shlex v1.2.0
   Compiling peeking_take_while v0.1.2
   Compiling same-file v1.0.6
   Compiling parking_lot_core v0.9.9
   Compiling log v0.4.20
   Compiling rustc-hash v1.1.0
   Compiling walkdir v2.4.0
   Compiling serde_spanned v0.6.5
   Compiling toml_datetime v0.6.5
   Compiling toml_edit v0.21.0
   Compiling convert_case v0.6.0
   Compiling toml v0.8.8
   Compiling cargo_toml v0.16.3
   Compiling petgraph v0.6.4
   Compiling rustc_version v0.3.3
   Compiling pgrx-pg-config v0.11.2
   Compiling crossbeam-deque v0.8.4
   Compiling rustc_version v0.4.0
   Compiling rand_core v0.6.4
   Compiling num-traits v0.2.17
   Compiling rustls v0.21.10
   Compiling rayon-core v1.12.0
   Compiling unescape v0.1.0
   Compiling ppv-lite86 v0.2.17
   Compiling adler v1.0.2
   Compiling smallvec v1.11.2
   Compiling byteorder v1.5.0
   Compiling radium v0.7.0
   Compiling pgrx-pg-sys v0.11.2
   Compiling rand_chacha v0.3.1
   Compiling miniz_oxide v0.7.1
   Compiling pgrx-sql-entity-graph v0.11.2
   Compiling heapless v0.7.17
   Compiling atomic-traits v0.3.0
   Compiling rustls-webpki v0.101.7
   Compiling sct v0.7.1
   Compiling bytemuck_derive v1.5.0
   Compiling validator_types v0.16.0
   Compiling c v0.0.0 (/build/source/crates/c)
   Compiling if_chain v1.0.2
   Compiling tap v1.0.1
   Compiling wyz v0.5.1
   Compiling validator_derive v0.16.0
   Compiling bytemuck v1.14.0
   Compiling multiversion-macros v0.7.3
   Compiling flate2 v1.0.28
   Compiling pgrx-macros v0.11.2
   Compiling rand v0.8.5
   Compiling hash32 v0.2.1
   Compiling uuid v1.6.1
   Compiling enum-map-derive v0.17.0
   Compiling ctor v0.2.6
   Compiling idna v0.4.0
   Compiling crossbeam-channel v0.5.10
   Compiling crossbeam-queue v0.3.10
   Compiling std_detect v0.1.5 (https://github.com/tensorchord/stdarch.git?branch=avx512fp16#db0cdbc9)
error[E0658]: use of unstable library feature 'stdarch_x86_has_cpuid'
  --> /build/cargo-vendor-dir/std_detect-0.1.5/src/detect/os/x86.rs:33:9
   |
33 |     if !has_cpuid() {
   |         ^^^^^^^^^
   |
   = note: see issue #60123 <https://github.com/rust-lang/rust/issues/60123> for more information
   = help: add `#![feature(stdarch_x86_has_cpuid)]` to the crate attributes to enable
   = note: this compiler was built on 2024-04-29; consider upgrading it if it is out of date

For more information about this error, try `rustc --explain E0658`.
error: could not compile `std_detect` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...

Additional context

I was able to build pgvecto-rs 0.2.1 successfully in the past, and there hasn't been an update to pgvecto-rs or cargo-pgrx recently, so I'm not sure why this is failing now. Perhaps I was relying on the build cache's copy of cargo-pgrx, and now I'm not?

The error looks to be due to using an unstable rust library feature (stdarch_x86_has_cpuid) while not using a nightly rust compiler. Did the default rust compiler used to build packages change recently?

Notify maintainers

cargo-pgrx maintainers:

pgvecto-rs maintainers:

Metadata

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.32, NixOS, 24.11 (Vicuna), 24.11.20240613.e9ee548`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.2`
 - nixpkgs: `/nix/store/qqwr649pc0qprc9lw2fmdsi1km6p7q2h-source`

Add a 👍 reaction to issues you find important.

@anoadragon453 anoadragon453 added the 0.kind: build failure A package fails to build label Jun 15, 2024
@happysalada
Copy link
Contributor

Its most likely a version issue.
Cargo pgrx is very version sensitive. Every minor upgrade is breaking. Ive been waiting for 1.0 to try to make the upgrade in nixpkgs otherwise we have to add and maitain every minor version.
You cam try with a different version is you want and that might solve your problem.
Sorry for not having a better solution than this unfortunately.

@diogotcorreia
Copy link
Member

This seems to have been caused by an upgrade of rustc to 1.78 (from 1.77.2). I'll see if it can be patched in pgvecto.rs (or pgrx if that's the case).

nixpkgs on nixos-24.05
❯ nix repl
Welcome to Nix 2.18.2. Type :? for help.

nix-repl> :l .
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
Added 21484 variables.

nix-repl> pkgs.rustPlatform.rust.rustc.version
"1.77.2"

nix-repl> pkgs.rustc.version
"1.77.2"
nixpkgs on nixos-unstable
❯ nix repl
Welcome to Nix 2.18.2. Type :? for help.

nix-repl> :l .
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
Added 21680 variables.

nix-repl> pkgs.rustPlatform.rust.rustc.version
"1.78.0"

nix-repl> pkgs.rustc.version
"1.78.0"

@diogotcorreia
Copy link
Member

Some more information I found:

I think the easiest fix here would be to patch pgvecto-rs to use Rust's crate instead of the fork, which should work fine. I'll still have to investigate whether there were any other changes to the std_detect crate that could cause problems, but it seems to be a fairly small crate, so fingers crossed it doesn't.

@diogotcorreia
Copy link
Member

@anoadragon453 Can you try my branch in PR #320302?
It's based on commit e9ee548, so it should be a drop-in replacement for nixos-unstable.

Let me know on the PR if it works fine with Immich (perhaps backup first, but I don't think it should have problems).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: build failure A package fails to build
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants