[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Native windows EXEs for modern GNU coreutils

From: Assaf Gordon
Subject: Native windows EXEs for modern GNU coreutils
Date: Fri, 3 May 2019 19:55:28 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1


I've built coreutils as native 64bit windows executables.

The EXE files are available here (in a zip archive):

(It will take mirrors about 24h to sync, until then you might get 404 file-not-found. To download immediately, replace "download"
with "download-mirror" in the URL server name).

For anyone using these executables: I have not checked them beyond trying "seq 20 | sort -nr" on Windows 7. So use at your own risk.

(also, downloading EXEs from the Internet is a terrible habit...)


Native windows executables are of course unsupported, but there have
been few inquires recently, and seems the only available native windows binaries are of very old versions.

The version and help screens of these executable have been modified to clearly indicate these are unsupported versions.

Below are complete building instructions.
They are mostly for minor gnulib-vs-mingw tweaks.

Comments and testing are welcomed (email to address@hidden ),
but of course don't expect any official support for these, so do not
write to bug-coreutils@ about problems.

Features that definitely won't work:
- anything requiring 'fork' ("install --strip",
  "sort --compress-program", "split --filter")
- anything using UID/GID (will show UID/GID of zero for everything).
- anything involving signals (e.g. "env --block-signals")
- "stat --file-system".
- chown, chmod, chgrp, chcon
- "tail -f"
- kill
- mkfifo
- runcon
- missing programs: timeout, df

 - assaf

Build instructions

Save the attached tarball to some local directory
and extract the tar.gz file to get the patches (3 for gnulib, 15 for coreutils).

Then run the following:

  git clone git://
  cd coreutils

  # This is the current coreutils version (8.31-28).
  # Other (future) version should also work, but not tested.
  git checkout -b mingw 7d8adb20f6bb37ab8e922cca9ea367bea078b28c

  # Fetch gnulib, checkout the needed version and initialize it

  # Patch gnulib
  cd gnulib
  git am [PATCHES DIRECTORY]/gnulib-000*.patch
  cd ..

  # Patch coreutils
  git am [PATCH DIRECTORY]/coreutils-000*.patch

  # Re-generate the m4 cache and the 'configure' file.
  # Needed because gnulib's m4/mountlist.m4 was patched to detect
  # windows' GetLogicalDrives()
  autoreconf -if

  # Flag the version string to avoid any doubts
  sed -Ei "/^PACKAGE_VERSION=/{s/(.)$/-UNSUPPORTED\1/}" configure

  # First stage, needed to build 'make-prime-list' as native executable.
  # Does coreutils support cross-compliation while building
  # 'make-prime-list' natively from git ? couldn't find a way.
  # This isn't an issue when building from tarball, as prime.h
  # is pre-packaged there.
  # src/primes.h is not cleaned, so it will remain for the next build.
  make src/primes.h

  # Now the cross-compilation configuration using mingw.
  # - random/srandom is used to override sort,shuf random functions.
  # - -Wno-error is used to disable warning-as-errors, which
  #   are enabled by default when building from git.
  #   There are lots of warnings with mingw. Some might be important...
  # - -fno-builtin ensures gcc does not include built-in definitions of
  #   things like fork(2).
  # - "-lws2_32" is used to ensure proper linking with winsock2.
  ./configure --host=x86_64-w64-mingw32 --disable-nls \
     --enable-threads=windows \
     CPPFLAGS="-Drandom=rand -Dsrandom=srand" \
     CFLAGS="-Wno-error -fno-builtin" \

  # Build executables.
  # The LIB_PTHEAD trick is from .
  # It is used to force sort(1) to be linked with STATIC threading code.
  # Otherwise, you'll get runtime abouts missing "libwinpthread-1.dll".
  # The rest of the libraries (e.g. MSVCRT.DLL) are still dynamically
  # linked. An alternative might be to use global -static.
  make SUBDIRS=. \
LIB_PTHREAD="-Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive"

Executables will be in ./src/*.exe .

Attachment: coreutils-mingw-patches.tar.gz
Description: application/gzip

reply via email to

[Prev in Thread] Current Thread [Next in Thread]