fix: rewrite cmake and pkg-config paths after Linux tarball reshape#28147
Open
Rishi-Dave wants to merge 1 commit intomicrosoft:mainfrom
Open
fix: rewrite cmake and pkg-config paths after Linux tarball reshape#28147Rishi-Dave wants to merge 1 commit intomicrosoft:mainfrom
Rishi-Dave wants to merge 1 commit intomicrosoft:mainfrom
Conversation
The Linux release packaging script `copy_strip_binary.sh` renames `lib64/` to `lib/` and flattens `include/onnxruntime/*` into `include/` after the cmake install step. However the files generated by `install(EXPORT ...)` (`onnxruntimeTargets-release.cmake` etc.) and the pkg-config file (`libonnxruntime.pc`) still contain the pre-reshape paths, causing `find_package(onnxruntime CONFIG)` and `pkg-config --libs onnxruntime` to fail for tarball consumers. Patch the stale paths in place after the reshape steps using narrow `sed` substitutions, guarded by existence checks so builds without pkg-config or cmake exports are unaffected. Fixes microsoft#23642
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lib64/andinclude/onnxruntime/paths in the generated cmake export and pkg-config files after the Linux tarball packaging script reshapes the directory layout.find_package(onnxruntime CONFIG)andpkg-config --libs onnxruntimework against the released Linux tarball.Motivation
Fixes #23642.
On x86-64 Linux,
GNUInstallDirssetsCMAKE_INSTALL_LIBDIR=lib64and the build installs headers underinclude/onnxruntime/. The packaging scripttools/ci_build/github/linux/copy_strip_binary.shthen reshapes the tarball:mv $ARTIFACT_NAME/lib64 $ARTIFACT_NAME/libmv $ARTIFACT_NAME/include/onnxruntime/* $ARTIFACT_NAME/include && rmdir $ARTIFACT_NAME/include/onnxruntimeThe files produced by
install(EXPORT onnxruntimeTargets ...)(onnxruntimeTargets-release.cmake, etc.) andconfigure_file(libonnxruntime.pc.cmake.in ...)still reference the pre-reshape locations, so downstream consumers see:IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib64/libonnxruntime.so.X"— file does not existINTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/onnxruntime"— directory does not existlibdir=${prefix}/lib64/includedir=${prefix}/include/onnxruntimeinlibonnxruntime.pcAn earlier attempt (#26104) tried to eliminate the reshape itself and was reverted (#26767) because downstream release pipelines and example repos depended on the
lib/+ flatinclude/layout. This change takes the opposite approach: keep the existing tarball layout and fix the metadata to match it — fully self-contained in the packaging step.Changes
tools/ci_build/github/linux/copy_strip_binary.sh— after the existingmv lib64 libstep, add two guardedsedblocks:/lib64/→/lib/and/include/onnxruntime"→/include"in every*.cmakeunder$ARTIFACT_NAME/lib/cmake(coversonnxruntimeConfig.cmake,onnxruntimeTargets.cmake, and per-configonnxruntimeTargets-*.cmake).libdirandincludedirentries in$ARTIFACT_NAME/lib/pkgconfig/libonnxruntime.pc.Patterns are anchored (trailing
/, trailing", or end-of-line) to avoid over-matching. Guarded with[ -d ]/[ -f ]so builds that don't install cmake exports or pkg-config files are unaffected. No cmake build-system changes; no effect on the macOS branch.Test Plan
bash -n tools/ci_build/github/linux/copy_strip_binary.sh— syntax clean.lib/cmake/onnxruntime/onnxruntimeTargets-release.cmakewith${_IMPORT_PREFIX}/lib64/libonnxruntime.so.Xand${_IMPORT_PREFIX}/include/onnxruntime, andlib/pkgconfig/libonnxruntime.pcwithlibdir=${prefix}/lib64/includedir=${prefix}/include/onnxruntime. After running the new block,grep -r 'lib64\|include/onnxruntime' lib/returns no matches; the rewrittenIMPORTED_LOCATION_RELEASEandlibdirpoint at the real, reshaped locations.