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

Failing to build Gecko #1270

Closed
Utopiah opened this issue Feb 26, 2024 · 16 comments
Closed

Failing to build Gecko #1270

Utopiah opened this issue Feb 26, 2024 · 16 comments
Labels
build Build issues

Comments

@Utopiah
Copy link

Utopiah commented Feb 26, 2024

I managed to build Wolvic 1.7 for Lynx today. Works on device, no problem.

Unfortunately it doesn't support WebXR so I'm trying to do that again but building Gecko first.

I'm following https://github.com/Igalia/wolvic/wiki/Developer-workflow#4-build-gecko and have no problem so far.

Unfortunately with ./mach build I'm hitting :

 0:06.53 checking for mingw32 environment... no
 0:06.57 checking for executable suffix... configure: error: installation or configuration problem: compiler cannot create executables.
 0:06.57 DEBUG: <truncated - see config.log for full output>
 0:06.57 DEBUG: return __CYGWIN__;
 0:06.57 DEBUG: ; return 0; }
 0:06.57 DEBUG: configure:741: checking for mingw32 environment
 0:06.58 DEBUG: configure:753: /usr/bin/clang -std=gnu99 --target=aarch64-linux-android21 -c -fno-short-enums  --sysroot=/home/fabien/.mozbuild/android-ndk-r23c/toolchains/llvm/prebuilt/linux-x86_64/sysroot --gcc-toolchain=/home/fabien/.mozbuild/android-ndk-r23c/toolchains/llvm/prebuilt/linux-x86_64  conftest.c 1>&5
 0:06.58 DEBUG: configure:749:8: error: use of undeclared identifier '__MINGW32__'
 0:06.58 DEBUG: return __MINGW32__;
 0:06.58 DEBUG:        ^
 0:06.58 DEBUG: 1 error generated.
 0:06.58 DEBUG: configure: failed program was:
 0:06.58 DEBUG: #line 746 "configure"
 0:06.58 DEBUG: #include "confdefs.h"
 0:06.58 DEBUG:
 0:06.58 DEBUG: int main() {
 0:06.58 DEBUG: return __MINGW32__;
 0:06.58 DEBUG: ; return 0; }
 0:06.58 DEBUG: configure:772: checking for executable suffix
 0:06.58 DEBUG: configure:782: /usr/bin/clang -std=gnu99 --target=aarch64-linux-android21 -o conftest -fno-short-enums  --sysroot=/home/fabien/.mozbuild/android-ndk-r23c/toolchains/llvm/prebuilt/linux-x86_64/sysroot --gcc-toolchain=/home/fabien/.mozbuild/android-ndk-r23c/toolchains/llvm/prebuilt/linux-x86_64  --sysroot=/home/fabien/.mozbuild/android-ndk-r23c/toolchains/llvm/prebuilt/linux-x86_64/sysroot --gcc-toolchain=/home/fabien/.mozbuild/android-ndk-r23c/toolchains/llvm/prebuilt/linux-x86_64 -L/home/fabien/Prototypes/wolvic/gecko-dev/firefox-121.0.1/build/android  -fuse-ld=lld -Wl,--rpath-link=/home/fabien/.mozbuild/android-ndk-r23c/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android -Wl,--rpath-link=/home/fabien/.mozbuild/android-ndk-r23c/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/21  conftest.c  1>&5
 0:06.58 DEBUG: ld.lld: error: unable to find library -lunwind
 0:06.58 DEBUG: clang: error: linker command failed with exit code 1 (use -v to see invocation)
 0:06.58 DEBUG: configure: error: installation or configuration problem: compiler cannot create executables.
 0:06.58 ERROR: old-configure failed
*** Fix above errors and then restart with "./mach build"

When I see __MINGW32__ I think of Windows but I'm building on Linux and targeting Android so not sure if relevant.

Also I see ld.lld: error: unable to find library -lunwind yet on the Ubuntu 23.10 I'm using to build I do have

/usr/lib/i386-linux-gnu/libunwind.so.8
/usr/lib/llvm-16/lib/clang/16/include/unwind.h
/usr/lib/x86_64-linux-gnu/libunwind.so.8

so any pointer would be welcomed!

@Utopiah
Copy link
Author

Utopiah commented Feb 26, 2024

Details I forgot :

fabien@fabien-CORSAIR-ONE-i160:~/Prototypes/wolvic/gecko-dev/firefox-121.0.1$ cat mozconfig 
ac_add_options --enable-project=mobile/android
ac_add_options --target=aarch64 --enable-linker=lld

ac_add_options --enable-project=mobile/android

@svillar
Copy link
Member

svillar commented Feb 27, 2024

You better ask in Mozilla channels for Gecko build issues. That said I've never hit that mingw error which indeed is related to the windows build. Have you run the match bootstrap first?

@svillar svillar added the build Build issues label Feb 27, 2024
@Utopiah
Copy link
Author

Utopiah commented Feb 27, 2024

Indeed I understand it’s a Gecko problem so didn’t want to bother you with it but thought it might be due to Wolvic patches or documented process.

I did run match bootstrap first.

I will try on another machine with the previous Ubuntu just in case.

@svillar
Copy link
Member

svillar commented Feb 27, 2024

Indeed I understand it’s a Gecko problem so didn’t want to bother you with it but thought it might be due to Wolvic patches or documented process.

Wolvic patches could cause build issues but not at that point, i.e. the build configuration. You could try without applying the patches just in case

No problem in asking, just that Mozillians have very likely hit similar problems in the past so you'd likely get more useful info from their forums/channels.

I did run match bootstrap first.

I will try on another machine with the previous Ubuntu just in case.

In my experience Gecko builds are unreliable. Minor changes in your config can easily break them. Also as it uses as much local libraries as it can, it's really difficult to get reproducible builds or even normal builds but from previous versions with different library dependencies.

@Utopiah
Copy link
Author

Utopiah commented Feb 27, 2024

FWIW I'm building on another machine now (older Ubuntu 22.04.3 LTS) and it seems to work well. I didn't have a lot of the issues I encountered so far (unwind, wasi, etc). Assuming it does complete, can I copy that build over to the machine and continue there? That'd mean building Gecko on this machine then import back with Android Studio on the other machine to build for Lynx.

PS: I'll try to rebuild it all on the same machine obviously, as this is not convenient, so mostly asking due to impatience and curiosity.

PPS: "12:49.60 Your build was successful!" it didn't even take very long.

@Utopiah
Copy link
Author

Utopiah commented Feb 27, 2024

it's really difficult to get reproducible builds or even normal builds but from previous versions with different library dependencies.

Indeed, I might for the sake of the exercise (and my sanity) try this again through a Docker container, e.g https://github.com/Deadolus/android-studio-docker , in order to have something that doesn't depend on small details of my normal working environment.

@Utopiah Utopiah closed this as completed Feb 27, 2024
@Utopiah
Copy link
Author

Utopiah commented Mar 1, 2024

FWIW after ./mach build on the latest Ubuntu I get

Paste the lines between the chevrons (>>> and <<<) into
/home/fabien/Prototypes/firefox-121.0.1/mozconfig:

>>>
# Build GeckoView/Firefox for Android:
ac_add_options --enable-project=mobile/android
# Targeting the following architecture.
# For regular phones, no --target is needed.
# For x86 emulators (and x86 devices, which are uncommon):
# ac_add_options --target=i686
# For newer phones or Apple silicon
# ac_add_options --target=aarch64
# For x86_64 emulators (and x86_64 devices, which are even less common):
# ac_add_options --target=x86_64

<<<

Your system should be ready to build GeckoView/Firefox for Android!

fabien@fabien-CORSAIR-ONE-i160:~/Prototypes/firefox-121.0.1$ ./mach build

whereas on Ubuntu LTS (where I successfully built Gecko then Wolvic) I remember a line that suggested to restart the environment, e.g entering bash again. This is missing here so something is different and maybe causing the build to fail.

@Utopiah
Copy link
Author

Utopiah commented Mar 1, 2024

I'll try to build within a 22.04 container https://hub.docker.com/_/ubuntu/ hopefully that will solve it.

@Utopiah
Copy link
Author

Utopiah commented Mar 1, 2024

Indeed within a container I get :

To build GeckoView/Firefox for Android, please restart the shell (Start a new terminal window)

as the last line.

@Utopiah
Copy link
Author

Utopiah commented Mar 1, 2024

Seems to be building. If it succeed I'll share the Dockerfile back.

@Utopiah
Copy link
Author

Utopiah commented Mar 2, 2024

So I'm managing to build Gecko for Android headlessly but the gradle part headlessly remains tricky. I managed to have some of the Android SDK installed, accept certificates, but starting gradlew there are some issues.

While searching in this very repository for details ongradle (to build yet avoiding Android Studio) I found https://github.com/Igalia/wolvic/blob/main/tools/docker/Dockerfile with plenty of interesting solutions. It does seem quite out of date though and untouched for 2 years. Wondering if @svillar knowns if it could be updated.

PS: on the "inspiration" side for the Android SDK https://github.com/mindrunner/docker-android-sdk/blob/main/ubuntu/standalone/Dockerfile seems up to date so maybe using runmymind/docker-android-sdk:ubuntu-standalone as base image could help.

Unfortunately it doesn't seem to play well with mach :

34.66 Looks like you have an outdated Android SDK installed at:
34.66 /opt/android-sdk-linux

@Utopiah
Copy link
Author

Utopiah commented Mar 2, 2024

FWIW this is what I have so far, before trying again with the docker-android-sdk Ubuntu based image :

FROM ubuntu:22.04
# motivated by https://github.com/Igalia/wolvic/wiki/Developer-workflow#building-gecko
# necessary due to https://github.com/Igalia/wolvic/issues/1270
RUN apt update && apt install -y curl git patch python3 python3-pip xz-utils wget openjdk-17-jre-headless
RUN mkdir Prototypes
WORKDIR Prototypes
ARG VERSION=121.0.1
RUN curl -O https://ftp.mozilla.org/pub/firefox/releases/$VERSION/source/firefox-$VERSION.source.tar.xz
RUN tar -xf firefox-$VERSION.source.tar.xz
RUN git clone https://github.com/Igalia/wolvic-gecko-patches.git
WORKDIR firefox-$VERSION
RUN find ../wolvic-gecko-patches/gecko-$VERSION/ -type f -name "*patch" -print0 | sort -z | xargs -t -n1 -0 patch -p1 -i 
RUN echo "ac_add_options --enable-project=mobile/android" > mozconfig
RUN echo "ac_add_options --target=aarch64 --enable-linker=lld" >> mozconfig
RUN ./mach --no-interactive bootstrap --application-choice="GeckoView/Firefox for Android"
RUN bash
# needed to reload some environment
RUN ./mach build
RUN git clone https://github.com/Igalia/wolvic
WORKDIR wolvic
RUN git submodule update --init --recursive
RUN mkdir third_party
WORKDIR third_party
RUN git clone https://github.com/KhronosGroup/OpenXR-SDK
RUN mkdir lynx
WORKDIR lynx
RUN wget https://portal.lynx-r.com/downloads/item/9/download/latest -O loader-release.aar
WORKDIR ../../

@Utopiah
Copy link
Author

Utopiah commented Mar 2, 2024

FWIW appending

RUN cd /opt && wget -q https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O android-sdk.zip
RUN cd /opt && unzip android-sdk.zip
RUN cd /opt && rm -f android-sdk.zip
RUN cd /opt && mv cmdline-tools tools

# should probably be 34.sth?
ENV ANDROID_BUILD_TOOLS_VERSION_29 "29.0.2"
ENV ANDROID_SDK_HOME /opt
ENV ANDROID_HOME /opt
ENV PATH ${PATH}:${ANDROID_SDK_HOME}/tools/bin:${ANDROID_SDK_HOME}/platform-tools:/opt/tools:${ANDROID_SDK_HOME}/build-tools/${ANDROID_BUILD_TOOLS_VERSION_29}
# maybe the commandlinetools changed since the version used then, maybe some tools were even removed
# /opt/cmdline-tools/bin/
# apkanalyzer  avdmanager  lint  profgen  resourceshrinker  retrace  screenshot2  sdkmanager

RUN echo y | sdkmanager "ndk-bundle" --sdk_root=$ANDROID_SDK_HOME
RUN echo y | sdkmanager "cmake;3.10.2.4988404" --sdk_root=$ANDROID_SDK_HOME
RUN echo y | sdkmanager "platforms;android-29" --sdk_root=$ANDROID_SDK_HOME
RUN echo y | sdkmanager "build-tools;${ANDROID_BUILD_TOOLS_VERSION_29}" --sdk_root=$ANDROID_SDK_HOME

even though some wrong versions this still allows gradlew to use the SDK and pull the right versions, e.g CMake 3.22.1, Android SDK Build-Tools 34 v.34.0.0, etc.

@Utopiah
Copy link
Author

Utopiah commented Mar 2, 2024

Ok seems the whole Dockerfile now could look like :

FROM ubuntu:22.04
# motivated by https://github.com/Igalia/wolvic/wiki/Developer-workflow#building-gecko
# necessary due to https://github.com/Igalia/wolvic/issues/1270
RUN apt update && apt install -y curl git patch python3 python3-pip xz-utils wget openjdk-17-jre-headless
# should use a volume here
RUN mkdir Prototypes
WORKDIR Prototypes
# should have used WORKDIR instead... pointless and would take time, space, bandwith to rebuild from this stage/layer
ARG VERSION=121.0.1
RUN curl -O https://ftp.mozilla.org/pub/firefox/releases/$VERSION/source/firefox-$VERSION.source.tar.xz
RUN tar -xf firefox-$VERSION.source.tar.xz
RUN git clone https://github.com/Igalia/wolvic-gecko-patches.git
WORKDIR firefox-$VERSION
RUN find ../wolvic-gecko-patches/gecko-$VERSION/ -type f -name "*patch" -print0 | sort -z | xargs -t -n1 -0 patch -p1 -i
RUN echo "ac_add_options --enable-project=mobile/android" > mozconfig
RUN echo "ac_add_options --target=aarch64 --enable-linker=lld" >> mozconfig
RUN ./mach --no-interactive bootstrap --application-choice="GeckoView/Firefox for Android"
RUN bash
# needed to reload some environment
RUN ./mach build
RUN git clone https://github.com/Igalia/wolvic
WORKDIR wolvic
RUN git submodule update --init --recursive
RUN mkdir third_party
WORKDIR third_party
RUN git clone https://github.com/KhronosGroup/OpenXR-SDK
RUN mkdir lynx
WORKDIR lynx
RUN wget https://portal.lynx-r.com/downloads/item/9/download/latest -O loader-release.aar
WORKDIR ../../

RUN cd /opt && wget -q https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O android-sdk.zip
RUN cd /opt && unzip android-sdk.zip
RUN cd /opt && rm -f android-sdk.zip
RUN cd /opt && mv cmdline-tools tools
# maybe the commandlinetools changed since the version used then, maybe some tools were even removed

ENV ANDROID_BUILD_TOOLS_VERSION_34 "34.0.0"
ENV ANDROID_SDK_HOME /opt
ENV ANDROID_HOME /opt
ENV PATH ${PATH}:${ANDROID_SDK_HOME}/tools/bin:${ANDROID_SDK_HOME}/platform-tools:/opt/tools:${ANDROID_SDK_HOME}/build-tools/${ANDROID_BUILD_TOOLS_VERSION_34}

RUN echo y | sdkmanager "ndk-bundle" --sdk_root=$ANDROID_SDK_HOME
RUN echo y | sdkmanager "cmake;3.22.1" --sdk_root=$ANDROID_SDK_HOME
RUN echo y | sdkmanager "platforms;android-34" --sdk_root=$ANDROID_SDK_HOME
RUN echo y | sdkmanager "build-tools;${ANDROID_BUILD_TOOLS_VERSION_34}" --sdk_root=$ANDROID_SDK_HOME

RUN echo /Prototypes/firefox-121.0.1 > local.properties
RUN echo /Prototypes/firefox-121.0.1/obj-aarch64-unknown-linux-android >> local.properties

RUN ./gradlew --no-daemon compileLynxArm64GeckoGenericReleaseSources
RUN ./gradlew --no-daemon assembleLynxArm64GeckoGeneric
RUN ./gradlew --no-daemon bundleLynxArm64GeckoGeneric

I don't know if it works yet on the device the output as Wolvic-lynx-arm64-gecko-generic-release-unsigned.apk specifically /Prototypes/firefox-121.0.1/wolvic/app/build/outputs/apk/lynxArm64GeckoGeneric/release/Wolvic-lynx-arm64-gecko-generic-release-unsigned.apk

Warning : this is a BIG build virtual 50.6GB and take ~35min on a good desktop.

@coderofsalvation
Copy link

great work!
if we shoehorn this into a github action then anybody who forks can build it?

@Utopiah
Copy link
Author

Utopiah commented Mar 5, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build issues
Projects
None yet
Development

No branches or pull requests

3 participants