Skip to content

add support for non-standard name of stdc++ library #28495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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%/}
Expand Down
4 changes: 2 additions & 2 deletions mk/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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), \
Expand Down
5 changes: 3 additions & 2 deletions src/etc/mklldeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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
Expand Down Expand Up @@ -77,15 +78,15 @@ def run(args):
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
# right standard library.
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")