diff --git a/.azure-pipelines/azure-pipelines-win.yml b/.azure-pipelines/azure-pipelines-win.yml index 0417ef5..dbbaddb 100755 --- a/.azure-pipelines/azure-pipelines-win.yml +++ b/.azure-pipelines/azure-pipelines-win.yml @@ -83,10 +83,12 @@ jobs: call activate base run_conda_forge_build_setup displayName: conda-forge build setup - - script: | call activate base + if EXIST LICENSE.txt ( + copy LICENSE.txt "recipe\\recipe-scripts-license.txt" + ) conda.exe mambabuild "recipe" -m .ci_support\%CONFIG%.yaml --suppress-variables displayName: Build recipe env: diff --git a/.scripts/build_steps.sh b/.scripts/build_steps.sh index d71d6ae..595f8b5 100755 --- a/.scripts/build_steps.sh +++ b/.scripts/build_steps.sh @@ -24,7 +24,10 @@ export CONFIG_FILE="${CI_SUPPORT}/${CONFIG}.yaml" cat >~/.condarc < /dev/null +if [[ -f "${FEEDSTOCK_ROOT}/LICENSE.txt" ]]; then + cp "${FEEDSTOCK_ROOT}/LICENSE.txt" "${RECIPE_ROOT}/recipe-scripts-license.txt" +fi + if [[ "${BUILD_WITH_CONDA_DEBUG:-0}" == 1 ]]; then if [[ "x${BUILD_OUTPUT_ID:-}" != "x" ]]; then EXTRA_CB_OPTIONS="${EXTRA_CB_OPTIONS:-} --output-id ${BUILD_OUTPUT_ID}" diff --git a/LICENSE.txt b/LICENSE.txt index 6ec1401..2ec51d7 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,13 +1,27 @@ -BSD 3-clause license +BSD-3-Clause license Copyright (c) 2015-2022, conda-forge contributors All rights reserved. -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. -2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. diff --git a/README.md b/README.md index a5a7c96..bd818be 100644 --- a/README.md +++ b/README.md @@ -320,6 +320,9 @@ Current release info | Name | Downloads | Version | Platforms | | --- | --- | --- | --- | | [![Conda Recipe](https://img.shields.io/badge/recipe-nvcc_linux--64-green.svg)](https://anaconda.org/conda-forge/nvcc_linux-64) | [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/nvcc_linux-64.svg)](https://anaconda.org/conda-forge/nvcc_linux-64) | [![Conda Version](https://img.shields.io/conda/vn/conda-forge/nvcc_linux-64.svg)](https://anaconda.org/conda-forge/nvcc_linux-64) | [![Conda Platforms](https://img.shields.io/conda/pn/conda-forge/nvcc_linux-64.svg)](https://anaconda.org/conda-forge/nvcc_linux-64) | +| [![Conda Recipe](https://img.shields.io/badge/recipe-nvcc_linux--aarch64-green.svg)](https://anaconda.org/conda-forge/nvcc_linux-aarch64) | [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/nvcc_linux-aarch64.svg)](https://anaconda.org/conda-forge/nvcc_linux-aarch64) | [![Conda Version](https://img.shields.io/conda/vn/conda-forge/nvcc_linux-aarch64.svg)](https://anaconda.org/conda-forge/nvcc_linux-aarch64) | [![Conda Platforms](https://img.shields.io/conda/pn/conda-forge/nvcc_linux-aarch64.svg)](https://anaconda.org/conda-forge/nvcc_linux-aarch64) | +| [![Conda Recipe](https://img.shields.io/badge/recipe-nvcc_linux--ppc64le-green.svg)](https://anaconda.org/conda-forge/nvcc_linux-ppc64le) | [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/nvcc_linux-ppc64le.svg)](https://anaconda.org/conda-forge/nvcc_linux-ppc64le) | [![Conda Version](https://img.shields.io/conda/vn/conda-forge/nvcc_linux-ppc64le.svg)](https://anaconda.org/conda-forge/nvcc_linux-ppc64le) | [![Conda Platforms](https://img.shields.io/conda/pn/conda-forge/nvcc_linux-ppc64le.svg)](https://anaconda.org/conda-forge/nvcc_linux-ppc64le) | +| [![Conda Recipe](https://img.shields.io/badge/recipe-nvcc_win--64-green.svg)](https://anaconda.org/conda-forge/nvcc_win-64) | [![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/nvcc_win-64.svg)](https://anaconda.org/conda-forge/nvcc_win-64) | [![Conda Version](https://img.shields.io/conda/vn/conda-forge/nvcc_win-64.svg)](https://anaconda.org/conda-forge/nvcc_win-64) | [![Conda Platforms](https://img.shields.io/conda/pn/conda-forge/nvcc_win-64.svg)](https://anaconda.org/conda-forge/nvcc_win-64) | Installing nvcc =============== @@ -331,16 +334,16 @@ conda config --add channels conda-forge conda config --set channel_priority strict ``` -Once the `conda-forge` channel has been enabled, `nvcc_linux-64` can be installed with `conda`: +Once the `conda-forge` channel has been enabled, `nvcc_linux-64, nvcc_linux-aarch64, nvcc_linux-ppc64le, nvcc_win-64` can be installed with `conda`: ``` -conda install nvcc_linux-64 +conda install nvcc_linux-64 nvcc_linux-aarch64 nvcc_linux-ppc64le nvcc_win-64 ``` or with `mamba`: ``` -mamba install nvcc_linux-64 +mamba install nvcc_linux-64 nvcc_linux-aarch64 nvcc_linux-ppc64le nvcc_win-64 ``` It is possible to list all of the versions of `nvcc_linux-64` available on your platform with `conda`: diff --git a/build-locally.py b/build-locally.py index eec38a0..3f4b7a7 100755 --- a/build-locally.py +++ b/build-locally.py @@ -86,12 +86,19 @@ def main(args=None): verify_config(ns) setup_environment(ns) - if ns.config.startswith("linux") or ( - ns.config.startswith("osx") and platform.system() == "Linux" - ): - run_docker_build(ns) - elif ns.config.startswith("osx"): - run_osx_build(ns) + try: + if ns.config.startswith("linux") or ( + ns.config.startswith("osx") and platform.system() == "Linux" + ): + run_docker_build(ns) + elif ns.config.startswith("osx"): + run_osx_build(ns) + finally: + recipe_license_file = os.path.join( + "recipe", "recipe-scripts-license.txt" + ) + if os.path.exists(recipe_license_file): + os.remove(recipe_license_file) if __name__ == "__main__": diff --git a/recipe/install_nvcc.sh b/recipe/install_nvcc.sh deleted file mode 100755 index 1bdf526..0000000 --- a/recipe/install_nvcc.sh +++ /dev/null @@ -1,189 +0,0 @@ -#!/bin/bash - -set -xeuo pipefail - -# Set `CUDA_HOME` in an activation script. -mkdir -p "${PREFIX}/etc/conda/activate.d" -cat > "${PREFIX}/etc/conda/activate.d/${PKG_NAME}_activate.sh" < "${PREFIX}/etc/conda/deactivate.d/${PKG_NAME}_deactivate.sh" < "${PREFIX}/bin/nvcc" <<'EOF' -#!/bin/bash -for arg in "${@}" ; do - case ${arg} in -ccbin) - # If -ccbin argument is already provided, don't add an additional one. - exec "${CUDA_HOME}/bin/nvcc" "${@}" - esac -done -exec "${CUDA_HOME}/bin/nvcc" -ccbin "${CXX}" "${@}" -EOF -chmod +x "${PREFIX}/bin/nvcc" diff --git a/recipe/linux/activate.sh b/recipe/linux/activate.sh new file mode 100644 index 0000000..f09ebe2 --- /dev/null +++ b/recipe/linux/activate.sh @@ -0,0 +1,110 @@ +#!/bin/bash + +# Set `CUDA_HOME` in an activation script. + +# Backup environment variables (only if the variables are set) +if [[ ! -z "${CUDA_HOME+x}" ]] +then + export CUDA_HOME_CONDA_NVCC_BACKUP="${CUDA_HOME:-}" +fi + +if [[ ! -z "${CUDA_PATH+x}" ]] +then + export CUDA_PATH_CONDA_NVCC_BACKUP="${CUDA_PATH:-}" +fi + +if [[ ! -z "${CFLAGS+x}" ]] +then + export CFLAGS_CONDA_NVCC_BACKUP="${CFLAGS:-}" +fi + +if [[ ! -z "${CPPFLAGS+x}" ]] +then + export CPPFLAGS_CONDA_NVCC_BACKUP="${CPPFLAGS:-}" +fi + +if [[ ! -z "${CXXFLAGS+x}" ]] +then + export CXXFLAGS_CONDA_NVCC_BACKUP="${CXXFLAGS:-}" +fi + +if [[ ! -z "${CMAKE_ARGS+x}" ]] +then + export CMAKE_ARGS_CONDA_NVCC_BACKUP="${CMAKE_ARGS:-}" +fi + +# Default to using $(cuda-gdb) to specify $(CUDA_HOME). +if [[ -z "${CUDA_HOME+x}" ]] +then + CUDA_GDB_EXECUTABLE=$(which cuda-gdb || exit 0) + if [[ -n "$CUDA_GDB_EXECUTABLE" ]] + then + CUDA_HOME=$(dirname $(dirname $CUDA_GDB_EXECUTABLE)) + else + echo "Cannot determine CUDA_HOME: cuda-gdb not in PATH" + return 1 + fi +fi + +if [[ ! -d "${CUDA_HOME}" ]] +then + echo "Directory specified in CUDA_HOME(=${CUDA_HOME}) doesn't exist" + return 1 +fi + +if [[ ! -f "${CUDA_HOME}/lib64/stubs/libcuda.so" ]] +then + echo "File ${CUDA_HOME}/lib64/stubs/libcuda.so doesn't exist" + return 1 +fi + +if [[ -z "$(${CUDA_HOME}/bin/nvcc --version | grep "Cuda compilation tools, release __PKG_VERSION__")" ]] +then + if [ "${CONDA_BUILD}" = "1" ] + then + echo "Error: Version of installed CUDA didn't match package" + return 1 + else + echo "Warning: Version of installed CUDA didn't match package" + fi +fi + +export CUDA_HOME="${CUDA_HOME}" +export CFLAGS="${CFLAGS} -isystem ${CUDA_HOME}/include" +export CPPFLAGS="${CPPFLAGS} -isystem ${CUDA_HOME}/include" +export CXXFLAGS="${CXXFLAGS} -isystem ${CUDA_HOME}/include" + +### CMake configurations + +# CMake looks up components in CUDA_PATH, not CUDA_HOME +export CUDA_PATH="${CUDA_HOME}" +# New-style CUDA integrations in CMake +CMAKE_ARGS="${CMAKE_ARGS:-} -DCUDAToolkit_ROOT=${CUDA_HOME}" +# Old-style CUDA integrations in CMake +## See https://github.com/conda-forge/nvcc-feedstock/pull/58#issuecomment-752179349 +CMAKE_ARGS+=" -DCUDA_TOOLKIT_ROOT_DIR=${CUDA_HOME}" +## Avoid https://github.com/conda-forge/openmm-feedstock/pull/44#issuecomment-753560234 +## We need CUDA_HOME in _front_ of CMAKE_FIND_ROOT_PATH +CMAKE_ARGS="$(echo ${CMAKE_ARGS} | sed -E -e "s|(-DCMAKE_FIND_ROOT_PATH=)(\S+)|\1$CUDA_HOME;\2|")" +export CMAKE_ARGS="${CMAKE_ARGS}" + +### /CMake configurations + +# Add $(libcuda.so) shared object stub to the compiler sysroot. +# Needed for things that want to link to $(libcuda.so). +# Stub is used to avoid getting driver code linked into binaries. + +if [[ ! -z "${CONDA_BUILD_SYSROOT+x}" ]] +then + mkdir -p "${CONDA_BUILD_SYSROOT}/lib" + # Make a backup of $(libcuda.so) + LIBCUDA_SO_CONDA_NVCC_BACKUP="${CONDA_BUILD_SYSROOT}/lib/libcuda.so-conda-nvcc-backup" + if [[ -f "${CONDA_BUILD_SYSROOT}/lib/libcuda.so" ]] + then + mv -f "${CONDA_BUILD_SYSROOT}/lib/libcuda.so" "${LIBCUDA_SO_CONDA_NVCC_BACKUP}" + fi + ln -s "${CUDA_HOME}/lib64/stubs/libcuda.so" "${CONDA_BUILD_SYSROOT}/lib/libcuda.so" +else + mkdir -p "${CONDA_PREFIX}/lib/stubs" + ln -sf "${CUDA_HOME}/lib64/stubs/libcuda.so" "${CONDA_PREFIX}/lib/stubs/libcuda.so" +fi diff --git a/recipe/linux/deactivate.sh b/recipe/linux/deactivate.sh new file mode 100644 index 0000000..f19ce84 --- /dev/null +++ b/recipe/linux/deactivate.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# Unset `CUDA_HOME` in a deactivation script. + +# Restore environment variables (if there is anything to restore) +if [[ ! -z "${CUDA_HOME_CONDA_NVCC_BACKUP+x}" ]] +then + export CUDA_HOME="${CUDA_HOME_CONDA_NVCC_BACKUP}" + unset CUDA_HOME_CONDA_NVCC_BACKUP +fi + +if [[ ! -z "${CUDA_PATH_CONDA_NVCC_BACKUP+x}" ]] +then + export CUDA_PATH="${CUDA_PATH_CONDA_NVCC_BACKUP}" + unset CUDA_PATH_CONDA_NVCC_BACKUP +fi + +if [[ ! -z "${CFLAGS_CONDA_NVCC_BACKUP+x}" ]] +then + export CFLAGS="${CFLAGS_CONDA_NVCC_BACKUP}" + unset CFLAGS_CONDA_NVCC_BACKUP +fi + +if [[ ! -z "${CPPFLAGS_CONDA_NVCC_BACKUP+x}" ]] +then + export CPPFLAGS="${CPPFLAGS_CONDA_NVCC_BACKUP}" + unset CPPFLAGS_CONDA_NVCC_BACKUP +fi + +if [[ ! -z "${CXXFLAGS_CONDA_NVCC_BACKUP+x}" ]] +then + export CXXFLAGS="${CXXFLAGS_CONDA_NVCC_BACKUP}" + unset CXXFLAGS_CONDA_NVCC_BACKUP +fi + +if [[ ! -z "${CMAKE_ARGS_CONDA_NVCC_BACKUP+x}" ]] +then + export CMAKE_ARGS="${CMAKE_ARGS_CONDA_NVCC_BACKUP}" + unset CMAKE_ARGS_CONDA_NVCC_BACKUP +fi + +# Remove or restore $(libcuda.so) shared object stub from the compiler sysroot. +LIBCUDA_SO_CONDA_NVCC_BACKUP="${CONDA_BUILD_SYSROOT}/lib/libcuda.so-conda-nvcc-backup" +if [[ -f ""${LIBCUDA_SO_CONDA_NVCC_BACKUP}"" ]] +then + mv -f "${LIBCUDA_SO_CONDA_NVCC_BACKUP}" "${CONDA_BUILD_SYSROOT}/lib/libcuda.so" +else + if [[ ! -z "${CONDA_BUILD_SYSROOT+x}" ]] + then + rm -f "${CONDA_BUILD_SYSROOT}/lib/libcuda.so" + else + rm -f "${CONDA_PREFIX}/lib/stubs/libcuda.so" + fi +fi diff --git a/recipe/linux/install_nvcc.sh b/recipe/linux/install_nvcc.sh new file mode 100755 index 0000000..f58e142 --- /dev/null +++ b/recipe/linux/install_nvcc.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -xeuo pipefail + +# Activation script +mkdir -p "${PREFIX}/etc/conda/activate.d" +sed -i "s/__PKG_VERSION__/$PKG_VERSION/g" $RECIPE_DIR/linux/activate.sh +cp $RECIPE_DIR/linux/activate.sh "${PREFIX}/etc/conda/activate.d/${PKG_NAME}_activate.sh" + +# Deactivation script +mkdir -p "${PREFIX}/etc/conda/deactivate.d" +cp $RECIPE_DIR/linux/deactivate.sh "${PREFIX}/etc/conda/deactivate.d/${PKG_NAME}_deactivate.sh" + +# Create `nvcc` script in `bin` so it can be easily run. +mkdir -p "${PREFIX}/bin" +cp $RECIPE_DIR/linux/nvcc.sh "${PREFIX}/bin/nvcc" +chmod +x "${PREFIX}/bin/nvcc" diff --git a/recipe/linux/nvcc.sh b/recipe/linux/nvcc.sh new file mode 100644 index 0000000..4b126d4 --- /dev/null +++ b/recipe/linux/nvcc.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +for arg in "${@}" ; do + case ${arg} in -ccbin) + # If -ccbin argument is already provided, don't add an additional one. + exec "${CUDA_HOME}/bin/nvcc" "${@}" + esac +done +exec "${CUDA_HOME}/bin/nvcc" -ccbin "${CXX}" "${@}" diff --git a/recipe/test_nvcc.sh b/recipe/linux/test_nvcc.sh similarity index 100% rename from recipe/test_nvcc.sh rename to recipe/linux/test_nvcc.sh diff --git a/recipe/meta.yaml b/recipe/meta.yaml old mode 100755 new mode 100644 index ad925b4..6bd0e36 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -1,5 +1,5 @@ {% set name = "nvcc" %} -{% set number = 20 %} +{% set number = 21 %} {% if cuda_compiler_version in (None, "None", True, False) %} {% set cuda_major = 0 %} @@ -26,7 +26,7 @@ outputs: - name: "{{ name }}_{{ target_platform }}" version: "{{ cuda_compiler_version }}" number: {{ number }} - script: install_nvcc.sh # [linux] + script: linux/install_nvcc.sh # [linux] script: windows/install_nvcc.bat # [win] build: ignore_run_exports: @@ -67,11 +67,11 @@ outputs: {% endif %} # [linux] files: - test.cu - - test_nvcc.sh # [linux] + - linux/test_nvcc.sh # [linux] - windows\test_nvcc.bat # [win] commands: - - bash test_nvcc.sh # [linux] - - windows\test_nvcc.bat # [win] + - bash linux/test_nvcc.sh # [linux] + - windows\test_nvcc.bat # [win] about: home: https://github.com/conda-forge/nvcc-feedstock license: BSD-3-Clause