From bef23f7e59338ebd2ed7415b8221e1416bba5075 Mon Sep 17 00:00:00 2001 From: Joshua Gray <61458311+jgray-19@users.noreply.github.com> Date: Wed, 13 May 2026 20:45:15 +0200 Subject: [PATCH 01/69] compilation binary --- .github/workflows/compile_madng.yml | 50 +++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/compile_madng.yml diff --git a/.github/workflows/compile_madng.yml b/.github/workflows/compile_madng.yml new file mode 100644 index 0000000..8ad5d99 --- /dev/null +++ b/.github/workflows/compile_madng.yml @@ -0,0 +1,50 @@ +# 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: + workflow_dispatch: + +jobs: + build: + runs-on: ${{ matrix.os }} + 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 + + - name: Select Makefile + run: | + if [ "$RUNNER_OS" = "Linux" ]; then + cp MAD/src/makefile.lxplus MAD/src/Makefile + elif [ "$RUNNER_OS" = "macOS" ]; then + cp MAD/src/makefile.macos MAD/src/Makefile + else + echo "Unsupported OS: $RUNNER_OS" + exit 1 + fi + + - name: Compile MAD-NG + run: | + cd MAD/src + make -j + + - name: Upload it + - uses: actions/upload-artifact@v7 + with: + name: executable-${{ runner.os }} + path: MAD/src/mad \ No newline at end of file From 860070b11590986687f8c44b51d52fb8f82f8e70 Mon Sep 17 00:00:00 2001 From: Joshua Gray <61458311+jgray-19@users.noreply.github.com> Date: Wed, 13 May 2026 20:47:57 +0200 Subject: [PATCH 02/69] compilation binary --- .github/workflows/compile_madng.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/compile_madng.yml b/.github/workflows/compile_madng.yml index 8ad5d99..3ccd2d0 100644 --- a/.github/workflows/compile_madng.yml +++ b/.github/workflows/compile_madng.yml @@ -39,12 +39,11 @@ jobs: fi - name: Compile MAD-NG - run: | - cd MAD/src - make -j + working-directory: MAD/src + run: make -j - name: Upload it - - uses: actions/upload-artifact@v7 + uses: actions/upload-artifact@v7 with: name: executable-${{ runner.os }} - path: MAD/src/mad \ No newline at end of file + path: MAD/src/mad From 9e02a45bfb6c8a1ecd35b4cc6cd7bf1e387cb5ed Mon Sep 17 00:00:00 2001 From: Joshua Gray <61458311+jgray-19@users.noreply.github.com> Date: Wed, 13 May 2026 21:28:16 +0200 Subject: [PATCH 03/69] Add staging scripts for MAD-NG headers on Linux and macOS --- .github/workflows/compile_madng.yml | 16 +++ tools/stage_madng_headers_linux.sh | 165 ++++++++++++++++++++++++++++ tools/stage_madng_headers_macos.sh | 165 ++++++++++++++++++++++++++++ 3 files changed, 346 insertions(+) create mode 100755 tools/stage_madng_headers_linux.sh create mode 100755 tools/stage_madng_headers_macos.sh diff --git a/.github/workflows/compile_madng.yml b/.github/workflows/compile_madng.yml index 8f16d73..297c1a0 100644 --- a/.github/workflows/compile_madng.yml +++ b/.github/workflows/compile_madng.yml @@ -39,6 +39,22 @@ jobs: exit 1 fi + - name: Stage MAD-NG headers + run: | + mkdir -p MAD/tools + cp -f tools/stage_madng_headers_linux.sh MAD/tools/ || true + cp -f tools/stage_madng_headers_macos.sh MAD/tools/ || true + chmod +x MAD/tools/stage_madng_headers_*.sh + + if [ "$RUNNER_OS" = "Linux" ]; then + (cd MAD && ./tools/stage_madng_headers_linux.sh) + elif [ "$RUNNER_OS" = "macOS" ]; then + (cd MAD && ./tools/stage_madng_headers_macos.sh) + else + echo "Unsupported OS: $RUNNER_OS" + exit 1 + fi + - name: Install Linux dependencies if: runner.os == 'Linux' run: | diff --git a/tools/stage_madng_headers_linux.sh b/tools/stage_madng_headers_linux.sh new file mode 100755 index 0000000..c74534a --- /dev/null +++ b/tools/stage_madng_headers_linux.sh @@ -0,0 +1,165 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Stage headers into the layout expected by MAD-NG's unmodified `src/Makefile`. +# +# Expected include paths (from `src/Makefile`): +# -I../lib/luajit/src -> lua.h, luaconf.h, lualib.h, lauxlib.h, lua.hpp +# -I../lib/nlopt/src/api -> nlopt.h +# -I../lib/fftw3/api -> fftw3.h +# -I../lib/nfft3/include -> nfft3.h (and friends) +# +# This script does NOT build archives; it only ensures headers exist (by +# downloading sources, or by symlinking/copying from user-provided locations). + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +LIB_DIR="${ROOT}/lib" + +LUAJIT_REF="${LUAJIT_REF:-mad-patch}" +LUAJIT_REPO="${LUAJIT_REPO:-https://github.com/MethodicalAcceleratorDesign/LuaJIT.git}" + +NLOPT_REF="${NLOPT_REF:-v2.7.1}" +NLOPT_REPO="${NLOPT_REPO:-https://github.com/stevengj/nlopt.git}" + +FFTW_VERSION="${FFTW_VERSION:-3.3.10}" +NFFT_VERSION="${NFFT_VERSION:-3.5.3}" + +# Optional: point these at already-installed headers (will be copied/symlinked) +LUAJIT_SRC_DIR="${LUAJIT_SRC_DIR:-}" # directory containing lua.h etc +NLOPT_INC_DIR="${NLOPT_INC_DIR:-}" # directory containing nlopt.h +FFTW_INC_DIR="${FFTW_INC_DIR:-}" # directory containing fftw3.h +NFFT_INC_DIR="${NFFT_INC_DIR:-}" # directory containing nfft3.h + +need_cmd() { + command -v "$1" >/dev/null 2>&1 || { echo "Missing command: $1" >&2; exit 1; } +} + +fetch_tarball() { + local url="$1" + local out="$2" + if [[ -f "${out}" ]]; then return 0; fi + if command -v curl >/dev/null 2>&1; then + curl -L --fail "${url}" -o "${out}" + else + need_cmd wget + wget -O "${out}" "${url}" + fi +} + +stage_dir_copy_or_link() { + local src="$1" + local dest="$2" + local mode="${3:-symlink}" # symlink|copy + rm -rf "${dest}" + mkdir -p "$(dirname "${dest}")" + case "${mode}" in + symlink) ln -s "${src}" "${dest}" ;; + copy) cp -a "${src}" "${dest}" ;; + *) echo "Unknown mode: ${mode}" >&2; exit 1 ;; + esac +} + +stage_file_copy_or_link() { + local src="$1" + local dest="$2" + local mode="${3:-symlink}" # symlink|copy + rm -f "${dest}" + mkdir -p "$(dirname "${dest}")" + case "${mode}" in + symlink) ln -s "${src}" "${dest}" ;; + copy) cp -a "${src}" "${dest}" ;; + *) echo "Unknown mode: ${mode}" >&2; exit 1 ;; + esac +} + +main() { + mkdir -p "${LIB_DIR}" + + # LuaJIT headers -> lib/luajit/src/* + if [[ -n "${LUAJIT_SRC_DIR}" ]]; then + echo "Staging LuaJIT headers from LUAJIT_SRC_DIR=${LUAJIT_SRC_DIR}" + mkdir -p "${LIB_DIR}/luajit" + stage_dir_copy_or_link "${LUAJIT_SRC_DIR}" "${LIB_DIR}/luajit/src" "symlink" + else + echo "Fetching LuaJIT repo for headers (${LUAJIT_REF})" + need_cmd git + local_dir="${LIB_DIR}/luajit" + if [[ ! -d "${local_dir}/.git" ]]; then + git clone "${LUAJIT_REPO}" "${local_dir}" + fi + ( cd "${local_dir}" + git fetch --all --tags + git checkout "${LUAJIT_REF}" + git pull --ff-only || true + ) + fi + + # NLOpt headers -> lib/nlopt/src/api/nlopt.h + if [[ -n "${NLOPT_INC_DIR}" ]]; then + echo "Staging NLOpt header from NLOPT_INC_DIR=${NLOPT_INC_DIR}" + stage_file_copy_or_link "${NLOPT_INC_DIR}/nlopt.h" "${LIB_DIR}/nlopt/src/api/nlopt.h" "symlink" + else + echo "Fetching NLOpt repo for headers (${NLOPT_REF})" + need_cmd git + local_dir="${LIB_DIR}/nlopt" + if [[ ! -d "${local_dir}/.git" ]]; then + git clone "${NLOPT_REPO}" "${local_dir}" + fi + ( cd "${local_dir}" + git fetch --all --tags + git checkout "${NLOPT_REF}" + git pull --ff-only || true + ) + fi + + # FFTW headers -> lib/fftw3/api/fftw3.h + if [[ -n "${FFTW_INC_DIR}" ]]; then + echo "Staging FFTW header from FFTW_INC_DIR=${FFTW_INC_DIR}" + stage_file_copy_or_link "${FFTW_INC_DIR}/fftw3.h" "${LIB_DIR}/fftw3/api/fftw3.h" "symlink" + else + echo "Fetching FFTW tarball for headers (${FFTW_VERSION})" + need_cmd tar + tar_name="fftw-${FFTW_VERSION}.tar.gz" + tar_path="${LIB_DIR}/${tar_name}" + url="https://fftw.org/${tar_name}" + fetch_tarball "${url}" "${tar_path}" + ( cd "${LIB_DIR}" && tar xzf "${tar_name}" ) + rm -f "${LIB_DIR}/fftw3" + ln -s "fftw-${FFTW_VERSION}" "${LIB_DIR}/fftw3" + fi + + # NFFT headers -> lib/nfft3/include/nfft3.h + if [[ -n "${NFFT_INC_DIR}" ]]; then + echo "Staging NFFT header from NFFT_INC_DIR=${NFFT_INC_DIR}" + mkdir -p "${LIB_DIR}/nfft3" + stage_dir_copy_or_link "${NFFT_INC_DIR}" "${LIB_DIR}/nfft3/include" "symlink" + else + echo "Fetching NFFT tarball for headers (${NFFT_VERSION})" + need_cmd tar + tar_name="nfft-${NFFT_VERSION}.tar.gz" + tar_path="${LIB_DIR}/${tar_name}" + url="http://www.nfft.org/download/${tar_name}" + fetch_tarball "${url}" "${tar_path}" + ( cd "${LIB_DIR}" && tar xzf "${tar_name}" ) + rm -f "${LIB_DIR}/nfft3" + ln -s "nfft-${NFFT_VERSION}" "${LIB_DIR}/nfft3" + fi + + echo + echo "Header checks (expected by src/Makefile):" + for f in \ + "${LIB_DIR}/luajit/src/lua.h" \ + "${LIB_DIR}/nlopt/src/api/nlopt.h" \ + "${LIB_DIR}/fftw3/api/fftw3.h" \ + "${LIB_DIR}/nfft3/include/nfft3.h" + do + if [[ -e "${f}" ]]; then + echo " OK ${f}" + else + echo " MISS ${f}" + fi + done +} + +main "$@" + diff --git a/tools/stage_madng_headers_macos.sh b/tools/stage_madng_headers_macos.sh new file mode 100755 index 0000000..44f5b59 --- /dev/null +++ b/tools/stage_madng_headers_macos.sh @@ -0,0 +1,165 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Stage headers into the layout expected by MAD-NG's unmodified `src/Makefile`. +# +# Expected include paths (from `src/Makefile`): +# -I../lib/luajit/src -> lua.h etc +# -I../lib/nlopt/src/api -> nlopt.h +# -I../lib/fftw3/api -> fftw3.h +# -I../lib/nfft3/include -> nfft3.h +# +# This script does NOT build archives; it only ensures headers exist (by +# downloading sources, or by symlinking/copying from user-provided locations). + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +LIB_DIR="${ROOT}/lib" + +LUAJIT_REF="${LUAJIT_REF:-mad-patch}" +LUAJIT_REPO="${LUAJIT_REPO:-https://github.com/MethodicalAcceleratorDesign/LuaJIT.git}" + +NLOPT_REF="${NLOPT_REF:-v2.7.1}" +NLOPT_REPO="${NLOPT_REPO:-https://github.com/stevengj/nlopt.git}" + +FFTW_VERSION="${FFTW_VERSION:-3.3.10}" +NFFT_VERSION="${NFFT_VERSION:-3.5.3}" + +# Optional: point these at already-installed headers (will be copied/symlinked) +LUAJIT_SRC_DIR="${LUAJIT_SRC_DIR:-}" # directory containing lua.h etc +NLOPT_INC_DIR="${NLOPT_INC_DIR:-}" # directory containing nlopt.h +FFTW_INC_DIR="${FFTW_INC_DIR:-}" # directory containing fftw3.h +NFFT_INC_DIR="${NFFT_INC_DIR:-}" # directory containing nfft3.h + +need_cmd() { + command -v "$1" >/dev/null 2>&1 || { echo "Missing command: $1" >&2; exit 1; } +} + +fetch_tarball() { + local url="$1" + local out="$2" + if [[ -f "${out}" ]]; then return 0; fi + if command -v curl >/dev/null 2>&1; then + curl -L --fail "${url}" -o "${out}" + else + need_cmd wget + wget -O "${out}" "${url}" + fi +} + +stage_dir_copy_or_link() { + local src="$1" + local dest="$2" + local mode="${3:-symlink}" # symlink|copy + rm -rf "${dest}" + mkdir -p "$(dirname "${dest}")" + case "${mode}" in + symlink) ln -s "${src}" "${dest}" ;; + copy) cp -a "${src}" "${dest}" ;; + *) echo "Unknown mode: ${mode}" >&2; exit 1 ;; + esac +} + +stage_file_copy_or_link() { + local src="$1" + local dest="$2" + local mode="${3:-symlink}" # symlink|copy + rm -f "${dest}" + mkdir -p "$(dirname "${dest}")" + case "${mode}" in + symlink) ln -s "${src}" "${dest}" ;; + copy) cp -a "${src}" "${dest}" ;; + *) echo "Unknown mode: ${mode}" >&2; exit 1 ;; + esac +} + +main() { + mkdir -p "${LIB_DIR}" + + # LuaJIT headers -> lib/luajit/src/* + if [[ -n "${LUAJIT_SRC_DIR}" ]]; then + echo "Staging LuaJIT headers from LUAJIT_SRC_DIR=${LUAJIT_SRC_DIR}" + mkdir -p "${LIB_DIR}/luajit" + stage_dir_copy_or_link "${LUAJIT_SRC_DIR}" "${LIB_DIR}/luajit/src" "symlink" + else + echo "Fetching LuaJIT repo for headers (${LUAJIT_REF})" + need_cmd git + local_dir="${LIB_DIR}/luajit" + if [[ ! -d "${local_dir}/.git" ]]; then + git clone "${LUAJIT_REPO}" "${local_dir}" + fi + ( cd "${local_dir}" + git fetch --all --tags + git checkout "${LUAJIT_REF}" + git pull --ff-only || true + ) + fi + + # NLOpt headers -> lib/nlopt/src/api/nlopt.h + if [[ -n "${NLOPT_INC_DIR}" ]]; then + echo "Staging NLOpt header from NLOPT_INC_DIR=${NLOPT_INC_DIR}" + stage_file_copy_or_link "${NLOPT_INC_DIR}/nlopt.h" "${LIB_DIR}/nlopt/src/api/nlopt.h" "symlink" + else + echo "Fetching NLOpt repo for headers (${NLOPT_REF})" + need_cmd git + local_dir="${LIB_DIR}/nlopt" + if [[ ! -d "${local_dir}/.git" ]]; then + git clone "${NLOPT_REPO}" "${local_dir}" + fi + ( cd "${local_dir}" + git fetch --all --tags + git checkout "${NLOPT_REF}" + git pull --ff-only || true + ) + fi + + # FFTW headers -> lib/fftw3/api/fftw3.h + if [[ -n "${FFTW_INC_DIR}" ]]; then + echo "Staging FFTW header from FFTW_INC_DIR=${FFTW_INC_DIR}" + stage_file_copy_or_link "${FFTW_INC_DIR}/fftw3.h" "${LIB_DIR}/fftw3/api/fftw3.h" "symlink" + else + echo "Fetching FFTW tarball for headers (${FFTW_VERSION})" + need_cmd tar + tar_name="fftw-${FFTW_VERSION}.tar.gz" + tar_path="${LIB_DIR}/${tar_name}" + url="https://fftw.org/${tar_name}" + fetch_tarball "${url}" "${tar_path}" + ( cd "${LIB_DIR}" && tar xzf "${tar_name}" ) + rm -f "${LIB_DIR}/fftw3" + ln -s "fftw-${FFTW_VERSION}" "${LIB_DIR}/fftw3" + fi + + # NFFT headers -> lib/nfft3/include/nfft3.h + if [[ -n "${NFFT_INC_DIR}" ]]; then + echo "Staging NFFT header(s) from NFFT_INC_DIR=${NFFT_INC_DIR}" + mkdir -p "${LIB_DIR}/nfft3" + stage_dir_copy_or_link "${NFFT_INC_DIR}" "${LIB_DIR}/nfft3/include" "symlink" + else + echo "Fetching NFFT tarball for headers (${NFFT_VERSION})" + need_cmd tar + tar_name="nfft-${NFFT_VERSION}.tar.gz" + tar_path="${LIB_DIR}/${tar_name}" + url="http://www.nfft.org/download/${tar_name}" + fetch_tarball "${url}" "${tar_path}" + ( cd "${LIB_DIR}" && tar xzf "${tar_name}" ) + rm -f "${LIB_DIR}/nfft3" + ln -s "nfft-${NFFT_VERSION}" "${LIB_DIR}/nfft3" + fi + + echo + echo "Header checks (expected by src/Makefile):" + for f in \ + "${LIB_DIR}/luajit/src/lua.h" \ + "${LIB_DIR}/nlopt/src/api/nlopt.h" \ + "${LIB_DIR}/fftw3/api/fftw3.h" \ + "${LIB_DIR}/nfft3/include/nfft3.h" + do + if [[ -e "${f}" ]]; then + echo " OK ${f}" + else + echo " MISS ${f}" + fi + done +} + +main "$@" + From 37c98a3bb577b92bfefa221621d207a506405c18 Mon Sep 17 00:00:00 2001 From: Joshua Gray <61458311+jgray-19@users.noreply.github.com> Date: Wed, 13 May 2026 21:31:59 +0200 Subject: [PATCH 04/69] Update NFFT download URL in staging scripts for Linux and macOS --- tools/stage_madng_headers_linux.sh | 3 +-- tools/stage_madng_headers_macos.sh | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/stage_madng_headers_linux.sh b/tools/stage_madng_headers_linux.sh index c74534a..6b199d2 100755 --- a/tools/stage_madng_headers_linux.sh +++ b/tools/stage_madng_headers_linux.sh @@ -138,7 +138,7 @@ main() { need_cmd tar tar_name="nfft-${NFFT_VERSION}.tar.gz" tar_path="${LIB_DIR}/${tar_name}" - url="http://www.nfft.org/download/${tar_name}" + url="https://www-user.tu-chemnitz.de/~potts/nfft/download/${tar_name}" fetch_tarball "${url}" "${tar_path}" ( cd "${LIB_DIR}" && tar xzf "${tar_name}" ) rm -f "${LIB_DIR}/nfft3" @@ -162,4 +162,3 @@ main() { } main "$@" - diff --git a/tools/stage_madng_headers_macos.sh b/tools/stage_madng_headers_macos.sh index 44f5b59..23fb440 100755 --- a/tools/stage_madng_headers_macos.sh +++ b/tools/stage_madng_headers_macos.sh @@ -138,7 +138,7 @@ main() { need_cmd tar tar_name="nfft-${NFFT_VERSION}.tar.gz" tar_path="${LIB_DIR}/${tar_name}" - url="http://www.nfft.org/download/${tar_name}" + url="https://www-user.tu-chemnitz.de/~potts/nfft/download/${tar_name}" fetch_tarball "${url}" "${tar_path}" ( cd "${LIB_DIR}" && tar xzf "${tar_name}" ) rm -f "${LIB_DIR}/nfft3" @@ -162,4 +162,3 @@ main() { } main "$@" - From ad14b967086e4ead7c07ea12918692ac15c0d758 Mon Sep 17 00:00:00 2001 From: Joshua Gray <61458311+jgray-19@users.noreply.github.com> Date: Wed, 13 May 2026 21:38:34 +0200 Subject: [PATCH 05/69] Enhance header staging scripts for LuaJIT compatibility and update Makefile selection for macOS --- .github/workflows/compile_madng.yml | 16 +++++++++++++++- tools/stage_madng_headers_linux.sh | 8 +++++++- tools/stage_madng_headers_macos.sh | 8 +++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/.github/workflows/compile_madng.yml b/.github/workflows/compile_madng.yml index 297c1a0..a325ebb 100644 --- a/.github/workflows/compile_madng.yml +++ b/.github/workflows/compile_madng.yml @@ -34,6 +34,15 @@ jobs: cp MAD/src/Makefile.lxplus MAD/src/Makefile elif [ "$RUNNER_OS" = "macOS" ]; then cp MAD/src/Makefile.macosx MAD/src/Makefile + + # Ensure we use Homebrew LLVM clang (Apple clang doesn't support -fopenmp) + brew_prefix_llvm="$(brew --prefix llvm)" + sed -i.bak \ + -e "s#^CC[[:space:]]*=[[:space:]]*gcc#CC=${brew_prefix_llvm}/bin/clang#g" \ + -e "s#^CC[[:space:]]*=[[:space:]]*clang#CC=${brew_prefix_llvm}/bin/clang#g" \ + -e "s#^CXX[[:space:]]*=[[:space:]]*g\\+\\+#CXX=${brew_prefix_llvm}/bin/clang++#g" \ + -e "s#^CXX[[:space:]]*=[[:space:]]*clang\\+\\+#CXX=${brew_prefix_llvm}/bin/clang++#g" \ + MAD/src/Makefile else echo "Unsupported OS: $RUNNER_OS" exit 1 @@ -61,6 +70,7 @@ jobs: sudo apt-get update sudo apt-get install -y \ build-essential \ + clang \ gcc \ g++ \ make \ @@ -75,6 +85,10 @@ jobs: working-directory: MAD/src run: | + if [ "$RUNNER_OS" = "Linux" ]; then + export CC=clang + export CXX=clang++ + fi if [ "$RUNNER_OS" = "macOS" ]; then export PATH="$(brew --prefix llvm)/bin:$PATH" export CC="$(brew --prefix llvm)/bin/clang" @@ -82,7 +96,7 @@ jobs: export CPPFLAGS="-I$(brew --prefix libomp)/include" export LDFLAGS="-L$(brew --prefix libomp)/lib -lomp" fi - make -j + make -j SHELL=/bin/bash - name: Upload it uses: actions/upload-artifact@v7 diff --git a/tools/stage_madng_headers_linux.sh b/tools/stage_madng_headers_linux.sh index 6b199d2..0238cb6 100755 --- a/tools/stage_madng_headers_linux.sh +++ b/tools/stage_madng_headers_linux.sh @@ -4,7 +4,7 @@ set -euo pipefail # Stage headers into the layout expected by MAD-NG's unmodified `src/Makefile`. # # Expected include paths (from `src/Makefile`): -# -I../lib/luajit/src -> lua.h, luaconf.h, lualib.h, lauxlib.h, lua.hpp +# -I../lib/luajit/src -> lua.h, luajit.h, luaconf.h, lualib.h, lauxlib.h, lua.hpp # -I../lib/nlopt/src/api -> nlopt.h # -I../lib/fftw3/api -> fftw3.h # -I../lib/nfft3/include -> nfft3.h (and friends) @@ -92,6 +92,11 @@ main() { git checkout "${LUAJIT_REF}" git pull --ff-only || true ) + + # Some LuaJIT variants ship `luajit.h.in` instead of `luajit.h`. + if [[ ! -e "${local_dir}/src/luajit.h" && -e "${local_dir}/src/luajit.h.in" ]]; then + cp -f "${local_dir}/src/luajit.h.in" "${local_dir}/src/luajit.h" + fi fi # NLOpt headers -> lib/nlopt/src/api/nlopt.h @@ -149,6 +154,7 @@ main() { echo "Header checks (expected by src/Makefile):" for f in \ "${LIB_DIR}/luajit/src/lua.h" \ + "${LIB_DIR}/luajit/src/luajit.h" \ "${LIB_DIR}/nlopt/src/api/nlopt.h" \ "${LIB_DIR}/fftw3/api/fftw3.h" \ "${LIB_DIR}/nfft3/include/nfft3.h" diff --git a/tools/stage_madng_headers_macos.sh b/tools/stage_madng_headers_macos.sh index 23fb440..a713ab7 100755 --- a/tools/stage_madng_headers_macos.sh +++ b/tools/stage_madng_headers_macos.sh @@ -4,7 +4,7 @@ set -euo pipefail # Stage headers into the layout expected by MAD-NG's unmodified `src/Makefile`. # # Expected include paths (from `src/Makefile`): -# -I../lib/luajit/src -> lua.h etc +# -I../lib/luajit/src -> lua.h, luajit.h, etc # -I../lib/nlopt/src/api -> nlopt.h # -I../lib/fftw3/api -> fftw3.h # -I../lib/nfft3/include -> nfft3.h @@ -92,6 +92,11 @@ main() { git checkout "${LUAJIT_REF}" git pull --ff-only || true ) + + # Some LuaJIT variants ship `luajit.h.in` instead of `luajit.h`. + if [[ ! -e "${local_dir}/src/luajit.h" && -e "${local_dir}/src/luajit.h.in" ]]; then + cp -f "${local_dir}/src/luajit.h.in" "${local_dir}/src/luajit.h" + fi fi # NLOpt headers -> lib/nlopt/src/api/nlopt.h @@ -149,6 +154,7 @@ main() { echo "Header checks (expected by src/Makefile):" for f in \ "${LIB_DIR}/luajit/src/lua.h" \ + "${LIB_DIR}/luajit/src/luajit.h" \ "${LIB_DIR}/nlopt/src/api/nlopt.h" \ "${LIB_DIR}/fftw3/api/fftw3.h" \ "${LIB_DIR}/nfft3/include/nfft3.h" From 39d673c0a2237f055b64897be308a4726d0351d0 Mon Sep 17 00:00:00 2001 From: Joshua Gray <61458311+jgray-19@users.noreply.github.com> Date: Wed, 13 May 2026 21:46:28 +0200 Subject: [PATCH 06/69] Add fallback for luajit.h staging in Linux and macOS header scripts --- .github/workflows/compile_madng.yml | 9 ++++++++- tools/stage_madng_headers_linux.sh | 8 ++++++++ tools/stage_madng_headers_macos.sh | 8 ++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/compile_madng.yml b/.github/workflows/compile_madng.yml index a325ebb..21bee66 100644 --- a/.github/workflows/compile_madng.yml +++ b/.github/workflows/compile_madng.yml @@ -32,6 +32,12 @@ jobs: run: | if [ "$RUNNER_OS" = "Linux" ]; then cp MAD/src/Makefile.lxplus MAD/src/Makefile + + # Prefer clang/clang++ on CI (Makefile.lxplus may default to gcc/g++) + sed -i \ + -e 's#^CC[[:space:]]*=.*#CC=clang#g' \ + -e 's#^CXX[[:space:]]*=.*#CXX=clang++#g' \ + MAD/src/Makefile || true elif [ "$RUNNER_OS" = "macOS" ]; then cp MAD/src/Makefile.macosx MAD/src/Makefile @@ -96,7 +102,8 @@ jobs: export CPPFLAGS="-I$(brew --prefix libomp)/include" export LDFLAGS="-L$(brew --prefix libomp)/lib -lomp" fi - make -j SHELL=/bin/bash + # Enable job control for Makefile recipes that use `bg` + bash -m -lc "make -j CC='${CC}' CXX='${CXX}' CPPFLAGS='${CPPFLAGS:-}' LDFLAGS='${LDFLAGS:-}'" - name: Upload it uses: actions/upload-artifact@v7 diff --git a/tools/stage_madng_headers_linux.sh b/tools/stage_madng_headers_linux.sh index 0238cb6..1efeb3d 100755 --- a/tools/stage_madng_headers_linux.sh +++ b/tools/stage_madng_headers_linux.sh @@ -97,6 +97,14 @@ main() { if [[ ! -e "${local_dir}/src/luajit.h" && -e "${local_dir}/src/luajit.h.in" ]]; then cp -f "${local_dir}/src/luajit.h.in" "${local_dir}/src/luajit.h" fi + + # Fallback: some forks may place the template elsewhere. + if [[ ! -e "${local_dir}/src/luajit.h" ]]; then + alt="$(find "${local_dir}" -maxdepth 3 -name 'luajit.h.in' -o -name 'luajit.h' | head -n 1 || true)" + if [[ -n "${alt}" && -e "${alt}" ]]; then + cp -f "${alt}" "${local_dir}/src/luajit.h" + fi + fi fi # NLOpt headers -> lib/nlopt/src/api/nlopt.h diff --git a/tools/stage_madng_headers_macos.sh b/tools/stage_madng_headers_macos.sh index a713ab7..eeac3fb 100755 --- a/tools/stage_madng_headers_macos.sh +++ b/tools/stage_madng_headers_macos.sh @@ -97,6 +97,14 @@ main() { if [[ ! -e "${local_dir}/src/luajit.h" && -e "${local_dir}/src/luajit.h.in" ]]; then cp -f "${local_dir}/src/luajit.h.in" "${local_dir}/src/luajit.h" fi + + # Fallback: some forks may place the template elsewhere. + if [[ ! -e "${local_dir}/src/luajit.h" ]]; then + alt="$(find "${local_dir}" -maxdepth 3 -name 'luajit.h.in' -o -name 'luajit.h' | head -n 1 || true)" + if [[ -n "${alt}" && -e "${alt}" ]]; then + cp -f "${alt}" "${local_dir}/src/luajit.h" + fi + fi fi # NLOpt headers -> lib/nlopt/src/api/nlopt.h From e9e0cbd24ade2e4d89be75ae8fb4d7614aa740be Mon Sep 17 00:00:00 2001 From: Joshua Gray <61458311+jgray-19@users.noreply.github.com> Date: Wed, 13 May 2026 21:53:34 +0200 Subject: [PATCH 07/69] Refactor GitHub Actions workflow for MAD-NG binary compilation --- .github/workflows/compile_madng.yml | 99 ++++++++++++++--------------- 1 file changed, 46 insertions(+), 53 deletions(-) diff --git a/.github/workflows/compile_madng.yml b/.github/workflows/compile_madng.yml index 21bee66..03b4204 100644 --- a/.github/workflows/compile_madng.yml +++ b/.github/workflows/compile_madng.yml @@ -1,6 +1,3 @@ -# 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: @@ -19,94 +16,90 @@ jobs: steps: - name: Checkout current repo - uses: actions/checkout@v6 + uses: actions/checkout@v4 - - name: Clone another repo - uses: actions/checkout@v6 + - name: Clone MAD-NG + uses: actions/checkout@v4 with: repository: MethodicalAcceleratorDesign/MAD-NG path: MAD submodules: recursive + - name: Install dependencies + run: | + if [ "$RUNNER_OS" = "Linux" ]; then + sudo apt-get update + sudo apt-get install -y build-essential + elif [ "$RUNNER_OS" = "macOS" ]; then + brew update + brew install llvm libomp + fi + - name: Select Makefile run: | if [ "$RUNNER_OS" = "Linux" ]; then cp MAD/src/Makefile.lxplus MAD/src/Makefile - - # Prefer clang/clang++ on CI (Makefile.lxplus may default to gcc/g++) sed -i \ - -e 's#^CC[[:space:]]*=.*#CC=clang#g' \ - -e 's#^CXX[[:space:]]*=.*#CXX=clang++#g' \ + -e 's#^CC[[:space:]]*=.*#CC=gcc#g' \ + -e 's#^CXX[[:space:]]*=.*#CXX=g++#g' \ + -e 's#-fdiagnostics-all-candidates##g' \ MAD/src/Makefile || true elif [ "$RUNNER_OS" = "macOS" ]; then - cp MAD/src/Makefile.macosx MAD/src/Makefile - - # Ensure we use Homebrew LLVM clang (Apple clang doesn't support -fopenmp) brew_prefix_llvm="$(brew --prefix llvm)" + cp MAD/src/Makefile.macosx MAD/src/Makefile sed -i.bak \ -e "s#^CC[[:space:]]*=[[:space:]]*gcc#CC=${brew_prefix_llvm}/bin/clang#g" \ -e "s#^CC[[:space:]]*=[[:space:]]*clang#CC=${brew_prefix_llvm}/bin/clang#g" \ -e "s#^CXX[[:space:]]*=[[:space:]]*g\\+\\+#CXX=${brew_prefix_llvm}/bin/clang++#g" \ -e "s#^CXX[[:space:]]*=[[:space:]]*clang\\+\\+#CXX=${brew_prefix_llvm}/bin/clang++#g" \ + -e "s#-fdiagnostics-all-candidates##g" \ MAD/src/Makefile - else - echo "Unsupported OS: $RUNNER_OS" - exit 1 fi - name: Stage MAD-NG headers run: | mkdir -p MAD/tools - cp -f tools/stage_madng_headers_linux.sh MAD/tools/ || true - cp -f tools/stage_madng_headers_macos.sh MAD/tools/ || true - chmod +x MAD/tools/stage_madng_headers_*.sh - if [ "$RUNNER_OS" = "Linux" ]; then + cp -f tools/stage_madng_headers_linux.sh MAD/tools/ + chmod +x MAD/tools/stage_madng_headers_linux.sh (cd MAD && ./tools/stage_madng_headers_linux.sh) elif [ "$RUNNER_OS" = "macOS" ]; then + cp -f tools/stage_madng_headers_macos.sh MAD/tools/ + chmod +x MAD/tools/stage_madng_headers_macos.sh (cd MAD && ./tools/stage_madng_headers_macos.sh) - 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 \ - clang \ - 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: | + # GitHub Actions has no TTY/job-control; provide a synchronous `bg` shim. + mkdir -p "${RUNNER_TEMP}/madng-bin" + printf '#!/usr/bin/env bash\n[ "$#" -ge 2 ] && "$1" > "$2"\n' \ + > "${RUNNER_TEMP}/madng-bin/bg" + chmod +x "${RUNNER_TEMP}/madng-bin/bg" + export PATH="${RUNNER_TEMP}/madng-bin:${PATH}" + if [ "$RUNNER_OS" = "Linux" ]; then - export CC=clang - export CXX=clang++ - fi - 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 CC=gcc CXX=g++ + elif [ "$RUNNER_OS" = "macOS" ]; then + llvm="$(brew --prefix llvm)" + export PATH="${llvm}/bin:${PATH}" + export CC="${llvm}/bin/clang" CXX="${llvm}/bin/clang++" export CPPFLAGS="-I$(brew --prefix libomp)/include" export LDFLAGS="-L$(brew --prefix libomp)/lib -lomp" + # Avoid x86_64-specific tuning flags on arm64. + export CFLAGS="-O3 -ftree-vectorize -fPIC -flto" + export CXXFLAGS="-O3 -ftree-vectorize -fPIC -flto" fi - # Enable job control for Makefile recipes that use `bg` - bash -m -lc "make -j CC='${CC}' CXX='${CXX}' CPPFLAGS='${CPPFLAGS:-}' LDFLAGS='${LDFLAGS:-}'" - - name: Upload it - uses: actions/upload-artifact@v7 + JOBS=$(nproc 2>/dev/null || sysctl -n hw.logicalcpu) + make -j"${JOBS}" SHELL=/bin/bash \ + CC="${CC}" CXX="${CXX}" \ + CPPFLAGS="${CPPFLAGS:-}" LDFLAGS="${LDFLAGS:-}" \ + CFLAGS="${CFLAGS:-}" CXXFLAGS="${CXXFLAGS:-}" + + - name: Upload binary + uses: actions/upload-artifact@v4 with: - name: executable-${{ runner.os }} + name: mad-${{ runner.os }} path: MAD/src/mad From 0ab8ca231b53f1fdb59355d1d7e3022d1a3adfda Mon Sep 17 00:00:00 2001 From: Joshua Gray <61458311+jgray-19@users.noreply.github.com> Date: Wed, 13 May 2026 22:01:26 +0200 Subject: [PATCH 08/69] Add error handling for missing headers in staging scripts for Linux and macOS --- tools/stage_madng_headers_linux.sh | 5 ++++- tools/stage_madng_headers_macos.sh | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/stage_madng_headers_linux.sh b/tools/stage_madng_headers_linux.sh index 1efeb3d..81eebd2 100755 --- a/tools/stage_madng_headers_linux.sh +++ b/tools/stage_madng_headers_linux.sh @@ -160,6 +160,7 @@ main() { echo echo "Header checks (expected by src/Makefile):" + local rc=0 for f in \ "${LIB_DIR}/luajit/src/lua.h" \ "${LIB_DIR}/luajit/src/luajit.h" \ @@ -170,9 +171,11 @@ main() { if [[ -e "${f}" ]]; then echo " OK ${f}" else - echo " MISS ${f}" + echo " MISS ${f}" >&2 + rc=1 fi done + return "${rc}" } main "$@" diff --git a/tools/stage_madng_headers_macos.sh b/tools/stage_madng_headers_macos.sh index eeac3fb..ab19f85 100755 --- a/tools/stage_madng_headers_macos.sh +++ b/tools/stage_madng_headers_macos.sh @@ -160,6 +160,7 @@ main() { echo echo "Header checks (expected by src/Makefile):" + local rc=0 for f in \ "${LIB_DIR}/luajit/src/lua.h" \ "${LIB_DIR}/luajit/src/luajit.h" \ @@ -170,9 +171,11 @@ main() { if [[ -e "${f}" ]]; then echo " OK ${f}" else - echo " MISS ${f}" + echo " MISS ${f}" >&2 + rc=1 fi done + return "${rc}" } main "$@" From 756630c50908a860b782a5d8ba18c9c2a26d3657 Mon Sep 17 00:00:00 2001 From: Joshua Gray <61458311+jgray-19@users.noreply.github.com> Date: Wed, 13 May 2026 22:04:38 +0200 Subject: [PATCH 09/69] Add fallback to generate luajit.h during build in staging scripts for Linux and macOS --- tools/stage_madng_headers_linux.sh | 10 +++++++++- tools/stage_madng_headers_macos.sh | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tools/stage_madng_headers_linux.sh b/tools/stage_madng_headers_linux.sh index 81eebd2..dca2931 100755 --- a/tools/stage_madng_headers_linux.sh +++ b/tools/stage_madng_headers_linux.sh @@ -100,11 +100,19 @@ main() { # Fallback: some forks may place the template elsewhere. if [[ ! -e "${local_dir}/src/luajit.h" ]]; then - alt="$(find "${local_dir}" -maxdepth 3 -name 'luajit.h.in' -o -name 'luajit.h' | head -n 1 || true)" + alt="$(find "${local_dir}" -maxdepth 3 \( -name 'luajit.h.in' -o -name 'luajit.h' \) | head -n 1 || true)" if [[ -n "${alt}" && -e "${alt}" ]]; then cp -f "${alt}" "${local_dir}/src/luajit.h" fi fi + + # Last resort: the MAD-patch fork generates luajit.h during build. + if [[ ! -e "${local_dir}/src/luajit.h" ]]; then + echo "luajit.h not in repo — generating via make..." + make -C "${local_dir}/src" luajit.h 2>/dev/null \ + || make -C "${local_dir}" 2>/dev/null \ + || true + fi fi # NLOpt headers -> lib/nlopt/src/api/nlopt.h diff --git a/tools/stage_madng_headers_macos.sh b/tools/stage_madng_headers_macos.sh index ab19f85..5c15779 100755 --- a/tools/stage_madng_headers_macos.sh +++ b/tools/stage_madng_headers_macos.sh @@ -100,11 +100,19 @@ main() { # Fallback: some forks may place the template elsewhere. if [[ ! -e "${local_dir}/src/luajit.h" ]]; then - alt="$(find "${local_dir}" -maxdepth 3 -name 'luajit.h.in' -o -name 'luajit.h' | head -n 1 || true)" + alt="$(find "${local_dir}" -maxdepth 3 \( -name 'luajit.h.in' -o -name 'luajit.h' \) | head -n 1 || true)" if [[ -n "${alt}" && -e "${alt}" ]]; then cp -f "${alt}" "${local_dir}/src/luajit.h" fi fi + + # Last resort: the MAD-patch fork generates luajit.h during build. + if [[ ! -e "${local_dir}/src/luajit.h" ]]; then + echo "luajit.h not in repo — generating via make..." + make -C "${local_dir}/src" luajit.h 2>/dev/null \ + || make -C "${local_dir}" 2>/dev/null \ + || true + fi fi # NLOpt headers -> lib/nlopt/src/api/nlopt.h From 02a07e3a85751d66cecc08badab35fb53c130504 Mon Sep 17 00:00:00 2001 From: Joshua Gray <61458311+jgray-19@users.noreply.github.com> Date: Wed, 13 May 2026 22:08:34 +0200 Subject: [PATCH 10/69] Add library include paths for LuaJIT and other dependencies in compilation scripts --- .github/workflows/compile_madng.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/compile_madng.yml b/.github/workflows/compile_madng.yml index 03b4204..e60bdb2 100644 --- a/.github/workflows/compile_madng.yml +++ b/.github/workflows/compile_madng.yml @@ -79,13 +79,17 @@ jobs: chmod +x "${RUNNER_TEMP}/madng-bin/bg" export PATH="${RUNNER_TEMP}/madng-bin:${PATH}" + # Include paths the Makefile expects to find in ../lib relative to src/. + LIB_INCLUDES="-I../lib/luajit/src -I../lib/nlopt/src/api -I../lib/fftw3/api -I../lib/nfft3/include" + if [ "$RUNNER_OS" = "Linux" ]; then export CC=gcc CXX=g++ + export CPPFLAGS="${LIB_INCLUDES}" elif [ "$RUNNER_OS" = "macOS" ]; then llvm="$(brew --prefix llvm)" export PATH="${llvm}/bin:${PATH}" export CC="${llvm}/bin/clang" CXX="${llvm}/bin/clang++" - export CPPFLAGS="-I$(brew --prefix libomp)/include" + export CPPFLAGS="${LIB_INCLUDES} -I$(brew --prefix libomp)/include" export LDFLAGS="-L$(brew --prefix libomp)/lib -lomp" # Avoid x86_64-specific tuning flags on arm64. export CFLAGS="-O3 -ftree-vectorize -fPIC -flto" From f578ad1a814cb673afe22d175c3fef4c88580b18 Mon Sep 17 00:00:00 2001 From: Joshua Gray <61458311+jgray-19@users.noreply.github.com> Date: Wed, 13 May 2026 22:13:34 +0200 Subject: [PATCH 11/69] Update include paths to absolute references in Makefile for compatibility with sub-processes --- .github/workflows/compile_madng.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compile_madng.yml b/.github/workflows/compile_madng.yml index e60bdb2..906db3a 100644 --- a/.github/workflows/compile_madng.yml +++ b/.github/workflows/compile_madng.yml @@ -79,8 +79,9 @@ jobs: chmod +x "${RUNNER_TEMP}/madng-bin/bg" export PATH="${RUNNER_TEMP}/madng-bin:${PATH}" - # Include paths the Makefile expects to find in ../lib relative to src/. - LIB_INCLUDES="-I../lib/luajit/src -I../lib/nlopt/src/api -I../lib/fftw3/api -I../lib/nfft3/include" + # Absolute include paths — relative ones break when make spawns sub-processes. + LIB="$(cd ../lib && pwd)" + LIB_INCLUDES="-I${LIB}/luajit/src -I${LIB}/nlopt/src/api -I${LIB}/fftw3/api -I${LIB}/nfft3/include" if [ "$RUNNER_OS" = "Linux" ]; then export CC=gcc CXX=g++ From 10cf1a8a0d2455a98e60289a3cd6a4a332f59596 Mon Sep 17 00:00:00 2001 From: Joshua Gray <61458311+jgray-19@users.noreply.github.com> Date: Wed, 13 May 2026 22:18:37 +0200 Subject: [PATCH 12/69] Refactor Makefile selection and compilation steps for improved compatibility and clarity --- .github/workflows/compile_madng.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/compile_madng.yml b/.github/workflows/compile_madng.yml index 906db3a..1041343 100644 --- a/.github/workflows/compile_madng.yml +++ b/.github/workflows/compile_madng.yml @@ -53,6 +53,9 @@ jobs: -e "s#^CXX[[:space:]]*=[[:space:]]*g\\+\\+#CXX=${brew_prefix_llvm}/bin/clang++#g" \ -e "s#^CXX[[:space:]]*=[[:space:]]*clang\\+\\+#CXX=${brew_prefix_llvm}/bin/clang++#g" \ -e "s#-fdiagnostics-all-candidates##g" \ + -e "s#-march=native##g" \ + -e "s#-mtune=native##g" \ + -e "s#-mfma##g" \ MAD/src/Makefile fi @@ -82,26 +85,27 @@ jobs: # Absolute include paths — relative ones break when make spawns sub-processes. LIB="$(cd ../lib && pwd)" LIB_INCLUDES="-I${LIB}/luajit/src -I${LIB}/nlopt/src/api -I${LIB}/fftw3/api -I${LIB}/nfft3/include" + COMMON_CFLAGS="${LIB_INCLUDES}" if [ "$RUNNER_OS" = "Linux" ]; then export CC=gcc CXX=g++ - export CPPFLAGS="${LIB_INCLUDES}" + # MAD-NG Makefiles typically use CFLAGS for include paths. + export CFLAGS="${COMMON_CFLAGS}" + export CXXFLAGS="${COMMON_CFLAGS}" elif [ "$RUNNER_OS" = "macOS" ]; then llvm="$(brew --prefix llvm)" export PATH="${llvm}/bin:${PATH}" export CC="${llvm}/bin/clang" CXX="${llvm}/bin/clang++" - export CPPFLAGS="${LIB_INCLUDES} -I$(brew --prefix libomp)/include" + export CFLAGS="${COMMON_CFLAGS} -I$(brew --prefix libomp)/include" + export CXXFLAGS="${CFLAGS}" export LDFLAGS="-L$(brew --prefix libomp)/lib -lomp" - # Avoid x86_64-specific tuning flags on arm64. - export CFLAGS="-O3 -ftree-vectorize -fPIC -flto" - export CXXFLAGS="-O3 -ftree-vectorize -fPIC -flto" fi JOBS=$(nproc 2>/dev/null || sysctl -n hw.logicalcpu) make -j"${JOBS}" SHELL=/bin/bash \ CC="${CC}" CXX="${CXX}" \ - CPPFLAGS="${CPPFLAGS:-}" LDFLAGS="${LDFLAGS:-}" \ - CFLAGS="${CFLAGS:-}" CXXFLAGS="${CXXFLAGS:-}" + CFLAGS="${CFLAGS:-}" CXXFLAGS="${CXXFLAGS:-}" \ + LDFLAGS="${LDFLAGS:-}" - name: Upload binary uses: actions/upload-artifact@v4 From 84523862e3bdaebe0de8beaa91230f496c619b4d Mon Sep 17 00:00:00 2001 From: Joshua Gray <61458311+jgray-19@users.noreply.github.com> Date: Wed, 13 May 2026 22:23:37 +0200 Subject: [PATCH 13/69] Enhance MAD-NG compilation process by adding a synchronous bg shim and refining include path handling for improved compatibility --- .github/workflows/compile_madng.yml | 34 ++++++++++++++++++----------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/.github/workflows/compile_madng.yml b/.github/workflows/compile_madng.yml index 1041343..d20b826 100644 --- a/.github/workflows/compile_madng.yml +++ b/.github/workflows/compile_madng.yml @@ -75,29 +75,37 @@ jobs: - name: Compile MAD-NG working-directory: MAD/src run: | - # GitHub Actions has no TTY/job-control; provide a synchronous `bg` shim. - mkdir -p "${RUNNER_TEMP}/madng-bin" - printf '#!/usr/bin/env bash\n[ "$#" -ge 2 ] && "$1" > "$2"\n' \ - > "${RUNNER_TEMP}/madng-bin/bg" - chmod +x "${RUNNER_TEMP}/madng-bin/bg" - export PATH="${RUNNER_TEMP}/madng-bin:${PATH}" + # GitHub Actions has no job control/TTY. MAD-NG Makefiles use `bg ...` + # to parallelize some conversions; patch it to run synchronously. + sed -i.bak -e 's#^bg #./bg_shim #g' Makefile || true - # Absolute include paths — relative ones break when make spawns sub-processes. + printf '%s\n' \ + '#!/usr/bin/env bash' \ + 'set -euo pipefail' \ + '# expected: bg