Opened 12 months ago

Last modified 7 months ago

#68409 assigned defect

libgit2 1.7.1 build failure at link time: undefined symbol libiconv — at Version 3

Reported by: jrabinow Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.8.1
Keywords: Cc: dbevans (David B. Evans), mascguy (Christopher Nielsen)
Port: libgit2

Description (last modified by ryandesign (Ryan Carsten Schmidt))

Attempting to build libgit2 fails:

info:build ld: Undefined symbols:
:info:build   _libiconv, referenced from:
:info:build       _git_fs_path_iconv in fs_path.c.o
:info:build       _unicode_iconv_encoding_convert in unicode_iconv.c.o
:info:build   _libiconv_close, referenced from:
:info:build       _git_fs_path_direach in fs_path.c.o
:info:build       _git_fs_path_iconv_clear in fs_path.c.o
:info:build       _git_fs_path_diriter_free in fs_path.c.o
:info:build       _git_fs_path_dirload in fs_path.c.o
:info:build       _ntlm_unicode_shutdown in unicode_iconv.c.o
:info:build       _ntlm_unicode_shutdown in unicode_iconv.c.o
:info:build   _libiconv_open, referenced from:
:info:build       _git_fs_path_direach in fs_path.c.o
:info:build       _git_fs_path_iconv_init_precompose in fs_path.c.o
:info:build       _git_fs_path_diriter_init in fs_path.c.o
:info:build       _ntlm_unicode_init in unicode_iconv.c.o
:info:build       _ntlm_unicode_init in unicode_iconv.c.o
:info:build clang: error: linker command failed with exit code 1 (use -v to see invocation)

Digging deeper, it fails at exactly this part of the build process:

cd /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libgit2/libgit2/work/build/tests/libgit2 && /opt/local/bin/cmake -E cmake_link_script CMakeFiles/libgit2_tests.dir/link.txt --verbose=ON

I tried manually adding variations of -l /opt/local/lib/libiconv.dylib (-l libiconv.dylib, -l libiconv) to CMakeFiles/libgit2_tests.dir/link.txt without success:

/opt/local/bin/cmake -E cmake_link_script CMakeFiles/libgit2_tests.dir/link.txt --verbose=ON -v
ld: library '/opt/local/lib/libiconv.dylib' not found

This one is quite surprising, because libiconv is installed on my system:

$ port installed libiconv
The following ports are currently installed:
  libiconv @1.17_0+universal (active)
$ file /opt/local/lib/libiconv.*
/opt/local/lib/libiconv.2.dylib: Mach-O universal binary with 2 architectures: [x86_64:\012- Mach-O 64-bit x86_64 dynamically linked shared library, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|NO_REEXPORTED_DYLIBS>] [\012- arm64:\012- Mach-O 64-bit arm64 dynamically linked shared library, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|NO_REEXPORTED_DYLIBS>]
/opt/local/lib/libiconv.a:       Mach-O universal binary with 2 architectures: [x86_64:\012- current ar archive random library] [\012- arm64:\012- current ar archive random library]
/opt/local/lib/libiconv.dylib:   symbolic link to libiconv.2.dylib

I thought it might be related to the recent change [abd25f7f4a164c7ab2a8a8146fcbd746f45035a0/macports-ports], reverting that commit didn't seem to affect anything.

macOS 14.0 23A344 arm64
Xcode 15.0 15A240d

Change History (5)

Changed 12 months ago by jrabinow

Attachment: main.log added

build log

Changed 12 months ago by jrabinow

Attachment: cmake_manual_invocation.txt added

manual invocation of cmake: trace

comment:1 Changed 12 months ago by jrabinow

I just went back and looked at old tickets I had created. By complete chance, I'd created #66931 a few months back, and bnoctis was kind enough to provide a solution which I just tested and works.

I've created a PR at https://github.com/macports/macports-ports/pull/20805

Last edited 12 months ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:2 Changed 12 months ago by jrabinow

Would it make sense to leave this ticket open until we can explain why libgit2 builds on the build bots but not on some people's personal laptops?

comment:3 Changed 12 months ago by ryandesign (Ryan Carsten Schmidt)

Description: modified (diff)
Note: See TracTickets for help on using tickets.