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

[gettext-libintl] Build error on x64-linux (NixOS) due to hardcoded path #39641

Closed
easrng opened this issue Jul 1, 2024 · 9 comments · Fixed by #39662
Closed

[gettext-libintl] Build error on x64-linux (NixOS) due to hardcoded path #39641

easrng opened this issue Jul 1, 2024 · 9 comments · Fixed by #39662
Assignees
Labels
category:port-bug The issue is with a library, which is something the port should already support

Comments

@easrng
Copy link

easrng commented Jul 1, 2024

Package: gettext-libintl:[email protected]#1

Host Environment

  • Host: x64-linux (NixOS 24.11pre641786.d603719ec6e2 (Vicuna) x86_64)
  • Compiler: GNU 13.3.0
  • vcpkg-tool version: 2024-06-10-02590c430e4ed9215d27870138c2e579cc338772
    vcpkg-scripts version: f7423ee 2024-06-14 (2 weeks ago)

To Reproduce

vcpkg install --no-print-usage

Failure logs

CMake Error at buildtrees/versioning_/versions/gettext-libintl/ac89519d5ec11430978a4e45619befb7a1c4a062/portfile.cmake:4 (message):
  When targeting Linux, `libintl.h` is expected to come from the C Runtime
  Library (glibc).  Please use "sudo apt-get install libc-dev" or the
  equivalent to install development files.
Call Stack (most recent call first):
  scripts/ports.cmake:191 (include)



The issue here is that the portfile only checks if /usr/include/libintl.h exists, when on NixOS it'll be something like /nix/store/4vgk1rlzdqjnpjicb5qcxjcd4spi7wyw-glibc-2.39-52-dev/include/libintl.h

Additional context

vcpkg.json
{
  "builtin-baseline": "f7423ee180c4b7f40d43402c2feb3859161ef625",
  "dependencies": [
    {
      "name": "fontconfig",
      "platform": "linux | freebsd | openbsd"
    },
    "icu",
    "libjpeg-turbo",
    {
      "name": "libpng",
      "features": [
        "apng"
      ]
    },
    {
      "name": "skia",
      "platform": "osx",
      "features": [
        "metal"
      ]
    },
    {
      "name": "skia",
      "platform": "linux | freebsd | openbsd"
    },
    "sqlite3",
    "woff2"
  ],
  "overrides": [
    {
      "name": "fontconfig",
      "version": "2.14.2#1"
    },
    {
      "name": "icu",
      "version": "74.2#2"
    },
    {
      "name": "libjpeg-turbo",
      "version": "3.0.2"
    },
    {
      "name": "libpng",
      "version": "1.6.43#1"
    },
    {
      "name": "skia",
      "version": "124#0"
    },
    {
      "name": "sqlite3",
      "version": "3.45.3"
    },
    {
      "name": "woff2",
      "version": "1.0.2#4"
    }
  ]
}

@MonicaLiu0311 MonicaLiu0311 added the requires:repro The issue is not currently repro-able label Jul 2, 2024
@MonicaLiu0311
Copy link
Contributor

Sorry I didn't repro issue.

monica@monica003:/mnt/vcpkg$ cat /proc/version
Linux version 6.5.0-1016-azure (buildd@bos03-amd64-021) (x86_64-linux-gnu-gcc-11 (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #16~22.04.1-Ubuntu SMP Fri Feb 16 15:42:02 UTC 2024
monica@monica003:/mnt/vcpkg$ ./vcpkg install gettext-libintl
Computing installation plan...
The following packages will be built and installed:
    gettext-libintl:[email protected]#1
Detecting compiler hash for triplet x64-linux...
Compiler found: /usr/bin/c++
Restored 0 package(s) from /home/monica/.cache/vcpkg/archives in 7.3 us. Use --debug to see more details.
Installing 1/1 gettext-libintl:[email protected]#1...
Building gettext-libintl:[email protected]#1...
-- Skipping post-build validation due to VCPKG_POLICY_EMPTY_PACKAGE
Failed to store binary cache /home/monica/.cache/vcpkg/archives/78/788ba230ad941885894aeb2c5e59da66d508e4845420f1b8cf0c5e9f35d8ea6a.zip
No such file or directory
Stored binaries in 0 destinations in 3.31 ms.
Elapsed time to handle gettext-libintl:x64-linux: 47.2 ms
gettext-libintl:x64-linux package ABI: 788ba230ad941885894aeb2c5e59da66d508e4845420f1b8cf0c5e9f35d8ea6a
Total install time: 47.2 ms
gettext-libintl is compatible with built-in CMake targets:

    find_package(Intl REQUIRED)
    target_link_libraries(main PRIVATE Intl::Intl) # since CMake 3.20

@MonicaLiu0311
Copy link
Contributor

The issue here is that the portfile only checks if /usr/include/libintl.h exists, when on NixOS it'll be something like /nix/store/4vgk1rlzdqjnpjicb5qcxjcd4spi7wyw-glibc-2.39-52-dev/include/libintl.h

Could you please modify portfile.cmake as follows and install it, then use it in CMakeLists.txt according to usage to test whether it can be found.

if(VCPKG_TARGET_IS_LINUX)
    set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
        find_program(LIBINTL_H_FOUND NAMES libintl.h PATHS /usr/include /nix/store NO_DEFAULT_PATH)
        if(NOT LIBINTL_H_FOUND)
            message(FATAL_ERROR
                "Could not find libintl.h in either /usr/include or /nix/store. "
                "Please use \"sudo apt-get install libc-dev\" or the equivalent to install development files."
            )
        endif()
    endif()
endif()

@easrng
Copy link
Author

easrng commented Jul 2, 2024

I'll try when I get home, but that looks very inefficient. cmake finds the header just fine, is there a way to just ask it to run it's normal resolution logic instead of hacks like this?

@quentinmit
Copy link

/nix/store should never be searched for files like that; it might contain many different copies of libintl.h from different versions of glibc. You should just rely on the normal cmake logic for finding a header file (e.g. a Nix shell will automatically set CMAKE_INCLUDE_PATH to point to the packages in the shell).

@dg0yt
Copy link
Contributor

dg0yt commented Jul 3, 2024

It is really one unusual package manager meeting another one.

find_program(LIBINTL_H_FOUND NAMES libintl.h PATHS /usr/include /nix/store NO_DEFAULT_PATH)

This makes no sense. 🤦

The answer is probably building a test project, at least if /usr/include/libintl.h doesn't exist.

@dg0yt
Copy link
Contributor

dg0yt commented Jul 3, 2024

at least if /usr/include/libintl.h doesn't exist.

But this is the wrong indicator also for cross builds...

@dg0yt
Copy link
Contributor

dg0yt commented Jul 3, 2024

Please test #39662. It uses a CMake project for detecting libintl.h.

@MonicaLiu0311 MonicaLiu0311 added category:port-bug The issue is with a library, which is something the port should already support and removed requires:repro The issue is not currently repro-able labels Jul 3, 2024
@quentinmit
Copy link

Please test #39662. It uses a CMake project for detecting libintl.h.

How can I test this? Do you have a sample invocation that will trigger the new detection code?

@dg0yt
Copy link
Contributor

dg0yt commented Jul 3, 2024

How can I test this?

You might simply checkout the branch which is the input to that PR.
Shortcut: https://github.com/dg0yt/vcpkg/tree/libintl

And then vcpkg install gettext-libintl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-bug The issue is with a library, which is something the port should already support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants