Opened 13 days ago

Closed 11 days ago

#71164 closed defect (fixed)

mpdecimal @4.0.0_1: Build failure on legacy OS X due to undefined symbols

Reported by: 0xbf00 (Jakob) Owned by: Schamschula (Marius Schamschula)
Priority: Normal Milestone:
Component: ports Version: 2.10.2
Keywords: leopard Cc:
Port: mpdecimal

Description

While trying to install python313 on an ancient Mac OS X 10.5 Leopard, the dependency mpdecimal fails to build.

According to the build logs, clang complains about undefined symbols, though checking the source code, these symbols should exist.

:info:build /opt/local/bin/clang++-mp-11 -pthread -L../libmpdec -dynamiclib -fPIC -install_name /opt/local/lib/libmpdec++.4.dylib -compatibility_version 4.0 -current_version 4.0.0 -o libmpdec++.4.0.0.dylib .objs/decimal.o -lmpdec -lm
:info:build Undefined symbols for architecture i386:
:info:build   "std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, int)", referenced from:
:info:build       decimal::Context::repr() const in decimal.o
:info:build       decimal::operator<<(std::ostream&, decimal::Context const&) in decimal.o
:info:build       decimal::operator<<(std::ostream&, decimal::Decimal const&) in decimal.o
:info:build   "std::runtime_error::runtime_error(char const*)", referenced from:
:info:build       decimal::Context::raiseit(unsigned int) in decimal.o
:info:build       __ZN7decimal11MallocErrorCI1St13runtime_errorEPKc in decimal.o
:info:build       decimal::Context::repr() const in decimal.o
:info:build       decimal::Decimal::exact(char const*, decimal::Context&) in decimal.o
:info:build       __ZN7decimal10ValueErrorCI1St13runtime_errorEPKc in decimal.o
:info:build       decimal::Decimal::ln10(long long, decimal::Context&) in decimal.o

Maybe another case of system-supplied headers interfering with building?

Attachments (1)

mpdecimal-failure.log (30.6 KB) - added by 0xbf00 (Jakob) 13 days ago.
Build log (failing)

Download all attachments as: .zip

Change History (9)

Changed 13 days ago by 0xbf00 (Jakob)

Attachment: mpdecimal-failure.log added

Build log (failing)

comment:1 Changed 13 days ago by Schamschula (Marius Schamschula)

Snow Leopard had a clean build for i386. I have no way of checking this on Leopard (my only computer with Leopard is on another continent and doesn't have MacPorts installed). I'm currently building on Sonoma and Sequoia.

Input/PRs from those running older systems is always welcome!

comment:2 Changed 13 days ago by 0xbf00 (Jakob)

At least the second symbol std::runtime_error::runtime_error(char const*) is part of the standard C++ library. I can compile a toy example program using this symbol with the same compiler used to compile mpdecimal.

comment:3 Changed 13 days ago by kencu (Ken)

possibly happening because -stdlib=macports-libstdc++ is not making it onto the link line, despite being in the CXXFLAGS.

Last edited 13 days ago by kencu (Ken) (previous) (diff)

comment:4 in reply to:  3 ; Changed 12 days ago by ryandesign (Ryan Carsten Schmidt)

Replying to Schamschula:

I have no way of checking this on Leopard

But you do have the ability on any system to verify whether the -stdlib flag is making it into the link command.

Replying to kencu:

possibly happening because -stdlib=macports-libstdc++ is not making it onto the link line, despite being in the CXXFLAGS.

Many build systems only use LDFLAGS (not CXXFLAGS) at link time. If that's the case here, options include patching the build system to add CXXFLAGS to the flags used at link time, or modifying the portfile to add the -stdlib flag to configure.ldflags such as:

if {[string match *clang* ${configure.cxx}] && ${configure.cxx_stdlib} ne ""} {
    configure.ldflags-append -stdlib=${configure.cxx_stdlib}
}

comment:5 Changed 12 days ago by Schamschula (Marius Schamschula)

./configure --help for mpdecimal has separate linker flags:

LDXX        C++ linker (default is $CXX)
LDXXFLAGS   C++ linker flags

comment:6 in reply to:  4 Changed 12 days ago by kencu (Ken)

Replying to ryandesign:

Many build systems only use LDFLAGS (not CXXFLAGS) at link time.

Some might, but it's just wrong if they do.

The link line for a CXX link should look like this:

$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $(appname) $(objects) $(LDLIBS)

comment:7 Changed 11 days ago by kencu (Ken)

this works on 10.5 Intel:

# https://trac.macports.org/ticket/71164
configure.args-append LDXXFLAGS=\"${configure.cxxflags}\"

comment:8 Changed 11 days ago by kencu (Ken)

Resolution: fixed
Status: assignedclosed

In e02a27ea2805e305da01cf3ee8c18fb0474da61f/macports-ports (master):

mpdecimal: use CXXFLAGS during link

closes: #71164

Note: See TracTickets for help on using tickets.