Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wizard recipe: MAiNGO-v0.7.2 #7812

Merged

Conversation

MAiNGO-github
Copy link
Contributor

This pull request contains a new build recipe we built using the BinaryBuilder.jl wizard:

Package name: MAiNGO
Version: v0.7.2

@staticfloat please review and merge.

Auditor complains about AVX2

Without setting march the Auditor detects avx2.
However, after using march="avx2", avx512 is detected.
Thus, we build without march as it is either a false detection or some dependency adapts to the march setting.
In both cases the selected setting should result in the most compatible binaries.

Why only Windows and Linux ?

MacOS support is held back by the following issue (XCode seems to be too old (?)): #7139
Note that we tried the suggestion in JuliaPackaging/BinaryBuilder.jl#1263 locally under Linux, but we received many errors for

rm -rf /opt/${target}/${target}/sys-root/System
cp -raf usr/* "/opt/${target}/${target}/sys-root/usr/."
cp -raf System "/opt/${target}/${target}/sys-root/."

similar to what was described in the issue comments.

FreeBSD was once successfully compiled using -DCMAKE_TOOLCHAIN_FILE=${CMAKE_/TARGET_TOOLCHAIN%.*}_gcc.cmake, but MAiNGO is not properly tested on that platform.

Aron Zingler added 3 commits December 15, 2023 19:29
Add comments explaining why certain platforms are not yet build.
Add expansion over cxxstring and libgfortran 4 and 5.
M/MAiNGO/build_tarballs.jl Outdated Show resolved Hide resolved
script = raw"""
cd $WORKSPACE/srcdir
cd maingo/
git remote set-url origin https://git.rwth-aachen.de/avt-svt/public/maingo.git
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Isn't this already the case?

Suggested change
git remote set-url origin https://git.rwth-aachen.de/avt-svt/public/maingo.git

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran into this problem before, at least in my tests locally the git remote is changed for caching.
See JuliaPackaging/BinaryBuilderBase.jl#355

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in our tests, this did not work because of caching. For now we would leave this in.

M/MAiNGO/build_tarballs.jl Outdated Show resolved Hide resolved
M/MAiNGO/build_tarballs.jl Show resolved Hide resolved
M/MAiNGO/build_tarballs.jl Outdated Show resolved Hide resolved
M/MAiNGO/build_tarballs.jl Outdated Show resolved Hide resolved
M/MAiNGO/build_tarballs.jl Outdated Show resolved Hide resolved
M/MAiNGO/build_tarballs.jl Outdated Show resolved Hide resolved
M/MAiNGO/build_tarballs.jl Outdated Show resolved Hide resolved
@giordano
Copy link
Member

giordano commented Dec 18, 2023

but we received many errors for

rm -rf /opt/${target}/${target}/sys-root/System
cp -raf usr/* "/opt/${target}/${target}/sys-root/usr/."
cp -raf System "/opt/${target}/${target}/sys-root/."

similar to what was described in the issue comments.

You need a privileged runner to be able to delete files from the root file system: https://docs.binarybuilder.org/stable/environment_variables/. That's what we use here in CI, which is what eventually matters for actually building the pacakge.

M/MAiNGO/build_tarballs.jl Outdated Show resolved Hide resolved
#FreeBsd builds only with gcc, that platform has not yet been sufficiently tested for inclusion.
platforms = [
Platform("x86_64", "linux", libgfortran_version=v"4"),
Platform("x86_64", "linux", libgfortran_version=v"5"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No v3 on purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We expand only to gfortan 4 and 5 (3 seems not to have std::variant)

M/MAiNGO/build_tarballs.jl Show resolved Hide resolved
MAiNGO-github and others added 2 commits December 19, 2023 13:36
Apply directly useable suggestions.

Co-authored-by: Mosè Giordano <[email protected]>
Add suggested commands for moving lib and bin targets.

Co-authored-by: Mosè Giordano <[email protected]>
@MAiNGO-github MAiNGO-github marked this pull request as draft December 19, 2023 12:51
Aron Zingler added 8 commits December 19, 2023 16:54
Not supported upstream and fails on trial build with

/workspace/srcdir/maingo/build/dep/ipopt/IpoptConfig/include/config.h:17:4: error: #error "No finite/_finite function available"
[16:31:28]    17 |   #error "No finite/_finite function available"

Likely would need deeper investigation and modification of the CMake files, as Ipopt without CMake seems to build.
@MAiNGO-github MAiNGO-github marked this pull request as ready for review December 19, 2023 16:57
@MAiNGO-github
Copy link
Contributor Author

@giordano maybe you could take another look.
We followed the suggestions about filtering out platforms instead of picking platforms that work.

Using GCC the build is successful for MacOS, but FreeBSD did not succeed, which would have to be investigated further and fixed upstream.

if [[ "${target}" == x86_64-apple-darwin* ]]; then
export MACOSX_DEPLOYMENT_TARGET=10.15
cmake -DCMAKE_INSTALL_PREFIX=${prefix} \
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN%.*}_gcc.cmake \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not clang? Also, at this point you could avoid the conditional and use gcc everywhere, but I'd prefer to understand what's wrong with clang, that's usually the best choice for macOS.

@giordano giordano marked this pull request as draft January 4, 2024 13:21
@giordano giordano marked this pull request as ready for review January 4, 2024 13:23
@giordano
Copy link
Member

giordano commented Jan 4, 2024

The error message on x86_64 macOS is (multiple times)

[13:29:02] In file included from /workspace/srcdir/maingo/dep/libale/src/symbol.cpp:12:
[13:29:02] In file included from /workspace/srcdir/maingo/dep/libale/src/symbol.hpp:14:
[13:29:02] In file included from /workspace/srcdir/maingo/dep/libale/src/value.hpp:16:
[13:29:02] /workspace/srcdir/maingo/dep/libale/src/tensor.hpp:460:31: error: no member named 'to_string' in namespace 'std'
[13:29:02]               "index " + std::to_string(index) + " out of bounds for shape = " + std::to_string(shape(0)));
[13:29:02]                          ~~~~~^
[13:29:02] /workspace/srcdir/maingo/dep/libale/src/tensor.hpp:460:87: error: no member named 'to_string' in namespace 'std'
[13:29:02]               "index " + std::to_string(index) + " out of bounds for shape = " + std::to_string(shape(0)));
[13:29:02]                                                                                  ~~~~~^
[13:29:02] 2 errors generated.

According to pytorch/pytorch#3192 (comment) there may be a missing

#include <string>

Also C++ docs shows that std::to_string requires the string header file: https://en.cppreference.com/w/cpp/string/basic_string/to_string. I don't see this header explicitly loaded in https://git.rwth-aachen.de/avt-svt/public/libale/-/blob/49bacdeaa0ae4c2236d01a65c8b31f87a8576926/src/tensor.hpp. This looks an upstream bug to me.

@MAiNGO-github
Copy link
Contributor Author

According to pytorch/pytorch#3192 (comment) there may be a missing

#include <string>

Also C++ docs shows that std::to_string requires the string header file: https://en.cppreference.com/w/cpp/string/basic_string/to_string. I don't see this header explicitly loaded in https://git.rwth-aachen.de/avt-svt/public/libale/-/blob/49bacdeaa0ae4c2236d01a65c8b31f87a8576926/src/tensor.hpp. This looks an upstream bug to me.

I agree that not including <string> is a mistake. In my understanding it is fragile as it implicitly assumes <string> will be included at the place where the template is used.

This has been noted and upstream will fix it in the next release.

However, I believe this is not the reason the compilation failed, but an outdated SDK version.

The first reason is that compilation outside of Binary Builder works with Clang on Linux.
Secondly, further down in the log it complained that std::variant is not yet supported (and here gives explicity that that requires SDK 10.15).
After changing to 10.15, we no longer see the error about std::to_string.

Instead, the problem is, as we had seen previously, #7139, that is shared_pointer to array is not yet supported.

For now I suggest building for MacOS with GCC, which we have seen before works.
Is that fine?

@MAiNGO-github
Copy link
Contributor Author

@giordano Would you still have access to the logs of the failed pipeline of the lastest commit (8c2ce78) that I reference above, even after I add another commit ?
I would like to put the pull request to the suggested state (=reverting to the situation of d56546f) with passing tests that might be accepted.

@giordano
Copy link
Member

Patching the offending file with

diff --git a/M/MAiNGO/build_tarballs.jl b/M/MAiNGO/build_tarballs.jl
index 3a28c6fd9..3e0e32ba0 100644
--- a/M/MAiNGO/build_tarballs.jl
+++ b/M/MAiNGO/build_tarballs.jl
@@ -7,58 +7,52 @@ version = v"0.7.2"
 
 # Collection of sources required to complete build
 sources = [
-    GitSource("https://git.rwth-aachen.de/avt-svt/public/maingo.git", "252733413a29dbe5b84a4cdaf53e60e9934f372f"),
+    GitSource("https://git.rwth-aachen.de/avt-svt/public/maingo.git",
+              "252733413a29dbe5b84a4cdaf53e60e9934f372f"),
+    ArchiveSource("https://github.com/phracker/MacOSX-SDKs/releases/download/10.15/MacOSX10.15.sdk.tar.xz",
+                  "2408d07df7f324d3beea818585a6d990ba99587c218a3969f924dfcc4de93b62"),
+    DirectorySource("./bundled"),
 ]
 
 # Bash recipe for building across all platforms
 script = raw"""
 cd $WORKSPACE/srcdir/maingo/
 git remote set-url origin https://git.rwth-aachen.de/avt-svt/public/maingo.git
-mkdir build
-cd build
-git submodule init
-git submodule update -j 1
+git submodule update --init
 
+atomic_patch -p1 -d dep/libale ../patches/libale-tensor-string.patch
 
-common_cmake_options="-DCMAKE_BUILD_TYPE=Release \
-                     -DMAiNGO_build_standalone=True \
-                     -DMAiNGO_build_shared_c_api=True \
-                     -DMAiNGO_build_parser=True \
-                     -DMAiNGO_use_cplex=False \
-                     -DMAiNGO_use_melon=False"
+common_cmake_options=(
+    -DCMAKE_BUILD_TYPE=Release
+    -DMAiNGO_build_standalone=True
+    -DMAiNGO_build_shared_c_api=True
+    -DMAiNGO_build_parser=True
+    -DMAiNGO_use_cplex=False
+    -DMAiNGO_use_melon=False
+)
 
-# GCC used because of https://github.com/JuliaPackaging/Yggdrasil/issues/7139
 if [[ "${target}" == x86_64-apple-darwin* ]]; then
+    # Install a newer SDK which supports `std::to_string`
+    pushd $WORKSPACE/srcdir/MacOSX10.*.sdk
+    rm -rf /opt/${target}/${target}/sys-root/System
+    cp -ra usr/* "/opt/${target}/${target}/sys-root/usr/."
+    cp -ra System "/opt/${target}/${target}/sys-root/."
+    popd
     export MACOSX_DEPLOYMENT_TARGET=10.15
-#    cmake -DCMAKE_INSTALL_PREFIX=${prefix} \
-#          -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN%.*}_gcc.cmake \
-#          ${common_cmake_options} \
-#          ..
 fi
-#else
-    cmake -DCMAKE_INSTALL_PREFIX=${prefix} \
-          -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \
-          ${common_cmake_options} \
-          ..
-#fi
 
+cmake -DCMAKE_INSTALL_PREFIX=${prefix} \
+      -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \
+      "${common_cmake_options[@]}" \
+      -B build
 
-
-cmake --build . --config Release --parallel ${nproc}
+cmake --build build --config Release --parallel ${nproc}
 install -Dvm 755 "MAiNGO${exeext}" "${bindir}/MAiNGO${exeext}"
 install -Dvm 755 "MAiNGOcpp${exeext}" "${bindir}/MAiNGOcpp${exeext}"
 install -Dvm 755 "libmaingo-c-api.${dlext}" "${libdir}/libmaingo-c-api.${dlext}"
 install_license ../LICENSE
 """
 
-# These are the platforms we will build for by default, unless further
-# platforms are passed in on the command line
-
-
-#Auditor complains about avx1.
-#Without march the Auditor detects avx2
-#but with march="avx2" avx512 is detected, so we build without march
-
 platforms = supported_platforms()
 #FreeBSD is not supported
 filter!(!Sys.isfreebsd, platforms)
diff --git a/M/MAiNGO/bundled/patches/libale-tensor-string.patch b/M/MAiNGO/bundled/patches/libale-tensor-string.patch
new file mode 100644
index 000000000..720792bee
--- /dev/null
+++ b/M/MAiNGO/bundled/patches/libale-tensor-string.patch
@@ -0,0 +1,12 @@
+diff --git a/src/tensor.hpp b/src/tensor.hpp
+index 2cc67d3..baa8577 100644
+--- a/src/tensor.hpp
++++ b/src/tensor.hpp
+@@ -15,6 +15,7 @@
+ #include <array>
+ #include <stdexcept>
+ #include <vector>
++#include <string>
+ 
+ #include <memory>
+ 

got me past the std::to_string error, but then I get a plethora of other errors, like

[  5%] Building CXX object dep/libale/CMakeFiles/ale.dir/src/parser.cpp.o
cd /workspace/srcdir/maingo/build/dep/libale && /opt/bin/x86_64-apple-darwin14-libgfortran5-cxx11/x86_64-apple-darwin14-clang++ --sysroot=/opt/x86_64-apple-darwin14/x86_64-apple-darwin14/sys-root  -I/workspace/srcdir/maingo/dep/libale/src -O3 -DNDEBUG -mmacosx-version-min=10.15 -fPIC -std=gnu++17 -MD -MT dep/libale/CMakeFiles/ale.dir/src/parser.cpp.o -MF CMakeFiles/ale.dir/src/parser.cpp.o.d -o CMakeFiles/ale.dir/src/parser.cpp.o -c /workspace/srcdir/maingo/dep/libale/src/parser.cpp
In file included from /workspace/srcdir/maingo/dep/libale/src/parser.cpp:12:
In file included from /workspace/srcdir/maingo/dep/libale/src/parser.hpp:26:
In file included from /workspace/srcdir/maingo/dep/libale/src/node.hpp:16:
In file included from /workspace/srcdir/maingo/dep/libale/src/value.hpp:16:
/workspace/srcdir/maingo/dep/libale/src/tensor.hpp:107:16: error: no matching member function for call to 'reset'
        m_data.reset(new TType[size]);
        ~~~~~~~^~~~~
/workspace/srcdir/maingo/dep/libale/src/tensor.hpp:92:9: note: in instantiation of member function 'ale::tensor<double, 3>::tensor' requested here
        tensor(other.cref()) { }
        ^
/workspace/srcdir/maingo/dep/libale/src/symbol.hpp:51:8: note: in instantiation of member function 'ale::tensor<double, 3>::tensor' requested here
struct parameter_symbol;
       ^
/workspace/srcdir/maingo/dep/libale/src/symbol.hpp:159:5: note: in instantiation of member function 'ale::derived_value_symbol<ale::parameter_symbol, ale::tensor_type<ale::base_real, 3>>::clone' requested here
    parameter_symbol(std::string name,
    ^
/workspace/srcdir/maingo/dep/libale/src/parser.tpp:2937:17: note: in instantiation of member function 'ale::parameter_symbol<ale::tensor_type<ale::base_real, 3>>::parameter_symbol' requested here
      name, new parameter_symbol<IteratorType>(name, IsPlaceholderFlag::TRUE));
                ^
/workspace/srcdir/maingo/dep/libale/src/parser.tpp:2804:10: note: in instantiation of function template specialization 'ale::parser::match_internal_function_impl<ale::sum_node<ale::tensor_type<ale::base_real, 3>>, ale::tensor_type<ale::base_real, 0>, ale::tensor_type<ale::base_real, 3>, ale::tensor_type<ale::base_real, 0>>' requested here
  return match_internal_function_impl<NodeType>(
         ^
/workspace/srcdir/maingo/dep/libale/src/parser.tpp:966:7: note: in instantiation of function template specialization 'ale::parser::match_internal_function<ale::sum_node<ale::tensor_type<ale::base_real, 3>>, ale::tensor_type<ale::base_real, 0>>' requested here
      match_internal_function<sum_node<real<IDim>>>(result, "sum") ||
      ^
/workspace/srcdir/maingo/dep/libale/src/parser.tpp:96:14: note: in instantiation of function template specialization 'ale::parser::match_any_sum<3U>' requested here
             match_any_sum<LIBALE_MAX_DIM>(result) ||
             ^
/workspace/srcdir/maingo/dep/libale/src/parser.cpp:248:9: note: in instantiation of function template specialization 'ale::parser::match_primary<ale::tensor_type<ale::base_real, 0>>' requested here
    if(!match_primary(child)) {
        ^
/opt/x86_64-apple-darwin14/x86_64-apple-darwin14/sys-root/usr/include/c++/v1/memory:3910:9: note: candidate template ignored: requirement 'is_convertible<double *, double (*)[]>::value' was not satisfied [with _Yp = double]
        reset(_Yp* __p);
        ^
/opt/x86_64-apple-darwin14/x86_64-apple-darwin14/sys-root/usr/include/c++/v1/memory:3902:10: note: candidate function not viable: requires 0 arguments, but 1 was provided
    void reset() _NOEXCEPT;
         ^
/opt/x86_64-apple-darwin14/x86_64-apple-darwin14/sys-root/usr/include/c++/v1/memory:3918:9: note: candidate function template not viable: requires 2 arguments, but 1 was provided
        reset(_Yp* __p, _Dp __d);
        ^
/opt/x86_64-apple-darwin14/x86_64-apple-darwin14/sys-root/usr/include/c++/v1/memory:3926:9: note: candidate function template not viable: requires 3 arguments, but 1 was provided
        reset(_Yp* __p, _Dp __d, _Alloc __a);
        ^

Ok, let's go back to using GCC, but the fact compilation is successful with a more forgiving compiler isn't an argument for good behaviour of the codebase.

@MAiNGO-github
Copy link
Contributor Author

The point is not that the compiler is more forgiving. Indeed, Clang can compile the codebase. But only when C++17 is fully supported on the platform. However, the compiler + XCode combination used for MacOS in BinaryBuilder does not implement the whole set of C++17 standard library features. See "std::shared_ptr and std::weak_ptr with array support" under here (https://en.cppreference.com/w/cpp/compiler_support/17).
The error you found with m_data.reset is showing the problem: this function should exist, but the compiler is not fully standard compliant.

@giordano giordano merged commit 6071309 into JuliaPackaging:master Jan 24, 2024
8 checks passed
grasph pushed a commit to Moelf/Yggdrasil that referenced this pull request Jul 1, 2024
* New Recipe: MAiNGO v0.7.2

* Delete unused patch and cleanup build_tarballs.jl.

Add comments explaining why certain platforms are not yet build.
Add expansion over cxxstring and libgfortran 4 and 5.

* Lower preferred_gcc_version to 9

* Apply suggestions from code review

Apply directly useable suggestions.

Co-authored-by: Mosè Giordano <[email protected]>

* Update M/MAiNGO/build_tarballs.jl

Add suggested commands for moving lib and bin targets.

Co-authored-by: Mosè Giordano <[email protected]>

* Try building for MacOS and FreeBSD

* Filter out non-working platforms instead of picking ones that work

* Fix CMake options

* Fix missing build folder in first CMake command

* Fix missing build folder in first CMake command (again)

* Fix typo in CMAKE_TARGET_TOOLCHAIN

* Remove FreeBSD build.

Not supported upstream and fails on trial build with

/workspace/srcdir/maingo/build/dep/ipopt/IpoptConfig/include/config.h:17:4: error: #error "No finite/_finite function available"
[16:31:28]    17 |   #error "No finite/_finite function available"

Likely would need deeper investigation and modification of the CMake files, as Ipopt without CMake seems to build.

* Fix bash script error

* Test Clang for MacOS

* Try forcing SDK 10.15 for std::variant

* Fix where if statement ends

* Revert to using GCC for MacOS

---------

Co-authored-by: Aron Zingler <[email protected]>
Co-authored-by: Mosè Giordano <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants