Bug 259454 - www/node: Fails to link: ld: error: undefined symbol: __atomic_is_lock_free
Summary: www/node: Fails to link: ld: error: undefined symbol: __atomic_is_lock_free
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: i386 Any
: --- Affects Some People
Assignee: Bradley T. Hughes
URL:
Keywords: needs-qa
Depends on:
Blocks:
 
Reported: 2021-10-26 06:54 UTC by Bedreddin Sahbaz
Modified: 2021-11-10 22:24 UTC (History)
2 users (show)

See Also:
bhughes: maintainer-feedback+


Attachments
0001-www-node-fix-build-of-bundled-ssl-on-i386 (2.15 KB, patch)
2021-10-27 16:17 UTC, Felix Palmen
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bedreddin Sahbaz 2021-10-26 06:54:12 UTC
I can't install www/node port. Error message;

ld: error: undefined symbol: __atomic_is_lock_free
>>> referenced by threads_pthread.c
>>>               threads_pthread:(CRYPTO_atomic_or) in archive /usr/ports/www/node/work/node-v17.0.0/out/Release/obj.target/deps/openssl/libopenssl.a
>>> referenced by threads_pthread.c
>>>               threads_pthread:(CRYPTO_atomic_load) in archive /usr/ports/www/node/work/node-v17.0.0/out/Release/obj.target/deps/openssl/libopenssl.a
c++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[3]: *** [deps/openssl/openssl-cli.target.mk:258: /usr/ports/www/node/work/node-v17.0.0/out/Release/openssl-cli] Error 1
gmake[3]: *** Waiting for unfinished jobs....
rm 45ea5d9210d9659c03236a4207678eddae27dc3a.intermediate
gmake[2]: *** [Makefile:110: node] Error 2
gmake[2]: Leaving directory '/usr/ports/www/node/work/node-v17.0.0'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/www/node
*** Error code 1

Stop.
make: stopped in /usr/ports/www/node

# uname -a
FreeBSD baki.xxxxxxxxxx.web.tr 12.2-RELEASE-p7 FreeBSD 12.2-RELEASE-p7 GENERIC  i386

Thank you..
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2021-10-27 00:44:06 UTC
 * What FreeBSD version? (uname -a)
 * Contents of /etc/make.conf (as an attachment, if not empty)
Comment 2 Bedreddin Sahbaz 2021-10-27 06:03:35 UTC
# uname -a
FreeBSD baki.xxxxxxxxxx.web.tr 12.2-RELEASE-p7 FreeBSD 12.2-RELEASE-p7 GENERIC  i386

# cat /etc/make.conf 
DEFAULT_VERSIONS=python2=2.7 python3=3.8
Comment 3 Felix Palmen freebsd_committer freebsd_triage 2021-10-27 16:17:36 UTC
Created attachment 229076 [details]
0001-www-node-fix-build-of-bundled-ssl-on-i386

This only happens on i386, not on amd64. And I assume it only happens with BUNDLED_SSL set, because the "offending" code is in the bundled OpenSSL.

As to *why* it happens, I'm currently at a loss, as this should be a compiler builtin, right? Is it somehow related to https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230888 ?

For now, I added a patch just disabling these atomic operations on i386, which is probably less then ideal. My test build is still running, but linking openssl-cli (which failed before) now worked.
Comment 4 Felix Palmen freebsd_committer freebsd_triage 2021-10-28 07:14:51 UTC
I can now confirm that www/node and some dependent ports like chromium and firefox build find on i386 with BUNDLED_SSL after adding the patch above and the one from https://bugs.freebsd.org/259377
Comment 5 John Hein 2021-10-28 17:10:53 UTC
Same here on 12.x/i386.

See also upstream bug with fix applied for mac & linux:

https://github.com/nodejs/node/issues/28231

I will try building with BUNDLED_SSL=off and DEFAULT_VERSIONS=ssl=openssl.
Comment 6 John Hein 2021-10-28 17:43:08 UTC
See also https://trac.macports.org/ticket/58695
Comment 7 commit-hook freebsd_committer freebsd_triage 2021-10-29 13:42:14 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=8de43db2771a9534f9a9d67c48c46152f2843128

commit 8de43db2771a9534f9a9d67c48c46152f2843128
Author:     Bradley T. Hughes <bhughes@FreeBSD.org>
AuthorDate: 2021-10-24 18:09:51 +0000
Commit:     Bradley T. Hughes <bhughes@FreeBSD.org>
CommitDate: 2021-10-29 13:40:45 +0000

    www/node: Update 17.0.0_1 -> 17.0.1

    https://nodejs.org/en/blog/release/v17.0.1/

    While here, update pkg-plist to allow building with the BUNDLED_SSL
    option enabled, and add the patch from PR 259454 to fix the build on
    i386.

    PR:             259454, 259377
    MFH:            2021Q4
    Sponsored by:   Miles AS

 www/node/Makefile                                  |    3 +-
 www/node/distinfo                                  |    6 +-
 ...openssl_openssl_crypto_threads__pthread.c (new) |   29 +
 www/node/pkg-plist                                 | 2446 +++++++++++++++++++-
 4 files changed, 2461 insertions(+), 23 deletions(-)
Comment 8 Felix Palmen freebsd_committer freebsd_triage 2021-10-29 13:56:04 UTC
Thanks Bradley for including my patch! But it still remains a mystery to me why this code doesn't work on i386… Do you want to analyze this further or just live with the workaround and close this PR?
Comment 9 Bedreddin Sahbaz 2021-10-29 21:45:14 UTC
I tried install node 17.0.1 and installed without any error. Thank you..

# make install
===>  Installing for node-17.0.1
===>  Checking if node is already installed
===>   Registering installation for node-17.0.1
Installing node-17.0.1...
Note: If you need npm (Node Package Manager), please install www/npm.

===> SECURITY REPORT: 
      This port has installed the following files which may act as network
      servers and may therefore pose a remote security risk to the system.
/usr/local/bin/node

      If there are vulnerabilities in these programs there may be a security
      risk to the system. FreeBSD makes no guarantee about the security of
      ports included in the Ports Collection. Please type 'make deinstall'
      to deinstall the port if this is a concern.

      For more information, and contact details about the security
      status of this software, see the following webpage: 
https://nodejs.org/