Skip to content

Conversation

@rhelmot
Copy link
Contributor

@rhelmot rhelmot commented Mar 6, 2025

Two pieces here in order to enable my successful build of some pgrx extensions from x86_64-linux to x86_64-freebsd:

  • cargo pgrx init --no-run does not attempt to run the discovered postgreses, since they could be for the target architecture or OS.
  • --target flag to some other commands is passed along to cargo build invocations and injected into the calculation of the build directory path. The builds done in order to generate bindings (?) are still done native, since the result has to run at build time.

Note that I was doing this within nix and nixpkgs, but I think it should generalize pretty well to the normal rust cross toolchains.

Note also that I haven't actually tested this diff precisely, since I was working with something that pinned, of all things, 0.12.0-alpha1. The rebase was pretty straightforward but if you want to see the diff that I know for sure works, check here.

@wolfgangwalther
Copy link

@rhelmot did you look at #981, too? Maybe that could be revived.

@rhelmot
Copy link
Contributor Author

rhelmot commented Mar 15, 2025

I had not seen that. Based on the diff, it seems pretty similar to this, with three additional knobs, two for sysroots and one for an alternative pg_config. All of those are pretty unnecessary if you're compiling though nixpkgs, and I would have thought that the sysroots wouldn't be necessary because of the comprehensive nature of the rust cross toolchain, though maybe the C pieces in the dependency tree care about this?

pg_config is concerning though. I am not actually familiar enough with pgrx to understand why we need pg_config for the build platform in addition to the host.

@wolfgangwalther
Copy link

pg_config is concerning though. I am not actually familiar enough with pgrx to understand why we need pg_config for the build platform in addition to the host.

Yes, that confuses me as well, and I am not familiar enough with it either.

Copy link
Contributor

@eeeebbbbrrrr eeeebbbbrrrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks okay. Before merging, however, I'd like to see the cargo-pgrx/README.md updated with these new command line options.

Ideally, adding a short section there to discuss cross-compilation would be nice too.

wolfgangwalther added a commit to wolfgangwalther/nixpkgs that referenced this pull request Mar 27, 2025
Because of [1], we can't run initdb / postgres inside the darwin
sandbox, even though it succeeds most of the time. It will lead to hard
to debug build failures eventually.

Since pgrx runs initdb as part of the build... there seems to be no
other way than marking those packages as broken for now. This could be
relaxed once [2] is available, because we could then disable the
checkPhase and all "initdb" for pgrx on darwin.

[1]:
NixOS#371242 (comment)
[2]: pgcentralfoundation/pgrx#1994
@eeeebbbbrrrr
Copy link
Contributor

eeeebbbbrrrr commented Mar 28, 2025

Hi @rhelmot, I'd like to merge this if you can address my comment here: #1994 (review)

@rhelmot
Copy link
Contributor Author

rhelmot commented Mar 30, 2025

Rebased and added a README section. I'll come back and update the nix stuff when the dust has settled over at nixpkgs.

Copy link
Contributor

@eeeebbbbrrrr eeeebbbbrrrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. I'll merge once CI passes

@eeeebbbbrrrr eeeebbbbrrrr merged commit b38ab98 into pgcentralfoundation:develop Apr 11, 2025
16 checks passed
KenjiBrown pushed a commit to SoftwareLibreMx/pgrx that referenced this pull request May 27, 2025
Two pieces here in order to enable my successful build of some pgrx
extensions from x86_64-linux to x86_64-freebsd:

- `cargo pgrx init --no-run` does not attempt to run the discovered
postgreses, since they could be for the target architecture or OS.
- `--target` flag to some other commands is passed along to cargo build
invocations and injected into the calculation of the build directory
path. The builds done in order to generate bindings (?) are still done
native, since the result has to run at build time.

Note that I was doing this within nix and nixpkgs, but I think it should
generalize pretty well to the normal rust cross toolchains.

Note also that I haven't actually tested this diff precisely, since I
was working with something that pinned, of all things, 0.12.0-alpha1.
The rebase was pretty straightforward but if you want to see the diff
that I know for sure works, check
[here](https://github.com/rhelmot/pgrx/tree/alpha-patched).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants