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

add sleef prefix to cmake options. #509

Merged
merged 5 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 17 additions & 17 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ env:
LLVM_VERSION: "17"
COMMON_CMAKE_FLAGS: |
-DSLEEF_SHOW_CONFIG=1
-DBUILD_GNUABI_LIBS=ON
-DBUILD_INLINE_HEADERS=ON
-DBUILD_DFT=ON
-DBUILD_QUAD=ON
-DBUILD_SCALAR_LIB=ON
-DBUILD_STATIC_TEST_BINS=ON
-DENFORCE_TESTER=ON
-DENFORCE_TESTER3=ON
-DSLEEF_BUILD_GNUABI_LIBS=ON
-DSLEEF_BUILD_INLINE_HEADERS=ON
-DSLEEF_BUILD_DFT=ON
-DSLEEF_BUILD_QUAD=ON
-DSLEEF_BUILD_SCALAR_LIB=ON
-DSLEEF_BUILD_STATIC_TEST_BINS=ON
-DSLEEF_ENFORCE_TESTER=ON
-DSLEEF_ENFORCE_TESTER3=ON

jobs:
build-native:
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Build native
shell: bash -ex -o pipefail {0}
run: |
EXTRA_CMAKE_FLAGS="-DENFORCE_SSE2=ON -DENFORCE_SSE4=ON -DENFORCE_AVX=ON -DENFORCE_AVX=ON -DENFORCE_AVX2=ON -DENFORCE_AVX512F=ON -DENFORCE_FMA4=ON"
EXTRA_CMAKE_FLAGS="-DSLEEF_ENFORCE_SSE2=ON -DSLEEF_ENFORCE_SSE4=ON -DSLEEF_ENFORCE_AVX=ON -DSLEEF_ENFORCE_AVX=ON -DSLEEF_ENFORCE_AVX2=ON -DSLEEF_ENFORCE_AVX512F=ON -DSLEEF_ENFORCE_FMA4=ON"
cmake -S . -B _build-native -GNinja \
-DCMAKE_INSTALL_PREFIX=$(pwd)/_install-native \
-DCMAKE_TOOLCHAIN_FILE=$(pwd)/toolchains/native-${{ matrix.compiler }}.cmake \
Expand Down Expand Up @@ -213,24 +213,24 @@ jobs:
run: |
EXTRA_CMAKE_FLAGS=""
if [[ ${{ matrix.arch }} = "aarch64" ]]; then
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DENFORCE_SVE=ON"
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DSLEEF_ENFORCE_SVE=ON"
elif [[ ${{ matrix.arch }} = "armhf" ]]; then
# Disable inline headers, they just don't compile on armhf
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DBUILD_INLINE_HEADERS=OFF"
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DSLEEF_BUILD_INLINE_HEADERS=OFF"
elif [[ ${{ matrix.arch }} = "ppc64el" ]]; then
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DENFORCE_VSX=ON -DENFORCE_VSX3=ON"
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DSLEEF_ENFORCE_VSX=ON -DSLEEF_ENFORCE_VSX3=ON"
elif [[ ${{ matrix.arch }} = "s390x" ]]; then
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DENFORCE_VXE=ON"
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DSLEEF_ENFORCE_VXE=ON"
# Disable VXE2 support, QEMU doesn't support some instructions generated by gcc or llvm
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DDISABLE_VXE2=ON"
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DSLEEF_DISABLE_VXE2=ON"
elif [[ ${{ matrix.arch }} = "riscv64" ]]; then
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DENFORCE_RVVM1=ON -DENFORCE_RVVM2=ON"
Copy link
Collaborator

Choose a reason for hiding this comment

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

These also would need prefixing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

# Disable inline headers, they just don't compile on riscv64
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DBUILD_INLINE_HEADERS=OFF"
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DSLEEF_BUILD_INLINE_HEADERS=OFF"
# Disable dft, it fails with linker error to `cexp`
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DBUILD_DFT=OFF"
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DSLEEF_BUILD_DFT=OFF"
# Disable quad, it's missing the `Sleef_quad` function
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DBUILD_QUAD=OFF"
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DSLEEF_BUILD_QUAD=OFF"
fi

cmake -S . -B _build-${{ matrix.arch }} -GNinja \
Expand Down
56 changes: 28 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@

# Options

option(BUILD_SHARED_LIBS "Build shared libs" ON)
option(BUILD_STATIC_TEST_BINS "Build statically linked test executables" OFF)
option(ENABLE_LTO "Enable LTO on GCC or ThinLTO on clang" OFF)
option(BUILD_LIBM "libsleef will be built." ON)
option(BUILD_DFT "libsleefdft will be built." OFF)
option(BUILD_QUAD "libsleefquad will be built." OFF)
option(BUILD_GNUABI_LIBS "libsleefgnuabi will be built." ON)
option(BUILD_SCALAR_LIB "libsleefscalar will be built." OFF)
option(BUILD_TESTS "Tests will be built." ON)
option(BUILD_INLINE_HEADERS "Build header for inlining whole SLEEF functions" OFF)
option(SLEEF_BUILD_SHARED_LIBS "Build shared libs" ON)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We think this option should be removed altogether and we should keep using the standard cmake variable BUILD_SHARED_LIBS in the rest of the build system. This way we ensure consistency with projects using SLEEF.
Remember that even if turned off libsleefgnuabi will be a shared library.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if not set SLEEF_BUILD_SHARED_LIBS , and then use BUILD_SHARED_LIBS ? let SLEEF_BUILD_SHARED_LIBS overwrite BUILD_SHARED_LIBS?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please rename all SLEEF_BUILD_SHARED_LIBS to BUILD_SHARED_LIBS, then remove this line

option(BUILD_SHARED_LIBS "Build shared libs" ON)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Please rename all SLEEF_BUILD_SHARED_LIBS to BUILD_SHARED_LIBS, then remove this line

option(BUILD_SHARED_LIBS "Build shared libs" ON)

option(SLEEF_BUILD_STATIC_TEST_BINS "Build statically linked test executables" OFF)
option(SLEEF_ENABLE_LTO "Enable LTO on GCC or ThinLTO on clang" OFF)
option(SLEEF_BUILD_LIBM "libsleef will be built." ON)
option(SLEEF_BUILD_DFT "libsleefdft will be built." OFF)
option(SLEEF_BUILD_QUAD "libsleefquad will be built." OFF)
option(SLEEF_BUILD_GNUABI_LIBS "libsleefgnuabi will be built." ON)
option(SLEEF_BUILD_SCALAR_LIB "libsleefscalar will be built." OFF)
option(SLEEF_BUILD_TESTS "Tests will be built." ON)
option(SLEEF_BUILD_INLINE_HEADERS "Build header for inlining whole SLEEF functions" OFF)

option(SLEEF_TEST_ALL_IUT "Perform tests on implementations with all vector extensions" OFF)
option(SLEEF_SHOW_CONFIG "Show SLEEF configuration status messages." ON)
option(SLEEF_SHOW_ERROR_LOG "Show cmake error log." OFF)
option(SLEEF_ASAN "Enable address sanitizing on all targets." OFF)

option(ENFORCE_TESTER "Build fails if tester is not available" OFF)
option(ENFORCE_TESTER3 "Build fails if tester3 is not built" OFF)
option(SLEEF_ENFORCE_TESTER "Build fails if tester is not available" OFF)
option(SLEEF_ENFORCE_TESTER3 "Build fails if tester3 is not built" OFF)

option(ENABLE_ALTDIV "Enable alternative division method (aarch64 only)" OFF)
option(ENABLE_ALTSQRT "Enable alternative sqrt method (aarch64 only)" OFF)
option(SLEEF_ENABLE_ALTDIV "Enable alternative division method (aarch64 only)" OFF)
option(SLEEF_ENABLE_ALTSQRT "Enable alternative sqrt method (aarch64 only)" OFF)

option(DISABLE_FFTW "Disable testing the DFT library with FFTW" OFF)
option(DISABLE_MPFR "Disable testing with the MPFR library" OFF)
option(DISABLE_SSL "Disable testing with the SSL library" OFF)
option(SLEEF_DISABLE_FFTW "Disable testing the DFT library with FFTW" OFF)
option(SLEEF_DISABLE_MPFR "Disable testing with the MPFR library" OFF)
option(SLEEF_DISABLE_SSL "Disable testing with the SSL library" OFF)

option(ENABLE_CUDA "Enable CUDA" OFF)
option(ENABLE_CXX "Enable C++" OFF)
option(SLEEF_ENABLE_CUDA "Enable CUDA" OFF)
option(SLEEF_ENABLE_CXX "Enable C++" OFF)

# Function used to generate safe command arguments for add_custom_command
function(command_arguments PROPNAME)
Expand Down Expand Up @@ -129,11 +129,11 @@ set(SLEEF_SOVERSION ${SLEEF_VERSION_MAJOR})

set(LANGLIST C)

if (ENABLE_CUDA)
if (SLEEF_ENABLE_CUDA)
set(LANGLIST ${LANGLIST} CUDA)
endif()

if (ENABLE_CXX)
if (SLEEF_ENABLE_CXX)
set(LANGLIST ${LANGLIST} CXX)
endif()

Expand All @@ -158,11 +158,11 @@ separate build directory. Note: Please remove autogenerated file \
`CMakeCache.txt` and directory `CMakeFiles` in the current directory.")
endif()

if(ENABLE_LTO AND BUILD_SHARED_LIBS)
message(FATAL_ERROR "ENABLE_LTO and BUILD_SHARED_LIBS cannot be specified at the same time")
endif(ENABLE_LTO AND BUILD_SHARED_LIBS)
if(SLEEF_ENABLE_LTO AND SLEEF_BUILD_SHARED_LIBS)
message(FATAL_ERROR "SLEEF_ENABLE_LTO and SLEEF_BUILD_SHARED_LIBS cannot be specified at the same time")
endif(SLEEF_ENABLE_LTO AND SLEEF_BUILD_SHARED_LIBS)

if(ENABLE_LTO)
if(SLEEF_ENABLE_LTO)
cmake_policy(SET CMP0069 NEW)
include(CheckIPOSupported)
check_ipo_supported(RESULT supported OUTPUT error)
Expand Down Expand Up @@ -306,8 +306,8 @@ if(SLEEF_SHOW_CONFIG)
message(" Native build dir: ${NATIVE_BUILD_DIR}")
endif(CMAKE_CROSSCOMPILING)
message(STATUS "Using option `${SLEEF_C_FLAGS}` to compile libsleef")
message(STATUS "Building shared libs : " ${BUILD_SHARED_LIBS})
message(STATUS "Building static test bins: " ${BUILD_STATIC_TEST_BINS})
message(STATUS "Building shared libs : " ${SLEEF_BUILD_SHARED_LIBS})
message(STATUS "Building static test bins: " ${SLEEF_BUILD_STATIC_TEST_BINS})
message(STATUS "MPFR : " ${LIB_MPFR})
if (MPFR_INCLUDE_DIR)
message(STATUS "MPFR header file in " ${MPFR_INCLUDE_DIR})
Expand All @@ -317,7 +317,7 @@ if(SLEEF_SHOW_CONFIG)
message(STATUS "FFTW3 : " ${LIBFFTW3})
message(STATUS "OPENSSL : " ${OPENSSL_VERSION})
message(STATUS "SDE : " ${SDE_COMMAND})
if (BUILD_INLINE_HEADERS)
if (SLEEF_BUILD_INLINE_HEADERS)
message(STATUS "SED : " ${SED_COMMAND})
endif()
message(STATUS "COMPILER_SUPPORTS_OPENMP : " ${COMPILER_SUPPORTS_OPENMP})
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt.nested
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ target_link_libraries(hellox86 sleef)

#

if (BUILD_DFT)
if (SLEEF_BUILD_DFT)
add_executable(dfttutorial tutorial.c)
set_target_properties(dfttutorial PROPERTIES C_STANDARD 99)
add_dependencies(dfttutorial sleef)
Expand Down