Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libcap] Build error on arm-linux #35661

Closed
igorkofman opened this issue Dec 13, 2023 · 10 comments · Fixed by #35735
Closed

[libcap] Build error on arm-linux #35661

igorkofman opened this issue Dec 13, 2023 · 10 comments · Fixed by #35735
Labels
category:community-triplet A PR or issue related to community triplets not officially validated by the vcpkg team.

Comments

@igorkofman
Copy link

Package: libcap:arm-linux -> 2.69#2

Host Environment

  • Host: arm-linux
  • Compiler: GNU 10.2.1
  • vcpkg-tool version: 2999-12-31-unknownhash
    vcpkg-scripts version: 3f3d8b0 2023-12-12 (22 hours ago)

To Reproduce

vcpkg install
Failure logs

-- Using cached libpcap-2.69.tar.gz.
-- Cleaning sources at /home/igor/drawme/src/vcpkg/buildtrees/libcap/src/libpcap-2-fe0a022327.clean. Use --editable to skip cleaning for the packages you specify.
-- Extracting source /home/igor/drawme/src/vcpkg/downloads/libpcap-2.69.tar.gz
-- Using source at /home/igor/drawme/src/vcpkg/buildtrees/libcap/src/libpcap-2-fe0a022327.clean
-- Getting CMake variables for arm-linux-dbg
-- Getting CMake variables for arm-linux-rel
-- Configuring arm-linux-dbg
-- Configuring arm-linux-rel
-- Building arm-linux-dbg
CMake Error at scripts/cmake/vcpkg_execute_build_process.cmake:134 (message):
    Command failed: /usr/bin/make V=1 -j 5 -f Makefile.vcpkg all
    Working Directory: /home/igor/drawme/src/vcpkg/buildtrees/libcap/arm-linux-dbg/
    See logs for more information:
      /home/igor/drawme/src/vcpkg/buildtrees/libcap/build-arm-linux-dbg-out.log
      /home/igor/drawme/src/vcpkg/buildtrees/libcap/build-arm-linux-dbg-err.log

Call Stack (most recent call first):
  scripts/cmake/vcpkg_build_make.cmake:151 (vcpkg_execute_build_process)
  scripts/cmake/vcpkg_install_make.cmake:2 (vcpkg_build_make)
  ports/libcap/portfile.cmake:25 (vcpkg_install_make)
  scripts/ports.cmake:170 (include)



/home/igor/drawme/src/vcpkg/buildtrees/libcap/build-arm-linux-dbg-err.log
/bin/sh: 1: ./_makenames: not found
make[1]: *** [Makefile:82: cap_names.h] Error 127
make: *** [Makefile.vcpkg:16: libcap/cap_names.h] Error 2
/home/igor/drawme/src/vcpkg/buildtrees/libcap/build-arm-linux-dbg-out.log
/usr/bin/make -C libcap cap_names.h "AR=/usr/bin/arm-linux-gnueabihf-ar"     "BUILD_CC=touch a.out | touch conftest | true"     "CC=/usr/bin/arm-linux-gnueabihf-gcc"     "RANLIB=/usr/bin/arm-linux-gnueabihf-ranlib"     "lib=lib"     "prefix=/home/igor/drawme/src/vcpkg_installed/arm-linux/debug" SHARED=no
make[1]: Entering directory '/home/igor/drawme/src/vcpkg/buildtrees/libcap/arm-linux-dbg/libcap'
=> making cap_names.list.h from /home/igor/drawme/src/vcpkg/buildtrees/libcap/arm-linux-dbg/libcap/../libcap/include/uapi/linux/capability.h
grep -E '^#define\s+CAP_([^\s]+)\s+[0-9]+\s*$' include/uapi/linux/capability.h | sed -e 's/^#define\s\+/{"/' -e 's/\s*$/},/' -e 's/\s\+/",/' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' > cap_names.list.h
touch a.out | touch conftest | true -O2 -Dlinux -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -Wunreachable-code  -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/home/igor/drawme/src/vcpkg/buildtrees/libcap/arm-linux-dbg/libcap/../libcap/include/uapi -I/home/igor/drawme/src/vcpkg/buildtrees/libcap/arm-linux-dbg/libcap/../libcap/include _makenames.c -o _makenames
./_makenames > cap_names.h
make[1]: Leaving directory '/home/igor/drawme/src/vcpkg/buildtrees/libcap/arm-linux-dbg/libcap'

Additional context

vcpkg.json
{
  "name": "your-project-name",
  "version-string": "0.1.0",
  "dependencies": [
    "boost-json",
    {
      "name": "google-cloud-cpp",
      "features": [
        "speech"
      ]
    },
    "curl",
    "sdl2",
    "sdl2-image",
    "sdl2-ttf"
  ]
}

@igorkofman
Copy link
Author

"BUILD_CC=touch a.out | touch conftest | true" seems weird and predictably doesn't output anything useful

@LilyWangLL LilyWangLL added the category:community-triplet A PR or issue related to community triplets not officially validated by the vcpkg team. label Dec 14, 2023
@dg0yt
Copy link
Contributor

dg0yt commented Dec 14, 2023

"BUILD_CC=touch a.out | touch conftest | true" seems weird and predictably doesn't output anything useful

This is intentional. Ports are not allow to build host binaries while building for another target triplet.
OTOH BUILD_CC shall be identical to CC (and working) when the target triplet is identical to the host triplet.

Based on this pattern, the port is designed to not need to build and run _makenames when the target triplet is different from the host triplet, by re-using cap_names.h from the host triplet. Now the question is why it doesn't work in your case.

  • What is the host triplet?
  • It the host triplet is different from arm-linux, does the vcpkg host libcap installation have the file?
  • Do the logs indicate whether copying the file fails?

@trolgar
Copy link

trolgar commented Dec 16, 2023

This is a side effect of the change made to linux.cmake file in the scripts/toolchains folder. It now assumes that all arm or arm64 builds are cross-compile builds, even on arm or arm64 hosts. Adding the x86_64 check back fixes this issue.

Would adding a test for ARM, instead of x86_64, in both the arm and arm64 conditions work?

if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" AND NOT CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^(arm|aarch64)")

@dg0yt
Copy link
Contributor

dg0yt commented Dec 16, 2023

Simple question again:
What is the host triplet?

@dg0yt
Copy link
Contributor

dg0yt commented Dec 16, 2023

"BUILD_CC=touch a.out | touch conftest | true" seems weird and predictably doesn't output anything useful

This is intentional. Ports are not allow to build host binaries while building for another target triplet. OTOH BUILD_CC shall be identical to CC (and working) when the target triplet is identical to the host triplet.

I notice that the last sentence doesn't match the actual behavior of vcpkg_configure_make. It just looks for --host instead:

if(NOT arg_BUILD_TRIPLET MATCHES "--host")
z_vcpkg_append_to_configure_environment(configure_env CC_FOR_BUILD "${VCPKG_DETECTED_CMAKE_C_COMPILER}")
z_vcpkg_append_to_configure_environment(configure_env CPP_FOR_BUILD "${VCPKG_DETECTED_CMAKE_C_COMPILER} -E")
z_vcpkg_append_to_configure_environment(configure_env CXX_FOR_BUILD "${VCPKG_DETECTED_CMAKE_CXX_COMPILER}")
else()
z_vcpkg_append_to_configure_environment(configure_env CC_FOR_BUILD "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true")
z_vcpkg_append_to_configure_environment(configure_env CPP_FOR_BUILD "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true")
z_vcpkg_append_to_configure_environment(configure_env CXX_FOR_BUILD "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true")
endif()

#35084 only made this visible. I see the proper fix in updating vcpkg_configure_make:
(also) use the host tool as <tool>_FOR_BUILD when not VCPKG_CROSSCOMPILING. CC @Neumann-A

@dg0yt
Copy link
Contributor

dg0yt commented Dec 16, 2023

As immediate workaround, you can try replacing CC_FOR_BUILD with CC in ports/libcap/configure.

@trolgar
Copy link

trolgar commented Dec 16, 2023

For me, both the host triplet and target triplet are arm64-linux. I am compiling on a Raspberry PI 4 running Ubuntu 22.04.

@dg0yt
Copy link
Contributor

dg0yt commented Dec 16, 2023

Thanks - Can you also try the proposed workaround?

@trolgar
Copy link

trolgar commented Dec 16, 2023

It does work. That is what I originally did to get by. But with the current linux.cmake, the compiler choice is aarch64-linux-gnu-gcc and not cc. In my case that is fine because they point to the same compiler. But would there be some instances that would not be the case?

@dg0yt
Copy link
Contributor

dg0yt commented Dec 16, 2023

But with the current linux.cmake, the compiler choice is aarch64-linux-gnu-gcc and not cc. In my case that is fine because they point to the same compiler. But would there be some instances that would not be the case?

There might be the situation that the prefixed variant doesn't exist for the native cc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:community-triplet A PR or issue related to community triplets not officially validated by the vcpkg team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants