This project aims to build a version of Electron that supports the Loong64 architecture.
Note: The Electron binaries require glibc >= 2.38
.
dev
: The development branch, containing the latest patches and build scripts.X.Y.Z
: The release branches, corresponding to the release versions of Electron.
Special thanks to @jiegec for his invaluable Chromium patches in AOSC-Dev/chromium-loongarch64, which make this project possible.
- This project builds upon the official Electron repository by applying custom patches. See
electron.patch
for details. - The build process runs in a dedicated container environment that includes all necessary build tools and dependencies. See
Dockerfile.builder
for details.
- Linux host machine with Loong64 architecture
- Docker with docker-buildx installed
- LATX version 1.4.4 (required for running
ghcr.io/darkyzhou/electron-buildtools
image) - System resources: minimum 16GB RAM and 100GB free disk space
For detailed reference, check the
prepare
job in.github/workflows/electron.yaml
-
Launch a
ghcr.io/darkyzhou/electron-buildtools
container. All subsequent steps should be executed inside this container -
Set up the Electron repository:
- Clone or update the official Electron repository
- Switch to your target branch, e.g.
v33.2.0
- Place it in
$BUILD_ROOT/src/electron
to match the Electron's requirement - Note: Do not apply
electron.patch
at this stage
-
Version alignment:
- Check chromium-loongarch64 and Electron Releases
- Identify the latest compatible Chromium version with available patches for your target Electron version
-
Launch a
ghcr.io/darkyzhou/electron-buildtools
container. All subsequent steps should be executed inside this container -
Update dependencies:
- Modify the
DEPS
file in$BUILD_ROOT/src/electron
to reference the selected Chromium version - Run
npx e sync
in$BUILD_ROOT/src
. This will apply all existing patches from the Electron repository
- Modify the
-
Apply existing patches:
- Apply
electron.patch
from the repository to$BUILD_ROOT/src/electron
usinggit apply
in$BUILD_ROOT/src/electron
- Apply
-
Apply Chromium patches:
- Apply the consolidated Chromium patch file (e.g.,
chromium-131.0.6778.85.diff
) to$BUILD_ROOT/src
- Resolve any conflicts if they occur
- Apply the consolidated Chromium patch file (e.g.,
-
Manage patches using Electron's
npx e patches
command:Note:
$BUILD_ROOT/src
is a git repository containing submodules, including$BUILD_ROOT/src/electron
and a few folders in$BUILD_ROOT/src/third_party
-
Commit changes in both the main repository and affected submodules
-
Use
npx e patches <name>
in$BUILD_ROOT/src
to update patches in$BUILD_ROOT/src/electron
-
The
<name>
parameter should match entries in$BUILD_ROOT/src/electron/patches/config.json
In
config.json
, all the items should be a valid git repository. So if the patches modified a folder in$BUILD_ROOT/src/third_party
but the folder itself is NOT a git repository, the modification will be collected in the mainchromium
item.
Following commands help demonstrate the process:
cd $BUILD_ROOT/src git add . # Don't commit submodules git restore --staged $(git submodule status | cut -d' ' -f2) git commit -m "loong64 support Co-authored-by: Jiajie Chen <c@jia.je>" npx e patches chromium # Then, we do the same thing for the submodules git submodule foreach git add . # ...
-
-
Run
npx e sync
again to sync the sources and apply our new patches.
-
Container setup:
- Launch a
ghcr.io/darkyzhou/electron-builder
container. Check available tags for the latest image - Note: You may need to create a custom image for specific Electron versions if the latest image runs into compilation issues
- Launch a
-
Build process:
- Follow the steps in the
build
job from.github/workflows/electron.yaml
- Ensure all environment variables from the
env
section are set - Note: The build process is time-intensive, typically requiring around 10 hours on a 3A6000 processor
- Follow the steps in the
Common compilation errors:
relocation R_LARCH_B26 out of range: 172745664 is not in [-134217728, 134217727]
- Root cause: The library was compiled without the
-mcmodel=medium
flag. For more details, see laelf.adoc. - Resolution: Recompile the library with the
-mcmodel=medium
flag. SeeDockerfile.libffi
for implementation examples.
- Root cause: The library was compiled without the