microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
22.81k stars 6.3k forks source link

[proj] build failure: x64-linux-static for CRT and LIBRARY #37032

Closed motto76 closed 4 days ago

motto76 commented 6 months ago

Operating system

Linux Mint 21.4

Compiler

g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0,

Steps to reproduce the behavior

made an x64-linux-static triplet with:

set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Linux)

an started install with:
./vcpkg --overlay-triplets=custom-triplets --triplet=x64-linux-static install proj[tools]

Failure logs

Computing installation plan...
A suitable version of cmake was not found (required v3.27.1) Downloading portable cmake 3.27.1...
Downloading cmake...
https://github.com/Kitware/CMake/releases/download/v3.27.1/cmake-3.27.1-linux-x86_64.tar.gz->/home/vmuser/build_proj/vcpkg/downloads/cmake-3.27.1-linux-x86_64.tar.gz
Extracting cmake...
The following packages will be built and installed:
  * curl[core,non-http,openssl,ssl]:x64-linux-static@8.6.0
  * libjpeg-turbo:x64-linux-static@3.0.2
  * liblzma:x64-linux-static@5.4.4
  * nlohmann-json:x64-linux-static@3.11.3
  * openssl:x64-linux-static@3.2.1
    proj[core,net,tiff,tools]:x64-linux-static@9.3.1
  * sqlite3[core,json1,tool]:x64-linux@3.45.1
  * sqlite3[core,json1]:x64-linux-static@3.45.1
  * tiff[core,jpeg,lzma,zip]:x64-linux-static@4.6.0#4
  * vcpkg-cmake:x64-linux@2023-05-04
  * vcpkg-cmake-config:x64-linux@2022-02-06#1
  * vcpkg-cmake-get-vars:x64-linux@2023-12-31
  * zlib:x64-linux-static@1.3.1
Additional packages (*) will be modified to complete this operation.
Detecting compiler hash for triplet x64-linux...
Detecting compiler hash for triplet x64-linux-static...
Restored 12 package(s) from /root/.cache/vcpkg/archives in 267 ms. Use --debug to see more details.
Installing 1/13 vcpkg-cmake:x64-linux@2023-05-04...
Elapsed time to handle vcpkg-cmake:x64-linux: 299 us
vcpkg-cmake:x64-linux package ABI: e7719d9667cab8da7ffeaacbea5b32a994866ef320a1a839bdb8abb1ea64077d
Installing 2/13 vcpkg-cmake-config:x64-linux@2022-02-06#1...
Elapsed time to handle vcpkg-cmake-config:x64-linux: 208 us
vcpkg-cmake-config:x64-linux package ABI: 3a732944d5c700f33b247431fd65346e977aad87f27caf167c0cd33d8183df76
Installing 3/13 vcpkg-cmake-get-vars:x64-linux@2023-12-31...
Elapsed time to handle vcpkg-cmake-get-vars:x64-linux: 207 us
vcpkg-cmake-get-vars:x64-linux package ABI: d0348f116ef9790cba411671e3f73ad8aaeef1a97d653292f1d2fa6c7216898e
Installing 4/13 openssl:x64-linux-static@3.2.1...
Elapsed time to handle openssl:x64-linux-static: 1.51 ms
openssl:x64-linux-static package ABI: ac7b9aef3ae014418714c3485c08a4e911b44477b2ee9e145353eb9f414c6914
Installing 5/13 zlib:x64-linux-static@1.3.1...
Elapsed time to handle zlib:x64-linux-static: 472 us
zlib:x64-linux-static package ABI: 80a9365cd14288328aa9f76ff6076a9550f3bae5c44f35651f2d3379be777517
Installing 6/13 curl[core,non-http,openssl,ssl]:x64-linux-static@8.6.0...
Elapsed time to handle curl:x64-linux-static: 806 us
curl:x64-linux-static package ABI: 33f1e9c8c013db5577b3efb68f1b9883feb20283b2aa60a857d05d2ad8b27171
Installing 7/13 libjpeg-turbo:x64-linux-static@3.0.2...
Elapsed time to handle libjpeg-turbo:x64-linux-static: 600 us
libjpeg-turbo:x64-linux-static package ABI: e69a3499704534260af47175625b1a64bff48d15f14ff81bf3c540cf145aba25
Installing 8/13 liblzma:x64-linux-static@5.4.4...
Elapsed time to handle liblzma:x64-linux-static: 504 us
liblzma:x64-linux-static package ABI: a3e744d8252751325e04666042e738f0f097a133ce5878decfbf652e889e4fb6
Installing 9/13 nlohmann-json:x64-linux-static@3.11.3...
Elapsed time to handle nlohmann-json:x64-linux-static: 830 us
nlohmann-json:x64-linux-static package ABI: 0fbf1efd3a70c9af5c933fb18affdeb7d046f67931cb25210a941672163a9636
Installing 10/13 sqlite3[core,json1,tool]:x64-linux@3.45.1...
Elapsed time to handle sqlite3:x64-linux: 569 us
sqlite3:x64-linux package ABI: 5750a60ed6e5c593647a4b03e21b1f4611bc35821ea6263965ed962a6d9ac152
Installing 11/13 sqlite3[core,json1]:x64-linux-static@3.45.1...
Elapsed time to handle sqlite3:x64-linux-static: 475 us
sqlite3:x64-linux-static package ABI: 12356d3598c04336f2812a485c467c90c3c1f2ab3391ea30b65cf17a8cb6cb9b
Installing 12/13 tiff[core,jpeg,lzma,zip]:x64-linux-static@4.6.0#4...
Elapsed time to handle tiff:x64-linux-static: 696 us
tiff:x64-linux-static package ABI: 372f2af9546f8c7b5b2df7c72d5846aa83d0c257152d4e74999deda9d2d7e6c9
Installing 13/13 proj[core,net,tiff,tools]:x64-linux-static@9.3.1...
Building proj[core,net,tiff,tools]:x64-linux-static@9.3.1...
-- [OVERLAY] Loading triplet configuration from: /home/vmuser/build_proj/vcpkg/custom-triplets/x64-linux-static.cmake
-- Downloading https://github.com/OSGeo/PROJ/archive/9.3.1.tar.gz -> OSGeo-PROJ-9.3.1.tar.gz...
-- Extracting source /home/vmuser/build_proj/vcpkg/downloads/OSGeo-PROJ-9.3.1.tar.gz
-- Applying patch fix-win-output-name.patch
-- Applying patch fix-proj4-targets-cmake.patch
-- Applying patch remove_toolset_restriction.patch
-- Using source at /home/vmuser/build_proj/vcpkg/buildtrees/proj/src/9.3.1-d1be81ccd7.clean
-- Configuring x64-linux-static
-- Building x64-linux-static-dbg
-- Building x64-linux-static-rel
CMake Error at scripts/cmake/vcpkg_execute_build_process.cmake:134 (message):
    Command failed: /home/vmuser/build_proj/vcpkg/downloads/tools/cmake-3.27.1-linux/cmake-3.27.1-linux-x86_64/bin/cmake --build . --config Release --target install -- -v -j9
    Working Directory: /home/vmuser/build_proj/vcpkg/buildtrees/proj/x64-linux-static-rel
    See logs for more information:
      /home/vmuser/build_proj/vcpkg/buildtrees/proj/install-x64-linux-static-rel-out.log
      /home/vmuser/build_proj/vcpkg/buildtrees/proj/install-x64-linux-static-rel-err.log

Call Stack (most recent call first):
  installed/x64-linux/share/vcpkg-cmake/vcpkg_cmake_build.cmake:74 (vcpkg_execute_build_process)
  installed/x64-linux/share/vcpkg-cmake/vcpkg_cmake_install.cmake:16 (vcpkg_cmake_build)
  ports/proj/portfile.cmake:40 (vcpkg_cmake_install)
  scripts/ports.cmake:170 (include)

error: building proj:x64-linux-static failed with: BUILD_FAILED
Elapsed time to handle proj:x64-linux-static: 1.6 min
Please ensure you're using the latest port files with `git pull` and `vcpkg update`.
Then check for known issues at:
  https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+proj
You can submit a new issue at:
  https://github.com/microsoft/vcpkg/issues/new?title=[proj]+Build+error+on+x64-linux-static&body=Copy+issue+body+from+%2Fhome%2Fvmuser%2Fbuild_proj%2Fvcpkg%2Finstalled%2Fvcpkg%2Fissue_body.md

nano /home/vmuser/build_proj/vcpkg/buildtrees/proj/install-x64-linux-static-rel-out.log

Change Dir: '/home/vmuser/build_proj/vcpkg/buildtrees/proj/x64-linux-static-rel'

Run Build Command(s): /home/vmuser/build_proj/vcpkg/downloads/tools/ninja/1.10.2-linux/ninja -v -v -j9 install
[1/234] /usr/bin/c++ -DCURL_ENABLED -DCURL_STATICLIB -DEXTERNAL_NLOHMANN_JSON -DPROJ_DATA=\"/home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj\" -DPROJ_DLL="" -DPROJ_H>
[2/234] /usr/bin/c++ -DCURL_ENABLED -DCURL_STATICLIB -DEXTERNAL_NLOHMANN_JSON -DPROJ_DATA=\"/home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj\" -DPROJ_DLL="" -DPROJ_H>
[3/234] /usr/bin/c++ -DCURL_ENABLED -DCURL_STATICLIB -DEXTERNAL_NLOHMANN_JSON -DPROJ_DATA=\"/home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj\" -DPROJ_DLL="" -DPROJ_H>
[4/234] /usr/bin/c++ -DCURL_ENABLED -DCURL_STATICLIB -DEXTERNAL_NLOHMANN_JSON -DPROJ_DATA=\"/home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj\" -DPROJ_DLL="" -DPROJ_H>
[5/234] /usr/bin/c++ -DCURL_ENABLED -DCURL_STATICLIB -DEXTERNAL_NLOHMANN_JSON -DPROJ_DATA=\"/home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj\" -DPROJ_DLL="" -DPROJ_H>
[6/234] /usr/bin/c++ -DCURL_ENABLED -DCURL_STATICLIB -DEXTERNAL_NLOHMANN_JSON -DPROJ_DATA=\"/home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj\" -DPROJ_DLL="" -DPROJ_H>
[7/234] /usr/bin/c++ -DCURL_ENABLED -DCURL_STATICLIB -DEXTERNAL_NLOHMANN_JSON -DPROJ_DATA=\"/home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj\" -DPROJ_DLL="" -DPROJ_H>
[8/234] /usr/bin/c++ -DCURL_ENABLED -DCURL_STATICLIB -DEXTERNAL_NLOHMANN_JSON -DPROJ_DATA=\"/home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj\" -DPROJ_DLL="" -DPROJ_H>
...
[233/234] cd /home/vmuser/build_proj/vcpkg/buildtrees/proj/src/9.3.1-d1be81ccd7.clean/data && /home/vmuser/build_proj/vcpkg/downloads/tools/cmake-3.27.1-linux/cmake-3.27.1-linux-x86_64/bin>
[233/234] cd /home/vmuser/build_proj/vcpkg/buildtrees/proj/x64-linux-static-rel && /home/vmuser/build_proj/vcpkg/downloads/tools/cmake-3.27.1-linux/cmake-3.27.1-linux-x86_64/bin/cmake -P c>
-- Install configuration: "Release"
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/doc/proj/COPYING
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/doc/proj/NEWS
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/doc/proj/AUTHORS
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/lib/pkgconfig/proj.pc
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj/proj.ini
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj/world
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj/other.extra
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj/nad27
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj/GL27
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj/nad83
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj/nad.lst
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj/CH
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj/ITRF2000
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj/ITRF2008
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj/ITRF2014
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj/proj.db
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj/deformation_model.schema.json
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj/projjson.schema.json
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/share/proj/triangulation.schema.json
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/include/proj/util.hpp
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/include/proj/metadata.hpp
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/include/proj/common.hpp
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/include/proj/coordinates.hpp
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/include/proj/crs.hpp
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/include/proj/datum.hpp
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/include/proj/coordinatesystem.hpp
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/include/proj/coordinateoperation.hpp
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/include/proj/io.hpp
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/include/proj/nn.hpp
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/lib/libproj.a
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/include/proj.h
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/include/proj_experimental.h
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/include/proj_constants.h
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/include/proj_symbol_rename.h
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/include/geodesic.h
-- Installing: /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/bin/cct
FAILED: CMakeFiles/install.util
cd /home/vmuser/build_proj/vcpkg/buildtrees/proj/x64-linux-static-rel && /home/vmuser/build_proj/vcpkg/downloads/tools/cmake-3.27.1-linux/cmake-3.27.1-linux-x86_64/bin/cmake -P cmake_insta>
ninja: build stopped: subcommand failed.

nano /home/vmuser/build_proj/vcpkg/buildtrees/proj/install-x64-linux-static-rel-err.log

Make Error at src/apps/cmake_install.cmake:55 (file):
  file RPATH_CHANGE could not write new RPATH:

    $ORIGIN/../lib

  to the file:

    /home/vmuser/build_proj/vcpkg/packages/proj_x64-linux-static/bin/cct

  No valid ELF RPATH or RUNPATH entry exists in the file;
Call Stack (most recent call first):
  src/cmake_install.cmake:61 (include)
  cmake_install.cmake:61 (include)

Additional context

I tried a build without the tools and it completed without error. ./vcpkg --overlay-triplets=custom-triplets --triplet=x64-linux-static install proj

JonLiu1993 commented 6 months ago

This error can not reproduce in x64-linux, so I add community-triplet.

dg0yt commented 6 months ago

This is not a port bug.

It might be a general vcpkg script bug (for static CRT linkage), a CMake bug, or a PROJ bug: PROJ unconditionally sets CMAKE_INSTALL_RPATH (in src/apps/CMakeLists.txt), and then CMake tries to inject this path into the executable, failing due to static linkage.

There is a mitigation: Inject CMAKE_SKIP_RPATH into cmake builds. Add

list(PREPEND VCPKG_CMAKE_CONFIGURE_OPTIONS "-DCMAKE_SKIP_RPATH=ON")

to your custom triplet file. This will affect all (cmake based) ports. YMMV. In case of trouble, you can guard that line with

if([NOT] PORT STREQUAL "...")

Every change to the triplet invalidates cached binary artifacts, so you don't want to do it very often.

For ad-hoc tests, you can also use a command line option:

vcpkg install <port> "--cmake-args=-DVCPKG_CMAKE_CONFIGURE_OPTIONS=-DCMAKE_SKIP_RPATH=ON"

(And that's why I chose to suggest PREPEND above: Let command line override defaults.)

github-actions[bot] commented 2 weeks ago

This is an automated message. Per our repo policy, stale issues get closed if there has been no activity in the past 180 days. The issue will be automatically closed in 14 days. If you wish to keep this issue open, please add a new comment.