mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 17:53:56 +00:00
llvm: Add an option to statically link libstdc++
The goal of the snapshot bots is to produce binaries which can run in as many locations as possible. Currently we build on Centos 6 for this reason, but with LLVM's update to C++11, this reduces the number of platforms that we could possibly run on. This adds a --enable-llvm-static-stdcpp option to the ./configure script for Rust which will enable building a librustc with a static dependence on libstdc++. This normally isn't necessary, but this option can be used on the snapshot builders in order to continue to make binaries which should be able to run in as many locations as possible.
This commit is contained in:
parent
36d5635273
commit
acdee8b904
1
configure
vendored
1
configure
vendored
@ -388,6 +388,7 @@ opt ccache 0 "invoke gcc/clang via ccache to reuse object files between builds"
|
|||||||
opt local-rust 0 "use an installed rustc rather than downloading a snapshot"
|
opt local-rust 0 "use an installed rustc rather than downloading a snapshot"
|
||||||
opt pax-flags 0 "apply PaX flags to rustc binaries (required for GRSecurity/PaX-patched kernels)"
|
opt pax-flags 0 "apply PaX flags to rustc binaries (required for GRSecurity/PaX-patched kernels)"
|
||||||
opt inject-std-version 1 "inject the current compiler version of libstd into programs"
|
opt inject-std-version 1 "inject the current compiler version of libstd into programs"
|
||||||
|
opt llvm-static-stdcpp 0 "statically link to libstdc++ for LLVM"
|
||||||
opt rpath 1 "build rpaths into rustc itself"
|
opt rpath 1 "build rpaths into rustc itself"
|
||||||
opt nightly 0 "build nightly packages"
|
opt nightly 0 "build nightly packages"
|
||||||
opt verify-install 1 "verify installed binaries work"
|
opt verify-install 1 "verify installed binaries work"
|
||||||
|
19
mk/llvm.mk
19
mk/llvm.mk
@ -42,16 +42,25 @@ $$(LLVM_STAMP_$(1)): $(S)src/rustllvm/llvm-auto-clean-trigger
|
|||||||
@$$(call E, make: done cleaning llvm)
|
@$$(call E, make: done cleaning llvm)
|
||||||
touch $$@
|
touch $$@
|
||||||
|
|
||||||
endef
|
ifeq ($$(CFG_ENABLE_LLVM_STATIC_STDCPP),1)
|
||||||
|
LLVM_STDCPP_LOCATION_$(1) = $$(shell $$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
|
||||||
|
-print-file-name=libstdc++.a)
|
||||||
|
else
|
||||||
|
LLVM_STDCPP_LOCATION_$(1) =
|
||||||
|
endif
|
||||||
|
|
||||||
$(foreach host,$(CFG_HOST), \
|
endef
|
||||||
$(eval LLVM_CONFIGS := $(LLVM_CONFIGS) $(LLVM_CONFIG_$(host))))
|
|
||||||
|
|
||||||
$(foreach host,$(CFG_HOST), \
|
$(foreach host,$(CFG_HOST), \
|
||||||
$(eval $(call DEF_LLVM_RULES,$(host))))
|
$(eval $(call DEF_LLVM_RULES,$(host))))
|
||||||
|
|
||||||
|
$(foreach host,$(CFG_HOST), \
|
||||||
|
$(eval LLVM_CONFIGS := $(LLVM_CONFIGS) $(LLVM_CONFIG_$(host))))
|
||||||
|
|
||||||
$(S)src/librustc/lib/llvmdeps.rs: \
|
$(S)src/librustc/lib/llvmdeps.rs: \
|
||||||
$(LLVM_CONFIGS) \
|
$(LLVM_CONFIGS) \
|
||||||
$(S)src/etc/mklldeps.py
|
$(S)src/etc/mklldeps.py \
|
||||||
|
$(MKFILE_DEPS)
|
||||||
$(Q)$(CFG_PYTHON) $(S)src/etc/mklldeps.py \
|
$(Q)$(CFG_PYTHON) $(S)src/etc/mklldeps.py \
|
||||||
"$@" "$(LLVM_COMPONENTS)" $(LLVM_CONFIGS)
|
"$@" "$(LLVM_COMPONENTS)" "$(CFG_ENABLE_LLVM_STATIC_STDCPP)" \
|
||||||
|
$(LLVM_CONFIGS)
|
||||||
|
@ -83,6 +83,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
|
|||||||
$$(WFLAGS_ST$(1)) \
|
$$(WFLAGS_ST$(1)) \
|
||||||
-L "$$(RT_OUTPUT_DIR_$(2))" \
|
-L "$$(RT_OUTPUT_DIR_$(2))" \
|
||||||
-L "$$(LLVM_LIBDIR_$(2))" \
|
-L "$$(LLVM_LIBDIR_$(2))" \
|
||||||
|
-L "$$(dir $$(LLVM_STDCPP_LOCATION_$(2)))" \
|
||||||
--out-dir $$(@D) $$<
|
--out-dir $$(@D) $$<
|
||||||
@touch $$@
|
@touch $$@
|
||||||
$$(call LIST_ALL_OLD_GLOB_MATCHES,\
|
$$(call LIST_ALL_OLD_GLOB_MATCHES,\
|
||||||
|
@ -11,11 +11,14 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import itertools
|
||||||
|
from os import path
|
||||||
|
|
||||||
f = open(sys.argv[1], 'wb')
|
f = open(sys.argv[1], 'wb')
|
||||||
|
|
||||||
components = sys.argv[2].split(' ')
|
components = sys.argv[2].split(' ')
|
||||||
components = [i for i in components if i] # ignore extra whitespaces
|
components = [i for i in components if i] # ignore extra whitespaces
|
||||||
|
enable_static = sys.argv[3]
|
||||||
|
|
||||||
f.write("""// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
f.write("""// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
||||||
// file at the top-level directory of this distribution and at
|
// file at the top-level directory of this distribution and at
|
||||||
@ -41,7 +44,7 @@ def run(args):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
return out
|
return out
|
||||||
|
|
||||||
for llconfig in sys.argv[3:]:
|
for llconfig in sys.argv[4:]:
|
||||||
f.write("\n")
|
f.write("\n")
|
||||||
|
|
||||||
out = run([llconfig, '--host-target'])
|
out = run([llconfig, '--host-target'])
|
||||||
@ -94,6 +97,10 @@ for llconfig in sys.argv[3:]:
|
|||||||
|
|
||||||
# C++ runtime library
|
# C++ runtime library
|
||||||
out = run([llconfig, '--cxxflags'])
|
out = run([llconfig, '--cxxflags'])
|
||||||
|
if enable_static == '1':
|
||||||
|
assert('stdlib=libc++' not in out)
|
||||||
|
f.write("#[link(name = \"stdc++\", kind = \"static\")]\n")
|
||||||
|
else:
|
||||||
if 'stdlib=libc++' in out:
|
if 'stdlib=libc++' in out:
|
||||||
f.write("#[link(name = \"c++\")]\n")
|
f.write("#[link(name = \"c++\")]\n")
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user