From: Neil Horman Date: Mon, 16 Jun 2025 20:33:22 +0000 (-0400) Subject: Add pgo build type X-Git-Tag: openssl-3.6.0-alpha1~573 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d8277a6fba7afe6155884dd1c5300dbc829638a7;p=thirdparty%2Fopenssl.git Add pgo build type One of the ways we can optimize our builds is with profile guided optimization. This entails doing several things: 1) Building with --coverage 2) Running an application against the openssl library from step (1) to generate profile data 3) rebuilding openssl using the input profile from step (2) to optimize the build. This new build configuration will let developers use the profiled data to see what type of optimizations might be possible, as well as giving end users the ability to squeeze a bit more performance out of openssl Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/27839) --- diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf index 0701b733ecb..6465651507e 100644 --- a/Configurations/10-main.conf +++ b/Configurations/10-main.conf @@ -679,7 +679,9 @@ my %targets = ( CXX => "g++", CFLAGS => picker(default => "-Wall", debug => "-O0 -g", - release => "-O3"), + release => "-O3", + profiled => "-O3 -fprofile-generate -fprofile-arcs -fprofile-values -ftest-coverage", + pgo => "-O3 -fprofile-use -Wno-missing-profile"), CXXFLAGS => picker(default => "-Wall", debug => "-O0 -g", release => "-O3"), diff --git a/Configure b/Configure index 499585438a1..ef6ba49f6bb 100755 --- a/Configure +++ b/Configure @@ -990,6 +990,10 @@ while (@argvcopy) { $config{build_type} = "debug"; } + elsif (/^-p$/) + { + $config{build_type} = "profiled"; + } elsif (/^-v$/) # From older 'config' { $guess_opts{verbose} = 1; @@ -1017,6 +1021,14 @@ while (@argvcopy) { $config{build_type} = "release"; } + elsif (/^--profiled$/) + { + $config{build_type} = "profiled"; + } + elsif (/^--pgo$/) + { + $config{build_type} = "pgo"; + } elsif (/^386$/) { $config{processor}=386; } elsif (/^rsaref$/) diff --git a/INSTALL.md b/INSTALL.md index cb54c7ea717..731144b67fd 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -335,6 +335,14 @@ Build OpenSSL with debugging symbols and zero optimization level. Build OpenSSL without debugging symbols. This is the default. + --coverage + +Build OpenSSL with gcov profiling information included + + --pgo + +Build OpenSSL optimized using gcov data obtained from --coverage build + Directories ----------- @@ -2033,6 +2041,24 @@ around the problem by forcing the build procedure to use the following script: instead of the real clang. In which case it doesn't matter what clang version is used, as it is the version of the GNU assembler that will be checked. +Notes on profile guided optimization +------------------------------------ + +Some compilers support the concept of profile guided optimization. This feature +allows a user to build openssl and use profiling data gathered while running an +application such that it can then be rebuilt in a way that is optimized specifically +for that application, increasing performance. Currently this feature is built into +the openssl build system for x86_64 only. + +1) Configure openssl with the --coverage option. This will configure the compiler to + record profiling data for the libcrypto and libssl libraries +2) Run the application(s) which you wish to optimize for, ensuring that they use + the libraries compiled in step (1) (note this may entail the use of LD_LIBRARY_PATH) +3) Clean the openssl build with make clean. Note that the profile data (the .gcda and .gcno + files are retained through the clean operation). This is intentional. +4) Configure openssl again, but this time select the --pgo build type. This will use the + profiled data to optimize code layout for the application in question. + ---