# Windows on ARM64, clang/lld based. Must precede %%mingw_package_header. %global mingw_build_ucrtarm64 1 # win32/win64 build with the clang supplement drivers: the qemu-ga MSI ships # iconv.dll from clang/compiler-rt toolchain sysroots, where the GNU runtime # DLLs do not exist, so nothing shipped there may import them. %global mingw_toolchain_win32 clang %global mingw_toolchain_win64 clang %{?mingw_package_header} %global pkgname win-iconv Name: mingw-%{pkgname} Version: 0.0.10 Release: 5.2%{?dist} Summary: Iconv implementation using Win32 API BuildArch: noarch License: LicenseRef-Fedora-Public-Domain URL: https://github.com/win-iconv/win-iconv Source0: https://github.com/win-iconv/win-iconv/archive/v%{version}/%{pkgname}-%{version}.tar.gz BuildRequires: make BuildRequires: cmake # The win32/win64 clang columns dispatch to the supplement drivers only from # 152-1.9 on. Headers, CRT and binutils must be named; the GCC targets get # them through gcc. compiler-rt and libunwind: the drivers always link # -rtlib=compiler-rt -unwindlib=libunwind, and mock installs no weak # dependencies. BuildRequires: mingw32-filesystem >= 152-1.9 BuildRequires: mingw32-clang BuildRequires: mingw32-binutils BuildRequires: mingw32-headers BuildRequires: mingw32-crt BuildRequires: mingw32-compiler-rt >= 22.1.8 BuildRequires: mingw32-libunwind >= 22.1.8 BuildRequires: mingw64-filesystem >= 152-1.9 BuildRequires: mingw64-clang BuildRequires: mingw64-binutils BuildRequires: mingw64-headers BuildRequires: mingw64-crt BuildRequires: mingw64-compiler-rt >= 22.1.8 BuildRequires: mingw64-libunwind >= 22.1.8 # No gcc for this target: the toolchain is clang, lld and the llvm-* tools. # Headers and CRT must be named; the other targets get them through gcc. BuildRequires: ucrtarm64-filesystem >= 152 BuildRequires: ucrtarm64-clang BuildRequires: ucrtarm64-llvm-tools BuildRequires: ucrtarm64-headers BuildRequires: ucrtarm64-crt # The drivers always link -rtlib=compiler-rt (__chkstk lives there) and # -unwindlib=libunwind; libunwind only arrives through ucrtarm64-clang's # Recommends chain, and mock installs no weak dependencies. BuildRequires: ucrtarm64-compiler-rt >= 22.1.8 BuildRequires: ucrtarm64-libunwind >= 22.1.8 # win-iconv is pure C; %%prep restricts project() to LANGUAGES C, so cmake # configures no C++ compiler. Without that, the clang targets would need a # libc++ (only packaged for ucrtarm64), as clang++ always passes # -stdlib=libc++. %description MinGW Windows Iconv library %{?mingw_debug_package} # Win32 %package -n mingw32-win-iconv Summary: MinGW Windows Iconv library %description -n mingw32-win-iconv MinGW Windows cross compiled Iconv library. %package -n mingw32-win-iconv-static Summary: Static version of the MinGW Windows Iconv library Requires: mingw32-win-iconv = %{version}-%{release} %description -n mingw32-win-iconv-static Static version of the MinGW Windows Iconv library. # Win64 %package -n mingw64-win-iconv Summary: MinGW Windows Iconv library %description -n mingw64-win-iconv MinGW Windows Iconv library %package -n mingw64-win-iconv-static Summary: Static version of the MinGW Windows Iconv library Requires: mingw64-win-iconv = %{version}-%{release} %description -n mingw64-win-iconv-static Static version of the MinGW Windows Iconv library. # Windows on ARM64 %package -n ucrtarm64-win-iconv Summary: MinGW Windows Iconv library %description -n ucrtarm64-win-iconv MinGW Windows Iconv library %package -n ucrtarm64-win-iconv-static Summary: Static version of the MinGW Windows Iconv library Requires: ucrtarm64-win-iconv = %{version}-%{release} %description -n ucrtarm64-win-iconv-static Static version of the MinGW Windows Iconv library. %prep %autosetup -p1 -n %{pkgname}-%{version} # CMakeLists.txt joins the CRLF strip: the project() sed below anchors on # the line end and would silently miss the trailing carriage return. sed -i 's|\r||' readme.txt ChangeLog CMakeLists.txt # win-iconv is pure C, but project() without a LANGUAGES list makes cmake # configure a C++ compiler too; the clang targets have no libc++ to satisfy # clang++'s -stdlib=libc++. Restrict to C, and assert the sed took. sed -i 's/^project(win_iconv)$/project(win_iconv C)/' CMakeLists.txt grep -q '^project(win_iconv C)$' CMakeLists.txt %build %mingw_cmake -DDISABLE_LOCALE_CHARSET=ON %mingw_make_build %install %mingw_make_install rm %{buildroot}/%{mingw32_bindir}/win_iconv.exe rm %{buildroot}/%{mingw64_bindir}/win_iconv.exe rm %{buildroot}/%{ucrtarm64_bindir}/win_iconv.exe # Fix file conflict with mingw-libcharset rm -f %{buildroot}%{mingw32_includedir}/localcharset.h rm -f %{buildroot}%{mingw64_includedir}/localcharset.h rm -f %{buildroot}%{ucrtarm64_includedir}/localcharset.h %check # Verify the ucrtarm64 output with the llvm-* tools only: GNU nm/ar/objdump # silently mis-read AArch64 PE/COFF. %%check runs after the BRP passes. # 1. iconv.dll really is a Windows ARM64 PE, stripped, with its debuginfo # split out; if %%mingw_debug_package went missing it would ship unstripped. %{ucrtarm64_objdump} -f %{buildroot}%{ucrtarm64_bindir}/iconv.dll %{ucrtarm64_objdump} -f %{buildroot}%{ucrtarm64_bindir}/iconv.dll \ | grep -q 'file format coff-arm64' %{ucrtarm64_objdump} -h %{buildroot}%{ucrtarm64_bindir}/iconv.dll \ | grep -q '\.gnu_debuglink' test -f %{buildroot}%{_prefix}/lib/debug%{ucrtarm64_bindir}/iconv.dll.debug # 2. Every shipped archive still carries its ar symbol index. win-iconv # exports the POSIX spellings; the libiconv_* names are aliases that only # exist in the DLL export table (plain #defines in iconv.h), so iconv_open # is what has to be indexed. for a in %{buildroot}%{ucrtarm64_libdir}/libiconv.a \ %{buildroot}%{ucrtarm64_libdir}/libiconv.dll.a ; do magic=$(od -A n -t x1 -N 10 "$a" | tr -d ' \n') echo "archive $a: header $magic" test "$magic" = "213c617263683e0a2f20" %{ucrtarm64_nm} --print-armap "$a" \ | awk '$1 == "iconv_open" && $2 == "in" { found = 1 } END { exit !found }' done # 3. The members of both archives are ARM64 COFF as well, and nothing else # leaked in from the host or from one of the other two targets. for a in %{buildroot}%{ucrtarm64_libdir}/libiconv.a \ %{buildroot}%{ucrtarm64_libdir}/libiconv.dll.a ; do %{ucrtarm64_objdump} -f "$a" | grep -q 'file format coff-arm64' ! %{ucrtarm64_objdump} -f "$a" | grep -E 'file format (coff-i386|coff-x86-64|elf)' done # 4. win_iconv.c carries no __declspec(dllexport): iconv-g.def is the only # thing that makes the DLL export anything at all, and it also supplies the # libiconv_* aliases that GNU libiconv consumers resolve against. If lld # ignored the .def the link would still succeed -- mingw auto-export would # publish the POSIX names and silently drop every alias. Read the export # table proper (the " " rows below "Export Table:"), # not the whole -p dump, so an identically named import cannot stand in for # a missing export. # Scratch outside the source tree, like the link test below. exports=%{_builddir}/ucrtarm64-win-iconv-exports.txt %{ucrtarm64_objdump} -p %{buildroot}%{ucrtarm64_bindir}/iconv.dll %{ucrtarm64_objdump} -p %{buildroot}%{ucrtarm64_bindir}/iconv.dll \ | awk '/^Export Table:/ { in_exports = 1; next } in_exports && $1 ~ /^[0-9]+$/ && $2 ~ /^0x/ { print $3 }' \ > "$exports" cat "$exports" for sym in iconv iconv_open iconv_close iconvctl \ libiconv libiconv_open libiconv_close libiconvctl ; do grep -qx "$sym" "$exports" done # ... and locale_charset stays out: DISABLE_LOCALE_CHARSET=ON comments it out # of the .def, which is what keeps localcharset.h/locale_charset from # conflicting with mingw-libcharset. ! grep -qx locale_charset "$exports" rm -f "$exports" # 5. Link test: an iconv consumer has to compile and link against exactly what # is about to be packaged, both against the import library and statically. # Only the link and the resulting file format/imports can be checked here. armcheck=%{_builddir}/ucrtarm64-win-iconv-check rm -rf $armcheck mkdir -p $armcheck cat > $armcheck/t.c <<'EOF' #include #include #include int main (void) { static const char utf16le[] = { 'h', 0, 'i', 0 }; const char *inp = utf16le; size_t inleft = sizeof utf16le; char out[16]; char *outp = out; size_t outleft = sizeof out - 1; iconv_t cd; cd = iconv_open ("UTF-8", "UTF-16LE"); if (cd == (iconv_t) -1) return 1; if (iconv (cd, &inp, &inleft, &outp, &outleft) == (size_t) -1) return 1; if (iconv_close (cd) != 0) return 1; *outp = '\0'; printf ("%%s\n", out); return strcmp (out, "hi") == 0 ? 0 : 1; } EOF # Shared: -liconv resolves to libiconv.dll.a -> iconv.dll. %{ucrtarm64_cc} -isystem %{buildroot}%{ucrtarm64_includedir} $armcheck/t.c \ -L%{buildroot}%{ucrtarm64_libdir} -liconv -o $armcheck/t.exe %{ucrtarm64_objdump} -f $armcheck/t.exe %{ucrtarm64_objdump} -f $armcheck/t.exe | grep -q 'file format coff-arm64' %{ucrtarm64_objdump} -p $armcheck/t.exe | grep -i 'iconv.dll' # Static: the same program against ucrtarm64-win-iconv-static, which must not # end up importing the DLL. Capture the imports first: under "!" a crashed # objdump would count as "pattern absent" and pass. %{ucrtarm64_cc} -isystem %{buildroot}%{ucrtarm64_includedir} $armcheck/t.c \ -L%{buildroot}%{ucrtarm64_libdir} -Wl,-Bstatic -liconv -Wl,-Bdynamic \ -o $armcheck/t-static.exe %{ucrtarm64_objdump} -f $armcheck/t-static.exe %{ucrtarm64_objdump} -f $armcheck/t-static.exe | grep -q 'file format coff-arm64' imports=$(%{ucrtarm64_objdump} -p $armcheck/t-static.exe) if echo "$imports" | grep -qi 'iconv\.dll'; then echo "ERROR: the static link imports iconv.dll" >&2 exit 1 fi # 5b. The win32/win64 DLLs are now linked with the clang supplement drivers, # and the qemu-ga MSI ships iconv.dll from sysroots where the GNU runtime # DLLs do not exist: no libgcc, libssp or libunwind import may appear. # The same consumer links through the same drivers. for t in i686-w64-mingw32 x86_64-w64-mingw32 ; do case $t in i686-*) wbin_rel=%{mingw32_bindir} wlibdir=%{buildroot}%{mingw32_libdir} wincdir=%{buildroot}%{mingw32_includedir} peformat=pei-i386 ;; x86_64-*) wbin_rel=%{mingw64_bindir} wlibdir=%{buildroot}%{mingw64_libdir} wincdir=%{buildroot}%{mingw64_includedir} peformat=pei-x86-64 ;; esac wbindir=%{buildroot}$wbin_rel $t-objdump -f $wbindir/iconv.dll | grep -q "file format $peformat" $t-objdump -h $wbindir/iconv.dll | grep -q '\.gnu_debuglink' test -f %{buildroot}%{_prefix}/lib/debug$wbin_rel/iconv.dll.debug imports=$($t-objdump -p $wbindir/iconv.dll | grep 'DLL Name' || :) echo "$t iconv.dll imports: $imports" if echo "$imports" | grep -qiE 'libgcc|libssp|libunwind'; then echo "ERROR: $t iconv.dll imports a GNU runtime or unwinder DLL" >&2 exit 1 fi $t-clang -isystem $wincdir $armcheck/t.c -L$wlibdir -liconv -o $armcheck/t-$t.exe $t-objdump -f $armcheck/t-$t.exe | grep -q "file format $peformat" $t-objdump -p $armcheck/t-$t.exe | grep -i 'iconv.dll' $t-clang -isystem $wincdir $armcheck/t.c -L$wlibdir \ -Wl,-Bstatic -liconv -Wl,-Bdynamic -o $armcheck/t-static-$t.exe imports=$($t-objdump -p $armcheck/t-static-$t.exe) if echo "$imports" | grep -qi 'iconv\.dll'; then echo "ERROR: the $t static link imports iconv.dll" >&2 exit 1 fi done rm -rf "$armcheck" %files -n mingw32-win-iconv %doc ChangeLog readme.txt %{mingw32_bindir}/iconv.dll %{mingw32_includedir}/iconv.h %{mingw32_libdir}/libiconv.dll.a %files -n mingw32-win-iconv-static %{mingw32_libdir}/libiconv.a %files -n mingw64-win-iconv %doc ChangeLog readme.txt %{mingw64_bindir}/iconv.dll %{mingw64_includedir}/iconv.h %{mingw64_libdir}/libiconv.dll.a %files -n mingw64-win-iconv-static %{mingw64_libdir}/libiconv.a %files -n ucrtarm64-win-iconv %doc ChangeLog readme.txt %{ucrtarm64_bindir}/iconv.dll %{ucrtarm64_includedir}/iconv.h %{ucrtarm64_libdir}/libiconv.dll.a %files -n ucrtarm64-win-iconv-static %{ucrtarm64_libdir}/libiconv.a %changelog * Mon Aug 24 2026 Erik Berg - 0.0.10-5.2 - Build the win32 and win64 targets with the clang supplement drivers: the qemu-ga MSI ships iconv.dll from clang/compiler-rt toolchain sysroots, where the GNU runtime DLLs do not exist - Restrict project() to LANGUAGES C: cmake no longer configures a C++ compiler, so the clang targets need no libc++ and the ucrtarm64-libcxx build dependency goes away - New checks assert the x86 DLLs import no libgcc, libssp or libunwind, and link an iconv consumer through the same drivers * Thu Aug 06 2026 Erik Berg - 0.0.10-5.1 - Add win-iconv for the Windows on ARM64 target * Thu Jul 16 2026 Fedora Release Engineering - 0.0.10-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild * Fri Jan 16 2026 Fedora Release Engineering - 0.0.10-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild * Thu Jul 24 2025 Fedora Release Engineering - 0.0.10-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild * Sat May 31 2025 Sandro Mani - 0.0.10-2 - Pass DISABLE_LOCALE_CHARSET=ON * Sat May 03 2025 Sandro Mani - 0.0.10-1 - Update to 0.0.10 * Mon Apr 28 2025 Sandro Mani - 0.0.9-2 - Fix file conflict with mingw-libcharset * Mon Apr 21 2025 Sandro Mani - 0.0.9-1 - Update to 0.0.9 * Fri Jan 17 2025 Fedora Release Engineering - 0.0.8-14 - Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild * Thu Jul 18 2024 Fedora Release Engineering - 0.0.8-13 - Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild * Thu Jan 25 2024 Fedora Release Engineering - 0.0.8-12 - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild * Sun Jan 21 2024 Fedora Release Engineering - 0.0.8-11 - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild * Thu Jul 20 2023 Fedora Release Engineering - 0.0.8-10 - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild * Thu Jan 19 2023 Fedora Release Engineering - 0.0.8-9 - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild * Fri Mar 25 2022 Sandro Mani - 0.0.8-8 - Rebuild with mingw-gcc-12 * Thu Jan 20 2022 Fedora Release Engineering - 0.0.8-7 - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild * Thu Jul 22 2021 Fedora Release Engineering - 0.0.8-6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild * Tue Jan 26 2021 Fedora Release Engineering - 0.0.8-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild * Tue Jul 28 2020 Fedora Release Engineering - 0.0.8-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild * Wed Jan 29 2020 Fedora Release Engineering - 0.0.8-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild * Thu Jul 25 2019 Fedora Release Engineering - 0.0.8-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild * Wed Apr 17 2019 Sandro Mani - 0.0.8-1 - Update to 0.0.8 - Update upstream URLs * Fri Feb 01 2019 Fedora Release Engineering - 0.0.6-10 - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild * Fri Jul 13 2018 Fedora Release Engineering - 0.0.6-9 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild * Thu Feb 08 2018 Fedora Release Engineering - 0.0.6-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild * Wed Jul 26 2017 Fedora Release Engineering - 0.0.6-7 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild * Fri Feb 10 2017 Fedora Release Engineering - 0.0.6-6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild * Thu Feb 04 2016 Fedora Release Engineering - 0.0.6-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild * Wed Jun 17 2015 Fedora Release Engineering - 0.0.6-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild * Sat Apr 11 2015 Erik van Pienbroek - 0.0.6-3 - Stop using deprecated MinGW packaging macros * Sat Jun 07 2014 Fedora Release Engineering - 0.0.6-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild * Wed May 28 2014 Erik van Pienbroek - 0.0.6-1 - Update to 0.0.6 * Sat Aug 03 2013 Fedora Release Engineering - 0.0.4-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild * Thu Feb 14 2013 Fedora Release Engineering - 0.0.4-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild * Fri Sep 21 2012 Kalev Lember - 0.0.4-1 - Update to 0.0.4 - Drop upstreamed dllname patch * Fri Jul 20 2012 Fedora Release Engineering - 0.0.3-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild * Sat Mar 10 2012 Erik van Pienbroek - 0.0-3-7 - Added win64 support * Mon Feb 27 2012 Erik van Pienbroek - 0.0.3-6 - Rebuild against the mingw-w64 toolchain * Fri Jan 13 2012 Fedora Release Engineering - 0.0.3-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild * Wed Jul 06 2011 Kalev Lember - 0.0.3-4 - Rename the shared library to iconv.dll instead of hacking up the import library * Wed Jul 6 2011 Erik van Pienbroek - 0.0.3-3 - Make sure that the .dll.a import library refers to libiconv.dll instead of iconv.dll * Sun Jul 3 2011 Erik van Pienbroek - 0.0.3-2 - Add versioned BR for cmake >= 2.8.0 * Fri Jun 3 2011 Erik van Pienbroek - 0.0.3-1 - Update to 0.0.3 * Thu Jun 2 2011 Erik van Pienbroek - 0.0.2-3 - Moved the obsoletes/provides to the proper location - Bumped the requirement for mingw32-filesystem to >= 68 because of RPM 4.9 support - Dropped the %%defattr tags - Dropped the %%{?dist} tag from the obsoletes/provides * Thu Jun 2 2011 Erik van Pienbroek - 0.0.2-2 - Use the name mingw-win-iconv for the srpm to ease the transition to the mingw-w64 based toolchain - Use the RPM 4.9 dependency generator - Dropped unnecessary tags * Thu Feb 17 2011 Erik van Pienbroek - 0.0.2-1 - Update to version 0.0.2 - Dropped upstreamed patch - Dropped the win_iconv.exe binary - Bumped the mingw32-iconv obsoletes * Thu Sep 30 2010 Erik van Pienbroek - 0.0.1-1 - Initial release - Obsoletes/provides mingw32-iconv and mingw32-iconv-static