Bug 269637 - sysutils/nix: build fails - linker issues - undefined symbols from AWS libs
Summary: sysutils/nix: build fails - linker issues - undefined symbols from AWS libs
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-17 18:49 UTC by John Hein
Modified: 2023-12-16 09:49 UTC (History)
6 users (show)

See Also:
0mp: maintainer-feedback+


Attachments
[patch] update nix to 2.13.2 - resolves aws linking issues (35.47 KB, patch)
2023-02-23 12:31 UTC, John Hein
no flags Details | Diff
[patch] update nix to 2.13.2 - resolves aws linking issues (v2) (51.01 KB, patch)
2023-02-28 21:48 UTC, John Hein
no flags Details | Diff
[patch] update nix to 2.13.2 - resolves aws linking issues (v3) (51.01 KB, patch)
2023-03-01 18:38 UTC, John Hein
no flags Details | Diff
[backtrace] i386 core dump for a 'nix flake' test (154.23 KB, text/plain)
2023-03-01 19:42 UTC, John Hein
jcfyecrayz: maintainer-approval? (bofh)
Details
[patch] update nix to 2.13.2 - resolves aws linking issues (v4) (51.47 KB, patch)
2023-10-01 19:37 UTC, John Hein
no flags Details | Diff
[patch] update nix to 2.13.2 - resolves aws linking issues (v5) (52.17 KB, patch)
2023-10-01 19:49 UTC, John Hein
no flags Details | Diff
[patch] update nix to 2.13.2 - resolves aws linking issues (v6) (52.17 KB, patch)
2023-10-01 20:13 UTC, John Hein
jcfyecrayz: maintainer-approval? (bofh)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Hein 2023-02-17 18:49:36 UTC
Trying to build sysutils/nix (2.3.11_1) in poudriere on 12.4-stable/amd64 triggers linker errors with some undefined symbols in AWS libs.

============
 .
 .
  LD     src/libstore/libnixstore.so
ld: error: undefined symbol: Aws::Crt::ByteCursorFromArray(unsigned char const*, unsigned long)
>>> referenced by DefaultEndpointProvider.h:53 (/usr/local/include/aws/core/endpoint/DefaultEndpointProvider.h:53)
>>>               src/libstore/s3-binary-cache-store.o:(Aws::Endpoint::DefaultEndpointProvider<Aws::Client::GenericClientConfiguration<true>, Aws::Endpoint::BuiltInParameters, Aws::Endpoint::ClientContextParameters>::DefaultEndpointProvider(char const*, unsigned long))
>>> referenced by DefaultEndpointProvider.h:54 (/usr/local/include/aws/core/endpoint/DefaultEndpointProvider.h:54)
>>>               src/libstore/s3-binary-cache-store.o:(Aws::Endpoint::DefaultEndpointProvider<Aws::Client::GenericClientConfiguration<true>, Aws::Endpoint::BuiltInParameters, Aws::Endpoint::ClientContextParameters>::DefaultEndpointProvider(char const*, unsigned long))
>>> referenced by DefaultEndpointProvider.h:53 (/usr/local/include/aws/core/endpoint/DefaultEndpointProvider.h:53)
>>>               src/libstore/s3-binary-cache-store.o:(Aws::Endpoint::DefaultEndpointProvider<Aws::S3::S3ClientConfiguration, Aws::S3::Endpoint::S3BuiltInParameters, Aws::S3::Endpoint::S3ClientContextParameters>::DefaultEndpointProvider(char const*, unsigned long))
>>> referenced 1 more times

ld: error: undefined symbol: Aws::Crt::ApiAllocator()
>>> referenced by DefaultEndpointProvider.h:53 (/usr/local/include/aws/core/endpoint/DefaultEndpointProvider.h:53)
>>>               src/libstore/s3-binary-cache-store.o:(Aws::Endpoint::DefaultEndpointProvider<Aws::Client::GenericClientConfiguration<true>, Aws::Endpoint::BuiltInParameters, Aws::Endpoint::ClientContextParameters>::DefaultEndpointProvider(char const*, unsigned long))
>>> referenced by DefaultEndpointProvider.h:53 (/usr/local/include/aws/core/endpoint/DefaultEndpointProvider.h:53)
>>>               src/libstore/s3-binary-cache-store.o:(Aws::Endpoint::DefaultEndpointProvider<Aws::S3::S3ClientConfiguration, Aws::S3::Endpoint::S3BuiltInParameters, Aws::S3::Endpoint::S3ClientContextParameters>::DefaultEndpointProvider(char const*, unsigned long))

ld: error: undefined symbol: Aws::Crt::Endpoints::RuleEngine::RuleEngine(aws_byte_cursor const&, aws_byte_cursor const&, aws_allocator*)
>>> referenced by DefaultEndpointProvider.h:53 (/usr/local/include/aws/core/endpoint/DefaultEndpointProvider.h:53)
>>>               src/libstore/s3-binary-cache-store.o:(Aws::Endpoint::DefaultEndpointProvider<Aws::Client::GenericClientConfiguration<true>, Aws::Endpoint::BuiltInParameters, Aws::Endpoint::ClientContextParameters>::DefaultEndpointProvider(char const*, unsigned long))
>>> referenced by DefaultEndpointProvider.h:53 (/usr/local/include/aws/core/endpoint/DefaultEndpointProvider.h:53)
>>>               src/libstore/s3-binary-cache-store.o:(Aws::Endpoint::DefaultEndpointProvider<Aws::S3::S3ClientConfiguration, Aws::S3::Endpoint::S3BuiltInParameters, Aws::S3::Endpoint::S3ClientContextParameters>::DefaultEndpointProvider(char const*, unsigned long))

ld: error: undefined symbol: Aws::Crt::Endpoints::RuleEngine::~RuleEngine()
>>> referenced by DefaultEndpointProvider.h:59 (/usr/local/include/aws/core/endpoint/DefaultEndpointProvider.h:59)
>>>               src/libstore/s3-binary-cache-store.o:(Aws::Endpoint::DefaultEndpointProvider<Aws::Client::GenericClientConfiguration<true>, Aws::Endpoint::BuiltInParameters, Aws::Endpoint::ClientContextParameters>::DefaultEndpointProvider(char const*, unsigned long))
>>> referenced by DefaultEndpointProvider.h:63 (/usr/local/include/aws/core/endpoint/DefaultEndpointProvider.h:63)
>>>               src/libstore/s3-binary-cache-store.o:(Aws::Endpoint::DefaultEndpointProvider<Aws::Client::GenericClientConfiguration<true>, Aws::Endpoint::BuiltInParameters, Aws::Endpoint::ClientContextParameters>::~DefaultEndpointProvider())
>>> referenced by DefaultEndpointProvider.h:59 (/usr/local/include/aws/core/endpoint/DefaultEndpointProvider.h:59)
>>>               src/libstore/s3-binary-cache-store.o:(Aws::Endpoint::DefaultEndpointProvider<Aws::S3::S3ClientConfiguration, Aws::S3::Endpoint::S3BuiltInParameters, Aws::S3::Endpoint::S3ClientContextParameters>::DefaultEndpointProvider(char const*, unsigned long))
>>> referenced 1 more times
c++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[1]: *** [mk/lib.mk:104: src/libstore/libnixstore.so] Error 1
gmake[1]: Leaving directory '/wrkdirs/usr/ports/sysutils/nix/work/nix-2.3.11'
===> Compilation failed unexpectedly.

============
Comment 1 John Hein 2023-02-23 12:31:51 UTC
Created attachment 240342 [details]
[patch] update nix to 2.13.2 - resolves aws linking issues

The attached patch updates nix to 2.13.2

- remove stale patches
- add new BUILD_DEPENDS & LIB_DEPENDS
- add CPUID option to optionally link with libcpuid (relevant to amd64 according to configure script)
- update (and simplify) list of files to strip (no need to strip sym links to nix)
- minor Makefile shuffling per portclippy suggestion (CPE_VENDOR line)
- update plist
Comment 2 Mateusz Piotrowski freebsd_committer freebsd_triage 2023-02-23 14:51:36 UTC
Thanks for the patch.

I cannot review the patch at the moment, but if any other committer would like to merge it, I'm alright with it.
Comment 3 John Hein 2023-02-28 21:48:32 UTC
Created attachment 240491 [details]
[patch] update nix to 2.13.2 - resolves aws linking issues (v2)

Here is an update to the previous patch to include missing deps now needed for 1.13.2, get non-default PREFIX working, and get 'make test' fully working.

In a bit more detail v2 includes the following changes missed in the previous patch:

- Add missing build deps: googletest, jq, nlohmann-json
- Add missing lib deps: USES+=libarchive
- Change HAS_CONFIGURE to GNU_CONFIGURE to get PREFIX working
- Specify GNU_CONFIGURE_MANPREFIX in share/ (matches plist) - needed after
   switch to GNU_CONFIGURE which specifies --mandir.
- Use static patches instead of REINPLACE_CMD for linux/freebsd test
   compatibility fixes (sed -i, wc -l, GNU vs BSD cmp & touch).  Some
   of these could be upstreamed.
- Fix getSelfExe for FreeBSD [[1]].  The patch for this can be
   submitted upstream.
- Update _ALL_TESTS (also see files/Makefile.regentestlist to help
   future developers when updating this port - the previous comment
   instructions for updating _ALL_TESTS do not work for 2.13.2).

QA:
 poudriere testport -P (ok - 12-stable (amd64 & i386))
 portlint, portclippy (ok)
 'make test' (ok, amd64)


[[1]] The getSelfExe() fix was noticed when the tests/flakes/flakes.sh test was run:

    error: executing 'nix': No such file or directory
    error:
           … while reading the response from the build hook

The reason is that src/libstore/build/hook-instance.c uses execv(3) which does not use PATH from the environment (like execvp(3)).  So it needs a full path to the executable.  And with the failure of getSelfExe() (before the patch), it would just use "nix" (instead of "/usr/local/bin/nix").  Hence the ENOENT failure.
Comment 4 John Hein 2023-03-01 18:38:38 UTC
Created attachment 240514 [details]
[patch] update nix to 2.13.2 - resolves aws linking issues (v3)

Minor update to patch.  I noticed that gxargs is no longer a test dependency.  That's the only change to the v3 patch (vs v2).
Comment 5 John Hein 2023-03-01 19:42:35 UTC
Created attachment 240518 [details]
[backtrace] i386 core dump for a 'nix flake' test

FYI, while 'make test' on amd64 passed, it did not on i386.  Attached is a backtrace of a core file produced by 'nix flake metadata flake1' in tests/flakes/flakes.sh

I don't necessarily think this failure on i386 is a show stopper for updating to the latest nix, it's worth noting.  I don't know if the old nix worked on i386 either (I could never build it with the latest versions dependencies - maybe it used to build on i386 with old aws-sdk-cpp, for instance?).  I'll try to dig in and find the root cause at some point.  Maybe setting TEST_BROKEN_i386 is the appropriate course of action for now.  It may be that the test failure is an indication that the tool is broken on i386 entirely.  I don't know yet.
Comment 6 John Hein 2023-05-02 17:22:27 UTC
The port is now marked broken with ports 9716c216d0b35bbae4a1946ed04506b1bc1c6f19 which did not reference this bug 269637

Also upstream is now at 2.15.0.  I will generate a new patch against the newer release when I have a chance.  But the current patch will unbreak the port and could be committed as a step to getting this port updated.
Comment 7 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2023-05-02 17:29:16 UTC
Can you share a refreshed patch based on current git tree. This patch no longer applies to the tree.
Comment 8 Marcin Cieślak 2023-05-08 00:07:08 UTC
This patch applied to me, just with -p1 with /usr/ports as the cwd
Comment 9 Marcin Cieślak 2023-05-08 00:45:12 UTC
I only had to add  ${LOCALBASE}/include/nlohmann/json.hpp:devel/nlohman
n-json to BUILD_DEPENDS to make it build on FreeBSD 14
Comment 10 John Hein 2023-10-01 19:37:07 UTC
Created attachment 245360 [details]
[patch] update nix to 2.13.2 - resolves aws linking issues (v4)

(In reply to Muhammad Moinur Rahman from comment #7)
Here's a refresh of the patch.
No functional changes from the patch as described in comment 3 and comment 4 - just re-generated against the latest ports tree.
Comment 11 John Hein 2023-10-01 19:49:29 UTC
Created attachment 245361 [details]
[patch] update nix to 2.13.2 - resolves aws linking issues (v5)

(In reply to John Hein from comment #10)
Forgot to remove BROKEN.
Comment 12 John Hein 2023-10-01 20:13:18 UTC
Created attachment 245362 [details]
[patch] update nix to 2.13.2 - resolves aws linking issues (v6)

(In reply to John Hein from comment #11)
Sigh.  Really regen against latest ports tree (missed recent PORTREVISION bump).
Comment 13 Muhammad Moinur Rahman freebsd_committer freebsd_triage 2023-10-02 04:49:00 UTC
I don't know why you asked for my approval as I am not the maintainer. But you should try these patches on a poudriere tester. There are lots of dependencies missing. I have tried to add some of the missing ones but it's going on and on. So I will stop here for now and request you to recheck this please. Take your time to solve this; there is no hurry. Just an example of what went wrong:
https://pkg.bofh.network/data/132-default/2023-10-02_06h42m09s/logs/errors/nix-2.13.2.log

Trying to build a port locally and submitting the patches is not helpful as you might be missing the dependencies which are already installed in your host.
Comment 14 takeda 2023-12-16 09:49:32 UTC
I just tried to install this port anyway so I made copy of the port and commented BROKEN= to my surprise it actually complied fine without any other changes. Perhaps the AWS sdk needed updating at the time?

nix-2.3.11_4
Name           : nix
Version        : 2.3.11_4
Installed on   : Fri Dec 15 22:36:27 2023 PST
Origin         : sysutils/nix-work
Architecture   : FreeBSD:13:amd64
Prefix         : /usr/local
Categories     : sysutils
Licenses       : LGPL21
Maintainer     : ports@FreeBSD.org
WWW            : https://nixos.org/nix/
Comment        : Purely functional package manager
Options        :
        DOCS           : off
Shared Libs required:
        libsqlite3.so.0
        libsodium.so.23
        libgc.so.1
        libeditline.so.1
        libcurl.so.4
        libbrotlienc.so.1
        libbrotlidec.so.1
        libboost_thread.so.1.83.0
        libboost_system.so.1.83.0
        libboost_context.so.1.83.0
        libaws-cpp-sdk-transfer.so
        libaws-cpp-sdk-s3.so
        libaws-cpp-sdk-core.so
Shared Libs provided:
        libnixutil.so
        libnixstore.so
        libnixmain.so
        libnixexpr.so
Annotations    :
        FreeBSD_version: 1302001
        cpe            : cpe:2.3:a:nix_project:nix:2.3.11:::::freebsd13:x64:4
Flat size      : 5.62MiB
Description    :
Nix is a purely functional package manager. This means that it treats packages
like values in purely functional programming languages such as Haskell -- they
are built by functions that don't have side-effects, and they never change
after they have been built. Nix stores packages in the Nix store, usually the
directory /nix/store, where each package has its own unique subdirectory such
as

    /nix/store/b6gvzjyb2pg0kjfwrjmg1vfhh54ad73z-firefox-33.1/

where b6gvzjyb2pg0... is a unique identifier for the package that captures all
its dependencies (it's a cryptographic hash of the package's build dependency
graph). This enables many powerful features.