See libfaketime on github for upstream project site general overview.
#!/usr/bin/env bash
set -Eeuo pipefail
LIBFAKETIME_SOURCE_PATH=$PWD/libfaketime
LIBFAKETIME_INSTALL32_PREFIX=$PWD/install-x86
LIBFAKETIME_INSTALL64_PREFIX=$PWD/install-x86_64
[[ -d $LIBFAKETIME_SOURCE_PATH ]] || git clone https://github.com/wolfcw/libfaketime.git
make -C $LIBFAKETIME_SOURCE_PATH PREFIX=$LIBFAKETIME_INSTALL64_PREFIX distclean install | tee build64.log
CFLAGS="-m32" LDFLAGS="-m32" make -C $LIBFAKETIME_SOURCE_PATH PREFIX=$LIBFAKETIME_INSTALL32_PREFIX distclean install | tee build32.log
# generate scripts for shell environment
echo "export LD_PRELOAD=$LIBFAKETIME_INSTALL32_PREFIX/lib/faketime/libfaketime.so.1" > libfaketime32.env
echo "export LD_PRELOAD=$LIBFAKETIME_INSTALL64_PREFIX/lib/faketime/libfaketime.so.1" > libfaketime64.env
64-bit application in 64-bit WINEPREFIX:
$ date
Sat Oct 19 19:11:58 CEST 2019
$ (source libfaketime64.env ; FAKETIME="-1y" wine64 "c:/windows/system32/cmd.exe" /c date /t)
Current Date is 10/19/2018
32-bit application in 64-bit WINEPREFIX:
$ date
Sat Oct 19 19:11:58 CEST 2019
$ (source libfaketime32.env ; FAKETIME="-1y" wine "c:/windows/syswow64/cmd.exe" /c date /t)
Current Date is 10/19/2018
NOTE: Since Wine 7.2, libfaketime doesn't work anymore for 32-bit processes due to missing 64-bit time_t support. See my comment
Links
Thank you for this piece of cmd-fu. The 64-bit example works.
32-bit application example gives error:
Trying to use the 64-bit lib with the 32-bit command also errors but with
wrong ELF class: ELFCLASS64
instead.Wineprefix is default, 64-bit, and freshly generated just for this gist.
Using
wine64
instead ofwine
in 32-bit example does not change anything, as I would expect.Trying to use
wine
instead ofwine64
in 64-bit example also complains about ELFCLASS64, as I would expect.No issues with building.
Inspecting with
file
command claims thatwine64
andsystem32/cmd.exe
are 64-bit executables, and same for 32-bit versions.Installed wine version is 9.20
What could be the cause?