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

Native cross compilation #34

Merged
merged 1 commit into from
Feb 1, 2022
Merged

Native cross compilation #34

merged 1 commit into from
Feb 1, 2022

Conversation

crazy-max
Copy link
Owner

@crazy-max crazy-max commented Sep 17, 2021

Fyi @tonistiigi

~1min against ~10min with qemu

image

@crazy-max
Copy link
Owner Author

crazy-max commented Sep 17, 2021

Ah I guess the build time is great because external libs for additional features (gnutls, libsecret, ) are not found:

#54 165.1 Install prefix ......... : /usr
#54 165.1 NLS support ............ : yes
#54 165.1 TLS support ............ : yes (Library: GnuTLS)
#54 165.1 IDN support ............ : yes (via GNU Libidn)
#54 165.1 GNU SASL support ....... : no (most likely unnecessary)
#54 165.1 Libsecret support (GNOME): yes
#54 165.1 MacOS X Keychain support : no
#54 165.1 Build msmtpd ............: yes
#54 166.8 /usr/bin/make  all-recursive

previously https://github.com/crazy-max/docker-msmtpd/runs/3627172553?check_suite_focus=true#step:8:2948

#42 11.92 Install prefix ......... : /usr
#42 11.92 NLS support ............ : yes
#42 11.92 TLS support ............ : no (Library: none)
#42 11.92 IDN support ............ : no
#42 11.92 GNU SASL support ....... : no (most likely unnecessary)
#42 11.92 Libsecret support (GNOME): no
#42 11.92 MacOS X Keychain support : no
#42 11.93 Build msmtpd ............: yes

xx: https://github.com/crazy-max/docker-msmtpd/runs/3627353227?check_suite_focus=true#step:8:1244

EDIT: Yeah I need xx-apk for each of them.

@crazy-max crazy-max force-pushed the xx branch 3 times, most recently from b587c42 to 3217764 Compare September 17, 2021 02:07
@crazy-max
Copy link
Owner Author

crazy-max commented Sep 17, 2021

Ok now I have a linker issue:

...
/usr/bin/armv7-alpine-linux-musleabihf-ld: warning: libp11-kit.so.0, needed by /armv7-alpine-linux-musleabihf/usr/lib/libgnutls.so, not found (try using -rpath or -rpath-link)

https://github.com/crazy-max/docker-msmtpd/pull/34/checks?check_run_id=3627893666#step:8:2608

@tonistiigi
Copy link

The easiest fix (for non-s390x) is to just use lld instead:

diff --git a/Dockerfile b/Dockerfile
index f249934..603e529 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -5,7 +5,7 @@ ARG XX_VERSION=1.0.0-rc.2
 FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
 FROM --platform=$BUILDPLATFORM crazymax/alpine-s6:${ALPINE_S6_VERSION} AS builder
 RUN apk --update --no-cache add \
-    clang \
+    clang lld \
     curl \
     file \
     make \
@@ -20,7 +20,7 @@ WORKDIR /src
 RUN curl -sSL "https://marlam.de/msmtp/releases/msmtp-$MSMTP_VERSION.tar.xz" | tar xJv --strip 1
 
 ARG TARGETPLATFORM
-ENV XX_CC_PREFER_LINKER=ld
+# ENV XX_CC_PREFER_LINKER=ld
 COPY --from=xx / /
 RUN xx-apk --no-cache add \
     g++ \

If ld is preferred then following fixes

diff --git a/Dockerfile b/Dockerfile
index f249934..b10d3da 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -31,6 +31,7 @@ RUN xx-apk --no-cache add \
     libgsasl-dev \
     libsecret-dev
 RUN set -x \
+  && export LDFLAGS="-Wl,-rpath-link,/$(xx-info)/usr/lib" \
   && ./configure \
     --host=$(xx-clang --print-target-triple) \
     --prefix=/usr \

We can set this automatically in xx in the cfg file but I'd like to understand more what the actual difference and what would be the cleanest fix.

Don't forget to use xx-verify as well.

@crazy-max crazy-max marked this pull request as ready for review February 1, 2022 21:56
@crazy-max crazy-max merged commit b0bc559 into master Feb 1, 2022
@crazy-max crazy-max deleted the xx branch February 1, 2022 21:58
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.

2 participants