Skip to content

compiler options for building OpenSSL dependency on Windows #31330

@richardlau

Description

@richardlau
  • Version: master
  • Platform: Windows
  • Subsystem: build, deps

As per #31311 (comment) it looks like gyp ignores cflags on Windows when generating for Visual Studio (msvs) so the following from our gyp files for OpenSSL are currently ignored:

'cflags': [
'-W3', '-wd4090', '-Gs0', '-GF', '-Gy', '-nologo','/O2',
],

These settings appear to mirror those in OpenSSL's own build configuration:

CFLAGS => "/W3 /wd4090 /nologo",

CFLAGS => add(picker(debug => '/Od',
release => '/O2')),
cflags => add(picker(default => '/Gs0 /GF /Gy',
debug =>
sub {
($disabled{shared} ? "" : "/MDd");
},
release =>
sub {
($disabled{shared} ? "" : "/MD");
})),

In practice we appear to be getting most of these via settings in our common.gypi. For the ones we aren't explicitly setting I don't know enough about Windows for the -Gs0 case to know if this is an issue we want to address (cc @nodejs/platform-windows).

Options we already set

-W3

from

'WarningLevel': 3, # /W3
(refs: VCCLCompilerTool.WarningLevel Property)

-GF

from

'StringPooling': 'true', # pool string literals
(refs: VCCLCompilerTool.StringPooling Property)

-Gy

from

'EnableFunctionLevelLinking': 'true',
(refs: VCCLCompilerTool.EnableFunctionLevelLinking Property)

-nologo

from

'SuppressStartupBanner': 'true',
(refs: VCCLCompilerTool.SuppressStartupBanner Property)

Options we don't currently explicitly set

-wd4090

being addressed by #31311

-Gs0

I don't know if there's a good reason that OpenSSL sets this. The MSDN docs says

/Gs0 initiates stack probes for every function call that requires storage for local variables. This can have a negative impact on performance.

/O2

We currently set

'Optimization': 3, # /Ox, full optimization
(refs: VCCLCompilerTool.Optimization Property) which maps 3 to /Ox and /Ox:

The /Ox compiler option enables the /O compiler options that favor speed. The /Ox compiler option does not include the additional /GF (Eliminate Duplicate Strings) and /Gy (Enable Function-Level Linking) options enabled by /O1 or /O2 (Minimize Size, Maximize Speed).

but we switch on /GF and /Gy via StringPooling and EnableFunctionLevelLinking above so this works out?

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildIssues and PRs related to build files or the CI.opensslIssues and PRs related to the OpenSSL dependency.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions