-stdlib=libc++ added to configure.cxxflags but not configure.ldflags

Rainer Müller raimue at macports.org
Tue Jan 26 09:55:54 PST 2016


On 2016-01-26 17:27, Ryan Schmidt wrote:
> I agree that MacPorts base only adds -stdlib=${configure.cxx_stdlib}
> to configure.cxxflags, not configure.ldflags, but that's not
> necessarily wrong, is it?

Actually -stdlib=libc++ is also needed for linking to ensure the
correct library will be linked in.

$ clang++ -stdlib=libc++ -o foo foo.o
$ otool -L foo
foo:
	/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.1.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

$ clang++ -stdlib=libc++ -o foo foo.o
$ otool -L foo
foo:
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)


> If the build system just wants to link
> already-compiled objects, it doesn't need compiler flags. If the
> build system wants to compile and link at the same time, it's the
> build system's responsibility to add both the compiler flags (CFLAGS
> or CXXFLAGS) and the linker flags (LDFLAGS) to the compile/link
> command.

-stdlib=... is a linker flag not for ld itself, but for the clang++ to
pass the correct library to ld.

I think this should be added to configure.ldflags in the same way it is
handled for configure.cxxflags.

Rainer


More information about the macports-dev mailing list