Auto merge of #28495 - semarie:stdcpp-name, r=alexcrichton
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. r? @alexcrichton I added this support globally instead of just for OpenBSD as it isn't specially related to OpenBSD (except OpenBSD use it for gcc-4.9). And as I would had to change `llvm.mk', having just a default value in `configure' for others platforms won't be very useful.
This commit is contained in:
commit
655b2ef45f
3 changed files with 11 additions and 4 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue