File tree Expand file tree Collapse file tree 4 files changed +25
-7
lines changed Expand file tree Collapse file tree 4 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -388,6 +388,7 @@ opt ccache 0 "invoke gcc/clang via ccache to reuse object files between builds"
388388opt local-rust 0 " use an installed rustc rather than downloading a snapshot"
389389opt pax-flags 0 " apply PaX flags to rustc binaries (required for GRSecurity/PaX-patched kernels)"
390390opt inject-std-version 1 " inject the current compiler version of libstd into programs"
391+ opt llvm-static-stdcpp 0 " statically link to libstdc++ for LLVM"
391392opt rpath 1 " build rpaths into rustc itself"
392393opt nightly 0 " build nightly packages"
393394opt verify-install 1 " verify installed binaries work"
Original file line number Diff line number Diff line change @@ -42,16 +42,25 @@ $$(LLVM_STAMP_$(1)): $(S)src/rustllvm/llvm-auto-clean-trigger
4242 @$$(call E, make: done cleaning llvm)
4343 touch $$@
4444
45+ ifeq ($$(CFG_ENABLE_LLVM_STATIC_STDCPP ) ,1)
46+ LLVM_STDCPP_LOCATION_$(1) = $$(shell $$(CC_$(1 ) ) $$(CFG_GCCISH_CFLAGS_$(1 ) ) \
47+ -print-file-name=libstdc++.a)
48+ else
49+ LLVM_STDCPP_LOCATION_$(1) =
50+ endif
51+
4552endef
4653
4754$(foreach host,$(CFG_HOST), \
48- $(eval LLVM_CONFIGS := $(LLVM_CONFIGS) $(LLVM_CONFIG_ $(host))))
55+ $(eval $(call DEF_LLVM_RULES, $(host))))
4956
5057$(foreach host,$(CFG_HOST), \
51- $(eval $(call DEF_LLVM_RULES, $(host))))
58+ $(eval LLVM_CONFIGS := $(LLVM_CONFIGS) $(LLVM_CONFIG_ $(host))))
5259
5360$(S ) src/librustc/lib/llvmdeps.rs : \
5461 $(LLVM_CONFIGS ) \
55- $(S ) src/etc/mklldeps.py
62+ $(S ) src/etc/mklldeps.py \
63+ $(MKFILE_DEPS )
5664 $(Q )$(CFG_PYTHON ) $(S ) src/etc/mklldeps.py \
57- " $@ " " $( LLVM_COMPONENTS) " $(LLVM_CONFIGS )
65+ " $@ " " $( LLVM_COMPONENTS) " " $( CFG_ENABLE_LLVM_STATIC_STDCPP) " \
66+ $(LLVM_CONFIGS )
Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
8383 $$(WFLAGS_ST$(1 ) ) \
8484 -L "$$(RT_OUTPUT_DIR_$(2 ) ) " \
8585 -L "$$(LLVM_LIBDIR_$(2 ) ) " \
86+ -L "$$(dir $$(LLVM_STDCPP_LOCATION_$(2 ) ) ) " \
8687 --out-dir $$(@D ) $$<
8788 @touch $$@
8889 $$(call LIST_ALL_OLD_GLOB_MATCHES,\
Original file line number Diff line number Diff line change 1111import os
1212import sys
1313import subprocess
14+ import itertools
15+ from os import path
1416
1517f = open (sys .argv [1 ], 'wb' )
1618
1719components = sys .argv [2 ].split (' ' )
1820components = [i for i in components if i ] # ignore extra whitespaces
21+ enable_static = sys .argv [3 ]
1922
2023f .write ("""// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2124// file at the top-level directory of this distribution and at
@@ -41,7 +44,7 @@ def run(args):
4144 sys .exit (1 )
4245 return out
4346
44- for llconfig in sys .argv [3 :]:
47+ for llconfig in sys .argv [4 :]:
4548 f .write ("\n " )
4649
4750 out = run ([llconfig , '--host-target' ])
@@ -94,9 +97,13 @@ def run(args):
9497
9598 # C++ runtime library
9699 out = run ([llconfig , '--cxxflags' ])
97- if 'stdlib=libc++' in out :
98- f .write ("#[link(name = \" c++\" )]\n " )
100+ if enable_static == '1' :
101+ assert ('stdlib=libc++' not in out )
102+ f .write ("#[link(name = \" stdc++\" , kind = \" static\" )]\n " )
99103 else :
104+ if 'stdlib=libc++' in out :
105+ f .write ("#[link(name = \" c++\" )]\n " )
106+ else :
100107 f .write ("#[link(name = \" stdc++\" )]\n " )
101108
102109 # Attach everything to an extern block
You can’t perform that action at this time.
0 commit comments