pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lang/rust: wrong stdlib for c++ on FreeBSD



Hi,

I am currently building lang/rust (rustc-1.24.0-src) on a FreeBSD host and I encounter (surprisingly ;D) build failures.

Building LLVM for x86_64-unknown-freebsd
[...]
-- The CXX compiler identification is Clang 4.0.0
[...]
-- Check for working CXX compiler: /usr/home/triaxx/pkgsrc-HEAD/lang/rust/work/.cwrapper/bin/clang++ -- broken
[...]
    /usr/bin/ld: cannot find -lstdc++

The full log is available here: http://ftp.netbsd.org/pub/NetBSD/misc/triaxx/logs/rust.log

$ /usr/bin/clang++ --version
FreeBSD clang version 4.0.0 (tags/RELEASE_400/final 297347) (based on LLVM 4.0.0)
Target: x86_64-unknown-freebsd11.1
Thread model: posix
InstalledDir: /usr/bin

$ CWRAPPERS_CONFIG_DIR=~/pkgsrc-HEAD/lang/rust/work/.cwrapper/config ~~/pkg/libexec/cwrappers/c++-wrapper --version FreeBSD clang version 4.0.0 (tags/RELEASE_400/final 297347) (based on LLVM 4.0.0)
Target: x86_64-unknown-freebsd11.1
Thread model: posix
InstalledDir: /usr/bin

The wrapper identified as the c++ compiler is the one provided by the FreeBSD basesystem that correctly works:
$ /usr/bin/clang++ foo.cc
$ ldd a.out
a.out:
        libc++.so.1 => /usr/lib/libc++.so.1 (0x800822000)
        libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x800ae9000)
        libm.so.5 => /lib/libm.so.5 (0x800d07000)
        libc.so.7 => /lib/libc.so.7 (0x800f32000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x8012ea000)

I can fix the problem with this kind of dirty hack (that force linking against libc++ instead of libstdc++):
$NetBSD$

--- src/bootstrap/native.rs.orig    2018-02-12 18:51:18.000000000 +0000
+++ src/bootstrap/native.rs
@@ -223,7 +223,11 @@ impl Step for Llvm {

             cfg.build_arg("-j").build_arg(build.jobs().to_string());
cfg.define("CMAKE_C_FLAGS", build.cflags(target).join(" ")); - cfg.define("CMAKE_CXX_FLAGS", build.cflags(target).join(" "));
+            if target.contains("freebsd") {
+ cfg.define("CMAKE_CXX_FLAGS", build.cflags(target).join(" ") + " -stdlib=libc++");
+            } else {
+ cfg.define("CMAKE_CXX_FLAGS", build.cflags(target).join(" "));
+            }
             if let Some(ar) = build.ar(target) {
                 if ar.is_absolute() {
// LLVM build breaks if `CMAKE_AR` is a relative path, for some reason it

But the same problem occurs latter when compiling rustc_apfloat:
-- Check for working CXX compiler: /usr/home/triaxx/pkgsrc-HEAD/lang/rust/work/.cwrapper/bin/clang++ -- broken

The exact problem occured with rustc-1.23.0-src.

The FreeBSD ports provide a patch that seems to address a similar problem. But it does not solve the ones described above:
--- src/librustc_llvm/build.rs.orig 2017-06-06 00:42:59 UTC
+++ src/librustc_llvm/build.rs
@@ -241,6 +241,8 @@ fn main() {
     let stdcppname = if target.contains("openbsd") {
         // OpenBSD has a particular C++ runtime library name
         "estdc++"
+    } else if target.contains("freebsd") {
+        "c++"
} else if target.contains("netbsd") && llvm_static_stdcpp.is_some() {
         // NetBSD uses a separate library when relocation is required
         "stdc++_pic"

Any idea to globally set the name of standard c++ for FreeBSD?


Home | Main Index | Thread Index | Old Index