diff --git a/configure b/configure index 2d03b5f6f41..1d95965150c 100755 --- a/configure +++ b/configure @@ -1095,6 +1095,12 @@ envopt CPP envopt CFLAGS envopt CXXFLAGS +# stdc++ name in use +# used to manage non-standard name (on OpenBSD for example) +program_transform_name=$($CFG_CC -v 2>&1 | sed -n "s/.*--program-transform-name='\([^']*\)'.*/\1/p") +CFG_STDCPP_NAME=$(echo "stdc++" | sed "${program_transform_name}") +putvar CFG_STDCPP_NAME + # a little post-processing of various config values CFG_PREFIX=${CFG_PREFIX%/} CFG_MANDIR=${CFG_MANDIR%/} diff --git a/mk/llvm.mk b/mk/llvm.mk index d5b608e88da..1cbf4a9fb84 100644 --- a/mk/llvm.mk +++ b/mk/llvm.mk @@ -73,7 +73,7 @@ $$(LLVM_STAMP_$(1)): $(S)src/rustllvm/llvm-auto-clean-trigger ifeq ($$(CFG_ENABLE_LLVM_STATIC_STDCPP),1) LLVM_STDCPP_RUSTFLAGS_$(1) = -L "$$(dir $$(shell $$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \ - -print-file-name=libstdc++.a))" + -print-file-name=lib$(CFG_STDCPP_NAME).a))" else LLVM_STDCPP_RUSTFLAGS_$(1) = endif @@ -83,7 +83,7 @@ endif LLVM_LINKAGE_PATH_$(1):=$$(abspath $$(RT_OUTPUT_DIR_$(1))/llvmdeps.rs) $$(LLVM_LINKAGE_PATH_$(1)): $(S)src/etc/mklldeps.py $$(LLVM_CONFIG_$(1)) $(Q)$(CFG_PYTHON) "$$<" "$$@" "$$(LLVM_COMPONENTS)" "$$(CFG_ENABLE_LLVM_STATIC_STDCPP)" \ - $$(LLVM_CONFIG_$(1)) + $$(LLVM_CONFIG_$(1)) "$(CFG_STDCPP_NAME)" endef $(foreach host,$(CFG_HOST), \ diff --git a/src/etc/mklldeps.py b/src/etc/mklldeps.py index 1cc65406b2c..215fa1cdd1b 100644 --- a/src/etc/mklldeps.py +++ b/src/etc/mklldeps.py @@ -17,6 +17,7 @@ f = open(sys.argv[1], 'wb') components = sys.argv[2].split() # splits on whitespace enable_static = sys.argv[3] llvm_config = sys.argv[4] +stdcpp_name = sys.argv[5] f.write("""// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at @@ -77,7 +78,7 @@ for lib in out.strip().split(' '): out = run([llvm_config, '--cxxflags']) if enable_static == '1': assert('stdlib=libc++' not in out) - f.write("#[link(name = \"stdc++\", kind = \"static\")]\n") + f.write("#[link(name = \"" + stdcpp_name + "\", kind = \"static\")]\n") else: # Note that we use `cfg_attr` here because on MSVC the C++ standard library # is not c++ or stdc++, but rather the linker takes care of linking the @@ -85,7 +86,7 @@ else: if 'stdlib=libc++' in out: f.write("#[cfg_attr(not(target_env = \"msvc\"), link(name = \"c++\"))]\n") else: - f.write("#[cfg_attr(not(target_env = \"msvc\"), link(name = \"stdc++\"))]\n") + f.write("#[cfg_attr(not(target_env = \"msvc\"), link(name = \"" + stdcpp_name + "\"))]\n") # Attach everything to an extern block f.write("extern {}\n")