Vcpkg: [protobuf] build failure on Linux

Created on 16 May 2020  ยท  18Comments  ยท  Source: microsoft/vcpkg

Host Environment

  • OS: Linux
  • Compiler: gcc (Arch Linux 9.3.0-1) 9.3.0

To Reproduce
Steps to reproduce the behavior:
./vcpkg install protobuf

Failure logs
```CMake Error at cmake_install.cmake:74 (file):
file RPATH_CHANGE could not write new RPATH:

$ORIGIN/../lib

to the file:

/home/panter/install/vcpkg/packages/protobuf_x64-linux/debug/bin/protoc-3.11.4.0

No valid ELF RPATH or RUNPATH entry exists in the file;



**Additional context**

triplets/x64-linux.cmake
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)

set(VCPKG_CMAKE_SYSTEM_NAME Linux)
```

I guess the main problem in VCPKG_CRT_LINKAGE static

port-bug

All 18 comments

pacman -S tar unzip git make curl`
pacman -U https://archive.archlinux.org/packages/g/gcc/gcc-9.3.0-1-x86_64.pkg.tar.zst
sed -ie 's/dynamic/static/g' triplets/x64-linux.cmake
./bootstrap-vcpkg.sh
./vcpkg install protobuf
cat buildtrees/protobuf/install-x64-linux-dbg-err.log

@linquize did you see I changed triplet?

yes, I set VCPKG_CRT_LINKAGE to static
patch protobuf cmake/install.cmake around line 34
if protobuf_MSVC_STATIC_RUNTIME, do not set PROPERTY INSTALL_RPATH for protoc

Hi @panter-dsd
Thanks for posting this issue.
I can reproduce this bug. We need to fix it.

@linquize
Thanks for your suggestion.
Would you like to submit a PR to fix this?

Hi @panter-dsd
protobufhas been updated to 3.12.0. It seems that this issue has been fixed now.
I can build successfully on my local.
Could you please try to update vcpkg and rebuild this port?

@NancyLi1013 , unfortunately the bug still exists.

โ”Œโ”€[panter@panter-dsd] - [~/install/vcpkg] - [2020-05-20 09:22:57]
โ””โ”€[0] <git:(master 9b4535e7eโœฑ) > git pull
Already up to date.
โ”Œโ”€[panter@panter-dsd] - [~/install/vcpkg] - [2020-05-20 09:23:27]
โ””โ”€[0] <git:(master 9b4535e7eโœฑ) > ./vcpkg install protobuf
Computing installation plan...
The following packages will be built and installed:
    protobuf[core]:x64-linux
Starting package 1/1: protobuf:x64-linux
Building package protobuf[core]:x64-linux...
-- Using cached /home/panter/install/vcpkg/downloads/protocolbuffers-protobuf-v3.12.0.tar.gz
-- Using source at /home/panter/install/vcpkg/buildtrees/protobuf/src/v3.12.0-8ba83cbbdb
-- Configuring x64-linux-dbg
-- Configuring x64-linux-rel
-- Building x64-linux-dbg
CMake Error at scripts/cmake/vcpkg_execute_build_process.cmake:136 (message):
    Command failed: /usr/bin/cmake --build . --config Debug --target install -- -v
    Working Directory: /home/panter/install/vcpkg/buildtrees/protobuf/x64-linux-dbg
    See logs for more information:
      /home/panter/install/vcpkg/buildtrees/protobuf/install-x64-linux-dbg-out.log
      /home/panter/install/vcpkg/buildtrees/protobuf/install-x64-linux-dbg-err.log

Call Stack (most recent call first):
  scripts/cmake/vcpkg_build_cmake.cmake:91 (vcpkg_execute_build_process)
  scripts/cmake/vcpkg_install_cmake.cmake:24 (vcpkg_build_cmake)
  ports/protobuf/portfile.cmake:54 (vcpkg_install_cmake)
  scripts/ports.cmake:90 (include)


Error: Building package protobuf:x64-linux failed with: BUILD_FAILED
Please ensure you're using the latest portfiles with `.\vcpkg update`, then
submit an issue at https://github.com/Microsoft/vcpkg/issues including:
  Package: protobuf:x64-linux
  Vcpkg version: 2020.02.04-unknownhash
โ”Œโ”€[panter@panter-dsd] - [~/install/vcpkg] - [2020-05-20 09:24:57]
โ””โ”€[1] <git:(master 9b4535e7eโœฑ) > cat buildtrees/protobuf/install-x64-linux-dbg-err.log
CMake Error at cmake_install.cmake:74 (file):
  file RPATH_CHANGE could not write new RPATH:

    $ORIGIN/../lib

  to the file:

    /home/panter/install/vcpkg/packages/protobuf_x64-linux/debug/bin/protoc-3.12.0.0

  No valid ELF RPATH or RUNPATH entry exists in the file;


Thanks for your instant update.
Sorry, I forgot to update the triplet.

Since the triplet is not the one that vcpkg supports originally.
We might support this in the near future, but not currently.

Could you please try to build with the suggestion from @linquize ?

I have tested and the workaround can work for me.

@NancyLi1013 sure, I'll try this today later. But initially, I have to figure out how to create and apply patches with vspkg. ๐Ÿ˜„

Of course, you can figure it out.
You can also refer to this doc.

@NancyLi1013 , @linquize thank you!

diff --git a/cmake/install.cmake b/cmake/install.cmake
index be47c54..8b1bd97 100644
--- a/cmake/install.cmake
+++ b/cmake/install.cmake
@@ -31,7 +31,7 @@ endforeach()
 if (protobuf_BUILD_PROTOC_BINARIES)
   install(TARGETS protoc EXPORT protobuf-targets
     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc)
-  if (UNIX AND NOT APPLE)
+  if (UNIX AND NOT APPLE AND NOT protobuf_MSVC_STATIC_RUNTIME)
     set_property(TARGET protoc
       PROPERTY INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
   elseif (APPLE)

This patch works for me.

@panter-dsd
All right, thanks for your info.

Since this issue has been resolved, i'm going to close this now. ๐Ÿ˜„

@NancyLi1013 can I hope that this patch will be included? Or better to create a PR?

Of course, it might be better to fix this.
If you are willing to create a PR and then try to do it. If not, I will do this later.

@NancyLi1013 I'm going to do it by myself at the end of the day. I want to make a small contribution to this project. ๐Ÿ˜„

It can't be better if you are interested in vcpkg and willing to join in the vcpkg contribution.

Welcome you. ๐Ÿ˜„

@NancyLi1013 could you take a look https://github.com/microsoft/vcpkg/pull/11504

Of course, no problem. Thanks for your reminder, I have assigned the PR to myself and will try to review it later.

@panter-dsd
Thanks for your efforts to this issue.
I'm closing this issue for now, since your PR has been merged. ๐Ÿ˜„

Was this page helpful?
0 / 5 - 0 ratings

Related issues

grandprixgp picture grandprixgp  ยท  3Comments

ghost picture ghost  ยท  3Comments

jack17529 picture jack17529  ยท  3Comments

husseinalihazime picture husseinalihazime  ยท  3Comments

cjvaijo picture cjvaijo  ยท  3Comments