microsoft / vcpkg

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

[libusb:x86-mingw] build failure #9751

Closed matwey closed 2 years ago

matwey commented 4 years ago

Host Environment

To Reproduce Steps to reproduce the behavior: ./vcpkg --triplet x86-mingw install libusb

Failure logs

Your feedback is important to improve Vcpkg! Please take 3 minutes to complete our survey by running: vcpkg contact --survey
The following packages will be built and installed:
    libusb[core]:x86-mingw
Starting package 1/1: libusb:x86-mingw
Building package libusb[core]:x86-mingw...
-- Using community triplet x86-mingw. This triplet configuration is not guaranteed to succeed.
-- [COMMUNITY] Loading triplet configuration from: C:\Users\User\source\repos\vcpkg\triplets\community\x86-mingw.cmake
CMake Error at ports/libusb/portfile.cmake:2 (message):
  Error: the port is unsupported on your platform.  Please open an issue on
  github.com/Microsoft/vcpkg to request a fix
Call Stack (most recent call first):
  scripts/ports.cmake:94 (include)

Error: Building package libusb:x86-mingw 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: libusb:x86-mingw
  Vcpkg version: 2020.01.17-nohash

Additionally, attach any relevant sections from the log files above.

Additional context Add any other context about the problem here, such as what you have already tried to resolve the issue.

alcroito commented 4 years ago

@cristianadam

cristianadam commented 4 years ago

This package is not compatible with the newly added MinGW support in vcpkg, which sets VCPKG_CMAKE_SYSTEM_NAME to MinGW.

It has a guard at the top of the ports/libusb/portfile.cmake:

if (VCPKG_CMAKE_SYSTEM_NAME)
    message(FATAL_ERROR "Error: the port is unsupported on your platform. Please open an issue on github.com/Microsoft/vcpkg to request a fix")
endif()

libusb is a project without a CMake port. It has Visual C++ project files and autoconf files for Unix.

The autoconf parts might work on Windows using MinGW and Msys2. But this means that the standalone MinGW distributions won't be working.

Since the project has a few C files it would be far easier to have a CMake port that would work everywhere, as hacking the ports/libusb/portfile.cmake.

matwey commented 3 years ago

With the recent vcpkg from master, libusb build is still failing. However, the error is different:

CMake Error at scripts/cmake/vcpkg_execute_build_process.cmake:145 (message):
    Command failed: C:/Users/User/vcpkg/downloads/tools/msys2/827af5fc5a9ac05f/usr/bin/make.exe -j 3 --trace -f Makefile all
    Working Directory: C:/Users/User/vcpkg/buildtrees/libusb/x64-mingw-dynamic-dbg
    See logs for more information:
      C:\Users\User\vcpkg\buildtrees\libusb\build-x64-mingw-dynamic-dbg-out.log
      C:\Users\User\vcpkg\buildtrees\libusb\build-x64-mingw-dynamic-dbg-err.log

Call Stack (most recent call first):
  scripts/cmake/vcpkg_build_make.cmake:195 (vcpkg_execute_build_process)
  scripts/cmake/vcpkg_install_make.cmake:26 (vcpkg_build_make)
  ports/libusb/portfile.cmake:59 (vcpkg_install_make)
  scripts/ports.cmake:136 (include)

Error: Building package libusb:x64-mingw-dynamic 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: libusb:x64-mingw-dynamic
  Vcpkg version: 2020.11.12--unknownhash

Additionally, attach any relevant sections from the log files above.

build-x64-mingw-dynamic-dbg-err.log is the following:

In file included from .././../src/3ae1ed06fa-f8218372d8.clean/libusb/libusbi.h:296,
                 from .././../src/3ae1ed06fa-f8218372d8.clean/libusb/descriptor.c:29:
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/os/threads_windows.h:63:8: error: redefinition of 'struct timespec'
   63 | struct timespec {
      |        ^~~~~~~~
In file included from .././../src/3ae1ed06fa-f8218372d8.clean/libusb/libusbi.h:296,
                 from .././../src/3ae1ed06fa-f8218372d8.clean/libusb/core.c:44:
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/os/threads_windows.h:63:8: error: redefinition of 'struct timespec'
   63 | struct timespec {
      |        ^~~~~~~~
In file included from .././../src/3ae1ed06fa-f8218372d8.clean/libusb/libusbi.h:32,
                 from .././../src/3ae1ed06fa-f8218372d8.clean/libusb/descriptor.c:29:
c:\mingw\include\time.h:115:8: note: originally defined here
  115 | struct timespec
      |        ^~~~~~~~
In file included from c:\mingw\include\sys\time.h:44,
                 from .././../src/3ae1ed06fa-f8218372d8.clean/libusb/core.c:34:
c:\mingw\include\time.h:115:8: note: originally defined here
  115 | struct timespec
      |        ^~~~~~~~
In file included from .././../src/3ae1ed06fa-f8218372d8.clean/libusb/libusbi.h:296,
                 from .././../src/3ae1ed06fa-f8218372d8.clean/libusb/hotplug.c:33:
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/os/threads_windows.h:63:8: error: redefinition of 'struct timespec'
   63 | struct timespec {
      |        ^~~~~~~~
In file included from .././../src/3ae1ed06fa-f8218372d8.clean/libusb/libusbi.h:32,
                 from .././../src/3ae1ed06fa-f8218372d8.clean/libusb/hotplug.c:33:
c:\mingw\include\time.h:115:8: note: originally defined here
  115 | struct timespec
      |        ^~~~~~~~
In file included from .././../src/3ae1ed06fa-f8218372d8.clean/libusb/descriptor.c:29:
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/descriptor.c: In function 'libusb_get_device_descriptor':
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/descriptor.c:546:11: warning: zero-length ms_printf format string [-Wformat-zero-length]
  546 |  usbi_dbg("");
      |           ^~
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/libusbi.h:238:71: note: in definition of macro '_usbi_log'
  238 | #define _usbi_log(ctx, level, ...) usbi_log(ctx, level, __FUNCTION__, __VA_ARGS__)
      |                                                                       ^~~~~~~~~~~
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/descriptor.c:546:2: note: in expansion of macro 'usbi_dbg'
  546 |  usbi_dbg("");
      |  ^~~~~~~~
In file included from .././../src/3ae1ed06fa-f8218372d8.clean/libusb/core.c:44:
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/core.c: In function 'libusb_get_device_list':
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/core.c:815:11: warning: zero-length ms_printf format string [-Wformat-zero-length]
  815 |  usbi_dbg("");
      |           ^~
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/libusbi.h:238:71: note: in definition of macro '_usbi_log'
  238 | #define _usbi_log(ctx, level, ...) usbi_log(ctx, level, __FUNCTION__, __VA_ARGS__)
      |                                                                       ^~~~~~~~~~~
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/core.c:815:2: note: in expansion of macro 'usbi_dbg'
  815 |  usbi_dbg("");
      |  ^~~~~~~~
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/core.c: In function 'libusb_close':
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/core.c:1495:11: warning: zero-length ms_printf format string [-Wformat-zero-length]
 1495 |  usbi_dbg("");
      |           ^~
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/libusbi.h:238:71: note: in definition of macro '_usbi_log'
  238 | #define _usbi_log(ctx, level, ...) usbi_log(ctx, level, __FUNCTION__, __VA_ARGS__)
      |                                                                       ^~~~~~~~~~~
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/core.c:1495:2: note: in expansion of macro 'usbi_dbg'
 1495 |  usbi_dbg("");
      |  ^~~~~~~~
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/core.c: In function 'libusb_get_configuration':
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/core.c:1578:11: warning: zero-length ms_printf format string [-Wformat-zero-length]
 1578 |  usbi_dbg("");
      |           ^~
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/libusbi.h:238:71: note: in definition of macro '_usbi_log'
  238 | #define _usbi_log(ctx, level, ...) usbi_log(ctx, level, __FUNCTION__, __VA_ARGS__)
      |                                                                       ^~~~~~~~~~~
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/core.c:1578:2: note: in expansion of macro 'usbi_dbg'
 1578 |  usbi_dbg("");
      |  ^~~~~~~~
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/core.c: In function 'libusb_reset_device':
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/core.c:1846:11: warning: zero-length ms_printf format string [-Wformat-zero-length]
 1846 |  usbi_dbg("");
      |           ^~
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/libusbi.h:238:71: note: in definition of macro '_usbi_log'
  238 | #define _usbi_log(ctx, level, ...) usbi_log(ctx, level, __FUNCTION__, __VA_ARGS__)
      |                                                                       ^~~~~~~~~~~
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/core.c:1846:2: note: in expansion of macro 'usbi_dbg'
 1846 |  usbi_dbg("");
      |  ^~~~~~~~
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/core.c: In function 'libusb_exit':
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/core.c:2370:11: warning: zero-length ms_printf format string [-Wformat-zero-length]
 2370 |  usbi_dbg("");
      |           ^~
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/libusbi.h:238:71: note: in definition of macro '_usbi_log'
  238 | #define _usbi_log(ctx, level, ...) usbi_log(ctx, level, __FUNCTION__, __VA_ARGS__)
      |                                                                       ^~~~~~~~~~~
.././../src/3ae1ed06fa-f8218372d8.clean/libusb/core.c:2370:2: note: in expansion of macro 'usbi_dbg'
 2370 |  usbi_dbg("");
      |  ^~~~~~~~
make[2]: *** [Makefile:685: libusb_1_0_la-hotplug.lo] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile:671: libusb_1_0_la-core.lo] Error 1
make[2]: *** [Makefile:678: libusb_1_0_la-descriptor.lo] Error 1
make[1]: *** [Makefile:475: all-recursive] Error 1
make: *** [Makefile:384: all] Error 2
matwey commented 3 years ago

I've found that ./configure is not able to properly detect struct timespec presence, and then libusb defines its own struct timespec.

configure:16785: checking for struct timespec
configure:16785: compile gcc.exe -c -g  conftest.c >&5
conftest.c: In function 'main':
conftest.c:66:13: error: invalid application of 'sizeof' to incomplete type 'struct timespec'
   66 | if (sizeof (struct timespec))
      |             ^~~~~~
configure:16785: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "libusb"
| #define PACKAGE_TARNAME "libusb"
| #define PACKAGE_VERSION "1.0.23"
| #define PACKAGE_STRING "libusb 1.0.23"
| #define PACKAGE_BUGREPORT "libusb-devel@lists.sourceforge.net"
| #define PACKAGE_URL "http://libusb.info"
| #define PACKAGE "libusb"
| #define VERSION "1.0.23"
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_DLFCN_H 1
| #define LT_OBJDIR ".libs/"
| #define _GNU_SOURCE 1
| #define OS_WINDOWS 1
| #define POLL_NFDS_TYPE unsigned int
| #define WINVER 0x0501
| #define _WIN32_WINNT 0x0501
| #define HAVE_DECL_TFD_NONBLOCK 0
| #define HAVE_DECL_TFD_CLOEXEC 0
| /* end confdefs.h.  */
| #include <stdio.h>
| #ifdef HAVE_SYS_TYPES_H
| # include <sys/types.h>
| #endif
| #ifdef HAVE_SYS_STAT_H
| # include <sys/stat.h>
| #endif
| #ifdef STDC_HEADERS
| # include <stdlib.h>
| # include <stddef.h>
| #else
| # ifdef HAVE_STDLIB_H
| #  include <stdlib.h>
| # endif
| #endif
| #ifdef HAVE_STRING_H
| # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
| #  include <memory.h>
| # endif
| # include <string.h>
| #endif
| #ifdef HAVE_STRINGS_H
| # include <strings.h>
| #endif
| #ifdef HAVE_INTTYPES_H
| # include <inttypes.h>
| #endif
| #ifdef HAVE_STDINT_H
| # include <stdint.h>
| #endif
| #ifdef HAVE_UNISTD_H
| # include <unistd.h>
| #endif
| int
| main ()
| {
| if (sizeof (struct timespec))
|    return 0;
|   ;
|   return 0;
| }
configure:16785: result: no
LilyWangLL commented 2 years ago

Thanks for posting this issue. x86-mingw is a community triplet, and there are no update about this issue for a long time. If there are new process or change of this issue, please reopen this issue.