Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
bef23f7
compilation binary
jgray-19 May 13, 2026
860070b
compilation binary
jgray-19 May 13, 2026
a3b9d87
Merge branch 'main' of https://github.com/MethodicalAcceleratorDesign…
jgray-19 May 13, 2026
9e02a45
Add staging scripts for MAD-NG headers on Linux and macOS
jgray-19 May 13, 2026
37c98a3
Update NFFT download URL in staging scripts for Linux and macOS
jgray-19 May 13, 2026
ad14b96
Enhance header staging scripts for LuaJIT compatibility and update Ma…
jgray-19 May 13, 2026
39d673c
Add fallback for luajit.h staging in Linux and macOS header scripts
jgray-19 May 13, 2026
e9e0cbd
Refactor GitHub Actions workflow for MAD-NG binary compilation
jgray-19 May 13, 2026
0ab8ca2
Add error handling for missing headers in staging scripts for Linux a…
jgray-19 May 13, 2026
756630c
Add fallback to generate luajit.h during build in staging scripts for…
jgray-19 May 13, 2026
02a07e3
Add library include paths for LuaJIT and other dependencies in compil…
jgray-19 May 13, 2026
f578ad1
Update include paths to absolute references in Makefile for compatibi…
jgray-19 May 13, 2026
10cf1a8
Refactor Makefile selection and compilation steps for improved compat…
jgray-19 May 13, 2026
8452386
Enhance MAD-NG compilation process by adding a synchronous bg shim an…
jgray-19 May 13, 2026
2f19b27
Update C++ compilation flags to enforce C++17 standard and permissive…
jgray-19 May 13, 2026
bb8560f
Update compilation settings in workflow for improved compatibility wi…
jgray-19 May 13, 2026
b3e361c
more edits
jgray-19 May 13, 2026
b9b152e
Refactor MAD-NG compilation to remove 'bg' commands for sequential ex…
jgray-19 May 13, 2026
aad88a4
Refactor header staging scripts to improve luajit.h generation and su…
jgray-19 May 13, 2026
6f26e6e
Remove 'bg' commands from Makefile for sequential execution and add v…
jgray-19 May 13, 2026
4e166a4
Refactor Makefile to remove 'bg' commands for sequential execution an…
jgray-19 May 13, 2026
11c757d
Refactor build scripts to use 'make' or 'gmake' based on availability…
jgray-19 May 13, 2026
85f3239
Refactor Makefile to remove 'bg' commands and ensure valid indentatio…
jgray-19 May 13, 2026
d84b9da
Remove async "bg" helper from Makefile for CI compatibility and verif…
jgray-19 May 13, 2026
4db441c
better luajit making
jgray-19 May 13, 2026
fbe6d3e
Refactor compile_madng.yml to streamline compiler options and remove …
jgray-19 May 13, 2026
008e35a
Update CI workflow to specify macOS version and set LDOPTIONS for com…
jgray-19 May 13, 2026
e8df36b
Refactor CI workflow to separate Linux and macOS builds, streamline d…
jgray-19 May 13, 2026
7f130d1
Refactor CI workflow for Linux build to use Docker, streamline depend…
jgray-19 May 13, 2026
040f35f
Add LuaJIT library handling in macOS build process
jgray-19 May 13, 2026
2b20e6d
Enhance build scripts for macOS and Linux: add static dependencies, s…
jgray-19 May 13, 2026
7140fb6
Remove static dependency on libstdc++-static from Linux build process
jgray-19 May 13, 2026
bdbbc17
remove lfs ref
jgray-19 May 13, 2026
f46f456
more fixes
jgray-19 May 13, 2026
06343d8
liblpeg fixes
jgray-19 May 13, 2026
3ad30a9
Refactor build scripts for Linux and macOS: streamline dependency bui…
jgray-19 May 13, 2026
e3d042a
copy tools correctly
jgray-19 May 13, 2026
021fc7b
librefblas
jgray-19 May 13, 2026
b6e9969
more fixes
jgray-19 May 13, 2026
5ad7c2c
linux lib gcc
jgray-19 May 13, 2026
6988261
remove replacments
jgray-19 May 13, 2026
0ae898e
add dnf plugins and enable crb for dependency installation; update bu…
jgray-19 May 13, 2026
004fa3c
gfortran
jgray-19 May 13, 2026
d0542da
static libs
jgray-19 May 14, 2026
ca0b0cf
cmake
jgray-19 May 14, 2026
6f429c1
Bump NLOpt to v2.9.1 to fix CMake 4.x compatibility
jgray-19 May 14, 2026
67c1d80
Reorder staging of MAD-NG headers in macOS build workflow
jgray-19 May 14, 2026
13853f3
add arm compilation
jgray-19 May 14, 2026
7d00c1e
actual name
jgray-19 May 14, 2026
fd9f7fc
Refactor macOS ARM build workflow: remove legacy steps and enhance Ma…
jgray-19 May 14, 2026
27fd8ae
CI: build macOS ARM deps from my_lib READMEs
jgray-19 May 14, 2026
c5c127a
print toolchain
jgray-19 May 14, 2026
ead7f47
my_lib -> lib
jgray-19 May 14, 2026
554230f
force gcc 13
jgray-19 May 14, 2026
af6c50a
Delete old sh files
jgray-19 May 14, 2026
542a98f
Download dependancies first
jgray-19 May 14, 2026
869426b
Make the edits to the files
jgray-19 May 14, 2026
0ec1d16
fix sed
jgray-19 May 14, 2026
1d2028a
Update macOS build configuration and refine Makefile edits
jgray-19 May 14, 2026
40b78ec
Enhance macOS build workflow for arm64 architecture and update depend…
jgray-19 May 14, 2026
0347b2d
Refactor Makefile modifications to use Python for replacements in mac…
jgray-19 May 14, 2026
ad678b3
on push
jgray-19 May 14, 2026
cfb86c3
more fixes
jgray-19 May 14, 2026
627f8f9
Rename macOS build job to x86_64 and update toolchain to use gcc@12
jgray-19 May 14, 2026
e74c138
Update compile_madng.yml
jgray-19 May 14, 2026
a7b7703
Update compile_madng.yml
jgray-19 May 14, 2026
29099d1
not use premium runner
jgray-19 May 14, 2026
e427593
Update compile_madng.yml
jgray-19 May 14, 2026
1feefdd
Make it so that the compilation yaml can be used
jgray-19 Jul 11, 2026
22f9712
Merge branch 'main' of https://github.com/MethodicalAcceleratorDesign…
jgray-19 Jul 11, 2026
522157c
Update readme and remove unnecessary script
jgray-19 Jul 11, 2026
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
344 changes: 281 additions & 63 deletions .github/workflows/compile_madng.yml
Original file line number Diff line number Diff line change
@@ -1,75 +1,293 @@
# This workflow will install Python dependencies, run tests on a variety Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Make a MAD-NG Binary

on:
push:
workflow_dispatch:
# Allow release workflows to build and consume these exact binaries.
workflow_call:

jobs:
build:
runs-on: ${{ matrix.os }}
build-linux:
runs-on: ubuntu-22.04
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]

steps:
- name: Checkout current repo
uses: actions/checkout@v6

- name: Clone another repo
uses: actions/checkout@v6
with:
repository: MethodicalAcceleratorDesign/MAD-NG
path: MAD
submodules: recursive

- name: Select Makefile
run: |
if [ "$RUNNER_OS" = "Linux" ]; then
cp MAD/src/Makefile.lxplus MAD/src/Makefile
elif [ "$RUNNER_OS" = "macOS" ]; then
- name: Checkout current repo
uses: actions/checkout@v4

- name: Clone MAD-NG
uses: actions/checkout@v4
with:
repository: MethodicalAcceleratorDesign/MAD-NG
path: MAD
submodules: recursive

- name: Build MAD-NG in Rocky Linux 9
run: |
docker run --rm \
-v "${GITHUB_WORKSPACE}:/work" \
-w /work \
rockylinux:9 \
bash -lc '
set -euo pipefail

dnf install -y dnf-plugins-core
dnf config-manager --enable crb
dnf install -y \
gcc gcc-c++ gcc-gfortran make cmake git \
libquadmath-devel libquadmath-static \
libgfortran-static libstdc++-static \
diffutils findutils sed which tar gzip

cp MAD/src/Makefile.lxplus MAD/src/Makefile
sed -i \
-e '"'"'s#^CC[[:space:]]*=.*#CC=gcc#g'"'"' \
-e '"'"'s#^CXX[[:space:]]*=.*#CXX=g++#g'"'"' \
-e '"'"'s#-fdiagnostics-all-candidates##g'"'"' \
MAD/src/Makefile || true

mkdir -p MAD/tools
cp -f tools/build_madng_deps_linux.sh MAD/tools/
chmod +x MAD/tools/build_madng_deps_linux.sh
(cd MAD && JOBS="$(nproc)" CC=gcc CXX=g++ FC=gfortran AR=ar RANLIB=ranlib ./tools/build_madng_deps_linux.sh)

cd MAD/src
export CC=gcc CXX=g++
gcc_libdir="$(gcc -print-libgcc-file-name | xargs dirname)"
export LIBRARY_PATH="${gcc_libdir}${LIBRARY_PATH:+:${LIBRARY_PATH}}"
export LDOPTIONS="-no-pie"

make SHELL=/bin/bash \
CC="${CC}" CXX="${CXX}" \
LDOPTIONS="${LDOPTIONS:-}"

chmod 755 mad
'

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: mad-Linux
path: MAD/src/mad

build-macos-x86_64:
runs-on: macos-15-intel
defaults:
run:
shell: bash

steps:
- name: Checkout current repo
uses: actions/checkout@v4

- name: Clone MAD-NG
uses: actions/checkout@v4
with:
repository: MethodicalAcceleratorDesign/MAD-NG
path: MAD
submodules: recursive

- name: Install build tools
run: |
brew update
brew install gcc@12 make cmake automake autoconf libtool pkg-config curl

- name: Prepare compiler shims
run: |
set -euo pipefail

gcc_prefix="$(brew --prefix gcc@12)"
toolshim="${RUNNER_TEMP}/gcc-shim"
mkdir -p "${toolshim}"

ln -sf "${gcc_prefix}/bin/gcc-12" "${toolshim}/gcc"
ln -sf "${gcc_prefix}/bin/g++-12" "${toolshim}/g++"
ln -sf "${gcc_prefix}/bin/gfortran-12" "${toolshim}/gfortran"
ln -sf "/usr/local/bin/make" "${toolshim}/make"
ln -sf "/usr/local/bin/cmake" "${toolshim}/cmake"
ln -sf "/usr/local/bin/pkg-config" "${toolshim}/pkg-config"
ln -sf "/usr/local/bin/libtool" "${toolshim}/libtool"
ln -sf "/usr/local/bin/ar" "${toolshim}/ar"
ln -sf "/usr/local/bin/ranlib" "${toolshim}/ranlib"

{
echo "${toolshim}"
echo "/usr/local/bin"
echo "$(brew --prefix)/bin"
} >> "${GITHUB_PATH}"

- name: Select MAD-NG macOS Makefile
run: |
cp MAD/src/Makefile.macosx MAD/src/Makefile
else
echo "Unsupported OS: $RUNNER_OS"
exit 1
fi

- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
gcc \
g++ \
make \

- name: Install macOS dependencies
if: runner.os == 'macOS'
run: |
brew update
brew install llvm libomp

- name: Compile MAD-NG
working-directory: MAD/src

run: |
if [ "$RUNNER_OS" = "macOS" ]; then
export PATH="$(brew --prefix llvm)/bin:$PATH"
export CC="$(brew --prefix llvm)/bin/clang"
export CXX="$(brew --prefix llvm)/bin/clang++"
export CPPFLAGS="-I$(brew --prefix libomp)/include"
export LDFLAGS="-L$(brew --prefix libomp)/lib -lomp"
fi
make -j

- name: Upload it
uses: actions/upload-artifact@v7
with:
name: executable-${{ runner.os }}
path: MAD/src/mad
python3 - <<'PY'
from pathlib import Path

path = Path("MAD/src/Makefile")
text = path.read_text()
replacements = [
("CC := gcc-11", "CC := gcc"),
("CXX := g++-11", "CXX := g++"),
("FC := gfortran-11", "FC := gfortran"),
("-fdiagnostics-all-candidates", ""),
("-flto", ""),
("-march=native", ""),
("-mtune=native", ""),
("-mfma", ""),
]
for old, new in replacements:
text = text.replace(old, new)
path.write_text(text)
PY

- name: Build MAD-NG dependencies (README order)
run: |
set -euo pipefail

echo "== Toolchain =="
which gcc
gcc --version
which g++
g++ --version
which gfortran
gfortran --version

export OS=macosx
export MACOSX_DEPLOYMENT_TARGET=11
export JOBS="$(sysctl -n hw.ncpu)"
export CC=gcc
export CXX=g++
export FC=gfortran
export AR=ar
export RANLIB=ranlib

mkdir -p MAD/bin/macosx

cd MAD/lib
echo "== MAD/lib contents (before download) =="
ls -la

echo "== LuaJIT (README.luajit) =="
rm -rf luajit
git clone https://github.com/MethodicalAcceleratorDesign/LuaJIT.git luajit
cd luajit
git checkout mad-patch
git pull
make clean
make -j"${JOBS}" amalg PREFIX="$(pwd)"
make install PREFIX="$(pwd)"
cp -f src/libluajit.a ../../bin/macosx/
cd ..

echo "== LFS (README.lfs) =="
rm -rf lfs
git clone https://github.com/MethodicalAcceleratorDesign/luafilesystem.git lfs
cd lfs
make clean || true
make lfs.a
cp -f liblfs.a ../../bin/macosx/
cd ..

echo "== LPEG (README.lpeg) =="
rm -rf lpeg lpeg-1.1.0 lpeg-1.1.0.tar.gz
curl -fsSL -o lpeg-1.1.0.tar.gz http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-1.1.0.tar.gz
tar xvzf lpeg-1.1.0.tar.gz
ln -s lpeg-1.1.0 lpeg
cd lpeg
python3 - <<'PY'
from pathlib import Path
import re

path = Path("makefile")
text = path.read_text()
text = re.sub(r"^LUADIR[ \t]*=.*$", "LUADIR = ../luajit/include/luajit-2.1", text, flags=re.MULTILINE)
text = re.sub(r"^LUALIB[ \t]*=.*$", "LUALIB = ../luajit/lib/libluajit-5.1.a", text, flags=re.MULTILINE)
text = re.sub(r"^COPT[ \t]*=.*$", "COPT = -O3 -DNDEBUG", text, flags=re.MULTILINE)
path.write_text(text)
PY
make clean || true
make -j"${JOBS}" CC="${CC:-gcc}" LUADIR="../luajit/include/luajit-2.1" lpvm.o lpcap.o lptree.o lpcode.o lpprint.o lpcset.o
ar -r liblpeg.a lpvm.o lpcap.o lptree.o lpcode.o lpprint.o lpcset.o
ranlib liblpeg.a
cp -f liblpeg.a ../../bin/macosx/
cd ..

echo "== LAPACK (README.lapack) =="
rm -rf lapack
git clone https://github.com/Reference-LAPACK/lapack lapack
cd lapack
cp -f make.inc.example make.inc
python3 - <<'PY'
from pathlib import Path
import re

path = Path("make.inc")
text = path.read_text()
for key in ("CFLAGS", "FFLAGS", "FFLAGS_NOOPT"):
text = re.sub(rf"^({key}[ \t]*=[ \t]*)(?!-fPIC\b)", r"\1-fPIC ", text, flags=re.MULTILINE)
path.write_text(text)
PY
make clean || true
make -j"${JOBS}" blaslib
make -j"${JOBS}" lapacklib
cp -f librefblas.a ../../bin/macosx/
cp -f liblapack.a ../../bin/macosx/
cd ..

echo "== FFTW3 (README.fftw3) =="
rm -rf fftw3 fftw-3.3.10 fftw-3.3.10.tar.gz
curl -fsSL -o fftw-3.3.10.tar.gz ftp://ftp.fftw.org/pub/fftw/fftw-3.3.10.tar.gz
tar xvzf fftw-3.3.10.tar.gz
ln -s fftw-3.3.10 fftw3
cd fftw3
make clean || true
./configure --disable-shared
make -j"${JOBS}"
cp -f .libs/libfftw3.a ../../bin/macosx/
cd ..

echo "== NFFT3 (README.nfft3) =="
rm -rf nfft3 nfft-3.5.3 nfft-3.5.3.tar.gz
curl -fsSL -o nfft-3.5.3.tar.gz https://www-user.tu-chemnitz.de/~potts/nfft/download/nfft-3.5.3.tar.gz
tar xvzf nfft-3.5.3.tar.gz
ln -s nfft-3.5.3 nfft3
cd nfft3
make clean || true
./configure --enable-all --disable-shared \
--with-fftw3="$(pwd)"/../fftw3 \
--with-fftw3-libdir="$(pwd)"/../fftw3/.libs \
--with-fftw3-includedir="$(pwd)"/../fftw3/api
make -j"${JOBS}"
cp -f .libs/libnfft3.a ../../bin/macosx/
cd ..

echo "== NLOPT (README.nlopt) =="
rm -rf nlopt
git clone https://github.com/stevengj/nlopt nlopt
cd nlopt
rm -rf build
mkdir -p build
cd build
cmake -DBUILD_SHARED_LIBS=OFF -DNLOPT_CXX=OFF ..
make -j"${JOBS}"
cp -f libnlopt.a ../../../bin/macosx/

- name: Compile MAD-NG
working-directory: MAD/src
run: |
echo "== Toolchain =="
which gcc
gcc --version
which g++
g++ --version
which gfortran
gfortran --version

make SHELL=/bin/bash CC=gcc CXX=g++ FC=gfortran

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: mad-macOS-x86_64
path: MAD/src/mad
Loading
Loading