Skip to content

Conversation

@gim913
Copy link
Contributor

@gim913 gim913 commented Sep 14, 2025

Libunistring package on windows is built without iconv support - which renders it a bit useless.

Unfortunatelly, iconv is not a required for the libunistring build to succeed.

Fragment of build log without the patch:

checking for the common suffixes of directories in the library search path... lib,lib,lib
checking for iconv... yes
checking for working iconv... no              // <-----
checking whether iconv is compatible with its POSIX signature... yes
checking absolute name of <iconv.h>... "C:/vcpkg/installed/x64-windows/include\\iconv.h"
checking for inline... inline

With patch:

checking for the common suffixes of directories in the library search path... lib,lib,lib
checking for iconv... yes
checking for working iconv... (cached) yes              // <-----
checking how to link with libiconv... -liconv
checking whether iconv is compatible with its POSIX signature... yes
checking absolute name of <iconv.h>... "c:/vcpkg/installed/x64-windows/include\\iconv.h"
checking for inline... inline

Imported libs (without patch):

>dumpbin /imports unistring-5.dll | rg \.dll
Dump of file unistring-5.dll
    KERNEL32.dll
    VCRUNTIME140.dll
    api-ms-win-crt-runtime-l1-1-0.dll
    api-ms-win-crt-heap-l1-1-0.dll
    api-ms-win-crt-string-l1-1-0.dll
    api-ms-win-crt-stdio-l1-1-0.dll
    api-ms-win-crt-locale-l1-1-0.dll
    api-ms-win-crt-convert-l1-1-0.dll
    api-ms-win-crt-environment-l1-1-0.dll
    api-ms-win-crt-math-l1-1-0.dll

Imported libs (with patch):

> dumpbin /imports unistring-5.dll | rg \.dll
Dump of file unistring-5.dll
    iconv-2.dll
    KERNEL32.dll
    VCRUNTIME140.dll
    api-ms-win-crt-runtime-l1-1-0.dll
    api-ms-win-crt-heap-l1-1-0.dll
    api-ms-win-crt-string-l1-1-0.dll
    api-ms-win-crt-stdio-l1-1-0.dll
    api-ms-win-crt-locale-l1-1-0.dll
    api-ms-win-crt-convert-l1-1-0.dll
    api-ms-win-crt-environment-l1-1-0.dll
    api-ms-win-crt-math-l1-1-0.dll
Example affected function (without patch)
> dumpbin /disasm unistring-5.dll | rg -A28 -i "str_iconveh:"
libunistring_str_iconveh:
  0000000180004A10: 40 53              push        rbx
  0000000180004A12: 48 83 EC 20        sub         rsp,20h
  0000000180004A16: 80 39 00           cmp         byte ptr [rcx],0
  0000000180004A19: 48 8B C2           mov         rax,rdx
  0000000180004A1C: 48 8B D9           mov         rbx,rcx
  0000000180004A1F: 74 23              je          0000000180004A44
  0000000180004A21: 49 8B D0           mov         rdx,r8
  0000000180004A24: 48 8B C8           mov         rcx,rax
  0000000180004A27: E8 74 C8 FF FF     call        libunistring_c_strcasecmp
  0000000180004A2C: 85 C0              test        eax,eax
  0000000180004A2E: 74 14              je          0000000180004A44
  0000000180004A30: FF 15 D2 27 04 00  call        qword ptr [__imp__errno]
  0000000180004A36: C7 00 28 00 00 00  mov         dword ptr [rax],28h
  0000000180004A3C: 33 C0              xor         eax,eax
  0000000180004A3E: 48 83 C4 20        add         rsp,20h
  0000000180004A42: 5B                 pop         rbx
  0000000180004A43: C3                 ret
  0000000180004A44: 48 8B CB           mov         rcx,rbx
  0000000180004A47: FF 15 3B 28 04 00  call        qword ptr [__imp__strdup]
  0000000180004A4D: 48 8B D8           mov         rbx,rax
  0000000180004A50: 48 85 C0           test        rax,rax
  0000000180004A53: 75 0C              jne         0000000180004A61
  0000000180004A55: FF 15 AD 27 04 00  call        qword ptr [__imp__errno]
  0000000180004A5B: C7 00 0C 00 00 00  mov         dword ptr [rax],0Ch
  0000000180004A61: 48 8B C3           mov         rax,rbx
  0000000180004A64: 48 83 C4 20        add         rsp,20h
  0000000180004A68: 5B                 pop         rbx
  0000000180004A69: C3                 ret
Example affected function (with patch)
> dumpbin /disasm unistring-5.dll | rg -A28 "str_iconveh:"
libunistring_str_iconveh:
  0000000180004E00: 48 89 5C 24 10     mov         qword ptr [rsp+10h],rbx
  0000000180004E05: 48 89 6C 24 18     mov         qword ptr [rsp+18h],rbp
  0000000180004E0A: 48 89 74 24 20     mov         qword ptr [rsp+20h],rsi
  0000000180004E0F: 57                 push        rdi
  0000000180004E10: 48 83 EC 70        sub         rsp,70h
  0000000180004E14: 80 39 00           cmp         byte ptr [rcx],0
  0000000180004E17: 41 8B E9           mov         ebp,r9d
  0000000180004E1A: 49 8B F8           mov         rdi,r8
  0000000180004E1D: 48 8B F2           mov         rsi,rdx
  0000000180004E20: 48 8B D9           mov         rbx,rcx
  0000000180004E23: 0F 84 EC 00 00 00  je          0000000180004F15
  0000000180004E29: 49 8B D0           mov         rdx,r8
  0000000180004E2C: 48 8B CE           mov         rcx,rsi
  0000000180004E2F: E8 6C C4 FF FF     call        libunistring_c_strcasecmp
  0000000180004E34: 85 C0              test        eax,eax
  0000000180004E36: 0F 84 D9 00 00 00  je          0000000180004F15
  0000000180004E3C: 4C 8D 44 24 58     lea         r8,[rsp+58h]
  0000000180004E41: 48 8B D6           mov         rdx,rsi
  0000000180004E44: 48 8B CF           mov         rcx,rdi
  0000000180004E47: E8 94 FB FF FF     call        libunistring_iconveh_open
  0000000180004E4C: 85 C0              test        eax,eax
  0000000180004E4E: 0F 88 BD 00 00 00  js          0000000180004F11
  0000000180004E54: 33 FF              xor         edi,edi
  0000000180004E56: 48 8B CB           mov         rcx,rbx
  0000000180004E59: 48 89 BC 24 80 00  mov         qword ptr [rsp+80h],rdi
                    00 00
  0000000180004E61: 48 89 7C 24 50     mov         qword ptr [rsp+50h],rdi
  0000000180004E66: E8 0B 30 04 00     call        strlen
  • Changes comply with the maintainer guide.
  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.
  • Only one version is added to each modified port's versions file.

P.S. The other two packages that might have similar issue (I only did some grepping, haven't verified it), might be mpir and openmpi.

@gim913
Copy link
Contributor Author

gim913 commented Sep 14, 2025

@microsoft-github-policy-service agree

@gim913 gim913 force-pushed the libunistring-iconv-fix branch 2 times, most recently from 930ea85 to e5e40da Compare September 14, 2025 16:27
@dg0yt
Copy link
Contributor

dg0yt commented Sep 14, 2025

I am curious to see the iconv check from the config.log for a debug build before this change. There must be a reason why this fails.

P.S. The other two packages that might have similar issue (I only did some grepping, haven't verified it), might be mpir and openmpi.

mpir does not declare a dependency on iconv.
openmpi doesn't support windows.

@gim913
Copy link
Contributor Author

gim913 commented Sep 14, 2025

There's "--with-libiconv-prefix=${CURRENT_INSTALLED_DIR}" passed, which I believe is correct.
From what I remember there's simply linking issue (maybe not passing proper dir? idk), will check that later and report.
(Not super eager, as every build rel+deb takes me 18mins or so).

@gim913
Copy link
Contributor Author

gim913 commented Sep 14, 2025

Ok, got it - was obviously wrong about linking part, I cut out, actual programs, as they are not important, the issue is clearly visible:

I'm not sure if this is issue on my end, or should the dll be copied during the tests to a dir where the tests are made?

configure:25057: checking for working iconv
configure:25201: compile cl.exe -o conftest.exe -Xcompiler -nologo -Xcompiler -utf-8 -Xcompiler -MP -Xcompiler -MD -Xcompiler -O2 -Xcompiler -Oi -Xcompiler -Gy -Xcompiler -Z7 -DWIN32 -D_WINDOWS -DNDEBUG -Xlinker -Xlinker -Xlinker -LIBPATH:c:/vcpkg/installed/x64-windows/lib -Xlinker -Xlinker -Xlinker -LIBPATH:c:/vcpkg/installed/x64-windows/lib/manual-link -Xlinker -Xlinker -Xlinker -machine:x64 -Xlinker -Xlinker -Xlinker -nologo -Xlinker -Xlinker -Xlinker -DEBUG -Xlinker -Xlinker -Xlinker -INCREMENTAL:NO -Xlinker -Xlinker -Xlinker -OPT:REF -Xlinker -Xlinker -Xlinker -OPT:ICF conftest.c -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -lcomdlg32 -ladvapi32 -liconv >&5
conftest.c
configure:25201: $? = 0
configure:25201: ./conftest.exe
c:/vcpkg/buildtrees/libunistring/x64-windows-rel/conftest.exe: error while loading shared libraries: iconv-2.dll: cannot open shared object file: No such file or directory
configure:25201: $? = 127
configure: program exited with status 127
configure: failed program was:
...
configure:25201: compile cl.exe -o conftest.exe -Xcompiler -nologo -Xcompiler -utf-8 -Xcompiler -MP -Xcompiler -MD -Xcompiler -O2 -Xcompiler -Oi -Xcompiler -Gy -Xcompiler -Z7 -DWIN32 -D_WINDOWS -DNDEBUG -Xlinker -Xlinker -Xlinker -LIBPATH:c:/vcpkg/installed/x64-windows/lib -Xlinker -Xlinker -Xlinker -LIBPATH:c:/vcpkg/installed/x64-windows/lib/manual-link -Xlinker -Xlinker -Xlinker -machine:x64 -Xlinker -Xlinker -Xlinker -nologo -Xlinker -Xlinker -Xlinker -DEBUG -Xlinker -Xlinker -Xlinker -INCREMENTAL:NO -Xlinker -Xlinker -Xlinker -OPT:REF -Xlinker -Xlinker -Xlinker -OPT:ICF conftest.c -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -lcomdlg32 -ladvapi32 -liconv >&5
conftest.c
configure:25201: $? = 0
configure:25201: ./conftest.exe
c:/vcpkg/buildtrees/libunistring/x64-windows-rel/conftest.exe: error while loading shared libraries: iconv-2.dll: cannot open shared object file: No such file or directory
configure:25201: $? = 127
configure: program exited with status 127
configure: failed program was:
...
configure:25216: result: no


if(VCPKG_TARGET_IS_WINDOWS)
list(APPEND OPTIONS
# Avoid unnecessary tests.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix this to explain more clearly what the fix is? I see you described it well in the PR but it really should be here for the next person trying to figure out why this is here. As written it looks like this is a perf fix someone may choose to omit but here it's actually load bearing.

It may be helpful if you can show which particular test it does not like...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added comment, hopefully ok

"port-version": 2
},
{
"git-tree": "70d16d271eb087c5a92ce320b8329b740494edcb",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is damaged. Please

git checkout origin/master -- versions
vcpkg x-add-version libunistring

or similar to restore the value for 1.2#1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebased on master and fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems CI is still complaining, although I'm not quite sure why :|

@BillyONeal BillyONeal marked this pull request as draft September 16, 2025 01:50
@BillyONeal BillyONeal added category:port-bug The issue is with a library, which is something the port should already support info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this. labels Sep 16, 2025
@gim913 gim913 force-pushed the libunistring-iconv-fix branch from e5e40da to fa42419 Compare September 16, 2025 09:42
…ort)

(trying to bump version for the third time)
@gim913 gim913 force-pushed the libunistring-iconv-fix branch from fa42419 to ce60525 Compare October 13, 2025 11:46
@gim913 gim913 marked this pull request as ready for review October 13, 2025 18:18
@BillyONeal BillyONeal closed this Oct 14, 2025
@BillyONeal BillyONeal reopened this Oct 14, 2025
@BillyONeal
Copy link
Member

microsoft/vcpkg-tool#1817 bug fix

@BillyONeal BillyONeal added the requires:tool-release An issue that has been fixed in the microsoft/vcpkg-tool repo and is waiting for a release thereof label Oct 16, 2025
@BillyONeal BillyONeal closed this Oct 16, 2025
@BillyONeal BillyONeal reopened this Oct 16, 2025
@BillyONeal BillyONeal removed the requires:tool-release An issue that has been fixed in the microsoft/vcpkg-tool repo and is waiting for a release thereof label Oct 16, 2025
@BillyONeal BillyONeal enabled auto-merge (squash) October 17, 2025 00:01
@BillyONeal BillyONeal disabled auto-merge October 17, 2025 05:33
@BillyONeal BillyONeal merged commit dfee761 into microsoft:master Oct 17, 2025
18 of 20 checks passed
@BillyONeal
Copy link
Member

Thanks and sorry for the mess!

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 info:needs-maintainer-attention Lets the current 'on rotation' vcpkg maintainer know they need to look at this.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants