#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)
Change History (11)
Changed 8 years ago by kenneth.f.cunningham@…
Attachment: | main.log.zip added |
---|
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: | new → closed |
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
comment:6 follow-up: 7 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 follow-up: 8 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 follow-up: 9 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 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.
Failed build log of original build attempt.