Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

darwin's stdenv bootstrap tools ship a broken libiconv.dylib #158331

Closed
veprbl opened this issue Feb 6, 2022 · 3 comments
Closed

darwin's stdenv bootstrap tools ship a broken libiconv.dylib #158331

veprbl opened this issue Feb 6, 2022 · 3 comments
Labels
0.kind: bug Something is broken 6.topic: darwin Running or building packages on Darwin 6.topic: stdenv Standard environment

Comments

@veprbl
Copy link
Member

veprbl commented Feb 6, 2022

Follow up on #158328

Steps to reproduce

nix-build pkgs/stdenv/darwin/make-bootstrap-tools.nix -A test
clang -idirafter /nix/store/widcf6mipqv5hazgwawj5hhj5xpykgmv-unpack/include-Libsystem --sysroot=/nix/store/widcf6mipqv5hazgwawj5hhj5xpykgmv-unpack -L/nix/store/widcf6mipqv5hazgwawj5hhj5xpykgmv-unpack/lib -L/private/tmp/nix-build-test.drv-0/libSystem-boot -Wl,-rpath,/nix/store/widcf6mipqv5hazgwawj5hhj5xpykgmv-unpack/lib -Wl,-v  -g -O2   -o hello src/hello.o  ./lib/libhello.a 
@(#)PROGRAM:ld  PROJECT:ld64-530
BUILD 03:37:00 Jan 17 2022
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
Library search paths:
        /nix/store/widcf6mipqv5hazgwawj5hhj5xpykgmv-unpack/lib
        /private/tmp/nix-build-test.drv-0/libSystem-boot
Framework search paths:
Undefined symbols for architecture x86_64:
  "_iconv", referenced from:
      _mem_cd_iconv in libhello.a(striconv.o)
      _str_cd_iconv in libhello.a(striconv.o)
     (maybe you meant: _str_cd_iconv, _mem_cd_iconv , _xstr_cd_iconv , _xstr_iconv , _str_iconv , _xmem_cd_iconv )
  "_iconv_close", referenced from:
      _str_iconv in libhello.a(striconv.o)
  "_iconv_open", referenced from:
      _str_iconv in libhello.a(striconv.o)
ld: symbol(s) not found for architecture x86_64
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [Makefile:2173: hello] Error 1
make[2]: Leaving directory '/private/tmp/nix-build-test.drv-0/hello-2.12'
make[1]: *** [Makefile:2496: all-recursive] Error 1
make[1]: Leaving directory '/private/tmp/nix-build-test.drv-0/hello-2.12'
make: *** [Makefile:1899: all] Error 2

Problem

The library itself doesn't contain any symbols:

nm $(nix-build pkgs/stdenv/darwin/make-bootstrap-tools.nix -A build --no-out-link)/pack/lib/libiconv.dylib
0000000000000fb0 T _dont_use_this
                 U dyld_stub_binder

It seems to rely on LC_REEXPORT_DYLIB to link to the two other libraries:

otool -l $(nix-build pkgs/stdenv/darwin/make-bootstrap-tools.nix -A build --no-out-link)/pack/lib/libiconv.dylib | grep -A6 LC_REEXPORT_DYLIB
          cmd LC_REEXPORT_DYLIB
      cmdsize 56
         name @rpath/libiconv-nocharset.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 7.0.0
compatibility version 7.0.0
Load command 9
          cmd LC_REEXPORT_DYLIB
      cmdsize 56
         name @rpath/libcharset.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 2.0.0
compatibility version 2.0.0
Load command 10

However the RPATH is not set for the library (the store path can not be known in advance). But set during the test:

export CC="clang $flags -Wl,-rpath,${unpack}/lib -Wl,-v -Wl,-sdk_version,10.10"

Perhaps this should use @origin (but would that work for linking libhello?). And/or it could be that we can get rid of libiconv from the tools.

The normal version just uses full paths:

otool -l $(nix-build -A darwin.libiconv --no-out-link)/lib/libiconv.dylib | grep -A6 LC_REEXPORT_DYLIB
          cmd LC_REEXPORT_DYLIB
      cmdsize 112
         name /nix/store/cp7cr0c6q5cl4zxmpv21xzpaj131q9n8-libiconv-50/lib/libiconv-nocharset.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 7.0.0
compatibility version 7.0.0
Load command 9
          cmd LC_REEXPORT_DYLIB
      cmdsize 104
         name /nix/store/cp7cr0c6q5cl4zxmpv21xzpaj131q9n8-libiconv-50/lib/libcharset.1.dylib (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 2.0.0
compatibility version 2.0.0
Load command 10
@veprbl veprbl added 0.kind: bug Something is broken 6.topic: darwin Running or building packages on Darwin labels Feb 6, 2022
@zowoq
Copy link
Contributor

zowoq commented Feb 7, 2022

Opened a PR with a workaround in the bootstrap tools build for now so this doesn't happen the next time someone bumps hello: #158517

@veprbl veprbl added the 6.topic: stdenv Standard environment label Sep 18, 2022
@reckenrode
Copy link
Contributor

Is this resolved by #302387?

@ghost
Copy link

ghost commented May 2, 2024

yes. i'd close the issue but do not have the necessary permissions.

@veprbl veprbl closed this as completed May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: darwin Running or building packages on Darwin 6.topic: stdenv Standard environment
Projects
None yet
Development

No branches or pull requests

3 participants