Opened 4 years ago

Closed 3 weeks ago

#60773 closed defect (fixed)

chez-scheme @9.5.2: ld: warning: unexpected dylib (/opt/local/lib/libz.dylib) on link line

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: mohd-akram (Mohamed Akram)
Priority: Normal Milestone:
Component: ports Version: 2.6.2
Keywords: Cc:
Port: chez-scheme

Description

chez-scheme fails to build on 10.7 at least:

/usr/bin/clang -I/opt/local/include -m64 -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -Werror -O2 -pipe -Os -arch x86_64 -static -nostdlib -o ../boot/ta6osx/kernel.o statics.o segment.o alloc.o symbol.o intern.o gcwrapper.o gc-ocd.o gc-oce.o number.o schsig.o io.o new-io.o print.o fasl.o stats.o foreign.o prim.o prim5.o flushcache.o schlib.o thread.o expeditor.o scheme.o i3le.o -L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64 -lz -Wl,-r
ld: warning: unexpected dylib (/opt/local/lib/libz.dylib) on link line
0  0x104151098  __assert_rtn + 144
1  0x10419c682  std::__1::map<ld::File const*, ld::File::Ordinal, std::__1::less<ld::File const*>, std::__1::allocator<std::__1::pair<ld::File const* const, ld::File::Ordinal> > >::operator[](ld::File const* const&) + 0
2  0x10419c35f  ld::tool::SectionRelocationsAtom<x86_64>::sectSymNum(bool, ld::Atom const*) + 45
3  0x104191abb  ld::tool::SectionRelocationsAtom<x86_64>::encodeSectionReloc(ld::Internal::FinalSection*, ld::tool::SectionRelocationsAtom<x86_64>::Entry const&, std::__1::vector<macho_relocation_info<Pointer64<LittleEndian> >, std::__1::allocator<macho_relocation_info<Pointer64<LittleEndian> > > >&) + 77
4  0x1041b30a2  ld::tool::SectionRelocationsAtom<x86_64>::encode() + 62
5  0x104197340  ld::tool::OutputFile::updateLINKEDITAddresses(ld::Internal&) + 420
6  0x104193030  ld::tool::OutputFile::write(ld::Internal&) + 136
7  0x1041514d7  main + 713
A linker snapshot was created at:
	/tmp/kernel.o-2020-06-03-134001.ld-snapshot
ld: Assertion failed: (_machoSection != 0), function machoSection, file /SourceCache/ld64/ld64-136/src/ld/ld.hpp, line 641.
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The problem is it's trying to make a statically-linked ../boot/ta6osx/kernel.o using -static, but then it asks to link with zlib using -L/opt/local/lib and -lz, which ends up finding libz.dylib; you can't link a static object with a dynamic library. If you want to embed a copy of the zlib static library instead, use /opt/local/lib/libz.a instead of -L/opt/local/lib -lz. We frown upon linking with static libraries in a port, but I'm not sure if there's a better way given how this is building.

Change History (3)

comment:1 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

For comparison, it did build on 10.8 and later. Maybe the compiler or linker got smarter and realized that -L/opt/local/lib -lz should refer to the static library not the dynamic library if you're trying to build statically. So just making the change I suggested above may be all we need to do to get it to build on 10.7 like it does on later systems.

comment:2 Changed 4 years ago by mohd-akram (Mohamed Akram)

Seems fixed now. The new version links dynamically.

comment:3 Changed 3 weeks ago by mohd-akram (Mohamed Akram)

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.