Opened 2 years ago

Last modified 11 days ago

#66250 assigned defect

libunwind: Causes other ports to fail to build

Reported by: opencoff (Sudhi Herle) Owned by: jeremyhu (Jeremy Huddleston Sequoia)
Priority: Normal Milestone:
Component: ports Version: 2.8.0
Keywords: Cc: jeremyhu (Jeremy Huddleston Sequoia), nilason (Nicklas Larsson), barracuda156, fhgwright (Fred Wright), Dave-Allured (Dave Allured)
Port: libunwind

Description

xz on arm64 macbook pro (Monterey) fails to build.

configure:5920: checking whether the C compiler works
configure:5942: /usr/bin/clang -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -arch arm64 -arch x8
6_64 -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_arch
ivers_xz/xz/work/xz-5.2.7/src/liblzma/check -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.
sdk -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk 
-arch arm64 -arch x86_64 conftest.c  >&5
ld: in '/opt/local/lib/libunwind.dylib', building for macOS-x86_64 but attempting to link with file built for macOS-arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Is likely the culprit?

Attachments (1)

config.log (17.4 KB) - added by opencoff (Sudhi Herle) 2 years ago.
config.log

Download all attachments as: .zip

Change History (12)

Changed 2 years ago by opencoff (Sudhi Herle)

Attachment: config.log added

config.log

comment:1 Changed 2 years ago by jmroot (Joshua Root)

Cc: jeremyhu ryandesign added
Keywords: xz arm64 removed
Port: libunwind added
Summary: xz on M1 Pro MBP fails to buildxz fails to build with libunwind active

The libunwind port really needs to move to a separate prefix so things won't accidentally link with it like this.

comment:2 Changed 2 years ago by kencu (Ken)

the libunwind port should not install anything on 10.7+

comment:3 Changed 2 years ago by kencu (Ken)

that will break dozens of existing builds, but has to be done eventually

comment:4 Changed 13 months ago by nilason (Nicklas Larsson)

Cc: nilason added

comment:5 Changed 13 months ago by nilason (Nicklas Larsson)

I first experienced a crash of MacPort's and System's libunwind as reported with #68250.

It seems to me Xcode 15 brought changes that are causing this. With the libunwind port installed, building against libc++ the linker hooks up any binary to MacPorts' dylib making opportunistic linking for basically all C++ based ports. Something that will also cause crash in case of thrown exception. This was not the case pre-Xcode 15.

I tend to agree with Ken, to not install the port libunwind on 10.7+ (even though it is included in the system since 10.6: https://github.com/llvm/llvm-project/blob/main/libunwind/include/libunwind.h). I also believe this is quite an urgent matter, as most problems will likely appear only in runtime, for potentially any C++ based ports.

comment:6 Changed 12 months ago by nilason (Nicklas Larsson)

To illustrate the automatic linking by Xcode 15's Clang to MacPorts' libunwind, if present:

cat << EOF > /tmp/test.cpp
#include <iostream>
int main() {
    std::cout << "Hello MacPorts!";
    return 0;
}
EOF

/usr/bin/clang++ --version
echo 'With LIBRARY_PATH set to $prefix/lib:'
LIBRARY_PATH='/opt/local/lib' /usr/bin/clang++ -dynamiclib -o /tmp/test.dylib  /tmp/test.cpp
/usr/bin/otool -L /tmp/test.dylib
echo "With LIBRARY_PATH **not** set:"
/usr/bin/clang++ -dynamiclib -o /tmp/test.dylib  /tmp/test.cpp
/usr/bin/otool -L /tmp/test.dylib

Will result in

Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
With LIBRARY_PATH set to $prefix/lib:
test.dylib: 
	/tmp/test.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1600.151.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1336.0.0)
	/opt/local/lib/libunwind.1.dylib (compatibility version 1.0.0, current version 5.0.1)
With LIBRARY_PATH **not** set:
test.dylib: 
	/tmp/test.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1600.151.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1336.0.0)}}}
Last edited 12 months ago by nilason (Nicklas Larsson) (previous) (diff)

comment:7 Changed 12 months ago by nilason (Nicklas Larsson)

In 5741e9657e2fced0b576b2adc4f2e5eb1282334f/macports-ports (master):

PDAL: enable use of system libunwind, drop dependency of port

This doesn't solve the problem with Xcode 15, automatically linking to
MacPorts' libunwind, but it makes it possible to some degree avoid
installing the port in the first place.

See #68250
See #66250

comment:8 Changed 11 months ago by ryandesign (Ryan Carsten Schmidt)

Cc: barracuda156 added; ryandesign removed
Owner: set to jeremyhu
Port: xz removed
Status: newassigned
Summary: xz fails to build with libunwind activelibunwind: Causes other ports to fail to build

Has duplicate #68609.

comment:9 in reply to:  5 Changed 7 months ago by barracuda156

Replying to nilason:

I first experienced a crash of MacPort's and System's libunwind as reported with #68250.

It seems to me Xcode 15 brought changes that are causing this. With the libunwind port installed, building against libc++ the linker hooks up any binary to MacPorts' dylib making opportunistic linking for basically all C++ based ports. Something that will also cause crash in case of thrown exception. This was not the case pre-Xcode 15.

I tend to agree with Ken, to not install the port libunwind on 10.7+ (even though it is included in the system since 10.6: https://github.com/llvm/llvm-project/blob/main/libunwind/include/libunwind.h). I also believe this is quite an urgent matter, as most problems will likely appear only in runtime, for potentially any C++ based ports.

Yes, this is a problem on Sonoma, multiple ports opportunistically link to libunwind. Just one example: #68701 (but there are many more).

comment:10 Changed 11 days ago by fhgwright (Fred Wright)

Cc: fhgwright added

comment:11 Changed 11 days ago by Dave-Allured (Dave Allured)

Cc: Dave-Allured added
Note: See TracTickets for help on using tickets.