mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
add support for non-standard name of stdc++ library
it makes rustc compatible with gcc installation that are using `--program-transform-name' configure flag (on OpenBSD for example). - detects at configure the name of stdc++ library on the system - use the detected name in llvm makefile (with enable-static-stdcpp), and pass it to mklldeps.py - generate mklldeps.rs using this detected name note that CFG_STDCPP_NAME is about stdc++ name, not about libc++. If using libc++, the default name will be `stdc++', but it won't be used when linking.
This commit is contained in:
parent
cff0411706
commit
913fe6dbe9
6
configure
vendored
6
configure
vendored
@ -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%/}
|
||||
|
@ -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), \
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user