From ac75aab32321a1c4f469018d9b3596fd89f5bf14 Mon Sep 17 00:00:00 2001 From: Christian Andersen Date: Tue, 9 Apr 2024 21:39:21 +0200 Subject: Remove the dist-win compilation script With the CMake version of building for windows there is support for building with MINGW, clang, and Visual Studio. CMake can build for MINGW using the regular method of autogen and CMake. Removing this makes it a bit simpler to get an overview of how to build for windows. Reducing confusion. --- README.windows | 22 ---------------------- dist-win.sh | 48 ------------------------------------------------ 2 files changed, 70 deletions(-) delete mode 100755 dist-win.sh diff --git a/README.windows b/README.windows index 4d74a2e..2d342fa 100644 --- a/README.windows +++ b/README.windows @@ -41,25 +41,3 @@ use the new ABI. 64-bit systems always have a 64-bit time_t and are not affected by this problem. - -# Using Libressl with Visual Studio - -A script for generating ready-to-use .DLL and static .LIB files is included in -the source repository at -https://github.com/libressl/portable/blob/master/dist-win.sh - -This script uses mingw-w64 to build LibreSSL and then uses Visual Studio tools -to generate compatible library import files ready-to-use with Visual -Studio projects. Static and dynamic libraries are included. The script uses -cv2pdb to generate Visual Studio and windbg compatible debug files. cv2pdb is a -tool developed for the D language and can be found here: -https://github.com/rainers/cv2pdb - -The mingw-w64 code is largely, but not 100%, compatible with code built from -Visual Studio. Notably, FILE * pointers cannot be shared between code built for -Mingw-w64 and Visual Studio. - -As of LibreSSL 2.2.2, Visual Studio Native builds can also be produced using -CMake. This produces ABI-compatible libraries for linking with native code -generated by Visual Studio. Currently tested versions are VS 2019 and 2022, -though earlier versions may work as well. diff --git a/dist-win.sh b/dist-win.sh deleted file mode 100755 index e4e0fd0..0000000 --- a/dist-win.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -set -e -#set -x - -export PATH=/cygdrive/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio\ 12.0/VC/bin:$PATH -VERSION=`cat VERSION` -DIST=libressl-$VERSION-windows - -rm -fr $DIST -mkdir -p $DIST -autoreconf -i - -for ARCH in X86 X64; do - - if [ $ARCH = X86 ]; then - HOST=i686-w64-mingw32 - ARCHDIR=x86 - else - HOST=x86_64-w64-mingw32 - ARCHDIR=x64 - fi - - echo Building for $HOST - - CC=$HOST-gcc ./configure --host=$HOST --with-openssldir=c:/libressl/ssl - make clean - PATH=$PATH:/usr/$HOST/sys-root/mingw/bin \ - make -j 4 check - make -j 4 install DESTDIR=`pwd`/stage-$ARCHDIR - - mkdir -p $DIST/$ARCHDIR - if [ ! -e $DIST/include ]; then - cp -r stage-$ARCHDIR/usr/local/include $DIST - fi - - cp stage-$ARCHDIR/usr/local/bin/* $DIST/$ARCHDIR - - for i in libcrypto libssl libtls; do - DLL=$(basename `ls -1 $DIST/$ARCHDIR/$i*.dll`|cut -d. -f1) - echo EXPORTS > $DLL.def - dumpbin /exports $DIST/$ARCHDIR/$DLL.dll | \ - awk '{print $4}' | awk 'NF' |tail -n +9 >> $DLL.def - lib /MACHINE:$ARCH /def:$DLL.def /out:$DIST/$ARCHDIR/$DLL.lib - cv2pdb $DIST/$ARCHDIR/$DLL.dll - done -done - -zip -r $DIST.zip $DIST -- cgit v1.2.3-55-g6feb From ad6e77ca9fe3da77a23b6b89e9678c92663c9cc8 Mon Sep 17 00:00:00 2001 From: Christian Andersen Date: Tue, 9 Apr 2024 21:44:41 +0200 Subject: Rename README.windows to README.mingw.md Since it is mingw specific and does not really involve other compilers. --- Makefile.am | 2 +- README.md | 2 +- README.mingw.md | 43 +++++++++++++++++++++++++++++++++++++++++++ README.windows | 43 ------------------------------------------- m4/check-os-options.m4 | 2 +- 5 files changed, 46 insertions(+), 46 deletions(-) create mode 100644 README.mingw.md delete mode 100644 README.windows diff --git a/Makefile.am b/Makefile.am index 2edef0d..3f62cd9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -10,7 +10,7 @@ if !ENABLE_LIBTLS_ONLY pkgconfig_DATA += libcrypto.pc libssl.pc openssl.pc endif -EXTRA_DIST = README.md README.windows VERSION config scripts +EXTRA_DIST = README.md README.mingw.md VERSION config scripts EXTRA_DIST += CMakeLists.txt cmake_export_symbol.cmake cmake_uninstall.cmake.in FindLibreSSL.cmake LibreSSLConfig.cmake.in EXTRA_DIST += cert.pem openssl.cnf x509v3.cnf diff --git a/README.md b/README.md index ab159ab..9c07175 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ make LibreSSL builds against relatively recent versions of Mingw-w64, not to be confused with the original mingw.org project. Mingw-w64 3.2 or later -should work. See README.windows for more information +should work. See README.mingw.md for more information. #### Windows - Visual Studio diff --git a/README.mingw.md b/README.mingw.md new file mode 100644 index 0000000..7c567bc --- /dev/null +++ b/README.mingw.md @@ -0,0 +1,43 @@ +## Building with mingw-w64 for 32- and 64-bit + +For Windows systems, LibreSSL supports the mingw-w64 toolchain, which can use +GCC or Clang as the compiler. Contrary to its name, mingw-w64 supports both +32-bit and 64-bit build environments. If your project already uses mingw-w64, +then LibreSSL should integrate very nicely. Old versions of the mingw-w64 +toolchain, such as the one packaged with Ubuntu 12.04, may have trouble +building LibreSSL. Please try it with a recent toolchain if you encounter +troubles. Cygwin provides an easy method of installing the latest mingw-w64 +cross compilers on Windows. + +To configure and build LibreSSL for a 32-bit system, use the following +build steps: + + CC=i686-w64-mingw32-gcc CPPFLAGS=-D__MINGW_USE_VC2005_COMPAT \ + ./configure --host=i686-w64-mingw32 + make + make check + +For 64-bit builds, use these instead: + + CC=x86_64-w64-mingw32-gcc ./configure --host=x86_64-w64-mingw32 + make + make check + +### Why the -D__MINGW_USE_VC2005_COMPAT flag on 32-bit systems? + +An ABI change introduced with Microsoft Visual C++ 2005 (also known as +Visual C++ 8.0) switched time_t from 32-bit to 64-bit. It is important to +build LibreSSL with 64-bit time_t whenever possible, because 32-bit time_t +is unable to represent times past 2038 (this is commonly known as the +Y2K38 problem). + +If LibreSSL is built with 32-bit time_t, when verifying a certificate whose +expiry date is set past 19 January 2038, it will be unable to tell if the +certificate has expired or not, and thus take the safe stance and reject it. + +In order to avoid this, you need to build LibreSSL (and everything that links +with it) with the -D__MINGW_USE_VC2005_COMPAT flag. This tells mingw-w64 to +use the new ABI. + +64-bit systems always have a 64-bit time_t and are not affected by this +problem. diff --git a/README.windows b/README.windows deleted file mode 100644 index 2d342fa..0000000 --- a/README.windows +++ /dev/null @@ -1,43 +0,0 @@ -# Building - -For Windows systems, LibreSSL supports the mingw-w64 toolchain, which can use -GCC or Clang as the compiler. Contrary to its name, mingw-w64 supports both -32-bit and 64-bit build environments. If your project already uses mingw-w64, -then LibreSSL should integrate very nicely. Old versions of the mingw-w64 -toolchain, such as the one packaged with Ubuntu 12.04, may have trouble -building LibreSSL. Please try it with a recent toolchain if you encounter -troubles. Cygwin provides an easy method of installing the latest mingw-w64 -cross compilers on Windows. - -To configure and build LibreSSL for a 32-bit system, use the following -build steps: - - CC=i686-w64-mingw32-gcc CPPFLAGS=-D__MINGW_USE_VC2005_COMPAT \ - ./configure --host=i686-w64-mingw32 - make - make check - -For 64-bit builds, use these instead: - - CC=x86_64-w64-mingw32-gcc ./configure --host=x86_64-w64-mingw32 - make - make check - -# Why the -D__MINGW_USE_VC2005_COMPAT flag on 32-bit systems? - -An ABI change introduced with Microsoft Visual C++ 2005 (also known as -Visual C++ 8.0) switched time_t from 32-bit to 64-bit. It is important to -build LibreSSL with 64-bit time_t whenever possible, because 32-bit time_t -is unable to represent times past 2038 (this is commonly known as the -Y2K38 problem). - -If LibreSSL is built with 32-bit time_t, when verifying a certificate whose -expiry date is set past 19 January 2038, it will be unable to tell if the -certificate has expired or not, and thus take the safe stance and reject it. - -In order to avoid this, you need to build LibreSSL (and everything that links -with it) with the -D__MINGW_USE_VC2005_COMPAT flag. This tells mingw-w64 to -use the new ABI. - -64-bit systems always have a 64-bit time_t and are not affected by this -problem. diff --git a/m4/check-os-options.m4 b/m4/check-os-options.m4 index 77edd14..3775b79 100644 --- a/m4/check-os-options.m4 +++ b/m4/check-os-options.m4 @@ -145,7 +145,7 @@ if test "$ac_cv_sizeof_time_t" = "4"; then if test "$host_os" = "mingw32" ; then echo " **" echo " ** You can solve this by adjusting the build flags in your" - echo " ** mingw-w64 toolchain. Refer to README.windows for details." + echo " ** mingw-w64 toolchain. Refer to README.mingw.md for details." fi fi -- cgit v1.2.3-55-g6feb From 937a3d920ead4c5a8bff162bbc719f39208988ee Mon Sep 17 00:00:00 2001 From: Christian Andersen Date: Tue, 9 Apr 2024 22:14:04 +0200 Subject: Try to simplify build instruction. In particular simplify the Windows build instructions, by only having a short CMake section about it. While mentioning that bash shell is required also on Windows up-front. Splits the build section into a section for configure and one for CMake so it is easier to pick one of them. Moves the additional CMake options into the CMake section. Moves dist.sh text into the configure section as it is configure specific. --- README.md | 96 ++++++++++++++++++++++++++------------------------------- README.mingw.md | 16 +++++----- 2 files changed, 52 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index 9c07175..b4fff87 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ LibreSSL also supports the following Windows environments: * Microsoft Windows (Windows 7 / Windows Server 2008r2 or later, x86 and x64) * Wine (32-bit and 64-bit) -* Mingw-w64, Cygwin, and Visual Studio +* MinGW-w64, Cygwin, and Visual Studio Official release tarballs are available at your friendly neighborhood OpenBSD mirror in directory @@ -68,27 +68,24 @@ sent to the core team at libressl-security@openbsd.org. # Building LibreSSL -## Prerequisites when building from a Git checkout +## Building from a Git checkout -If you have checked this source using Git, or have downloaded a source tarball -from GitHub, follow these initial steps to prepare the source tree for +If you have checked out this source using Git, or have downloaded a source +tarball from GitHub, follow these initial steps to prepare the source tree for building. _Note: Your build will fail if you do not follow these instructions! -If you cannot follow these instructions (e.g. Windows system using CMake) or -cannot meet these prerequistes, please download an official release distribution -from https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/ instead. Using official +If you cannot follow these instructions or cannot meet these prerequisites, +please download an official release distribution from +https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/ instead. Using official releases is strongly advised if you are not a developer._ -1. Ensure you have the following packages installed: - automake, autoconf, git, libtool, perl -2. Run `./autogen.sh` to prepare the source tree for building or - run `./dist.sh` to prepare a tarball. +1. Ensure that you have a bash shell. This is also required on Windows. +2. Ensure that you have the following packages installed: + automake, autoconf, git, libtool, perl. +3. Run `./autogen.sh` to prepare the source tree for building. -## Steps that apply to all builds +## Build steps using configure -Once you have a source tree, either by downloaded using git and having -run the `autogen.sh` script above, or by downloading a release distribution from -an OpenBSD mirror, run these commands to build and install the package on most -systems: +Once you have the source tree prepared, run these commands to build and install: ```sh ./configure # see ./configure --help for configuration options @@ -96,7 +93,11 @@ make check # runs builtin unit tests make install # set DESTDIR= to install to an alternate location ``` -If you wish to use the CMake build system, use these commands: +Alternatively, it is possible to run `./dist.sh` to prepare a tarball. + +## Build steps using CMake + +Once you have the source tree prepared, run these commands to build and install: ```sh mkdir build @@ -106,7 +107,7 @@ make make test ``` -For faster builds, you can use Ninja as well: +For faster builds, you can use Ninja: ```sh mkdir build-ninja @@ -116,44 +117,15 @@ ninja ninja test ``` -### OS specific build information - -#### HP-UX (11i) - -Set the UNIX_STD environment variable to `2003` before running `configure` -in order to build with the HP C/aC++ compiler. See the "standards(5)" man -page for more details. - -```sh -export UNIX_STD=2003 -./configure -make -``` - -#### Windows - Mingw-w64 - -LibreSSL builds against relatively recent versions of Mingw-w64, not to be -confused with the original mingw.org project. Mingw-w64 3.2 or later -should work. See README.mingw.md for more information. - -#### Windows - Visual Studio - -LibreSSL builds using the CMake target "Visual Studio 12 2013" and newer. To -generate a Visual Studio project, install CMake, enter the LibreSSL source -directory and run: +Or another supported build system like Visual Studio: ```sh -./update.sh -mkdir build-vs2013 -cd build-vs2013 -cmake -G"Visual Studio 12 2013" .. +mkdir build-vs2022 +cd build-vs2022 +cmake -G"Visual Studio 17 2022" .. ``` -Replace "Visual Studio 12 2013" with whatever version of Visual Studio you -have installed. This will generate a LibreSSL.sln file that you can incorporate -into other projects or build by itself. - -#### CMake - Additional Options +#### Additional CMake Options | Option Name | Default | Description | |-------------------------|--------:|-----------------------------------------------------------------------------------------------------------------| @@ -166,6 +138,26 @@ into other projects or build by itself. | `ENABLE_NC` | `OFF` | Enable installing TLS-enabled nc(1) | | `OPENSSLDIR` | Blank | Set the default openssl directory. Can be specified from command line using
```-DOPENSSLDIR=``` | +## Build information for specific systems + +### HP-UX (11i) + +Set the UNIX_STD environment variable to `2003` before running `configure` +in order to build with the HP C/aC++ compiler. See the "standards(5)" man +page for more details. + +```sh +export UNIX_STD=2003 +./configure +make +``` + +### MinGW-w64 - Windows + +LibreSSL builds against relatively recent versions of [MinGW-w64](https://www.mingw-w64.org/), not to be +confused with the original mingw.org project. MinGW-w64 3.2 or later +should work. See [README.mingw.md](README.mingw.md) for more information. + # Using LibreSSL ## CMake diff --git a/README.mingw.md b/README.mingw.md index 7c567bc..a90de5f 100644 --- a/README.mingw.md +++ b/README.mingw.md @@ -1,13 +1,13 @@ -## Building with mingw-w64 for 32- and 64-bit +## Building with MinGW-w64 for 32- and 64-bit -For Windows systems, LibreSSL supports the mingw-w64 toolchain, which can use -GCC or Clang as the compiler. Contrary to its name, mingw-w64 supports both -32-bit and 64-bit build environments. If your project already uses mingw-w64, -then LibreSSL should integrate very nicely. Old versions of the mingw-w64 +For Windows systems, LibreSSL supports the MinGW-w64 toolchain, which can use +GCC or Clang as the compiler. Contrary to its name, MinGW-w64 supports both +32-bit and 64-bit build environments. If your project already uses MinGW-w64, +then LibreSSL should integrate very nicely. Old versions of the MinGW-w64 toolchain, such as the one packaged with Ubuntu 12.04, may have trouble building LibreSSL. Please try it with a recent toolchain if you encounter -troubles. Cygwin provides an easy method of installing the latest mingw-w64 -cross compilers on Windows. +troubles. Cygwin provides an easy method of installing the latest MinGW-w64 +cross-compilers on Windows. To configure and build LibreSSL for a 32-bit system, use the following build steps: @@ -36,7 +36,7 @@ expiry date is set past 19 January 2038, it will be unable to tell if the certificate has expired or not, and thus take the safe stance and reject it. In order to avoid this, you need to build LibreSSL (and everything that links -with it) with the -D__MINGW_USE_VC2005_COMPAT flag. This tells mingw-w64 to +with it) with the -D__MINGW_USE_VC2005_COMPAT flag. This tells MinGW-w64 to use the new ABI. 64-bit systems always have a 64-bit time_t and are not affected by this -- cgit v1.2.3-55-g6feb