Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions .github/workflows/arch-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Arch Package

on:
push:
tags:
- 'v*'

jobs:
arch-pkgbuild:
runs-on: ubuntu-latest
container:
image: archlinux:latest

steps:
- name: Install build dependencies
run: |
pacman -Syu --noconfirm base-devel cmake ninja clang python git

- name: Derive LLVM branch from tag
id: llvm
run: |
TAG="${GITHUB_REF_NAME}"
# Extract major version: v22.1.0-rc1 -> 22
MAJOR="${TAG#v}"
MAJOR="${MAJOR%%.*}"
echo "branch=release/${MAJOR}.x" >> "$GITHUB_OUTPUT"
echo "Using LLVM branch: release/${MAJOR}.x for tag ${TAG}"

- name: Checkout eld
uses: actions/checkout@v4
with:
path: eld-src

- name: Checkout llvm-project
uses: actions/checkout@v4
with:
repository: llvm/llvm-project
ref: ${{ steps.llvm.outputs.branch }}
path: llvm-project

- name: Set up build tree
run: |
ln -sfn "${GITHUB_WORKSPACE}/eld-src" \
"${GITHUB_WORKSPACE}/llvm-project/llvm/tools/eld"

- name: Configure
working-directory: ${{ github.workspace }}
run: |
cmake -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DLLVM_ENABLE_PROJECTS='llvm;clang' \
-DLLVM_TARGETS_TO_BUILD='ARM;AArch64;RISCV;Hexagon;X86' \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DELD_ENABLE_SYMBOL_VERSIONING=ON \
-Wno-dev \
-B obj \
-S llvm-project/llvm

- name: Build eld
run: |
cmake --build obj --target ld.eld
cmake --build obj --target LW
cmake --build obj --target LSParserVerifier

- name: Verify build outputs
run: |
echo "--- Binaries ---"
test -x obj/bin/ld.eld
test -x obj/bin/LSParserVerifier
test -f obj/lib/libLW.so.4
test -L obj/lib/libLW.so

echo "--- Version ---"
obj/bin/ld.eld --version

echo "--- Symlinks ---"
for link in arm-link aarch64-link hexagon-link riscv-link x86_64-link; do
test -L "obj/bin/${link}" || test -x "obj/bin/${link}"
done

echo "--- Plugin headers ---"
test -f obj/tools/eld/include/eld/PluginAPI/PluginBase.h

echo "All arch package build outputs verified."

- name: Clean up
if: always()
run: rm -rf obj llvm-project eld-src
23 changes: 23 additions & 0 deletions packaging/arch/.SRCINFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
pkgbase = eld
pkgdesc = ELF linker for embedded software with plugin support and GNU LD compatibility
pkgver = 22.1.0rc3
pkgrel = 1
url = https://github.com/qualcomm/eld
arch = x86_64
license = BSD-3-Clause
makedepends = cmake
makedepends = ninja
makedepends = clang
makedepends = python
makedepends = git
depends = gcc-libs
depends = zlib
depends = libxml2
optdepends = python: YAMLMapParser.py map file parsing utility
options = !lto
source = eld-22.1.0rc3.tar.gz::https://github.com/qualcomm/eld/archive/refs/tags/v22.1.0-rc3.tar.gz
source = llvm-project::git+https://github.com/llvm/llvm-project.git#branch=release/22.x
sha256sums = SKIP
sha256sums = SKIP

pkgname = eld
104 changes: 104 additions & 0 deletions packaging/arch/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Maintainer: Your Name <your.email@example.com>
pkgname=eld
pkgver=22.1.0rc3
pkgrel=1
pkgdesc='ELF linker for embedded software with plugin support and GNU LD compatibility'
arch=('x86_64')
url='https://github.com/qualcomm/eld'
license=('BSD-3-Clause')
depends=('gcc-libs' 'zlib' 'libxml2')
makedepends=('cmake' 'ninja' 'clang' 'python' 'git')
optdepends=('python: YAMLMapParser.py map file parsing utility')

# The eld git tag for this release (pkgver cannot contain hyphens).
_eldtag=v22.1.0-rc3

# ELD's version is derived from LLVM's PACKAGE_VERSION, so the versions are
# synchronized. The eld release/N.x branch builds against llvm release/N.x.
# LLVM 22.x has no stable release yet; use the release/22.x branch.
_llvmbranch=release/22.x

source=(
"${pkgname}-${pkgver}.tar.gz::https://github.com/qualcomm/eld/archive/refs/tags/${_eldtag}.tar.gz"
"llvm-project::git+https://github.com/llvm/llvm-project.git#branch=${_llvmbranch}"
)
sha256sums=('SKIP' 'SKIP')

# LTO is disabled because the build compiles LLVM components and applying
# LTO across the full LLVM+eld build is impractical for packaging.
options=('!lto')

prepare() {
# Place eld source inside the LLVM tree as a tool so it is discovered
# by LLVM's build system automatically.
ln -sfn "${srcdir}/eld-${_eldtag#v}" \
"${srcdir}/llvm-project/llvm/tools/eld"
}

build() {
local cmake_args=(
-G Ninja
-DCMAKE_BUILD_TYPE=None
-DCMAKE_INSTALL_PREFIX=/usr
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DLLVM_ENABLE_PROJECTS='llvm;clang'
-DLLVM_TARGETS_TO_BUILD='ARM;AArch64;RISCV;Hexagon;X86'
-DLLVM_ENABLE_ASSERTIONS=OFF
-DELD_ENABLE_SYMBOL_VERSIONING=ON
-Wno-dev
)

cmake -B build -S llvm-project/llvm "${cmake_args[@]}"

# Build only eld targets to avoid building the entire LLVM toolchain
cmake --build build --target ld.eld
cmake --build build --target LW
cmake --build build --target LSParserVerifier
}

check() {
cmake --build build --target check-eld
}

package() {
local _eldsrc="eld-${_eldtag#v}"

# Install the eld binary
install -Dm755 build/bin/ld.eld "${pkgdir}/usr/bin/ld.eld"

# Install LSParserVerifier
install -Dm755 build/bin/LSParserVerifier "${pkgdir}/usr/bin/LSParserVerifier"

# Install the linker wrapper shared library
install -Dm755 build/lib/libLW.so.4 "${pkgdir}/usr/lib/libLW.so.4"
ln -s libLW.so.4 "${pkgdir}/usr/lib/libLW.so"

# Install target-specific symlinks (names match the build output)
local _symlinks=('arm-link' 'aarch64-link' 'hexagon-link' 'riscv-link' 'x86_64-link')
for _link in "${_symlinks[@]}"; do
ln -s ld.eld "${pkgdir}/usr/bin/${_link}"
done

# Install plugin API headers
install -d "${pkgdir}/usr/include/ELD/PluginAPI"
for _hdr in "${_eldsrc}"/include/eld/PluginAPI/*.h; do
[[ "$(basename "$_hdr")" == "PluginConfig.h" ]] && continue
install -Dm644 "$_hdr" "${pkgdir}/usr/include/ELD/PluginAPI/$(basename "$_hdr")"
done
# Install the generated PluginBase.h (from .h.inc template)
install -Dm644 build/tools/eld/include/eld/PluginAPI/PluginBase.h \
"${pkgdir}/usr/include/ELD/PluginAPI/PluginBase.h"

# Install linker script templates
install -d "${pkgdir}/usr/share/eld/templates"
cp -a "${_eldsrc}"/templates/. "${pkgdir}/usr/share/eld/templates/"

# Install YAMLMapParser utility
install -Dm755 "${_eldsrc}/utils/YAMLMapParser/YAMLMapParser.py" \
"${pkgdir}/usr/bin/YAMLMapParser.py"

# Install license
install -Dm644 "${_eldsrc}/LICENSE" \
"${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
102 changes: 102 additions & 0 deletions packaging/arch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Arch Linux Package for ELD

This directory contains the files needed to submit ELD to the
[Arch User Repository (AUR)](https://aur.archlinux.org/).

## Files

- `PKGBUILD` - The package build script
- `.SRCINFO` - Machine-readable metadata (regenerated before each push)

## Prerequisites

1. An Arch Linux system (or VM/container) with `base-devel` installed
2. An [AUR account](https://aur.archlinux.org/register) with SSH key configured
3. Tools: `makepkg`, `namcap` (from `namcap` package)

## Local Testing

```bash
# Copy PKGBUILD to a clean directory
mkdir /tmp/eld-pkg && cp PKGBUILD /tmp/eld-pkg/ && cd /tmp/eld-pkg

# Build the package locally (downloads sources, builds, creates .pkg.tar.zst)
makepkg -s

# Lint the PKGBUILD
namcap PKGBUILD

# Lint the built package
namcap eld-*.pkg.tar.zst

# Install locally to test
makepkg -si
```

For maximum correctness, build in a clean chroot:

```bash
# Requires 'devtools' package
extra-x86_64-build
```

## Submitting to the AUR

```bash
# 1. Clone the AUR git repo (first time only)
git clone ssh://aur@aur.archlinux.org/eld.git
cd eld

# 2. Copy the PKGBUILD
cp /path/to/PKGBUILD .

# 3. Generate .SRCINFO (REQUIRED on every push)
makepkg --printsrcinfo > .SRCINFO

# 4. Commit and push
git add PKGBUILD .SRCINFO
git commit -m "Initial upload: eld 22.1.0rc3-1"
git push origin master
```

## Updating the Package

When a new eld version is released:

1. Update `pkgver` in `PKGBUILD`
2. Update `_llvmver` if the LLVM compatibility version changed
3. Reset `pkgrel` to `1`
4. Update checksums: `updpkgsums` (from `pacman-contrib`)
5. Regenerate `.SRCINFO`: `makepkg --printsrcinfo > .SRCINFO`
6. Test locally, then commit and push to AUR

## LLVM Version Compatibility

ELD must be built within the LLVM source tree (placed in `llvm/tools/eld`).
ELD's version number is derived from LLVM's `PACKAGE_VERSION`, so the
versions are intentionally synchronized. The eld `release/N.x` branch
tracks the `release/N.x` branch of `llvm/llvm-project`.

When LLVM has a stable release tarball available, the PKGBUILD can use a
tarball source instead of the git clone. When only an RC is available (as
with 22.x), the PKGBUILD uses a git source for the `release/N.x` branch.

## Package Layout

The built package installs:

```
/usr/bin/ld.eld # Main linker binary
/usr/bin/arm-link -> ld.eld # Target symlinks
/usr/bin/aarch64-link -> ld.eld
/usr/bin/hexagon-link -> ld.eld
/usr/bin/riscv-link -> ld.eld
/usr/bin/x86_64-link -> ld.eld
/usr/bin/LSParserVerifier # Linker script parser verifier
/usr/bin/YAMLMapParser.py # YAML map file parser
/usr/lib/libLW.so.4 # Plugin API shared library
/usr/lib/libLW.so -> libLW.so.4
/usr/include/ELD/PluginAPI/*.h # Plugin development headers
/usr/share/eld/templates/ # Linker script templates
/usr/share/licenses/eld/LICENSE # BSD 3-Clause license
```
Loading