petersasi / deluge2-win-build

A set of scripts to prepare and build Deluge2 and it's prerequisites for Windows
https://github.com/petersasi/deluge2-win-build
96 stars 6 forks source link

LTO build of openssl addition. #17

Closed mhertz closed 3 years ago

mhertz commented 3 years ago

Most CPU intensive task in libtorrent is hashing I believe, through openssl presumably, so if wanted, then here's instructions for adding LTO(WPO) build of openssl to this project, and sorry if you already know it. I doubt I will add this myself, when already pre-built (non-lto)builds available, but still thinking about it. You could also ditch the CFLAGS/LDFLAGS and just use '/GL' instead, as then '/LTCG' is implied, but is just little faster building if specifically adding '/LTCG', hence I use the flags, as /LTCG cannot be added like /GL on configure line, since unknown options passed to compiler and one is for the linker. It's the default flags used for the VC-WIN64A 'release' build, just with /GL and /LTCG appended, as the flags override and not append - if wanted then remove the '/debug' from linkflags, though doesn't mean debug-build and just generates seperate pdb files with debug-symbols, not included in deluge anyway(and if removing that option, then needs some more changes, as error out during "install" for missing pdb files). There where an error when extracting from pipe through bsdtar, so I needed doing it in steps with the strawberry perl download/"install". You need adapt to your way of doing things of-course e.g. where having stuff installed/located etc. Tested working and links fine during (lto)libtorrent builds.

openssl.cmd

cd "%~dp0"
cd ..
set OUT_DIR="%cd%\OpenSSL-Win64"
set MSVC_DIR="%cd%\msvc"
set NASM_PATH="%cd%\nasm"
set PERL_PATH="%cd%\perl\perl\bin"
set MSYSPATH="%cd%\msys64\usr\bin"
set PATH=%NASM_PATH%;%PERL_PATH%;%MSYSPATH%;%PATH%
rd /s /q OpenSSL-Win64
rd /s /q OpenSSL-Win64
for /f %%i in ('git ls-remote --tags https://github.com/openssl/openssl ^| grep -E 'OpenSSL_[0-9]_[0-9]_[0-9][a-z]' ^| cut -d/ -f3 ^| tr -d "^{}"') do set var=%%i
git clone https://github.com/openssl/openssl -b %var% openssl-build\openssl
call msvc\VC\Auxiliary\Build\vcvars64.bat
cd openssl-build\openssl
perl configure VC-WIN64A --prefix=%OUT_DIR% --openssldir=%OUT_DIR% CFLAGS="/W3 /wd4090 /nologo /O2 /GL" LDFLAGS="/nologo /debug /LTCG"
nmake
nmake install
cd ..\..
rd /s /q openssl-build\openssl
rd /s /q openssl-build\openssl
copy /y OpenSSL-Win64\bin\*.dll overlay\Lib\site-packages
for /f %%i in ('dir /b deluge-2* ^| findstr /v dev') do copy /y OpenSSL-Win64\bin\*.dll %%i\Lib\site-packages
for /f %%i in ('dir /b deluge-2* ^| findstr dev') do copy /y OpenSSL-Win64\bin\*.dll %%i\Lib\site-packages

install-components.cmd:

[...]
for /f %%i in ('curl https://www.nasm.us/ ^| grep releasebuilds/[0-9] ^| cut -d^'^"^' -f2') do set var=%%i
mkdir nasm & curl -L %var%win64/nasm-%var:~42,-1%-win64.zip | bsdtar xf - --strip-components 1 -C nasm
for /f %%i in ('curl https://strawberryperl.com/ ^| grep download/[0-9] ^| cut -d/ -f3') do set var=%%i
mkdir perl & curl -O https://strawberryperl.com/download/%var%/strawberry-perl-%var%-64bit.zip
bsdtar xf strawberry-perl-%var%-64bit.zip --exclude="^c" -C perl
del strawberry-perl-%var%-64bit.zip
[...]

Edit: Just added locally on second thought, why not right... Btw, please add a 'discussion' tab to your repo if you don't mind, i.e. this should rather go there, well probably a PR would be better, but nonetheless.