Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#43828 closed defect (worksforme)

clang-3.4 package uses mismatched libc++ headers and libraries — at Version 3

Reported by: howarth.at.macports@… Owned by: jeremyhu@…
Priority: Normal Milestone:
Component: ports Version: 2.3.0
Keywords: Cc:
Port: clang-3.4

Description (last modified by larryv (Lawrence Velázquez))

On 10.7, I noticed that the MacPort's clang++-mp-3.4 compiler from the clang-3.4 package is using a mismatched set of libc++ headers and libraries…

% clang++-mp-3.4 -stdlib=libc++ hello.cc -v
clang version 3.4 (tags/RELEASE_34/final)
Target: x86_64-apple-darwin11.4.2
Thread model: posix
 "/opt/local/libexec/llvm-3.4/bin/clang" -cc1 -triple x86_64-apple-macosx10.7.0 -emit-obj -mrelax-all -disable-free -main-file-name hello.cc -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 136 -v -resource-dir /opt/local/libexec/llvm-3.4/bin/../lib/clang/3.4 -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/howarth -ferror-limit 19 -fmessage-length 125 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.7.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o /var/folders/b8/ybr6czsd73s1qds_6bh5v0v80000gn/T/hello-8467e9.o -x c++ hello.cc
clang -cc1 version 3.4 based upon LLVM 3.4 default target x86_64-apple-darwin11.4.2
ignoring nonexistent directory "/usr/include/c++/v1"
ignoring nonexistent directory "/usr/local/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/local/libexec/llvm-3.4/bin/../include/c++/v1
 /opt/local/libexec/llvm-3.4/bin/../lib/clang/3.4/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
 "/opt/local/libexec/llvm-3.4/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.7.0 -o a.out -lcrt1.10.6.o /var/folders/b8/ybr6czsd73s1qds_6bh5v0v80000gn/T/hello-8467e9.o -lc++ -lSystem /opt/local/libexec/llvm-3.4/bin/../lib/clang/3.4/lib/darwin/libclang_rt.osx.a

% otool -L ./a.out
./a.out:
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 28.4.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)

So the newer libc++ 3.4.1 headers stored in /opt/local/libexec/llvm-3.4/include are being used the much older system libc++…

% otool -L /usr/lib/libc++.1.dylib
/usr/lib/libc++.1.dylib:
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 28.4.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
	/usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 14.0.0)

We fixed this on fink by adding…

        # Adjust path for relocation of libc++ headers
        if test "$darwin_vers" -ge 13
                then sed -i.orig2 -e 's|AddPath("/usr/include/c++/v1"|AddPath("/Library/Developer/CommandLineTools/usr/lib/c++/v1"|' \
                        tools/clang/lib/Frontend/InitHeaderSearch.cpp
        elif test "$darwin_vers" -ge 11
                then sed -i.orig2 -e 's|AddPath("/usr/include/c++/v1"|AddPath("/usr/lib/c++/v1"|' \
                        tools/clang/lib/Frontend/InitHeaderSearch.cpp
        fi

so clang-3.4 in MacPorts needs something like…

if {${os.major} > 12} {
    post-patch {
      reinplace "s|AddPath(\"/usr/include/c++/v1\"|AddPath(\"/Library/Developer/CommandLineTools/usr/lib/c++/v1\"|" ${worksrcpath}/tools/clang/lib/Frontend/InitHeaderSearch.cpp
    }
elseif {${os.major} > 10} {
    post-patch {
      reinplace "s|AddPath(\"/usr/include/c++/v1\"|AddPath(\"/usr/lib/c++/v1\"|" ${worksrcpath}/tools/clang/lib/Frontend/InitHeaderSearch.cpp
   }
}

As you can see from the verbose output of clang-3.4 at the beginning of this report…

ignoring nonexistent directory "/usr/include/c++/v1"

…the stock sources default to a /usr/include/c++/v1 directory which Apple has never used instead of /usr/lib/c++/v1 on 10.7/10.8 and /Library/Developer/CommandLineTools/usr/lib/c++/v1 on 10.9.

Change History (3)

comment:1 Changed 10 years ago by mf2k (Frank Schima)

Cc: jeremyhu@… removed
Keywords: lang removed
Owner: changed from macports-tickets@… to jeremyhu@…

comment:2 Changed 10 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Resolution: worksforme
Status: newclosed

Yes. This is by design.

comment:3 Changed 10 years ago by larryv (Lawrence Velázquez)

Description: modified (diff)
Note: See TracTickets for help on using tickets.