Skip to content

Conversation

@jaanrebane
Copy link

The win32 builds have been using a workaround for building the openssl dependency. This breaks building x86 assembler files for unsupported architectures (32-bit linux-elf etc).

These git commits aim to solve the situation in a more inclusive way by adding an if statement to the perl script x86asm.pl that is used to create the assembler files. This way, win32 builds still get assembler files with %ifdef syntax, which is how Node has been building them so far. Official OpenSSL has #ifdef and not %ifdef in x86asm.pl.

There are actually only 2 necessary modifications:

  • tools/dep_updaters/update-openssl.sh - a perl line to rewrite x86asm.pl endbranch subroutine, not only #ifdef to %ifdef
  • documentation in doc/contributing/maintaining/maintaining-openssl.md about how to change x86asm.pl

Other changes in this pull request happen automatically after running tools/dep_updaters/update-openssl.sh regenerate:

  • deps/openssl/openssl/crypto/perlasm/x86asm.pl - changed directly from the update script
  • assembler files for non-win32 x86 get an %ifdef to #ifdef modification
  • buildinf.h files only see a DATE change
  • configdata.pm files only see a RANLIB change

The .S files that openssl creates are supposed to go through the C preprocessor before using the assembler, and cpp doesn't understand the %ifdef syntax, it needs #ifdef. Although 32-bit Linux is no longer supported, people still build for x86 linux (and maybe other x86) and the workaround for building for linux-elf has been so far to revert the %ifdef syntax back to original (openssl source) #ifdef.

In any case, if this pull request gets rejected, after Node drops support for all win32 releases, there will be no need to keep the ifdef modification, and after that, node openssl dependency will be building again for linux x86.

References:

Some sed lines were previously used to change from C-style #ifdef
to nasm-style %ifdef in x86asm.pl for 32-bit Windows builds,
but this creates problems when the C preprocessor is used before
the assembler to build x86 assembly files.

OpenSSL is using C preprocessor before nasm and uses #ifdef
in this context.

The perl line added to update-openssl.sh will work around the ifdef
issue in a way that enables building for win32 and other x86.

After update-openssl.sh script is run with "regenerate", x86asm.pl
will end up with a modified "endbranch" subroutine that allows to
use 2 types of ifdef (nasm-style %ifdef for win32 and gcc-style #ifdef
for others). Then, after x86asm.pl is run during the node openssl
build process, x86 assembly files may change their ifdef and endif
lines depending on the system they are built for.
The file deps/openssl/openssl/crypto/perlasm/x86asm.pl that is creating
assembly code for x86, now creates nasm-style %ifdef and %endif for
win32 and gcc-style #ifdef and #endif for all other x86.

A large number of files in this commit are here after re-running the
openssl update script: tools/dep_updaters/update-openssl.sh regenerate

Assembler files for non-win32 x86 get a %ifdef to #ifdef modification,
buildinf.h files only see a DATE change,
configdata.pm files only see a RANLIB change.
Using perl in not allowed from
https://github.com/nodejs/node/blob/HEAD/doc/README.md#code-blocks
although the ifdef syntax change always has been in perl. Until perl is
enabled, use text.
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/security-wg

@nodejs-github-bot nodejs-github-bot added dependencies Pull requests that update a dependency file. needs-ci PRs that need a full CI run. openssl Issues and PRs related to the OpenSSL dependency. labels Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file. needs-ci PRs that need a full CI run. openssl Issues and PRs related to the OpenSSL dependency.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants