prefix-dev / rattler-build

rattler-build is a universal package builder for Windows, macOS and Linux
https://prefix-dev.github.io/rattler-build
BSD 3-Clause "New" or "Revised" License
211 stars 45 forks source link

`rpath` setting does not work #1148

Open munechika-koyo opened 16 hours ago

munechika-koyo commented 16 hours ago

Issues

I encountered a strange error in the Packaging new files phase in rattler-build's build process with command rattler-build build -c ../../cython-cmake/output/ -c conda-forge:

 │ ╭─ Packaging new files
 │ │ Copying done!
 │ │ Rpath not in prefix or allow-listed: @loader_path/ – removing it
 │ │ install_name_tool for "/var/folders/2g/fll_q1p93gs0zrg0v2v02pr80000gn/T/imas-coreS6jIZx/lib/python3.13/site-packages/imas_core.libs/libkrb5.3.3.dylib":
 │ │  - changing absolute rpath from "@loader_path/" to "@loader_path/../../.."
 │ │  - add rpath "@loader_path/"
 │ │ × error install_name_tool failed: error: /Library/Developer/CommandLineTools/usr/bin/install_name_tool: can't specify both "-delete_rpath @loader_path/" and "-add_rpath @loader_path/"
 │ │ × error Usage: /Library/Developer/CommandLineTools/usr/bin/install_name_tool [-change old new] ... [-rpath old new] ... [-add_rpath new] ... [-delete_rpath old] ... [-id name] input
 │ │
 │ ╰─────────────────── (took 0 seconds)
 │
 ╰─────────────────── (took 63 seconds)
Error:   × failed to run install_name_tool

When run the rattler-build build -c ../../cython-cmake/output/ -c conda-forge --wrap-log-lines false -v,

2024-10-31T15:24:04.524180Z DEBUG Running build for{recipe="imas-core-5.4.1-hd72abfb_0"}:Packaging new files: rattler_build::macos::link: Adding rpath: "/Users/koyo/Documents/imas/al-core/recipe/output/bld/rattler-build_imas-core_1730388182/host_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib/"
Rpath not in prefix or allow-listed: @loader_path/ – removing it
2024-10-31T15:24:04.524205Z DEBUG Running build for{recipe="imas-core-5.4.1-hd72abfb_0"}:Packaging new files: rattler_build::macos::link: Builtin relink can't deal with rpath changes
install_name_tool for "/var/folders/2g/fll_q1p93gs0zrg0v2v02pr80000gn/T/imas-coree8h4oj/lib/python3.13/site-packages/imas_core.libs/libsz.2.dylib":
 - changing absolute rpath from "@loader_path/" to "@loader_path/../../.."
 - add rpath "@loader_path/"

2024-10-31T15:24:04.532287Z ERROR Running build for{recipe="imas-core-5.4.1-hd72abfb_0"}:Packaging new files: rattler_build::macos::link: install_name_tool failed: error: /Library/Developer/CommandLineTools/usr/bin/install_name_tool: can't specify both "-delete_rpath @loader_path/" and "-add_rpath @loader_path/"
Usage: /Library/Developer/CommandLineTools/usr/bin/install_name_tool [-change old new] ... [-rpath old new] ... [-add_rpath new] ... [-delete_rpath old] ... [-id name] input

Error:   × failed to run install_name_tool

On Linux-64 PC, the result was shown like:

 │ ╭─ Packaging new files
 │ │ Copying done!
 │ │ Rpath not in prefix or allow-listed: $ORIGIN/. – removing it
 │ │ New relative path: $ORIGIN/../../..
 │ │ × error new value is longer than old value
 │ │ patchelf for "/tmp/imas-coreGapitT/lib/python3.12/site-packages/imas_core.libs/libgssapi_krb5.so.2.2": "$ORIGIN/.:$ORIGIN/../../.."
 │ │
 │ ╰─────────────────── (took 0 seconds)
 │
 ╰─────────────────── (took 64 seconds)
Error:   × failed to find `patchelf` (cannot find binary path)

If I specify patchelf in build/host requirement, the error disappears.

Key points to address

Configs

I built a Python-C++ library, which is not open to the public yet, but I will share the recipe.yaml, build.sh, and variants.yaml.

recipe.yaml ```yaml context: version: "5.4.1" name: "imas-core" package: name: ${{ name }} version: ${{ version }} source: path: .. build: number: 0 files: include: ["**"] exclude: - "$SP_DIR/share/common/" requirements: build: - ${{ compiler("c") }} - ${{ compiler("cxx") }} - ${{ stdlib("c") }} - git - cmake - ninja - pkg-config host: - pip - python - numpy - cython - cython-cmake - setuptools - setuptools-scm - scikit-build-core - scikit-build - libboost-devel >=1.66 - hdf5 >=1.8.12 - if: linux then: mdsplus run_exports: - imas-core tests: - python: imports: - imas_core pip_check: false - script: - pytest files: source: - python/tests/ - pyproject.toml requirements: run: - pytest about: homepage: https://imas.iter.org/ license_file: LICENSE.md summary: IMAS High Level Interface for Python. documentation: https://sharepoint.iter.org/departments/POP/CM/IMDesign/Code%20Documentation/ACCESS-LAYER-doc/python/latest.html repository: https://git.iter.org/scm/imas/al-python.git ```
build.sh ```shell #!/bin/bash if [[ "$OSTYPE" == "linux-gnu"* ]]; then export AL_BACKEND_MDSPLUS=OFF export AL_BUILD_MDSPLUS_MODELS=ON else export AL_BACKEND_MDSPLUS=OFF export AL_BUILD_MDSPLUS_MODELS=OFF fi # CMake extra configuration: extra_cmake_args=( -GNinja -DCMAKE_INSTALL_LIBDIR=lib -DBUILD_SHARED_LIBS=ON # Enable all backends -DAL_BACKEND_HDF5=ON -DAL_BACKEND_MDSPLUS=$AL_BACKEND_MDSPLUS -DAL_BACKEND_UDA=OFF # Build MDSplus models -DAL_BUILD_MDSPLUS_MODELS=$AL_BUILD_MDSPLUS_MODELS # Build Python bindings -DPython_EXECUTABLE="$PYTHON" -DPython3_EXECUTABLE="$PYTHON" -DAL_PYTHON_BINDINGS=no-build-isolation # Download dependencies -DAL_DOWNLOAD_DEPENDENCIES=ON ) mkdir build && cd build cmake ${CMAKE_ARGS} "${extra_cmake_args[@]}" \ -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_PREFIX_PATH=$PREFIX \ -DCMAKE_INSTALL_PREFIX=$PREFIX \ $SRC_DIR # Build and install ninja -v ninja install -v ```
variants.yaml ```yaml c_stdlib: - if: linux then: sysroot - if: osx then: macosx_deployment_target c_stdlib_version: - if: linux then: 2.17 - if: osx and x86_64 then: 10.13 - if: osx and arm64 then: 11.0 ```
munechika-koyo commented 16 hours ago

cython-cmake has not been uploaded to conda-forge yet, so I created a .conda file on a local PC.