Skip to content

rustc-1.24.0-src: cannot find -lstdc++ on FreeBSD 11.1 #48578

@triaxx

Description

@triaxx

I am trying to build lang/rust for FreeBSD using the pkgsrc framework.

The clang++ check fails during LLVM build since ld cannot find -lstdc++. Actually -lc++ should be used.

This dirty hack solves the problem but there probably is a better way to do that:

--- 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

The build trace is attached in the following file:
rust.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions