Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Oct 2013 11:37:48 GMT
From:      Harti Brandt <harti@FreeBSD.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/183297: cannot pass -stdlib=libc++ to linker
Message-ID:  <201310251137.r9PBbmit077543@oldred.freebsd.org>
Resent-Message-ID: <201310251140.r9PBe0X4088760@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         183297
>Category:       bin
>Synopsis:       cannot pass -stdlib=libc++ to linker
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 25 11:40:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Harti Brandt
>Release:        10.0-current
>Organization:
DLR
>Environment:
FreeBSD FreeBSD10 10.0-CURRENT FreeBSD 10.0-CURRENT #1 r246551M: Fri Feb  8 20:56:00 CET 2013     harti@FreeBSD10:/usr/obj/usr/svn/sys/FreeBSD10  amd64
>Description:
When building a C++ program both the compiler and link are identified as /usr/bin/CC. The compiling works fine - CC seems to be able to figure out the language from the extension. When linking, however, CC refuses the -stdlib=libc++ option. Looks like it doesn't know when parsing the command line.
>How-To-Repeat:
CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
project(test CXX)
add_executable(test test.cc)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -std=c++11")

test.cc:
int
main()
{
}

Run
cmake .
make VERBOSE=1
and observe the warning message from the linker:
CC: warning: argument unused during compilation: '-stdlib=libc++'

>Fix:
In analogy to Linux create a Platform/FreeBSD-CXX.cmake:

if(NOT CMAKE_CXX_COMPILER_NAMES)
  set(CMAKE_CXX_COMPILER_NAMES c++)
endif()

This seems to make the default c++ compiler and linker /usr/bin/c++ and the problem disappears.


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310251137.r9PBbmit077543>