Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#52002 closed defect (fixed)

lilypond build fails due to missing reference to libc++ on some Darwin systems - fix attached

Reported by: kenneth.f.cunningham@… Owned by: nerdling (Jeremy Lavergne)
Priority: Normal Milestone:
Component: ports Version: 2.3.4
Keywords: Cc: ryandesign (Ryan Carsten Schmidt)
Port: lilypond

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

Lily pond fails to build on Snow Leopard with the LibcxxOnOlderSystems upgrade, due to missing reference to libc++. Failed build log attached. Fix Portfile diff also attached, that add reference to libc++ on Darwin Mountain Lion and lower with configure.cxx_stdlib=libc++

Attachments (2)

main.log.zip (92.4 KB) - added by kenneth.f.cunningham@… 8 years ago.
Failed build log of original build attempt.
change-lilypond-libcxx.diff (800 bytes) - added by kenneth.f.cunningham@… 8 years ago.
Portfile fix to add libc++ reference (diff)

Download all attachments as: .zip

Change History (11)

Changed 8 years ago by kenneth.f.cunningham@…

Attachment: main.log.zip added

Failed build log of original build attempt.

Changed 8 years ago by kenneth.f.cunningham@…

Attachment: change-lilypond-libcxx.diff added

Portfile fix to add libc++ reference (diff)

comment:1 Changed 8 years ago by larryv (Lawrence Velázquez)

Cc: snc@… removed
Owner: changed from macports-tickets@… to snc@…

The check seems overzealous. Why bother with version? Just add the flag always.

platform darwin {
    if {${configure.cxx_stdlib} eq "libc++"} {
        configure.ldflags-append    "-lc++"
    }
}

comment:2 Changed 8 years ago by kenneth.f.cunningham@…

Thanks.Yes, more general version certainly fine with me, if there's no trouble with adding the reference to systems when not really needed -- was trying to be specific (perhaps overly careful). Presumably this additional library reference is not needed on platforms above mountain lion. Wasn't sure if adding it would cause trouble there. -- K

comment:3 Changed 8 years ago by nerdling (Jeremy Lavergne)

Resolution: fixed
Status: newclosed

Patched in r151452.

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

Cc: ryandesign@… added
Description: modified (diff)

Can anyone explain why -lc++ is used here instead of the more usual -stdlib=libc++?

Indeed, does this need to be specific to darwin or libc++? Why not just:

configure.ldflags-append -stdlib=${configure.cxx_stdlib}

Has anyone reported this problem to the developers of lilypond so they can fix it in their sources? MacPorts sets -stdlib=whatever in CXXFLAGS, lilypond just seems to be neglecting to use the CXXFLAGS variable when linking C++ code.

comment:5 Changed 8 years ago by kenneth.f.cunningham@…

Thanks for your observation -- lilypond uses the CXXFLAGS including -stdlib=libc++ all throughout the build, but not in the final link stage, where all the missing symbols appear, as per that attached log. will see if adding

configure.ldflags-append -stdlib=${configure.cxx_stdlib)

works to fix the final link on this system and report back. Certainly want to do this the right way from the start. -- K

Last edited 8 years ago by kenneth.f.cunningham@… (previous) (diff)

comment:6 Changed 8 years ago by kenneth.f.cunningham@…

Hi Ryan, - as you suspected, adding that line to the linker flags

configure.ldflags-append -stdlib=${configure.cxx_stdlib}

also allows lilypond to link. Without this line, the link fails. As you say, that is the more usual linker flag to add, so I'll use that from now on rather than "-lc++" (which also works, and I guess in the end does the same thing making libc++ available for linking, although admittedly less elegantly and less clearly.

I don't yet understand why it is needed for only some ports, though -- unless their configure scripts are just incorrectly / incompletely written.

Isn't it the case that libc++ should be one of the 'automatically' linked libraries, not usually needing to be specifically added? Perhaps that is what lilypond and other ports are expecting. I don't know if that's what the issue is here - some ports need this line added to link, others do not. The same port installs on a different system without modification to the portfile. Maybe with the libstdc++ and libc++ dichotomy on this libc++ upgraded machine, macports-clang-3.7++ is getting "confused" about which standard libraries to automatically link in, and is linking in the wrong one, or none?

I'm over my head at this point.

comment:7 in reply to:  6 ; Changed 8 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to kenneth.f.cunningham@…:

I don't yet understand why it is needed for only some ports, though -- unless their configure scripts are just incorrectly / incompletely written.

It would probably be their Makefiles which are incorrectly written.

Isn't it the case that libc++ should be one of the 'automatically' linked libraries, not usually needing to be specifically added? Perhaps that is what lilypond and other ports are expecting. I don't know if that's what the issue is here - some ports need this line added to link, others do not. The same port installs on a different system without modification to the portfile. Maybe with the libstdc++ and libc++ dichotomy on this libc++ upgraded machine, macports-clang-3.7++ is getting "confused" about which standard libraries to automatically link in, and is linking in the wrong one, or none?

The default C++ library would be automatically linked. libc++ isn't the default C++ library on Snow Leopard.

The other system where it worked was also using Snow Leopard?

comment:8 in reply to:  7 ; Changed 8 years ago by kenneth.f.cunningham@…

Replying to ryandesign@…:

libc++ isn't the default C++ library on Snow Leopard.

The crux of the issue. Much current software will assume libc++ is the default, and not specifically link it.

I wonder if this can be changed somewhere in the guts of the clang-3.7 linker scripts where mortals should not venture...

The other system where it worked was also using Snow Leopard?

No - one of my El Cap machines.

comment:9 in reply to:  8 Changed 8 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to kenneth.f.cunningham@…:

Replying to ryandesign@…:

libc++ isn't the default C++ library on Snow Leopard.

The crux of the issue. Much current software will assume libc++ is the default, and not specifically link it.

Certainly, much current software will assume C++11 features are available in the C++ library. That's fine. Software developers are certainly free to make that decision for their own projects. If we offer that software in MacPorts, we will use the cxx11 1.0 port group to indicate this requirement.

I wonder if this can be changed somewhere in the guts of the clang-3.7 linker scripts where mortals should not venture...

There's nothing really to be changed there. The compiler and linker must respect the operating system's choice of default C++ library, unless told to do otherwise.

The other system where it worked was also using Snow Leopard?

No - one of my El Cap machines.

Then that makes perfect sense, since El Capitan defaults to libc++.

The problem is that MacPorts informs the lilypond build system that it should use libc++, by way of adding the -stdlib=... flag to CXXFLAGS, and lilypond's build system is ignoring that request during the link step. The lilypond build system needs to be fixed to respect the value of CXXFLAGS at every step that involves C++ files.

Note: See TracTickets for help on using tickets.