-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Statically linking libc++ requires disabling static-libstdcpp #94983
Copy link
Copy link
Open
Labels
A-contributor-roadblockArea: Makes things more difficult for new or seasoned contributors to RustArea: Makes things more difficult for new or seasoned contributors to RustA-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesP-mediumMedium priorityMedium priorityT-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Metadata
Metadata
Assignees
Labels
A-contributor-roadblockArea: Makes things more difficult for new or seasoned contributors to RustArea: Makes things more difficult for new or seasoned contributors to RustA-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesP-mediumMedium priorityMedium priorityT-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Type
Fields
Give feedbackNo fields configured for issues without a type.
In 737ef08, the default value of
static-libstdcppwas changed fromfalsetotrue. When statically linkinglibc++on linux, this has a rather unfortunate cascade of effects:static-libstdcppis set to true, thenbootstrap/compile.rswill askclang++wherelibstdc++.ais located.libc++.ais provided andclang++will unhelpfully return "libstdc++.a".compile.rsstores this inLLVM_STATIC_STDCPP.rustc_llvm's build script checks whetherLLVM_STATIC_STDCPPis set. Seeing that it is, it addscargo:rustc-link-search=native=<PARENT_DIR>to the command line where<PARENT_DIR>is the directory containingLLVM_STATIC_STDCPP.-L native=, which triggers the error "empty search path given via-L" inrustc_session/src/search_paths.rs.To get the behavior that we actually want, we need to fall into the case where
LLVM_STATIC_STDCPPis not defined, and instead add-stdlib=libc++tocxxflags. To do so, we have to setstatic-libstdcpp = falseinconfig.toml. This is unintuitive behavior as it appears that we're disabling static linking entirely, but in reality we're just statically linking againstlibc++instead oflibstdc++.