Bug 238556 - lang/rust 1.35.0 fails to build: CXX compiler: /usr/bin/clang++ -- broken
Summary: lang/rust 1.35.0 fails to build: CXX compiler: /usr/bin/clang++ -- broken
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: FreeBSD Rust Team
URL:
Keywords: needs-qa
Depends on:
Blocks:
 
Reported: 2019-06-14 05:15 UTC by Matthias Apitz
Modified: 2019-06-17 13:36 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (rust)


Attachments
pudriere build log of lang/rust (98.37 KB, text/plain)
2019-06-14 05:21 UTC, Matthias Apitz
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Apitz 2019-06-14 05:15:34 UTC

    
Comment 1 Matthias Apitz 2019-06-14 05:20:29 UTC
I'm building ports with poudriere on FreeBSD 13.0-CURRENT r342378 with ports tree from June, 10. The build fails with

...
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- broken
CMake Error at /usr/local/share/cmake/Modules/CMakeTestCXXCompiler.cmake:53 (message):
  The C++ compiler

    "/usr/bin/clang++"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /wrkdirs/usr/ports/lang/rust/work/rustc-1.35.0-src/build/x86_64-unknown-freebsd/llvm/build/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/local/bin/gmake cmTC_359c5/fast
    gmake[1]: Entering directory '/wrkdirs/usr/ports/lang/rust/work/rustc-1.35.0-src/build/x86_64-unknown-freebsd/llvm/build/CMakeFiles/CMakeTmp'
    /usr/local/bin/gmake -f CMakeFiles/cmTC_359c5.dir/build.make CMakeFiles/cmTC_359c5.dir/build
    gmake[2]: Entering directory '/wrkdirs/usr/ports/lang/rust/work/rustc-1.35.0-src/build/x86_64-unknown-freebsd/llvm/build/CMakeFiles/CMakeTmp'
    Building CXX object CMakeFiles/cmTC_359c5.dir/testCXXCompiler.cxx.o
    /usr/bin/clang++    -ffunction-sections -fdata-sections -fPIC --target=x86_64-unknown-freebsd    -o CMakeFiles/cmTC_359c5.dir/testCXXCompiler.cxx.o -c /wrkdirs/usr/ports/lang/rust/work/rustc-1.35.0-src/build/x86_64-unknown-freebsd/llvm/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
    Linking CXX executable cmTC_359c5
    /usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_359c5.dir/link.txt --verbose=1
    /usr/bin/clang++  -ffunction-sections -fdata-sections -fPIC --target=x86_64-unknown-freebsd     CMakeFiles/cmTC_359c5.dir/testCXXCompiler.cxx.o  -o cmTC_359c5
    ld: error: unable to find library -lstdc++
    clang++: error: linker command failed with exit code 1 (use -v to see invocation)
    gmake[2]: *** [CMakeFiles/cmTC_359c5.dir/build.make:87: cmTC_359c5] Error 1
    gmake[2]: Leaving directory '/wrkdirs/usr/ports/lang/rust/work/rustc-1.35.0-src/build/x86_64-unknown-freebsd/llvm/build/CMakeFiles/CMakeTmp'
    gmake[1]: *** [Makefile:121: cmTC_359c5/fast] Error 2
    gmake[1]: Leaving directory '/wrkdirs/usr/ports/lang/rust/work/rustc-1.35.0-src/build/x86_64-unknown-freebsd/llvm/build/CMakeFiles/CMakeTmp'
...

I will attach the complete log.
Comment 2 Matthias Apitz 2019-06-14 05:21:22 UTC
Created attachment 205053 [details]
pudriere build log of lang/rust
Comment 3 mikael.urankar 2019-06-14 11:03:50 UTC
(In reply to Matthias Apitz from comment #1)
Why do you modify CC, CXX?

/usr/local/etc/poudriere.d/freebsd-r342378-make.conf
CC=clang             # Highly recommended over GCC,
CXX=clang++          # but only needed for 8.X and 9.X
CPP=clang-cpp        # since it's the default in 10.0
Comment 4 Tobias Kortkamp freebsd_committer 2019-06-14 12:12:15 UTC
(In reply to Matthias Apitz from comment #1)
> I'm building ports with poudriere on FreeBSD 13.0-CURRENT r342378 with ports
> tree from June, 10.

r342378 is ~6 months old at this point.  You should update ASAP.

Given the error message, can you compile any other C++ based port?

Or in the Poudriere build jail does

$ echo 'int main() {}' | clang++ -x c++ - && ./a.out

even work?
Comment 5 Matthias Apitz 2019-06-14 12:29:19 UTC
(In reply to mikael.urankar from comment #3)

I think I do not modify the CC, ... I just mention the defaults.
Comment 6 Matthias Apitz 2019-06-14 12:35:04 UTC
(In reply to Tobias Kortkamp from comment #4)

I've built with this jail and port checkout ~1800 ports. I don't know how many use clang++, but for example this one:
...
=======================<phase: configure      >============================
===>  Configuring for kf5-purpose-5.58.0
===>  Performing out-of-source build
/bin/mkdir -p /wrkdirs/usr/ports/misc/kf5-purpose/work/.build
-- The C compiler identification is Clang 7.0.1
-- The CXX compiler identification is Clang 7.0.1
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
...

In this case here, the real problem is;

      ld: error: unable to find library -lstdc++

why it is missing libstdc++?
Comment 7 Tobias Kortkamp freebsd_committer 2019-06-14 13:53:00 UTC
The problem can be reproduced with just

$ clang++ --target=x86_64-unknown-freebsd /dev/null
ld: error: unable to find library -lstdc++
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Looks like clang defaults to using libstdc++ with
--target=x86_64-unknown-freebsd.

Why Rust decides to add --target with CXX=clang++ I do not know.
It does not happen with CXX=c++ (see [1] for comparison).

I recommend you stop setting CC, CXX, CPP in make.conf to non-default
values for now.  There is no benefit to setting them to /usr/bin/clang
etc. anyway.

[1]  http://beefy12.nyi.freebsd.org/data/head-amd64-default/p503933_s348887/logs/rust-1.35.0.log
Comment 8 Matthias Apitz 2019-06-14 17:25:11 UTC
(In reply to Tobias Kortkamp from comment #7)

Unsetting CC, CXX, ... fixed the issue. Thanks.
Comment 9 Jan Beich freebsd_committer 2019-06-17 13:36:52 UTC
(In reply to Tobias Kortkamp from comment #7)
> Looks like clang defaults to using libstdc++ with --target=x86_64-unknown-freebsd.

Probably due to rust discarding OS version. --target=x86_64-unknown-freebsd13.0 is not affected.

// From contrib/llvm/tools/clang/lib/Driver/ToolChains/FreeBSD.cpp:
ToolChain::CXXStdlibType FreeBSD::GetDefaultCXXStdlibType() const {
  if (getTriple().getOSMajorVersion() >= 10)
    return ToolChain::CST_Libcxx;
  return ToolChain::CST_Libstdcxx;
}