Skip to content

Commit

Permalink
fortran test
Browse files Browse the repository at this point in the history
  • Loading branch information
galabovaa committed Jun 10, 2024
1 parent f9b5e7e commit ebfd9f7
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 105 deletions.
18 changes: 5 additions & 13 deletions .github/workflows/test-fortran-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,18 @@ name: test-fortran-macos
on: [push, pull_request]

jobs:
fast_build_release:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest]
toolchain:
- {compiler: gcc, version: 13}
release:
runs-on: macos-latest

steps:
- uses: actions/checkout@v4

- uses: fortran-lang/setup-fortran@v1
id: setup-fortran
with:
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}

- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build

- name: gfortran
run: brew install gfortran

- name: Configure CMake
shell: bash
working-directory: ${{runner.workspace}}/build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-fortran-ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test-fortran-ubuntu
name: test-fortran

on: [push, pull_request]

Expand Down
41 changes: 0 additions & 41 deletions .github/workflows/test-fortran-win.yml

This file was deleted.

100 changes: 51 additions & 49 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,59 +171,61 @@ if (BUILD_CXX)
check_type_size("int *" SIZEOF_INT_P LANGUAGE 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()

# 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)
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_supported OUTPUT check_ipo_support_output)
message(STATUS "IPO / LTO supported by compiler: ${ipo_supported}")
endif()

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}")
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()
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
4 changes: 3 additions & 1 deletion cmake/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
|:-------- | :---: | :------: | :----: | :----: | :----: |
| 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] |
| Windows | [![Status][windows_cpp_svg]][windows_cpp_link] | [![Status][windows_fortran_svg]][windows_fortran_link] | [![Status][windows_python_svg]][windows_python_link] | [![Status][windows_csharp_svg]][windows_csharp_link] | [![Status][windows_dotnet_svg]][windows_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
[linux_cpp_link]: https://github.com/ERGO-Code/HiGHS/actions/workflows/cmake-linux-cpp.yml
Expand Down Expand Up @@ -40,6 +40,8 @@
*(1)* CMake C# is currently only supported for Microsoft Visual Studio 11 2012 and
later. You can still build and run the HiGHS C# nuget package on Linux and MacOS with `dotnet`, see the workflows in the .NET column. It is only the CSharp example build with CMake that is not supported for Unix generators.

*(2)* Not tested yet.

<!--# ?branch=main -->
<br>

Expand Down

0 comments on commit ebfd9f7

Please sign in to comment.