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

[icu] ICU port adds -lm in pkgconfig files for debug MSVC builds #22311

Closed
equeim opened this issue Jan 3, 2022 · 2 comments · Fixed by #22388
Closed

[icu] ICU port adds -lm in pkgconfig files for debug MSVC builds #22311

equeim opened this issue Jan 3, 2022 · 2 comments · Fixed by #22388
Assignees
Labels
category:port-bug The issue is with a library, which is something the port should already support

Comments

@equeim
Copy link
Contributor

equeim commented Jan 3, 2022

Describe the bug
When ICU is built for Windows (MSVC) target with debug variant, its configure script adds -lm library to Libs.private property of pkgconfig files. As as I know, this library does not exist in MSVC toolchain. It is not used with dynamic linking, but static linking with pkgconfig results in linking error.

Environment

  • OS: Windows
  • Compiler: MSVC 19.29.30138

To Reproduce
Steps to reproduce the behavior:

  1. ./vcpkg install icu:x64-windows-static pkgconf:x64-windows-static
  2. Try to link to static ICU library by using pkgconfig
  3. Try to build CMake project with following CMakeLists.txt: https://gist.github.com/equeim/851df8e69165e509d9a511d1071e5631,
    dummy main.cpp and following CMake configuration command:
cmake -S \path\to\source -B \path\to\build -GNinja -DCMAKE_TOOLCHAIN_FILE=\path\to\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DPKG_CONFIG_EXECUTABLE=\path\to\vcpkg\installed\x64-windows-static\tools\pkgconf\pkgconf.exe -DCMAKE_BUILD_TYPE=Debug
  1. Observe linking error LINK : fatal error LNK1104: cannot open file 'm.lib'

Expected behavior
Statically linking ICU using pkgconfig should work.

Failure logs
build.log

Additional context
I believe that passing ac_cv_lib_m_floor=no to configure script in icu/portfile.cmake for MSVC toolchain fixes the issue but I don't know whether it is the correct solution.

@PhoebeHui PhoebeHui self-assigned this Jan 4, 2022
@PhoebeHui PhoebeHui added the category:port-bug The issue is with a library, which is something the port should already support label Jan 4, 2022
@PhoebeHui
Copy link
Contributor

@equeim, thanks for reporting this issue, I will take a look.

@equeim
Copy link
Contributor Author

equeim commented Jan 4, 2022

Here is log of passed test for libm in debug build:

configure:5384: checking for floor in -lm
configure:5409: cl.exe -o conftest.exe -nologo -W3 -utf-8 -MP -MTd -Z7 -Ob0 -Od -Xcompiler -RTC1 -W4 -W4 -DWIN32 -D_WINDOWS -D_DEBUG -LF:/projects/vcpkg/installed/x64-windows-static/debug/lib -LF:/projects/vcpkg/installed/x64-windows-static/debug/lib/manual-link conftest.c -lm  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -lcomdlg32 -ladvapi32 >&5
conftest.c
F:\projects\vcpkg\buildtrees\icu\x64-windows-static-dbg\conftest.c(31) : warning C4702: unreachable code
LINK : conftest.exe not found or not built by the last incremental link; performing full link
cl : Command line warning D9035 : option 'o' has been deprecated and will be removed in a future release
cl : Command line warning D9025 : overriding '/W3' with '/W4'
cl : Command line warning D9002 : ignoring unknown option '-Xcompiler'
cl : Command line warning D9002 : ignoring unknown option '-LF:/projects/vcpkg/installed/x64-windows-static/debug/lib'
cl : Command line warning D9002 : ignoring unknown option '-LF:/projects/vcpkg/installed/x64-windows-static/debug/lib/manual-link'
cl : Command line warning D9002 : ignoring unknown option '-lm'
cl : Command line warning D9002 : ignoring unknown option '-lkernel32'
cl : Command line warning D9002 : ignoring unknown option '-luser32'
cl : Command line warning D9002 : ignoring unknown option '-lgdi32'
cl : Command line warning D9002 : ignoring unknown option '-lwinspool'
cl : Command line warning D9002 : ignoring unknown option '-lshell32'
cl : Command line warning D9002 : ignoring unknown option '-lole32'
cl : Command line warning D9002 : ignoring unknown option '-loleaut32'
cl : Command line warning D9002 : ignoring unknown option '-lcomdlg32'
cl : Command line warning D9002 : ignoring unknown option '-ladvapi32'
configure:5409: $? = 0
configure:5418: result: yes

And log of failed test for libm in release build:

configure:5384: checking for floor in -lm
configure:5409: cl.exe -o conftest.exe -nologo -W3 -utf-8 -MP -MT -O2 -Oi -Gy -Z7 -W4 -W4 -DWIN32 -D_WINDOWS -DNDEBUG -LF:/projects/vcpkg/installed/x64-windows-static/lib -LF:/projects/vcpkg/installed/x64-windows-static/lib/manual-link conftest.c -lm  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -lcomdlg32 -ladvapi32 >&5
conftest.c
conftest.c(25): warning C4391: 'char floor()': incorrect return type for intrinsic function, expected 'double'
conftest.c(29): error C2168: 'floor': too few actual parameters for intrinsic function
cl : Command line warning D9035 : option 'o' has been deprecated and will be removed in a future release
cl : Command line warning D9025 : overriding '/W3' with '/W4'
cl : Command line warning D9002 : ignoring unknown option '-LF:/projects/vcpkg/installed/x64-windows-static/lib'
cl : Command line warning D9002 : ignoring unknown option '-LF:/projects/vcpkg/installed/x64-windows-static/lib/manual-link'
cl : Command line warning D9002 : ignoring unknown option '-lm'
cl : Command line warning D9002 : ignoring unknown option '-lkernel32'
cl : Command line warning D9002 : ignoring unknown option '-luser32'
cl : Command line warning D9002 : ignoring unknown option '-lgdi32'
cl : Command line warning D9002 : ignoring unknown option '-lwinspool'
cl : Command line warning D9002 : ignoring unknown option '-lshell32'
cl : Command line warning D9002 : ignoring unknown option '-lole32'
cl : Command line warning D9002 : ignoring unknown option '-loleaut32'
cl : Command line warning D9002 : ignoring unknown option '-lcomdlg32'
cl : Command line warning D9002 : ignoring unknown option '-ladvapi32'
configure:5409: $? = 2
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "ICU"
| #define PACKAGE_TARNAME "International Components for Unicode"
| #define PACKAGE_VERSION "69.1"
| #define PACKAGE_STRING "ICU 69.1"
| #define PACKAGE_BUGREPORT "http://icu-project.org/bugs"
| #define PACKAGE_URL "http://icu-project.org"
| #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_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define SIZEOF_VOID_P 8
| /* end confdefs.h.  */
| 
| /* Override any GCC internal prototype to avoid an error.
|    Use char because int might match the return type of a GCC
|    builtin and then its argument prototype would still apply.  */
| #ifdef __cplusplus
| extern "C"
| #endif
| char floor ();
| int
| main ()
| {
| return floor ();
|   ;
|   return 0;
| }
configure:5418: result: no

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.

2 participants