How to modify the example to include libpg (postgres) ? #2
-
Hi, I found this repo and the great article while looking for a solution to cross-compile The postgres client depends on libpg and so the idea is to add libpg lib to a custom sys-root. My preliminary cross-compile config for Linux aborts with an error:
That is expected, because the required libpg-dev is not installed on the host because it's From reading the Dockerfile that generates the sysroot, I am wondering if a simple
in the Ubuntu base image suffice to make libpg available to different platform sys-roots? The repo: |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 6 replies
-
Adding it to the base image would not be sufficient. You need to do something similar to what we do for teh RHEL libs: https://github.com/scasagrande/toolchains_llvm_sysroot/blob/main/Dockerfile#L162 The basic workflow would look like as follows. I have included links to the equivalent examples in the rhel section.
|
Beta Was this translation helpful? Give feedback.
-
Okay, thank you.
Much appreciated.
Let me try this tomorrow and see if I can bake a custom sysroot that makes
my project cross compile.
Again thank you for writing this up, it fills a real gap.
…On Thu, Sep 12, 2024 at 22:10 Steven Casagrande ***@***.***> wrote:
Adding it to the base image would not be sufficient. You need to do
something similar to what we do for teh RHEL libs:
https://github.com/scasagrande/toolchains_llvm_sysroot/blob/main/Dockerfile#L162
The basic workflow would look like as follows. I have included links to
the equivalent examples in the rhel section.
- make a FROM statement
<https://github.com/scasagrande/toolchains_llvm_sysroot/blob/main/Dockerfile#L160>
- install libpg-dev
<https://github.com/scasagrande/toolchains_llvm_sysroot/blob/main/Dockerfile#L162>
- make an isolated folder
<https://github.com/scasagrande/toolchains_llvm_sysroot/blob/main/Dockerfile#L163-L164>
- copy the files to an isolated location
<https://github.com/scasagrande/toolchains_llvm_sysroot/blob/main/Dockerfile#L165>
- copy these files into your final sysroot_* image
<https://github.com/scasagrande/toolchains_llvm_sysroot/blob/main/Dockerfile#L185>
—
Reply to this email directly, view it on GitHub
<#2 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFYR7XAA3MNO5EBMOTXVR23ZWGOE3AVCNFSM6AAAAABODKP7MKVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTANRSGY4DCMQ>
.
You are receiving this because you authored the thread.Message ID:
<scasagrande/toolchains_llvm_sysroot/repo-discussions/2/comments/10626812@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
Okay, makes sense.
I’ve looked at the RH UBI image and apparently it doesn’t contain libpg.
https://catalog.redhat.com/software/containers/ubi8/ubi/5c359854d70cc534b3a3784e?container-tabs=packages
I suppose the next viable option would be to download the source and
compile it in the build container?
…On Thu, Sep 12, 2024 at 22:18 Steven Casagrande ***@***.***> wrote:
You're welcome! Keep an eye on this line
<https://github.com/scasagrande/toolchains_llvm_sysroot/blob/main/Dockerfile#L160>
and the --platforms flag. You'll need to remove it to generate a native
x86_64 sysroot, or keep it for cross compiling to arm64.
—
Reply to this email directly, view it on GitHub
<#2 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFYR7XAKF5TZH275PDSFW4TZWGPDPAVCNFSM6AAAAABODKP7MKVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTANRSGY4TCNI>
.
You are receiving this because you authored the thread.Message ID:
<scasagrande/toolchains_llvm_sysroot/repo-discussions/2/comments/10626915@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
https://pkgs.org/download/libpq-devel |
Beta Was this translation helpful? Give feedback.
-
@scasagrande Thank you. As strange as it sounds, but I actually found a much simpler solution to the problem of cross compiling Diesel. There is a module that vendored and patched lib-pg so that it statically compiles for all major platforms. https://github.com/brainhivenl/libpq With that, you basically just do three things:
And it cross compiles Diesel / Postgres from and to all possible targets, I am baffled about the mind boggling simplicity but t.b.h it has just solved my problem. That said, it is possible that I have to come back to the custom sys-root at a later stage |
Beta Was this translation helpful? Give feedback.
-
Man this is brilliant. I did the alias and that makes things a lot better.
However, there is no way to build libpq without gen_build_script, so it is just one of those modules. On that occasion, by chance do you know how to configure multiple crate universe? Point is, Diesel with this static libpq cannot be vendored anymore for reasons I cannot figure out, if not no worries, I just wondered. |
Beta Was this translation helpful? Give feedback.
you'll want to change your target labels because you are using unstable labels that are not designed for direct reference
my suggestion to get around module visibility:
BUILD.bazel
and then your annotation, try disabling the build file generation, it will frequently break call its own toolchains and break out of your bazel ecosystem