From 2bc0353914f1ce8d7a5f19a2619c6f332e749be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Gl=C3=A4=C3=9Fle?= Date: Tue, 17 Dec 2024 07:57:41 +0100 Subject: [PATCH] Fix more errors with msys2 ucrt platform _mkdir being undefined: [ 81%] Building C object src/CMakeFiles/madx.dir/mad_sstate.c.obj C:\Users\Thomas\dev\hit\cpymad\src\MAD-X\src\mad_sstate.c: In function 'store_state': C:\Users\Thomas\dev\hit\cpymad\src\MAD-X\src\mad_sstate.c:42:5: error: implicit declaration of function '_mkdir'; did you mean 'mkdir'? [-Wimplicit-function-declaration] 42 | _mkdir(dir_name); | ^~~~~~ | mkdir and lots of undefined symbols (ad_alloc_, ad_free_, ...) in PTC. --- .github/patch/fix-madx-win32.patch | 23 +++++++++++++++++++++++ .github/workflows/build.yml | 3 +++ 2 files changed, 26 insertions(+) create mode 100644 .github/patch/fix-madx-win32.patch diff --git a/.github/patch/fix-madx-win32.patch b/.github/patch/fix-madx-win32.patch new file mode 100644 index 00000000..2da63491 --- /dev/null +++ b/.github/patch/fix-madx-win32.patch @@ -0,0 +1,23 @@ +diff --git a/libs/ptc/src/tpsa.h b/libs/ptc/src/tpsa.h +index 4a2f15bc..b0b3174c 100644 +--- a/libs/ptc/src/tpsa.h ++++ b/libs/ptc/src/tpsa.h +@@ -11,7 +11,7 @@ + //! \version $Id: tpsa.h,v 1.4 2009-04-17 17:32:23 frs Exp $ + //! \author Lingyun Yang, http://www.lingyunyang.com/ + +-#ifndef WIN32 ++#if !defined(WIN32) || defined(__GNUC__) + + /* should work unchanged on _win32 using Lahey */ + #define ad_print ad_print_ +diff --git a/src/mad_sstate.c b/src/mad_sstate.c +index fe909635..044ed409 100644 +--- a/src/mad_sstate.c ++++ b/src/mad_sstate.c +@@ -1,4 +1,5 @@ + #include "madx.h" ++#include // _mkdir() + + static void + move_files(const char* orig_name,const char* append,const char* dirname){ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7d138fc8..18d3f70a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -119,6 +119,9 @@ jobs: src/MAD-X -b $MADX_VERSION --depth 1 if: steps.madx-build-cache.outputs.cache-hit != 'true' + - name: Apply patches + if: steps.madx-build-cache.outputs.cache-hit != 'true' + run: patch -d src/MAD-X -p1 <.github/patch/fix_mkdir.patch - name: Build MAD-X if: steps.madx-build-cache.outputs.cache-hit != 'true' run: .github/build/windows/madx.sh src/MAD-X