Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
galabovaa committed Jun 10, 2024
1 parent ebfd9f7 commit bbd28e2
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 94 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmake-windows-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: ctest --timeout 300 --output-on-failure -C Release

release_all_tests:
runs-on: windows-latest
runs-on: windows-2019

steps:
- uses: actions/checkout@v4
Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/test-fortran-macos.yml

This file was deleted.

100 changes: 49 additions & 51 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,60 +172,58 @@ if (BUILD_CXX)
message(STATUS "Found int * size: ${SIZEOF_INT_P}")
cmake_pop_check_state()

if (NOT (FORTRAN AND MACOS))
# Use current CMAKE_C_FLAGS and CMAKE_CXX_FLAGS when checking for IPO support,
# instead of defaults: https://cmake.org/cmake/help/latest/policy/CMP0138.html
if(MSVC AND BUILD_SHARED_LIBS)
# MSVC does support LTO, but WINDOWS_EXPORT_ALL_SYMBOLS does not work if
# LTO is enabled.
set(ipo_supported NO)
message(STATUS "IPO / LTO not supported on MSVC when building a shared library")
elseif(MINGW AND NOT CLANG)
# MinGW supports LTO, but it causes tests to fail at runtime like this:
#
# Mingw-w64 runtime failure:
# 32 bit pseudo relocation at 00007FF779C9D070 out of range, targeting 00007FFAAC101400, yielding the value 000000033246438C.
#
# TODO Figure out and fix the root cause of that, then remove this section.
set(ipo_supported NO)
message(STATUS "IPO / LTO not currently supported building HiGHS on MinGW")
else()
if(CMAKE_VERSION VERSION_GREATER "3.23.0")
cmake_policy(SET CMP0138 NEW)
endif()

include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_supported OUTPUT check_ipo_support_output)
message(STATUS "IPO / LTO supported by compiler: ${ipo_supported}")
# Use current CMAKE_C_FLAGS and CMAKE_CXX_FLAGS when checking for IPO support,
# instead of defaults: https://cmake.org/cmake/help/latest/policy/CMP0138.html
if(MSVC AND BUILD_SHARED_LIBS)
# MSVC does support LTO, but WINDOWS_EXPORT_ALL_SYMBOLS does not work if
# LTO is enabled.
set(ipo_supported NO)
message(STATUS "IPO / LTO not supported on MSVC when building a shared library")
elseif(MINGW AND NOT CLANG)
# MinGW supports LTO, but it causes tests to fail at runtime like this:
#
# Mingw-w64 runtime failure:
# 32 bit pseudo relocation at 00007FF779C9D070 out of range, targeting 00007FFAAC101400, yielding the value 000000033246438C.
#
# TODO Figure out and fix the root cause of that, then remove this section.
set(ipo_supported NO)
message(STATUS "IPO / LTO not currently supported building HiGHS on MinGW")
else()
if(CMAKE_VERSION VERSION_GREATER "3.23.0")
cmake_policy(SET CMP0138 NEW)
endif()

if(DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
# The user explicitly requested IPO. If it's not supported, CMake *should*
# produce an error: https://cmake.org/cmake/help/latest/policy/CMP0069.html
# However, we can give a more helpful error message ourselves.
message(STATUS "IPO / LTO: ${CMAKE_INTERPROCEDURAL_OPTIMIZATION} as requested by user")
if(CMAKE_INTERPROCEDURAL_OPTIMIZATION AND NOT ipo_supported)
message(SEND_ERROR
"IPO / LTO was requested through CMAKE_INTERPROCEDURAL_OPTIMIZATION, "
"but it is not supported by the compiler. The check failed with this output:\n"
"${check_ipo_support_output}")
endif()
elseif(NOT ipo_supported)
message(STATUS "IPO / LTO: disabled because it is not supported")
elseif(NOT BUILD_SHARED_LIBS)
# For a static library, we can't be sure whether the final linking will
# happen with IPO enabled, so we err on the side of caution. A better
# approach would be to request "fat LTO" in this case (for gcc/clang), to
# make the static library usable whether or not LTO is enabled at link
# time. Unfortunately CMake makes that impossible:
# https://gitlab.kitware.com/cmake/cmake/-/issues/23136
message(STATUS
"IPO / LTO: disabled by default when building a static library; "
"set CMAKE_INTERPROCEDURAL_OPTIMIZATION=ON to enable")
else()
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
message(STATUS "IPO / LTO: enabled")
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_supported OUTPUT check_ipo_support_output)
message(STATUS "IPO / LTO supported by compiler: ${ipo_supported}")
endif()

if(DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
# The user explicitly requested IPO. If it's not supported, CMake *should*
# produce an error: https://cmake.org/cmake/help/latest/policy/CMP0069.html
# However, we can give a more helpful error message ourselves.
message(STATUS "IPO / LTO: ${CMAKE_INTERPROCEDURAL_OPTIMIZATION} as requested by user")
if(CMAKE_INTERPROCEDURAL_OPTIMIZATION AND NOT ipo_supported)
message(SEND_ERROR
"IPO / LTO was requested through CMAKE_INTERPROCEDURAL_OPTIMIZATION, "
"but it is not supported by the compiler. The check failed with this output:\n"
"${check_ipo_support_output}")
endif()
elseif(NOT ipo_supported)
message(STATUS "IPO / LTO: disabled because it is not supported")
elseif(NOT BUILD_SHARED_LIBS)
# For a static library, we can't be sure whether the final linking will
# happen with IPO enabled, so we err on the side of caution. A better
# approach would be to request "fat LTO" in this case (for gcc/clang), to
# make the static library usable whether or not LTO is enabled at link
# time. Unfortunately CMake makes that impossible:
# https://gitlab.kitware.com/cmake/cmake/-/issues/23136
message(STATUS
"IPO / LTO: disabled by default when building a static library; "
"set CMAKE_INTERPROCEDURAL_OPTIMIZATION=ON to enable")
else()
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
message(STATUS "IPO / LTO: enabled")
endif()
endif()

Expand Down
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,9 @@ solves the model in `ml.mps`
```sh
highs ml.mps
```
HiGHS is installed using the command

```sh
cmake --install build
```

with the optional setting of `--prefix <prefix>`, or the cmake option `CMAKE_INSTALL_PREFIX` if it is to be installed anywhere other than the default location.
More details on building with CMake can be found in `HiGHS/cmake/README.md`.

#### Building with Meson

As an alternative, HiGHS can be installed using the `meson` build interface:
``` sh
Expand Down Expand Up @@ -117,7 +112,6 @@ python
>>> highspy.Highs()
```


_The nix build files are provided by the community and are not officially supported by the HiGHS development team._

## Interfaces
Expand Down
2 changes: 1 addition & 1 deletion cmake/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
| OS | C++ | Fortran | Python | CSharp Example | .NET |
|:-------- | :---: | :------: | :----: | :----: | :----: |
| Linux | [![Status][linux_cpp_svg]][linux_cpp_link] | [![Status][linux_fortran_svg]][linux_fortran_link] | [![Status][linux_python_svg]][linux_python_link] | *(1)* | [![Status][linux_dotnet_svg]][linux_dotnet_link] |
| MacOS | [![Status][macos_cpp_svg]][macos_cpp_link] |[![Status][macos_fortran_svg]][macos_fortran_link] | [![Status][macos_python_svg]][macos_python_link] | *(1)* |[![Status][macos_dotnet_svg]][macos_dotnet_link] |
| MacOS | [![Status][macos_cpp_svg]][macos_cpp_link] | *(2)* | [![Status][macos_python_svg]][macos_python_link] | *(1)* |[![Status][macos_dotnet_svg]][macos_dotnet_link] |
| Windows | [![Status][windows_cpp_svg]][windows_cpp_link] | *(2)* | [![Status][windows_python_svg]][windows_python_link] | [![Status][windows_csharp_svg]][windows_csharp_link] | [![Status][windows_dotnet_svg]][windows_dotnet_link] |

[linux_cpp_svg]: https://github.com/ERGO-Code/HiGHS/actions/workflows/cmake-linux-cpp.yml/badge.svg
Expand Down

0 comments on commit bbd28e2

Please sign in to comment.